diff options
author | Alexander Early <alexander.early@gmail.com> | 2016-04-07 14:06:05 -0700 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2016-04-07 14:06:05 -0700 |
commit | b00abf296e13ee33b5a987e9b8484881aefa6d0f (patch) | |
tree | d726d55684e594554461397fc1bce88b64732553 | |
parent | 167a019496ba1b4e83f29ef502e4a7e2f056ba85 (diff) | |
download | async-b00abf296e13ee33b5a987e9b8484881aefa6d0f.tar.gz |
have applyEach pass results to the callback. Closes #1088
-rw-r--r-- | lib/applyEach.js | 4 | ||||
-rw-r--r-- | lib/applyEachSeries.js | 4 | ||||
-rw-r--r-- | lib/internal/applyEach.js | 5 | ||||
-rw-r--r-- | mocha_test/applyEach.js | 9 |
4 files changed, 12 insertions, 10 deletions
diff --git a/lib/applyEach.js b/lib/applyEach.js index 2c5f001..73a89d2 100644 --- a/lib/applyEach.js +++ b/lib/applyEach.js @@ -1,6 +1,6 @@ 'use strict'; import applyEach from './internal/applyEach'; -import eachOf from './eachOf'; +import map from './map'; -export default applyEach(eachOf); +export default applyEach(map); diff --git a/lib/applyEachSeries.js b/lib/applyEachSeries.js index e917618..3de977f 100644 --- a/lib/applyEachSeries.js +++ b/lib/applyEachSeries.js @@ -1,6 +1,6 @@ 'use strict'; import applyEach from './internal/applyEach'; -import eachOfSeries from './eachOfSeries'; +import mapSeries from './mapSeries'; -export default applyEach(eachOfSeries); +export default applyEach(mapSeries); diff --git a/lib/internal/applyEach.js b/lib/internal/applyEach.js index 47710d4..d472683 100644 --- a/lib/internal/applyEach.js +++ b/lib/internal/applyEach.js @@ -7,10 +7,9 @@ export default function applyEach(eachfn) { return rest(function(fns, args) { var go = initialParams(function(args, callback) { var that = this; - return eachfn(fns, function (fn, _, cb) { + return eachfn(fns, function (fn, cb) { fn.apply(that, args.concat([cb])); - }, - callback); + }, callback); }); if (args.length) { return go.apply(this, args); diff --git a/mocha_test/applyEach.js b/mocha_test/applyEach.js index d2080a6..6138d3f 100644 --- a/mocha_test/applyEach.js +++ b/mocha_test/applyEach.js @@ -27,9 +27,10 @@ describe('applyEach', function () { cb(null, 3); }, 15); }; - async.applyEach([one, two, three], 5, function (err) { + async.applyEach([one, two, three], 5, function (err, results) { assert(err === null, err + " passed instead of 'null'"); expect(call_order).to.eql(['two', 'one', 'three']); + expect(results).to.eql([1, 2, 3]); done(); }); }); @@ -57,9 +58,10 @@ describe('applyEach', function () { cb(null, 3); }, 15); }; - async.applyEachSeries([one, two, three], 5, function (err) { + async.applyEachSeries([one, two, three], 5, function (err, results) { assert(err === null, err + " passed instead of 'null'"); expect(call_order).to.eql(['one', 'two', 'three']); + expect(results).to.eql([1, 2, 3]); done(); }); }); @@ -87,9 +89,10 @@ describe('applyEach', function () { cb(null, 3); }, 15); }; - async.applyEach([one, two, three])(5, function (err) { + async.applyEach([one, two, three])(5, function (err, results) { if (err) throw err; expect(call_order).to.eql(['two', 'one', 'three']); + expect(results).to.eql([1, 2, 3]); done(); }); }); |