0.4.1 • Published 9 years ago

batchcalls v0.4.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

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) {
  // Do something
}, {
  wait: 1000
});

document.body.addEventListener('click', clicksWithinSecond);
var batchCalls = require('batchcalls');
var executeAfter5Clicks = batchCalls(function (events) {
  // Do something
}, {
  count: 5
});

document.body.addEventListener('click', executeAfter5Clicks);
var batchCalls = require('batchcalls');
var executeOnConditional = batchCalls(function (batchedArgs) {
  // Will batch as long as conditional is true
}, {
  conditional: function (args, prevArgs) {
    return args[0].foo === prevArgs[0].foo;
  }
});
0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago