batch-executor

1.0.0 • Public • Published

batch-executor

npm Build Status Coverage Status

A simple batch executor wrapped by event emitter. It emit an execute event when it received object more than max count, or reached max interval time.

Quick start

const BatchExecutor = require('batch-executor');
 
var executor = new BatchExecutor();
executor.on('error', (err) => {
    console.error(err);
});
executor.on('execute', (batch, callback) => {
    // batch is an array contains your batch objects created by cloneDeep,
    // Just do whatever you want with it.
    // If an error occurs, just call callback(err);
    // Or you can ignore it
});
 
executor.batch({
    foo: 'bar'
});

Usage

Callbacks

onError(err)
onExecute(batch, [onError])

Methods

new BatchExecutor([maxCount = 200], [maxInterval = 5000]);
executor.on('error', onError);
executor.on('execute', onExecute);
executor.batch(obj);

Readme

Keywords

Package Sidebar

Install

npm i batch-executor

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jasonz93