summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2016-03-09 13:24:52 -0800
committerAlexander Early <alexander.early@gmail.com>2016-03-09 13:24:52 -0800
commit4c88e6c69c9cb057e5bb9867653b29c492003875 (patch)
tree2474e1289a07ae08a48e061d48a2006d054fdee7
parentf0efabd6856def2a60b66869d35451ed3f77b445 (diff)
downloadasync-4c88e6c69c9cb057e5bb9867653b29c492003875.tar.gz
remove es6 idioms
-rw-r--r--lib/race.js7
-rw-r--r--lib/waterfall.js6
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/race.js b/lib/race.js
index 4a5f8a5..0ef6914 100644
--- a/lib/race.js
+++ b/lib/race.js
@@ -1,6 +1,7 @@
'use strict';
import isArray from 'lodash/isArray';
+import each from 'lodash/each';
import noop from 'lodash/noop';
import once from 'lodash/once';
@@ -8,7 +9,7 @@ export default function race(tasks, cb) {
cb = once(cb || noop);
if (!isArray(tasks)) return cb(new TypeError('First argument to race must be an array of functions'));
if (!tasks.length) return cb();
- for (let i = 0; i < tasks.length; i++) {
- tasks[i](cb);
- }
+ each(tasks, function (task) {
+ task(cb);
+ });
}
diff --git a/lib/waterfall.js b/lib/waterfall.js
index a31b3b4..9882e11 100644
--- a/lib/waterfall.js
+++ b/lib/waterfall.js
@@ -15,12 +15,12 @@ export default function(tasks, cb) {
function nextTask(args) {
if (taskIndex === tasks.length) {
- return cb(null, ...args);
+ return cb.apply(null, [null].concat(args));
}
var taskCallback = onlyOnce(rest(function(err, args) {
if (err) {
- return cb(err, ...args);
+ return cb.apply(null, [err].concat(args));
}
nextTask(args);
}));
@@ -28,7 +28,7 @@ export default function(tasks, cb) {
args.push(taskCallback);
var task = tasks[taskIndex++];
- task(...args);
+ task.apply(null, args);
}
nextTask([]);