Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

batch-executor

jasonz932MIT1.0.0

A simple batch executor

batch

readme

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);