UNPKG

rocky

Version:

Full-featured, middleware-oriented, hackable HTTP and WebSocket proxy

26 lines (19 loc) 445 B
module.exports = function eachConcurrently (arr, iterator, cb) { cb = cb || noop if (!Array.isArray(arr) || !arr.length) return cb() var errors = [] var pending = arr.length arr.forEach(function (item) { iterator(item, next) }) function next (err) { if (err) errors.push(err) if (!(pending--)) finish() } function finish () { if (errors.length) cb(errors) else cb() } next() } function noop () {}