UNPKG

418 BJavaScriptView Raw
1'use strict';
2
3module.exports = function each(arr, cb, done) {
4 if (arr.length === 0) {
5 return done();
6 }
7
8 let remaining = arr.length;
9 let err = null;
10 for (const v of arr) {
11 cb(v, function(_err) {
12 if (err != null) {
13 return;
14 }
15 if (_err != null) {
16 err = _err;
17 return done(err);
18 }
19
20 if (--remaining <= 0) {
21 return done();
22 }
23 });
24 }
25};
\No newline at end of file