2.0.2 • Published 1 year ago

taskerjs v2.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
1 year ago

taskerjs

Utilities to work with tasks.

Installation

npm install taskerjs

Accumulator

This class allows to process tasks in bulk.

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.

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`);
  };
}
2.0.0-rc.2

1 year ago

2.0.0-rc.0

1 year ago

2.0.0-rc.1

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.3

6 years ago

1.1.2

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago