diff options
author | Alexander Early <alexander.early@gmail.com> | 2018-07-08 19:15:32 -0700 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2018-07-08 19:15:32 -0700 |
commit | d713c8ac14115450d04b51e6599894178de01446 (patch) | |
tree | 4d2c29e2c5b41ab43709e52486c9a20be3421e5e /lib/internal | |
parent | d82becb8692e131cbc27cdb172fb7563dfdc80e3 (diff) | |
download | async-d713c8ac14115450d04b51e6599894178de01446.tar.gz |
disallow variable shadowing
Diffstat (limited to 'lib/internal')
-rw-r--r-- | lib/internal/applyEach.js | 10 | ||||
-rw-r--r-- | lib/internal/filter.js | 17 | ||||
-rw-r--r-- | lib/internal/iterator.js | 2 | ||||
-rw-r--r-- | lib/internal/map.js | 4 | ||||
-rw-r--r-- | lib/internal/parallel.js | 4 |
5 files changed, 16 insertions, 21 deletions
diff --git a/lib/internal/applyEach.js b/lib/internal/applyEach.js index b029184..f95d8ac 100644 --- a/lib/internal/applyEach.js +++ b/lib/internal/applyEach.js @@ -2,18 +2,16 @@ import initialParams from './initialParams'; import wrapAsync from './wrapAsync'; export default function applyEach(eachfn) { - return function(fns, ...args) { + return function(fns, ...callArgs) { var go = initialParams(function(args, callback) { var that = this; return eachfn(fns, (fn, cb) => { wrapAsync(fn).apply(that, args.concat(cb)); }, callback); }); - if (args.length) { - return go.apply(this, args); - } - else { - return go; + if (callArgs.length) { + return go.apply(this, callArgs); } + return go; }; } diff --git a/lib/internal/filter.js b/lib/internal/filter.js index 4c9422b..ab37390 100644 --- a/lib/internal/filter.js +++ b/lib/internal/filter.js @@ -5,10 +5,10 @@ import wrapAsync from './wrapAsync'; function filterArray(eachfn, arr, iteratee, callback) { var truthValues = new Array(arr.length); - eachfn(arr, (x, index, callback) => { + eachfn(arr, (x, index, iterCb) => { iteratee(x, (err, v) => { truthValues[index] = !!v; - callback(err); + iterCb(err); }); }, err => { if (err) return callback(err); @@ -22,16 +22,13 @@ function filterArray(eachfn, arr, iteratee, callback) { function filterGeneric(eachfn, coll, iteratee, callback) { var results = []; - eachfn(coll, (x, index, callback) => { + eachfn(coll, (x, index, iterCb) => { iteratee(x, (err, v) => { - if (err) { - callback(err); - } else { - if (v) { - results.push({index, value: x}); - } - callback(); + if (err) return iterCb(err); + if (v) { + results.push({index, value: x}); } + iterCb(); }); }, err => { if (err) return callback(err); diff --git a/lib/internal/iterator.js b/lib/internal/iterator.js index b0c4644..d167ff9 100644 --- a/lib/internal/iterator.js +++ b/lib/internal/iterator.js @@ -30,7 +30,7 @@ function createObjectIterator(obj) { }; } -export default function iterator(coll) { +export default function createIterator(coll) { if (isArrayLike(coll)) { return createArrayIterator(coll); } diff --git a/lib/internal/map.js b/lib/internal/map.js index b99d8ee..3da8d9c 100644 --- a/lib/internal/map.js +++ b/lib/internal/map.js @@ -8,11 +8,11 @@ export default function _asyncMap(eachfn, arr, iteratee, callback) { var counter = 0; var _iteratee = wrapAsync(iteratee); - return eachfn(arr, (value, _, callback) => { + return eachfn(arr, (value, _, iterCb) => { var index = counter++; _iteratee(value, (err, v) => { results[index] = v; - callback(err); + iterCb(err); }); }, err => { callback(err, results); diff --git a/lib/internal/parallel.js b/lib/internal/parallel.js index 89e181e..703947c 100644 --- a/lib/internal/parallel.js +++ b/lib/internal/parallel.js @@ -6,13 +6,13 @@ export default function _parallel(eachfn, tasks, callback) { callback = callback || noop; var results = isArrayLike(tasks) ? [] : {}; - eachfn(tasks, (task, key, callback) => { + eachfn(tasks, (task, key, taskCb) => { wrapAsync(task)((err, ...result) => { if (result.length < 2) { result = result[0]; } results[key] = result; - callback(err); + taskCb(err); }); }, err => callback(err, results)); } |