batchcalls
Batches calls to a function and passes arguments as arrays
var batchCalls = require('batchcalls');
var request = batchCalls(function (ids) {
fetch('/users/?ids=' + ids.join(',')).then(doSomething);
});
var ids = ['1', '2', '3'];
ids.forEach(request);
var batchCalls = require('batchcalls');
var clicksWithinSecond = batchCalls(function (events) {
}, {
wait: 1000
});
document.body.addEventListener('click', clicksWithinSecond);
var batchCalls = require('batchcalls');
var executeAfter5Clicks = batchCalls(function (events) {
}, {
count: 5
});
document.body.addEventListener('click', executeAfter5Clicks);
var batchCalls = require('batchcalls');
var executeOnConditional = batchCalls(function (batchedArgs) {
}, {
conditional: function (args, prevArgs) {
return args[0].foo === prevArgs[0].foo;
}
});