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)
forEachAsync that allows
n async calls at once.
Say you have 500 http requests that you want to get done
10 at a time and then know when they've all finished...
forAllAsync is your guy!
npm install forallasync
You can install from bower:
bower install forAllAsync
Or download the raw file from https://raw.github.com/FuturesJS/forAllAsync/master/forAllAsync.js:
Or build with pakmanager:
pakmanager build forAllAsync
;'use strict';var forAllAsync = exportsforAllAsync || require'forallasync'forAllAsyncmaxCallsAtOnce = 4 // defaultarr;setTimeoutconsole.logitem;complete;500;arr = 'a' 'b' 'c' 'd';forAllAsyncarr onEach maxCallsAtOncethenconsole.log'did all the things';;'undefined' !== typeof exports && exports || 'return this';
forAllAsync(array, iterator, n).then(callback)
iteratorfor each element in
nat a time and call
callbackwhen all are complete