diff options
Diffstat (limited to 'dist/async.js')
-rw-r--r-- | dist/async.js | 473 |
1 files changed, 249 insertions, 224 deletions
diff --git a/dist/async.js b/dist/async.js index 2d623c6..7851f55 100644 --- a/dist/async.js +++ b/dist/async.js @@ -1,21 +1,21 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.async = global.async || {}))); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.async = global.async || {}))); }(this, (function (exports) { 'use strict'; function slice(arrayLike, start) { - start = start | 0; + start = start|0; var newLen = Math.max(arrayLike.length - start, 0); var newArr = Array(newLen); - for (var idx = 0; idx < newLen; idx++) { + for(var idx = 0; idx < newLen; idx++) { newArr[idx] = arrayLike[start + idx]; } return newArr; } var initialParams = function (fn) { - return function () /*...args, callback*/{ + return function (/*...args, callback*/) { var args = slice(arguments); var callback = args.pop(); fn.call(this, args, callback); @@ -138,9 +138,9 @@ function asyncify(func) { } // if result is Promise object if (isObject(result) && typeof result.then === 'function') { - result.then(function (value) { + result.then(function(value) { callback(null, value); - }, function (err) { + }, function(err) { callback(err.message ? err : new Error(err)); }); } else { @@ -173,9 +173,9 @@ function wrapAsync(asyncFn) { var wrapAsync$1 = supportsAsync() ? wrapAsync : identity; function applyEach$1(eachfn) { - return function (fns /*, ...args*/) { + return function(fns/*, ...args*/) { var args = slice(arguments, 1); - var go = initialParams(function (args, callback) { + var go = initialParams(function(args, callback) { var that = this; return eachfn(fns, function (fn, cb) { wrapAsync$1(fn).apply(that, args.concat(cb)); @@ -183,7 +183,8 @@ function applyEach$1(eachfn) { }); if (args.length) { return go.apply(this, args); - } else { + } + else { return go; } }; @@ -856,18 +857,19 @@ function createArrayIterator(coll) { var i = -1; var len = coll.length; return function next() { - return ++i < len ? { value: coll[i], key: i } : null; - }; + return ++i < len ? {value: coll[i], key: i} : null; + } } function createES2015Iterator(iterator) { var i = -1; return function next() { var item = iterator.next(); - if (item.done) return null; + if (item.done) + return null; i++; - return { value: item.value, key: i }; - }; + return {value: item.value, key: i}; + } } function createObjectIterator(obj) { @@ -876,7 +878,7 @@ function createObjectIterator(obj) { var len = okeys.length; return function next() { var key = okeys[++i]; - return i < len ? { value: obj[key], key: key } : null; + return i < len ? {value: obj[key], key: key} : null; }; } @@ -890,7 +892,7 @@ function iterator(coll) { } function onlyOnce(fn) { - return function () { + return function() { if (fn === null) throw new Error("Callback was already called."); var callFn = fn; fn = null; @@ -913,15 +915,17 @@ function _eachOfLimit(limit) { if (err) { done = true; callback(err); - } else if (value === breakLoop || done && running <= 0) { + } + else if (value === breakLoop || (done && running <= 0)) { done = true; return callback(null); - } else { + } + else { replenish(); } } - function replenish() { + function replenish () { while (running < limit && !done) { var elem = nextElem(); if (elem === null) { @@ -961,7 +965,7 @@ function _eachOfLimit(limit) { * `iteratee` functions have finished, or an error occurs. Invoked with (err). */ function eachOfLimit(coll, limit, iteratee, callback) { - _eachOfLimit(limit)(coll, wrapAsync$1(iteratee), callback); + _eachOfLimit(limit)(coll, wrapAsync$1(iteratee), callback); } function doLimit(fn, limit) { @@ -983,7 +987,7 @@ function eachOfArrayLike(coll, iteratee, callback) { function iteratorCallback(err, value) { if (err) { callback(err); - } else if (++completed === length || value === breakLoop) { + } else if ((++completed === length) || value === breakLoop) { callback(null); } } @@ -1035,7 +1039,7 @@ var eachOfGeneric = doLimit(eachOfLimit, Infinity); * doSomethingWith(configs); * }); */ -var eachOf = function (coll, iteratee, callback) { +var eachOf = function(coll, iteratee, callback) { var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; eachOfImplementation(coll, wrapAsync$1(iteratee), callback); }; @@ -1250,9 +1254,9 @@ var applyEachSeries = applyEach$1(mapSeries); * two * three */ -var apply = function (fn /*, ...args*/) { +var apply = function(fn/*, ...args*/) { var args = slice(arguments, 1); - return function () /*callArgs*/{ + return function(/*callArgs*/) { var callArgs = slice(arguments); return fn.apply(null, args.concat(callArgs)); }; @@ -1526,7 +1530,10 @@ var auto = function (tasks, concurrency, callback) { arrayEach(dependencies, function (dependencyName) { if (!tasks[dependencyName]) { - throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', ')); + throw new Error('async.auto task `' + key + + '` has a non-existent dependency `' + + dependencyName + '` in ' + + dependencies.join(', ')); } addListener(dependencyName, function () { remainingDependencies--; @@ -1550,10 +1557,11 @@ var auto = function (tasks, concurrency, callback) { if (readyTasks.length === 0 && runningTasks === 0) { return callback(null, results); } - while (readyTasks.length && runningTasks < concurrency) { + while(readyTasks.length && runningTasks < concurrency) { var run = readyTasks.shift(); run(); } + } function addListener(taskName, fn) { @@ -1573,17 +1581,18 @@ var auto = function (tasks, concurrency, callback) { processQueue(); } + function runTask(key, task) { if (hasError) return; - var taskCallback = onlyOnce(function (err, result) { + var taskCallback = onlyOnce(function(err, result) { runningTasks--; if (arguments.length > 2) { result = slice(arguments, 1); } if (err) { var safeResults = {}; - baseForOwn(results, function (val, rkey) { + baseForOwn(results, function(val, rkey) { safeResults[rkey] = val; }); safeResults[key] = result; @@ -1623,7 +1632,9 @@ var auto = function (tasks, concurrency, callback) { } if (counter !== numTasks) { - throw new Error('async.auto cannot execute tasks due to a recursive dependency'); + throw new Error( + 'async.auto cannot execute tasks due to a recursive dependency' + ); } } @@ -1951,7 +1962,7 @@ function parseParams(func) { func = func.toString().replace(STRIP_COMMENTS, ''); func = func.match(FN_ARGS)[2].replace(' ', ''); func = func ? func.split(FN_ARG_SPLIT) : []; - func = func.map(function (arg) { + func = func.map(function (arg){ return trim(arg.replace(FN_ARG, '')); }); return func; @@ -2045,7 +2056,9 @@ function autoInject(tasks, callback) { baseForOwn(tasks, function (taskFn, key) { var params; var fnIsAsync = isAsync(taskFn); - var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0; + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); if (isArray(taskFn)) { params = taskFn.slice(0, -1); @@ -2087,7 +2100,7 @@ function fallback(fn) { } function wrap(defer) { - return function (fn /*, ...args*/) { + return function (fn/*, ...args*/) { var args = slice(arguments, 1); defer(function () { fn.apply(null, args); @@ -2121,9 +2134,11 @@ function setInitial(dll, node) { dll.head = dll.tail = node; } -DLL.prototype.removeLink = function (node) { - if (node.prev) node.prev.next = node.next;else this.head = node.next; - if (node.next) node.next.prev = node.prev;else this.tail = node.prev; +DLL.prototype.removeLink = function(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next; + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; node.prev = node.next = null; this.length -= 1; @@ -2131,46 +2146,50 @@ DLL.prototype.removeLink = function (node) { }; DLL.prototype.empty = function () { - while (this.head) this.shift(); + while(this.head) this.shift(); return this; }; -DLL.prototype.insertAfter = function (node, newNode) { +DLL.prototype.insertAfter = function(node, newNode) { newNode.prev = node; newNode.next = node.next; - if (node.next) node.next.prev = newNode;else this.tail = newNode; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; node.next = newNode; this.length += 1; }; -DLL.prototype.insertBefore = function (node, newNode) { +DLL.prototype.insertBefore = function(node, newNode) { newNode.prev = node.prev; newNode.next = node; - if (node.prev) node.prev.next = newNode;else this.head = newNode; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; node.prev = newNode; this.length += 1; }; -DLL.prototype.unshift = function (node) { - if (this.head) this.insertBefore(this.head, node);else setInitial(this, node); +DLL.prototype.unshift = function(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); }; -DLL.prototype.push = function (node) { - if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node); +DLL.prototype.push = function(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); }; -DLL.prototype.shift = function () { +DLL.prototype.shift = function() { return this.head && this.removeLink(this.head); }; -DLL.prototype.pop = function () { +DLL.prototype.pop = function() { return this.tail && this.removeLink(this.tail); }; DLL.prototype.toArray = function () { var arr = Array(this.length); var curr = this.head; - for (var idx = 0; idx < this.length; idx++) { + for(var idx = 0; idx < this.length; idx++) { arr[idx] = curr.data; curr = curr.next; } @@ -2179,7 +2198,7 @@ DLL.prototype.toArray = function () { DLL.prototype.remove = function (testFn) { var curr = this.head; - while (!!curr) { + while(!!curr) { var next = curr.next; if (testFn(curr)) { this.removeLink(curr); @@ -2192,7 +2211,8 @@ DLL.prototype.remove = function (testFn) { function queue(worker, concurrency, payload) { if (concurrency == null) { concurrency = 1; - } else if (concurrency === 0) { + } + else if(concurrency === 0) { throw new Error('Concurrency must not be zero'); } @@ -2210,7 +2230,7 @@ function queue(worker, concurrency, payload) { } if (data.length === 0 && q.idle()) { // call drain immediately if there are no tasks - return setImmediate$1(function () { + return setImmediate$1(function() { q.drain(); }); } @@ -2231,7 +2251,7 @@ function queue(worker, concurrency, payload) { } function _next(tasks) { - return function (err) { + return function(err){ numRunning -= 1; for (var i = 0, l = tasks.length; i < l; i++) { @@ -2248,7 +2268,7 @@ function queue(worker, concurrency, payload) { } } - if (numRunning <= q.concurrency - q.buffer) { + if (numRunning <= (q.concurrency - q.buffer) ) { q.unsaturated(); } @@ -2265,7 +2285,7 @@ function queue(worker, concurrency, payload) { concurrency: concurrency, payload: payload, saturated: noop, - unsaturated: noop, + unsaturated:noop, buffer: concurrency / 4, empty: noop, drain: noop, @@ -2292,9 +2312,8 @@ function queue(worker, concurrency, payload) { return; } isProcessing = true; - while (!q.paused && numRunning < q.concurrency && q._tasks.length) { - var tasks = [], - data = []; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ + var tasks = [], data = []; var l = q._tasks.length; if (q.payload) l = Math.min(l, q.payload); for (var i = 0; i < l; i++) { @@ -2328,16 +2347,14 @@ function queue(worker, concurrency, payload) { workersList: function () { return workersList; }, - idle: function () { + idle: function() { return q._tasks.length + numRunning === 0; }, pause: function () { q.paused = true; }, resume: function () { - if (q.paused === false) { - return; - } + if (q.paused === false) { return; } q.paused = false; setImmediate$1(q.process); } @@ -2423,7 +2440,7 @@ function queue(worker, concurrency, payload) { * }); */ function cargo(worker, payload) { - return queue(worker, 1, payload); + return queue(worker, 1, payload); } /** @@ -2488,12 +2505,12 @@ var eachOfSeries = doLimit(eachOfLimit, 1); function reduce(coll, memo, iteratee, callback) { callback = once(callback || noop); var _iteratee = wrapAsync$1(iteratee); - eachOfSeries(coll, function (x, i, callback) { - _iteratee(memo, x, function (err, v) { + eachOfSeries(coll, function(x, i, callback) { + _iteratee(memo, x, function(err, v) { memo = v; callback(err); }); - }, function (err) { + }, function(err) { callback(err, memo); }); } @@ -2536,9 +2553,9 @@ function reduce(coll, memo, iteratee, callback) { * }); * }); */ -function seq() /*...functions*/{ +function seq(/*...functions*/) { var _functions = arrayMap(arguments, wrapAsync$1); - return function () /*...args*/{ + return function(/*...args*/) { var args = slice(arguments); var that = this; @@ -2549,12 +2566,13 @@ function seq() /*...functions*/{ cb = noop; } - reduce(_functions, args, function (newargs, fn, cb) { - fn.apply(that, newargs.concat(function (err /*, ...nextargs*/) { + reduce(_functions, args, function(newargs, fn, cb) { + fn.apply(that, newargs.concat(function(err/*, ...nextargs*/) { var nextargs = slice(arguments, 1); cb(err, nextargs); })); - }, function (err, results) { + }, + function(err, results) { cb.apply(that, [err].concat(results)); }); }; @@ -2595,8 +2613,8 @@ function seq() /*...functions*/{ * // result now equals 15 * }); */ -var compose = function () /*...args*/{ - return seq.apply(null, slice(arguments).reverse()); +var compose = function(/*...args*/) { + return seq.apply(null, slice(arguments).reverse()); }; function concat$1(eachfn, arr, fn, callback) { @@ -2706,22 +2724,22 @@ var concatSeries = doSeries(concat$1); * //... * }, callback); */ -var constant = function () /*...values*/{ +var constant = function(/*...values*/) { var values = slice(arguments); var args = [null].concat(values); - return function () /*...ignoredArgs, callback*/{ + return function (/*...ignoredArgs, callback*/) { var callback = arguments[arguments.length - 1]; return callback.apply(this, args); }; }; function _createTester(check, getResult) { - return function (eachfn, arr, iteratee, cb) { + return function(eachfn, arr, iteratee, cb) { cb = cb || noop; var testPassed = false; var testResult; - eachfn(arr, function (value, _, callback) { - iteratee(value, function (err, result) { + eachfn(arr, function(value, _, callback) { + iteratee(value, function(err, result) { if (err) { callback(err); } else if (check(result) && !testResult) { @@ -2732,7 +2750,7 @@ function _createTester(check, getResult) { callback(); } }); - }, function (err) { + }, function(err) { if (err) { cb(err); } else { @@ -2830,9 +2848,9 @@ var detectLimit = doParallelLimit(_createTester(identity, _findGetResult)); var detectSeries = doLimit(detectLimit, 1); function consoleFunc(name) { - return function (fn /*, ...args*/) { + return function (fn/*, ...args*/) { var args = slice(arguments, 1); - args.push(function (err /*, ...args*/) { + args.push(function (err/*, ...args*/) { var args = slice(arguments, 1); if (typeof console === 'object') { if (err) { @@ -2906,7 +2924,7 @@ function doDuring(fn, test, callback) { var _fn = wrapAsync$1(fn); var _test = wrapAsync$1(test); - function next(err /*, ...args*/) { + function next(err/*, ...args*/) { if (err) return callback(err); var args = slice(arguments, 1); args.push(check); @@ -2920,6 +2938,7 @@ function doDuring(fn, test, callback) { } check(null, true); + } /** @@ -2947,7 +2966,7 @@ function doDuring(fn, test, callback) { function doWhilst(iteratee, test, callback) { callback = onlyOnce(callback || noop); var _iteratee = wrapAsync$1(iteratee); - var next = function (err /*, ...args*/) { + var next = function(err/*, ...args*/) { if (err) return callback(err); var args = slice(arguments, 1); if (test.apply(this, args)) return _iteratee(next); @@ -2977,7 +2996,7 @@ function doWhilst(iteratee, test, callback) { * callback. Invoked with (err, [results]); */ function doUntil(iteratee, test, callback) { - doWhilst(iteratee, function () { + doWhilst(iteratee, function() { return !test.apply(this, arguments); }, callback); } @@ -3101,7 +3120,7 @@ function _withoutIndex(iteratee) { * }); */ function eachLimit(coll, iteratee, callback) { - eachOf(coll, _withoutIndex(wrapAsync$1(iteratee)), callback); + eachOf(coll, _withoutIndex(wrapAsync$1(iteratee)), callback); } /** @@ -3125,7 +3144,7 @@ function eachLimit(coll, iteratee, callback) { * `iteratee` functions have finished, or an error occurs. Invoked with (err). */ function eachLimit$1(coll, limit, iteratee, callback) { - _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync$1(iteratee)), callback); + _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync$1(iteratee)), callback); } /** @@ -3318,7 +3337,7 @@ function filterGeneric(eachfn, coll, iteratee, callback) { callback(err); } else { if (v) { - results.push({ index: index, value: x }); + results.push({index: index, value: x}); } callback(); } @@ -3467,15 +3486,15 @@ function forever(fn, errback) { * functions have finished, or an error occurs. Result is an `Object` whoses * properties are arrays of values which returned the corresponding key. */ -var groupByLimit = function (coll, limit, iteratee, callback) { +var groupByLimit = function(coll, limit, iteratee, callback) { callback = callback || noop; var _iteratee = wrapAsync$1(iteratee); - mapLimit(coll, limit, function (val, callback) { - _iteratee(val, function (err, key) { + mapLimit(coll, limit, function(val, callback) { + _iteratee(val, function(err, key) { if (err) return callback(err); - return callback(null, { key: key, val: val }); + return callback(null, {key: key, val: val}); }); - }, function (err, mapResults) { + }, function(err, mapResults) { var result = {}; // from MDN, handle object having an `hasOwnProperty` prop var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -3610,7 +3629,7 @@ function mapValuesLimit(obj, limit, iteratee, callback) { callback = once(callback || noop); var newObj = {}; var _iteratee = wrapAsync$1(iteratee); - eachOfLimit(obj, limit, function (val, key, next) { + eachOfLimit(obj, limit, function(val, key, next) { _iteratee(val, key, function (err, result) { if (err) return next(err); newObj[key] = result; @@ -3738,14 +3757,14 @@ function memoize(fn, hasher) { var memoized = initialParams(function memoized(args, callback) { var key = hasher.apply(null, args); if (has(memo, key)) { - setImmediate$1(function () { + setImmediate$1(function() { callback.apply(null, memo[key]); }); } else if (has(queues, key)) { queues[key].push(callback); } else { queues[key] = [callback]; - _fn.apply(null, args.concat(function () /*args*/{ + _fn.apply(null, args.concat(function(/*args*/) { var args = slice(arguments); memo[key] = args; var q = queues[key]; @@ -3891,7 +3910,7 @@ function _parallel(eachfn, tasks, callback) { * }); */ function parallelLimit(tasks, callback) { - _parallel(eachOf, tasks, callback); + _parallel(eachOf, tasks, callback); } /** @@ -3914,7 +3933,7 @@ function parallelLimit(tasks, callback) { * Invoked with (err, results). */ function parallelLimit$1(tasks, limit, callback) { - _parallel(_eachOfLimit(limit), tasks, callback); + _parallel(_eachOfLimit(limit), tasks, callback); } /** @@ -4022,10 +4041,10 @@ function parallelLimit$1(tasks, limit, callback) { * }); */ var queue$1 = function (worker, concurrency) { - var _worker = wrapAsync$1(worker); - return queue(function (items, cb) { - _worker(items[0], cb); - }, concurrency, 1); + var _worker = wrapAsync$1(worker); + return queue(function (items, cb) { + _worker(items[0], cb); + }, concurrency, 1); }; /** @@ -4051,12 +4070,12 @@ var queue$1 = function (worker, concurrency) { * array of `tasks` is given, all tasks will be assigned the same priority. * * The `unshift` method was removed. */ -var priorityQueue = function (worker, concurrency) { +var priorityQueue = function(worker, concurrency) { // Start with a normal queue var q = queue$1(worker, concurrency); // Override push to accept second parameter representing priority - q.push = function (data, priority, callback) { + q.push = function(data, priority, callback) { if (callback == null) callback = noop; if (typeof callback !== 'function') { throw new Error('task callback must be a function'); @@ -4067,7 +4086,7 @@ var priorityQueue = function (worker, concurrency) { } if (data.length === 0) { // call drain immediately if there are no tasks - return setImmediate$1(function () { + return setImmediate$1(function() { q.drain(); }); } @@ -4167,9 +4186,9 @@ function race(tasks, callback) { * `iteratee` functions have finished. Result is the reduced value. Invoked with * (err, result). */ -function reduceRight(array, memo, iteratee, callback) { - var reversed = slice(array).reverse(); - reduce(reversed, memo, iteratee, callback); +function reduceRight (array, memo, iteratee, callback) { + var reversed = slice(array).reverse(); + reduce(reversed, memo, iteratee, callback); } /** @@ -4233,8 +4252,8 @@ function reflect(fn) { } function reject$1(eachfn, arr, iteratee, callback) { - _filter(eachfn, arr, function (value, cb) { - iteratee(value, function (err, v) { + _filter(eachfn, arr, function(value, cb) { + iteratee(value, function(err, v) { cb(err, !v); }); }, callback); @@ -4342,7 +4361,7 @@ function reflectAll(tasks) { results = arrayMap(tasks, reflect); } else { results = {}; - baseForOwn(tasks, function (task, key) { + baseForOwn(tasks, function(task, key) { results[key] = reflect.call(this, task); }); } @@ -4511,7 +4530,9 @@ function retry(opts, task, callback) { if (typeof t === 'object') { acc.times = +t.times || DEFAULT_TIMES; - acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL); + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant$1(+t.interval || DEFAULT_INTERVAL); acc.errorFilter = t.errorFilter; } else if (typeof t === 'number' || typeof t === 'string') { @@ -4537,8 +4558,10 @@ function retry(opts, task, callback) { var attempt = 1; function retryAttempt() { - _task(function (err) { - if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) { + _task(function(err) { + if (err && attempt++ < options.times && + (typeof options.errorFilter != 'function' || + options.errorFilter(err))) { setTimeout(retryAttempt, options.intervalFunc(attempt)); } else { callback.apply(null, arguments); @@ -4588,7 +4611,9 @@ var retryable = function (opts, task) { _task.apply(null, args.concat(cb)); } - if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback); + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + }); }; @@ -4657,7 +4682,7 @@ var retryable = function (opts, task) { * }); */ function series(tasks, callback) { - _parallel(eachOfSeries, tasks, callback); + _parallel(eachOfSeries, tasks, callback); } /** @@ -4784,12 +4809,12 @@ var someSeries = doLimit(someLimit, 1); * // result callback * }); */ -function sortBy(coll, iteratee, callback) { +function sortBy (coll, iteratee, callback) { var _iteratee = wrapAsync$1(iteratee); map(coll, function (x, callback) { _iteratee(x, function (err, criteria) { if (err) return callback(err); - callback(null, { value: x, criteria: criteria }); + callback(null, {value: x, criteria: criteria}); }); }, function (err, results) { if (err) return callback(err); @@ -4797,8 +4822,7 @@ function sortBy(coll, iteratee, callback) { }); function comparator(left, right) { - var a = left.criteria, - b = right.criteria; + var a = left.criteria, b = right.criteria; return a < b ? -1 : a > b ? 1 : 0; } } @@ -4857,7 +4881,7 @@ function timeout(asyncFn, milliseconds, info) { function timeoutCallback() { var name = asyncFn.name || 'anonymous'; - var error = new Error('Callback function "' + name + '" timed out.'); + var error = new Error('Callback function "' + name + '" timed out.'); error.code = 'ETIMEDOUT'; if (info) { error.info = info; @@ -4920,8 +4944,8 @@ function baseRange(start, end, step, fromRight) { * @param {Function} callback - see [async.map]{@link module:Collections.map}. */ function timeLimit(count, limit, iteratee, callback) { - var _iteratee = wrapAsync$1(iteratee); - mapLimit(baseRange(0, count, 1), limit, _iteratee, callback); + var _iteratee = wrapAsync$1(iteratee); + mapLimit(baseRange(0, count, 1), limit, _iteratee, callback); } /** @@ -5016,7 +5040,7 @@ var timesSeries = doLimit(timeLimit, 1); * // result is equal to {a: 2, b: 4, c: 6} * }) */ -function transform(coll, accumulator, iteratee, callback) { +function transform (coll, accumulator, iteratee, callback) { if (arguments.length <= 3) { callback = iteratee; iteratee = accumulator; @@ -5025,9 +5049,9 @@ function transform(coll, accumulator, iteratee, callback) { callback = once(callback || noop); var _iteratee = wrapAsync$1(iteratee); - eachOf(coll, function (v, k, cb) { + eachOf(coll, function(v, k, cb) { _iteratee(accumulator, v, k, cb); - }, function (err) { + }, function(err) { callback(err, accumulator); }); } @@ -5073,8 +5097,8 @@ function tryEach(tasks, callback) { var error = null; var result; callback = callback || noop; - eachSeries(tasks, function (task, callback) { - wrapAsync$1(task)(function (err, res /*, ...args*/) { + eachSeries(tasks, function(task, callback) { + wrapAsync$1(task)(function (err, res/*, ...args*/) { if (arguments.length > 2) { result = slice(arguments, 1); } else { @@ -5145,7 +5169,7 @@ function whilst(test, iteratee, callback) { callback = onlyOnce(callback || noop); var _iteratee = wrapAsync$1(iteratee); if (!test()) return callback(null); - var next = function (err /*, ...args*/) { + var next = function(err/*, ...args*/) { if (err) return callback(err); if (test()) return _iteratee(next); var args = slice(arguments, 1); @@ -5177,7 +5201,7 @@ function whilst(test, iteratee, callback) { * callback. Invoked with (err, [results]); */ function until(test, iteratee, callback) { - whilst(function () { + whilst(function() { return !test.apply(this, arguments); }, iteratee, callback); } @@ -5239,7 +5263,7 @@ function until(test, iteratee, callback) { * callback(null, 'done'); * } */ -var waterfall = function (tasks, callback) { +var waterfall = function(tasks, callback) { callback = once(callback || noop); if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); if (!tasks.length) return callback(); @@ -5251,7 +5275,7 @@ var waterfall = function (tasks, callback) { task.apply(null, args); } - function next(err /*, ...args*/) { + function next(err/*, ...args*/) { if (err || taskIndex === tasks.length) { return callback.apply(null, arguments); } @@ -5309,6 +5333,7 @@ var waterfall = function (tasks, callback) { * @see AsyncFunction */ + /** * A collection of `async` functions for manipulating collections, such as * arrays and objects. @@ -5326,99 +5351,99 @@ var waterfall = function (tasks, callback) { */ var index = { - applyEach: applyEach, - applyEachSeries: applyEachSeries, - apply: apply, - asyncify: asyncify, - auto: auto, - autoInject: autoInject, - cargo: cargo, - compose: compose, - concat: concat, - concatSeries: concatSeries, - constant: constant, - detect: detect, - detectLimit: detectLimit, - detectSeries: detectSeries, - dir: dir, - doDuring: doDuring, - doUntil: doUntil, - doWhilst: doWhilst, - during: during, - each: eachLimit, - eachLimit: eachLimit$1, - eachOf: eachOf, - eachOfLimit: eachOfLimit, - eachOfSeries: eachOfSeries, - eachSeries: eachSeries, - ensureAsync: ensureAsync, - every: every, - everyLimit: everyLimit, - everySeries: everySeries, - filter: filter, - filterLimit: filterLimit, - filterSeries: filterSeries, - forever: forever, - groupBy: groupBy, - groupByLimit: groupByLimit, - groupBySeries: groupBySeries, - log: log, - map: map, - mapLimit: mapLimit, - mapSeries: mapSeries, - mapValues: mapValues, - mapValuesLimit: mapValuesLimit, - mapValuesSeries: mapValuesSeries, - memoize: memoize, - nextTick: nextTick, - parallel: parallelLimit, - parallelLimit: parallelLimit$1, - priorityQueue: priorityQueue, - queue: queue$1, - race: race, - reduce: reduce, - reduceRight: reduceRight, - reflect: reflect, - reflectAll: reflectAll, - reject: reject, - rejectLimit: rejectLimit, - rejectSeries: rejectSeries, - retry: retry, - retryable: retryable, - seq: seq, - series: series, - setImmediate: setImmediate$1, - some: some, - someLimit: someLimit, - someSeries: someSeries, - sortBy: sortBy, - timeout: timeout, - times: times, - timesLimit: timeLimit, - timesSeries: timesSeries, - transform: transform, - tryEach: tryEach, - unmemoize: unmemoize, - until: until, - waterfall: waterfall, - whilst: whilst, - - // aliases - all: every, - any: some, - forEach: eachLimit, - forEachSeries: eachSeries, - forEachLimit: eachLimit$1, - forEachOf: eachOf, - forEachOfSeries: eachOfSeries, - forEachOfLimit: eachOfLimit, - inject: reduce, - foldl: reduce, - foldr: reduceRight, - select: filter, - selectLimit: filterLimit, - selectSeries: filterSeries, - wrapSync: asyncify + applyEach: applyEach, + applyEachSeries: applyEachSeries, + apply: apply, + asyncify: asyncify, + auto: auto, + autoInject: autoInject, + cargo: cargo, + compose: compose, + concat: concat, + concatSeries: concatSeries, + constant: constant, + detect: detect, + detectLimit: detectLimit, + detectSeries: detectSeries, + dir: dir, + doDuring: doDuring, + doUntil: doUntil, + doWhilst: doWhilst, + during: during, + each: eachLimit, + eachLimit: eachLimit$1, + eachOf: eachOf, + eachOfLimit: eachOfLimit, + eachOfSeries: eachOfSeries, + eachSeries: eachSeries, + ensureAsync: ensureAsync, + every: every, + everyLimit: everyLimit, + everySeries: everySeries, + filter: filter, + filterLimit: filterLimit, + filterSeries: filterSeries, + forever: forever, + groupBy: groupBy, + groupByLimit: groupByLimit, + groupBySeries: groupBySeries, + log: log, + map: map, + mapLimit: mapLimit, + mapSeries: mapSeries, + mapValues: mapValues, + mapValuesLimit: mapValuesLimit, + mapValuesSeries: mapValuesSeries, + memoize: memoize, + nextTick: nextTick, + parallel: parallelLimit, + parallelLimit: parallelLimit$1, + priorityQueue: priorityQueue, + queue: queue$1, + race: race, + reduce: reduce, + reduceRight: reduceRight, + reflect: reflect, + reflectAll: reflectAll, + reject: reject, + rejectLimit: rejectLimit, + rejectSeries: rejectSeries, + retry: retry, + retryable: retryable, + seq: seq, + series: series, + setImmediate: setImmediate$1, + some: some, + someLimit: someLimit, + someSeries: someSeries, + sortBy: sortBy, + timeout: timeout, + times: times, + timesLimit: timeLimit, + timesSeries: timesSeries, + transform: transform, + tryEach: tryEach, + unmemoize: unmemoize, + until: until, + waterfall: waterfall, + whilst: whilst, + + // aliases + all: every, + any: some, + forEach: eachLimit, + forEachSeries: eachSeries, + forEachLimit: eachLimit$1, + forEachOf: eachOf, + forEachOfSeries: eachOfSeries, + forEachOfLimit: eachOfLimit, + inject: reduce, + foldl: reduce, + foldr: reduceRight, + select: filter, + selectLimit: filterLimit, + selectSeries: filterSeries, + wrapSync: asyncify }; exports['default'] = index; |