Like forEachAsync and Join had a baby: sequences out n batches of async functions rather than all at once. Part of FuturesJS (Browser, Node.js, Bower, Pakmanager)


Basically a thread pool for asynchronous calls. The number of calls is limited to n.

Node.JS (Server):

npm install lateral


pakmanager build lateral
#or ender build lateral
var Lateral = require('lateral')
  , maxCallsAtOnce = 4 // default
  , lateral

lateral = Lateral.create(function (complete, item, i) {
  setTimeout(function () {
  }, 500);
}, maxCallsAtOnce);

lateral.add(['a', 'b', 'c', 'd']).when(function () {
  console.log('did all the things');

lateral.add(['d', 'e', 'f', 'g']).when(function () {
  console.log('did all the things');

Creates a Sequence-ish object for the purpose of synchronizing other Futures.


  • lateral = Lateral.create(handler, n)

    • create a Lateral that will execute fn on each item to do at most n things at once
  • lateral.add(arr) - adds arr to be handled by fn

  • lateral.add(arr).when(callback)

    • Fires callback when all items in the arr batch have been handled