# taskerjs

> Utilities to work with tasks.

Latest version **2.0.2** (published 2023-03-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install taskerjs
pnpm add taskerjs
yarn add taskerjs
bun add taskerjs
```

## 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 | 2.0.2 |
| Published | 2023-03-11 |
| First published | 2015-10-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alejandro Santiago Nieto |
| Maintainers | alemures |

## Links

- npm: https://www.npmjs.com/package/taskerjs
- Repository: https://github.com/alemures/taskerjs
- Homepage: https://github.com/alemures/taskerjs#readme
- Issues: https://github.com/alemures/taskerjs/issues
- npm.io page: https://npm.io/package/taskerjs

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [denque](https://npm.io/package/denque.md) ^2.1.0

## Recent versions

- 2.0.2 (latest) — 2023-03-11
- 2.0.1 — 2023-01-24
- 2.0.0 — 2023-01-22
- 2.0.0-rc.2 — 2023-01-22
- 2.0.0-rc.1 — 2023-01-21
- 2.0.0-rc.0 — 2023-01-21
- 1.1.3 — 2018-08-09
- 1.1.2 — 2017-01-12
- 1.1.1 — 2015-12-21
- 1.1.0 — 2015-11-27
- 1.0.0 — 2015-10-25

## README

# taskerjs

Utilities to work with tasks.

### Installation

`npm install taskerjs`

### Accumulator

This class allows to process tasks in bulk.

```javascript
const { Accumulator } = require('taskerjs');

const acc = new Accumulator({
  tasksLimit: 50, // Limit of tasks to call to the worker
  timeLimit: 1000, // Elapsed time between calls to the worker in milliseconds
  maxTasksLimit: 80, // Max number of tasks by worker execution
});

acc.setWorker((tasks, done) => {
  console.log(`${tasks.length} tasks processed`);
  done();
});

acc.add('Tasks number 1');
acc.add(1);
acc.add({ data: 1 });
```

### Delayer

This class allows set timeouts with ids so they can be overridden and reset easily.

```javascript
const { Delayer } = require('taskerjs');

const delayer = new Delayer();

delayer.add('#1', action('first'), 2000);
delayer.add('#2', action('second'), 2000);
delayer.add('#3', action('third'), 2000);

// It Will override action('first') that never will be called
delayer.add('#1', action('fourth'), 3000);

function action(order) {
  return () => {
    console.log(`Executing ${order} action`);
  };
}
```

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