# @dnpr/task-manager

> Run JavaScript functions concurrently with control.

Latest version **1.1.0** (published 2022-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dnpr/task-manager
pnpm add @dnpr/task-manager
yarn add @dnpr/task-manager
bun add @dnpr/task-manager
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-06-18 |
| First published | 2019-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dragonman225 |
| Maintainers | dragonman225 |

## Links

- npm: https://www.npmjs.com/package/@dnpr/task-manager
- Repository: https://github.com/dnpr/task-manager
- Issues: https://github.com/dnpr/task-manager/issues
- npm.io page: https://npm.io/package/@dnpr/task-manager

## Recent versions

- 1.1.0 (latest) — 2022-06-18
- 1.0.0 — 2020-01-23
- 0.1.2 — 2019-10-30
- 0.1.1 — 2019-07-24
- 0.1.0 — 2019-07-02

## README

# task-manager

A simple JavaScript task scheduler that manages execution of synchronous or asynchronous tasks.

## Installation

```bash
npm install @dnpr/task-manager
```

## Usage

* (Recommended) To use v2, see [`test/TaskManager2.spec.js`](test/TaskManager2.spec.js).
* To use v1, see [`test/TaskManager.spec.js`](test/TaskManager.spec.js).

## Background

Since this scheduler still executes tasks with single thread, it cannot make synchronous, computation intensive tasks faster. However, if the tasks are asynchronous, such as web requests or file-system reads / writes, which are more I/O bounded, they have chances to benefit from the **concurrency** under single thread.

The original reason I write this is for web crawling. I found making requests one by one was too slow, so I wonder if I can make it run in parallel. It turned out that I had to add quite much code to achieve the goal. Therefore, I decided to write a library to make reusing easier.

With this library I just need to prepare 3 things:

1. A tasks array, where each task is an object containing a URL and some metadata.
2. A function that execute a task. For instance, making a request to the URL and save its response.
3. A config object describing how to schedule the tasks. It may include the number of tasks that should run in parallel, the delay between two tasks, and the variation of delay to add some "randomness" to the traffic shape.

Then, let it run and wait !

---
_Source: https://npm.io/package/@dnpr/task-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
