1.0.0 • Published 9 years ago
batch-executor v1.0.0
batch-executor
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);1.0.0
9 years ago