summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml20
-rw-r--r--CHANGELOG.md11
-rw-r--r--dist/async.js10233
-rw-r--r--dist/async.min.js2
-rw-r--r--dist/async.min.map2
-rw-r--r--lib/internal/breakLoop.js3
-rw-r--r--lib/internal/createTester.js27
-rw-r--r--lib/internal/eachOfLimit.js7
-rw-r--r--lib/mapValues.js7
-rw-r--r--lib/mapValuesLimit.js5
-rw-r--r--lib/mapValuesSeries.js5
-rw-r--r--lib/race.js2
-rw-r--r--mocha_test/detect.js26
-rw-r--r--mocha_test/every.js27
-rw-r--r--mocha_test/queue.js6
-rw-r--r--mocha_test/retry.js4
-rw-r--r--mocha_test/some.js29
-rw-r--r--package.json36
-rw-r--r--support/build/aggregate-build.js4
-rw-r--r--support/jsdoc/jsdoc-custom.js18
-rw-r--r--support/jsdoc/jsdoc-fix-html.js58
-rw-r--r--support/jsdoc/theme/static/styles/jsdoc-default.css52
-rw-r--r--support/jsdoc/theme/tmpl/layout.tmpl42
23 files changed, 5636 insertions, 4990 deletions
diff --git a/.travis.yml b/.travis.yml
index 9feb56a..ff46739 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,19 @@
+sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "4"
- - "6"
-sudo: false
+
+matrix:
+ include:
+ - node_js: "6"
+ addons:
+ firefox: "49.0"
+ env: BROWSER=true MAKE_TEST=true
+env:
+ matrix: BROWSER=false MAKE_TEST=false
+
after_success: npm run coveralls
# Needed to run Karma with Firefox on Travis
@@ -12,3 +21,10 @@ after_success: npm run coveralls
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
+
+script:
+ - npm test
+ # ensure buildable
+ - "[ $MAKE_TEST == false ] || make"
+ # test in firefox
+ - "[ $BROWSER == false ] || npm run mocha-browser-test" \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 94cf2ca..a82f6fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+# v2.1.2
+- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs (#1293).
+
+# v2.1.0
+
+- `retry` and `retryable` now support an optional `errorFilter` function that determines if the `task` should retry on the error (#1256, #1261)
+- Optimized array iteration in `race`, `cargo`, `queue`, and `priorityQueue` (#1253)
+- Added alias documentation to doc site (#1251, #1254)
+- Added [BootStrap scrollspy](http://getbootstrap.com/javascript/#scrollspy) to docs to highlight in the sidebar the current method being viewed (#1289, #1300)
+- Various minor doc fixes (#1263, #1264, #1271, #1278, #1280, #1282, #1302)
+
# v2.0.1
- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc (#1245, #1246, #1247).
diff --git a/dist/async.js b/dist/async.js
index 6058c54..bb95651 100644
--- a/dist/async.js
+++ b/dist/async.js
@@ -1,4998 +1,5427 @@
(function (global, factory) {
- 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';
-
- /**
- * A faster alternative to `Function#apply`, this function invokes `func`
- * with the `this` binding of `thisArg` and the arguments of `args`.
- *
- * @private
- * @param {Function} func The function to invoke.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} args The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply(func, thisArg, args) {
- switch (args.length) {
- case 0: return func.call(thisArg);
- case 1: return func.call(thisArg, args[0]);
- case 2: return func.call(thisArg, args[0], args[1]);
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
- }
- return func.apply(thisArg, args);
- }
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
-
- /**
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- */
- function baseRest(func, start) {
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
-
- while (++index < length) {
- array[index] = args[start + index];
- }
- index = -1;
- var otherArgs = Array(start + 1);
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = array;
- return apply(func, this, otherArgs);
- };
- }
-
- function initialParams (fn) {
- return baseRest(function (args /*..., callback*/) {
- var callback = args.pop();
- fn.call(this, args, callback);
- });
- }
-
- function applyEach$1(eachfn) {
- return baseRest(function (fns, args) {
- var go = initialParams(function (args, callback) {
- var that = this;
- return eachfn(fns, function (fn, cb) {
- fn.apply(that, args.concat([cb]));
- }, callback);
- });
- if (args.length) {
- return go.apply(this, args);
- } else {
- return go;
- }
- });
- }
-
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
-
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
-
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
-
- var funcTag = '[object Function]';
- var genTag = '[object GeneratorFunction]';
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
-
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
-
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
-
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
- }
-
- /**
- * This method returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
- function noop() {
- // No operation performed.
- }
-
- function once(fn) {
- return function () {
- if (fn === null) return;
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
-
- var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
-
- function getIterator (coll) {
- return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
- }
-
- /**
- * Creates a function that invokes `func` with its first argument transformed.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} transform The argument transform.
- * @returns {Function} Returns the new function.
- */
- function overArg(func, transform) {
- return function(arg) {
- return func(transform(arg));
- };
- }
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetPrototype = Object.getPrototypeOf;
-
- /**
- * Gets the `[[Prototype]]` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
- */
- var getPrototype = overArg(nativeGetPrototype, Object);
-
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto$1.hasOwnProperty;
-
- /**
- * The base implementation of `_.has` without support for deep paths.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHas(object, key) {
- // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
- // that are composed entirely of index properties, return `false` for
- // `hasOwnProperty` checks of them.
- return object != null &&
- (hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototype(object) === null));
- }
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeKeys = Object.keys;
-
- /**
- * The base implementation of `_.keys` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- var baseKeys = overArg(nativeKeys, Object);
-
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
-
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
-
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
-
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object,
- * else `false`.
- * @example
- *
- * _.isArrayLikeObject([1, 2, 3]);
- * // => true
- *
- * _.isArrayLikeObject(document.body.children);
- * // => true
- *
- * _.isArrayLikeObject('abc');
- * // => false
- *
- * _.isArrayLikeObject(_.noop);
- * // => false
- */
- function isArrayLikeObject(value) {
- return isObjectLike(value) && isArrayLike(value);
- }
-
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]';
-
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$1 = objectProto$2.toString;
-
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
-
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
- return isArrayLikeObject(value) && hasOwnProperty$1.call(value, 'callee') &&
- (!propertyIsEnumerable.call(value, 'callee') || objectToString$1.call(value) == argsTag);
- }
-
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
-
- /** `Object#toString` result references. */
- var stringTag = '[object String]';
-
- /** Used for built-in method references. */
- var objectProto$3 = Object.prototype;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$2 = objectProto$3.toString;
-
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString$2.call(value) == stringTag);
- }
-
- /**
- * Creates an array of index keys for `object` values of arrays,
- * `arguments` objects, and strings, otherwise `null` is returned.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array|null} Returns index keys, else `null`.
- */
- function indexKeys(object) {
- var length = object ? object.length : undefined;
- if (isLength(length) &&
- (isArray(object) || isString(object) || isArguments(object))) {
- return baseTimes(length, String);
- }
- return null;
- }
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
-
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
-
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
- return !!length &&
- (typeof value == 'number' || reIsUint.test(value)) &&
- (value > -1 && value % 1 == 0 && value < length);
+ 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';
+
+/**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+function identity(value) {
+ return value;
+}
+
+/**
+ * A faster alternative to `Function#apply`, this function invokes `func`
+ * with the `this` binding of `thisArg` and the arguments of `args`.
+ *
+ * @private
+ * @param {Function} func The function to invoke.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} args The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+function apply(func, thisArg, args) {
+ switch (args.length) {
+ case 0: return func.call(thisArg);
+ case 1: return func.call(thisArg, args[0]);
+ case 2: return func.call(thisArg, args[0], args[1]);
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
+ return func.apply(thisArg, args);
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
-
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$4;
-
- return value === proto;
- }
-
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- var isProto = isPrototype(object);
- if (!(isProto || isArrayLike(object))) {
- return baseKeys(object);
+ while (++index < length) {
+ array[index] = args[start + index];
}
- var indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
-
- for (var key in object) {
- if (baseHas(object, key) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(isProto && key == 'constructor')) {
- result.push(key);
- }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
}
- return result;
- }
-
- function createArrayIterator(coll) {
- var i = -1;
- var len = coll.length;
- return function next() {
- 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;
- i++;
- return { value: item.value, key: i };
- };
- }
-
- function createObjectIterator(obj) {
- var okeys = keys(obj);
- var i = -1;
- var len = okeys.length;
- return function next() {
- var key = okeys[++i];
- return i < len ? { value: obj[key], key: key } : null;
- };
- }
-
- function iterator(coll) {
- if (isArrayLike(coll)) {
- return createArrayIterator(coll);
- }
-
- var iterator = getIterator(coll);
- return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
- }
-
- function onlyOnce(fn) {
- return function () {
- if (fn === null) throw new Error("Callback was already called.");
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
-
- function _eachOfLimit(limit) {
- return function (obj, iteratee, callback) {
- callback = once(callback || noop);
- if (limit <= 0 || !obj) {
- return callback(null);
- }
- var nextElem = iterator(obj);
- var done = false;
- var running = 0;
-
- function iterateeCallback(err) {
- running -= 1;
- if (err) {
- done = true;
- callback(err);
- } else if (done && running <= 0) {
- return callback(null);
- } else {
- replenish();
- }
- }
-
- function replenish() {
- while (running < limit && !done) {
- var elem = nextElem();
- if (elem === null) {
- done = true;
- if (running <= 0) {
- callback(null);
- }
- return;
- }
- running += 1;
- iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
- }
- }
-
- replenish();
- };
- }
-
- /**
- * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name eachOfLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.eachOf]{@link module:Collections.eachOf}
- * @alias forEachOfLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- function eachOfLimit(coll, limit, iteratee, callback) {
- _eachOfLimit(limit)(coll, iteratee, callback);
- }
-
- function doLimit(fn, limit) {
- return function (iterable, iteratee, callback) {
- return fn(iterable, limit, iteratee, callback);
- };
- }
-
- // eachOf implementation optimized for array-likes
- function eachOfArrayLike(coll, iteratee, callback) {
- callback = once(callback || noop);
- var index = 0,
- completed = 0,
- length = coll.length;
- if (length === 0) {
- callback(null);
- }
-
- function iteratorCallback(err) {
- if (err) {
- callback(err);
- } else if (++completed === length) {
- callback(null);
- }
- }
-
- for (; index < length; index++) {
- iteratee(coll[index], index, onlyOnce(iteratorCallback));
- }
- }
-
- // a generic version of eachOf which can handle array, object, and iterator cases.
- var eachOfGeneric = doLimit(eachOfLimit, Infinity);
-
- /**
- * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
- * to the iteratee.
- *
- * @name eachOf
- * @static
- * @memberOf module:Collections
- * @method
- * @alias forEachOf
- * @category Collection
- * @see [async.each]{@link module:Collections.each}
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
- * var configs = {};
- *
- * async.forEachOf(obj, function (value, key, callback) {
- * fs.readFile(__dirname + value, "utf8", function (err, data) {
- * if (err) return callback(err);
- * try {
- * configs[key] = JSON.parse(data);
- * } catch (e) {
- * return callback(e);
- * }
- * callback();
- * });
- * }, function (err) {
- * if (err) console.error(err.message);
- * // configs is now a map of JSON data
- * doSomethingWith(configs);
- * });
- */
- function eachOf (coll, iteratee, callback) {
- var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
- eachOfImplementation(coll, iteratee, callback);
- }
-
- function doParallel(fn) {
- return function (obj, iteratee, callback) {
- return fn(eachOf, obj, iteratee, callback);
- };
- }
-
- function _asyncMap(eachfn, arr, iteratee, callback) {
- callback = once(callback || noop);
- arr = arr || [];
- var results = [];
- var counter = 0;
-
- eachfn(arr, function (value, _, callback) {
- var index = counter++;
- iteratee(value, function (err, v) {
- results[index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
+}
+
+/**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+function constant(value) {
+ return function() {
+ return value;
+ };
+}
+
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+}
+
+/** `Object#toString` result references. */
+var funcTag = '[object Function]';
+var genTag = '[object GeneratorFunction]';
+var proxyTag = '[object Proxy]';
+
+/** Used for built-in method references. */
+var objectProto$1 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString = objectProto$1.toString;
+
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+function isFunction(value) {
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed array and other constructors.
+ var tag = isObject(value) ? objectToString.call(value) : '';
+ return tag == funcTag || tag == genTag || tag == proxyTag;
+}
+
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+/** Used to detect overreaching core-js shims. */
+var coreJsData = root['__core-js_shared__'];
+
+/** Used to detect methods masquerading as native. */
+var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+}());
+
+/**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+}
+
+/** Used for built-in method references. */
+var funcProto$1 = Function.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString$1 = funcProto$1.toString;
+
+/**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to process.
+ * @returns {string} Returns the source code.
+ */
+function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString$1.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
}
-
- /**
- * Produces a new collection of values by mapping each value in `coll` through
- * the `iteratee` function. The `iteratee` is called with an item from `coll`
- * and a callback for when it has finished processing. Each of these callback
- * takes 2 arguments: an `error`, and the transformed item from `coll`. If
- * `iteratee` passes an error to its callback, the main `callback` (for the
- * `map` function) is immediately called with the error.
- *
- * Note, that since this function applies the `iteratee` to each item in
- * parallel, there is no guarantee that the `iteratee` functions will complete
- * in order. However, the results array will be in the same order as the
- * original `coll`.
- *
- * If `map` is passed an Object, the results will be an Array. The results
- * will roughly be in the order of the original Objects' keys (but this can
- * vary across JavaScript engines)
- *
- * @name map
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an Array of the
- * transformed items from the `coll`. Invoked with (err, results).
- * @example
- *
- * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
- * // results is now an array of stats for each file
- * });
- */
- var map = doParallel(_asyncMap);
-
- /**
- * Applies the provided arguments to each function in the array, calling
- * `callback` after all functions have completed. If you only provide the first
- * argument, then it will return a function which lets you pass in the
- * arguments as if it were a single function call.
- *
- * @name applyEach
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
- * call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument is provided, it will return
- * a function which lets you pass in the arguments as if it were a single
- * function call.
- * @example
- *
- * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
- *
- * // partial application example:
- * async.each(
- * buckets,
- * async.applyEach([enableSearch, updateSchema]),
- * callback
- * );
- */
- var applyEach = applyEach$1(map);
-
- function doParallelLimit(fn) {
- return function (obj, limit, iteratee, callback) {
- return fn(_eachOfLimit(limit), obj, iteratee, callback);
- };
+ return '';
+}
+
+/**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
+
+/** Used to detect host constructors (Safari). */
+var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype;
+var objectProto = Object.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Used to detect if a method is native. */
+var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+);
+
+/**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
}
-
- /**
- * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
- *
- * @name mapLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a transformed
- * item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapLimit = doParallelLimit(_asyncMap);
-
- /**
- * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
- *
- * @name mapSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapSeries = doLimit(mapLimit, 1);
-
- /**
- * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
- *
- * @name applyEachSeries
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.applyEach]{@link module:ControlFlow.applyEach}
- * @category Control Flow
- * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
- * call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument is provided, it will return
- * a function which lets you pass in the arguments as if it were a single
- * function call.
- */
- var applyEachSeries = applyEach$1(mapSeries);
-
- /**
- * Creates a continuation function with some arguments already applied.
- *
- * Useful as a shorthand when combined with other control flow functions. Any
- * arguments passed to the returned function are added to the arguments
- * originally passed to apply.
- *
- * @name apply
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to. Invokes with (arguments...).
- * @param {...*} arguments... - Any number of arguments to automatically apply
- * when the continuation is called.
- * @example
- *
- * // using apply
- * async.parallel([
- * async.apply(fs.writeFile, 'testfile1', 'test1'),
- * async.apply(fs.writeFile, 'testfile2', 'test2')
- * ]);
- *
- *
- * // the same process without using apply
- * async.parallel([
- * function(callback) {
- * fs.writeFile('testfile1', 'test1', callback);
- * },
- * function(callback) {
- * fs.writeFile('testfile2', 'test2', callback);
- * }
- * ]);
- *
- * // It's possible to pass any number of additional arguments when calling the
- * // continuation:
- *
- * node> var fn = async.apply(sys.puts, 'one');
- * node> fn('two', 'three');
- * one
- * two
- * three
- */
- var apply$1 = baseRest(function (fn, args) {
- return baseRest(function (callArgs) {
- return fn.apply(null, args.concat(callArgs));
- });
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+}
+
+/**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+function getValue(object, key) {
+ return object == null ? undefined : object[key];
+}
+
+/**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+}
+
+var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+}());
+
+/**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
});
-
- /**
- * Take a sync function and make it async, passing its return value to a
- * callback. This is useful for plugging sync functions into a waterfall,
- * series, or other async functions. Any arguments passed to the generated
- * function will be passed to the wrapped function (except for the final
- * callback argument). Errors thrown will be passed to the callback.
- *
- * If the function passed to `asyncify` returns a Promise, that promises's
- * resolved/rejected state will be used to call the callback, rather than simply
- * the synchronous return value.
- *
- * This also means you can asyncify ES2016 `async` functions.
- *
- * @name asyncify
- * @static
- * @memberOf module:Utils
- * @method
- * @alias wrapSync
- * @category Util
- * @param {Function} func - The synchronous function to convert to an
- * asynchronous function.
- * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
- * (callback).
- * @example
- *
- * // passing a regular synchronous function
- * async.waterfall([
- * async.apply(fs.readFile, filename, "utf8"),
- * async.asyncify(JSON.parse),
- * function (data, next) {
- * // data is the result of parsing the text.
- * // If there was a parsing error, it would have been caught.
- * }
- * ], callback);
- *
- * // passing a function returning a promise
- * async.waterfall([
- * async.apply(fs.readFile, filename, "utf8"),
- * async.asyncify(function (contents) {
- * return db.model.create(contents);
- * }),
- * function (model, next) {
- * // `model` is the instantiated model object.
- * // If there was an error, this function would be skipped.
- * }
- * ], callback);
- *
- * // es6 example
- * var q = async.queue(async.asyncify(async function(file) {
- * var intermediateStep = await processFile(file);
- * return await somePromise(intermediateStep)
- * }));
- *
- * q.push(files);
- */
- function asyncify(func) {
- return initialParams(function (args, callback) {
- var result;
- try {
- result = func.apply(this, args);
- } catch (e) {
- return callback(e);
- }
- // if result is Promise object
- if (isObject(result) && typeof result.then === 'function') {
- result.then(function (value) {
- callback(null, value);
- }, function (err) {
- callback(err.message ? err : new Error(err));
- });
- } else {
- callback(null, result);
- }
- });
- }
-
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array ? array.length : 0;
-
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
+};
+
+/** Used to detect hot functions by number of calls within a span of milliseconds. */
+var HOT_COUNT = 500;
+var HOT_SPAN = 16;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeNow = Date.now;
+
+/**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+function shortOut(func) {
+ var count = 0,
+ lastCalled = 0;
+
+ return function() {
+ var stamp = nativeNow(),
+ remaining = HOT_SPAN - (stamp - lastCalled);
+
+ lastCalled = stamp;
+ if (remaining > 0) {
+ if (++count >= HOT_COUNT) {
+ return arguments[0];
}
+ } else {
+ count = 0;
}
- return array;
- }
-
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
-
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
+ return func.apply(undefined, arguments);
+ };
+}
+
+/**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var setToString = shortOut(baseSetToString);
+
+/**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+function baseRest$1(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+}
+
+var initialParams = function (fn) {
+ return baseRest$1(function (args /*..., callback*/) {
+ var callback = args.pop();
+ fn.call(this, args, callback);
+ });
+};
+
+function applyEach$1(eachfn) {
+ return baseRest$1(function (fns, args) {
+ var go = initialParams(function (args, callback) {
+ var that = this;
+ return eachfn(fns, function (fn, cb) {
+ fn.apply(that, args.concat([cb]));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ } else {
+ return go;
}
- }
- return object;
+ });
+}
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+}
+
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop() {
+ // No operation performed.
+}
+
+function once(fn) {
+ return function () {
+ if (fn === null) return;
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
};
+}
+
+var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
+
+var getIterator = function (coll) {
+ return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
+};
+
+/**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
}
-
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
-
- /**
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return object && baseFor(object, iteratee, keys);
- }
-
- /**
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
- * support for iteratee shorthands.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {Function} predicate The function invoked per iteration.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 1 : -1);
-
- while ((fromRight ? index-- : ++index < length)) {
- if (predicate(array[index], index, array)) {
- return index;
- }
+ return result;
+}
+
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+}
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]';
+
+/** Used for built-in method references. */
+var objectProto$4 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$1 = objectProto$4.toString;
+
+/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+function baseIsArguments(value) {
+ return isObjectLike(value) && objectToString$1.call(value) == argsTag;
+}
+
+/** Used for built-in method references. */
+var objectProto$3 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
+
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+};
+
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray = Array.isArray;
+
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse() {
+ return false;
+}
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
+
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+var isBuffer = nativeIsBuffer || stubFalse;
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER$1 = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+/** `Object#toString` result references. */
+var argsTag$1 = '[object Arguments]';
+var arrayTag = '[object Array]';
+var boolTag = '[object Boolean]';
+var dateTag = '[object Date]';
+var errorTag = '[object Error]';
+var funcTag$1 = '[object Function]';
+var mapTag = '[object Map]';
+var numberTag = '[object Number]';
+var objectTag = '[object Object]';
+var regexpTag = '[object RegExp]';
+var setTag = '[object Set]';
+var stringTag = '[object String]';
+var weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]';
+var dataViewTag = '[object DataView]';
+var float32Tag = '[object Float32Array]';
+var float64Tag = '[object Float64Array]';
+var int8Tag = '[object Int8Array]';
+var int16Tag = '[object Int16Array]';
+var int32Tag = '[object Int32Array]';
+var uint8Tag = '[object Uint8Array]';
+var uint8ClampedTag = '[object Uint8ClampedArray]';
+var uint16Tag = '[object Uint16Array]';
+var uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values of typed arrays. */
+var typedArrayTags = {};
+typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+typedArrayTags[uint32Tag] = true;
+typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
+typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
+typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+typedArrayTags[setTag] = typedArrayTags[stringTag] =
+typedArrayTags[weakMapTag] = false;
+
+/** Used for built-in method references. */
+var objectProto$5 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$2 = objectProto$5.toString;
+
+/**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[objectToString$2.call(value)];
+}
+
+/**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+}
+
+/** Detect free variable `exports`. */
+var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
+
+/** Detect free variable `process` from Node.js. */
+var freeProcess = moduleExports$1 && freeGlobal.process;
+
+/** Used to access faster Node.js helpers. */
+var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding('util');
+ } catch (e) {}
+}());
+
+/* Node.js helper references. */
+var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+/** Used for built-in method references. */
+var objectProto$2 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
+
+/**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty$1.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
}
- return -1;
}
-
- /**
- * The base implementation of `_.isNaN` without support for number objects.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
- */
- function baseIsNaN(value) {
- return value !== value;
+ return result;
+}
+
+/** Used for built-in method references. */
+var objectProto$7 = Object.prototype;
+
+/**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
+
+ return value === proto;
+}
+
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeKeys = overArg(Object.keys, Object);
+
+/** Used for built-in method references. */
+var objectProto$6 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$3 = objectProto$6.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
}
-
- /**
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- if (value !== value) {
- return baseFindIndex(array, baseIsNaN, fromIndex);
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
+ result.push(key);
}
- var index = fromIndex - 1,
- length = array.length;
-
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
}
+ return result;
+}
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+}
+
+function createArrayIterator(coll) {
+ var i = -1;
+ var len = coll.length;
+ return function next() {
+ 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;
+ i++;
+ return { value: item.value, key: i };
+ };
+}
+
+function createObjectIterator(obj) {
+ var okeys = keys(obj);
+ var i = -1;
+ var len = okeys.length;
+ return function next() {
+ var key = okeys[++i];
+ return i < len ? { value: obj[key], key: key } : null;
+ };
+}
- /**
- * Determines the best order for running the functions in `tasks`, based on
- * their requirements. Each function can optionally depend on other functions
- * being completed first, and each function is run as soon as its requirements
- * are satisfied.
- *
- * If any of the functions pass an error to their callback, the `auto` sequence
- * will stop. Further tasks will not execute (so any other functions depending
- * on it will not run), and the main `callback` is immediately called with the
- * error.
- *
- * Functions also receive an object containing the results of functions which
- * have completed so far as the first argument, if they have dependencies. If a
- * task function has no dependencies, it will only be passed a callback.
- *
- * @name auto
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Object} tasks - An object. Each of its properties is either a
- * function or an array of requirements, with the function itself the last item
- * in the array. The object's key of a property serves as the name of the task
- * defined by that property, i.e. can be used when specifying requirements for
- * other tasks. The function receives one or two arguments:
- * * a `results` object, containing the results of the previously executed
- * functions, only passed if the task has any dependencies,
- * * a `callback(err, result)` function, which must be called when finished,
- * passing an `error` (which can be `null`) and the result of the function's
- * execution.
- * @param {number} [concurrency=Infinity] - An optional `integer` for
- * determining the maximum number of tasks that can be run in parallel. By
- * default, as many as possible.
- * @param {Function} [callback] - An optional callback which is called when all
- * the tasks have been completed. It receives the `err` argument if any `tasks`
- * pass an error to their callback. Results are always returned; however, if an
- * error occurs, no further `tasks` will be performed, and the results object
- * will only contain partial results. Invoked with (err, results).
- * @returns undefined
- * @example
- *
- * async.auto({
- * // this function will just be passed a callback
- * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
- * showData: ['readData', function(results, cb) {
- * // results.readData is the file's contents
- * // ...
- * }]
- * }, callback);
- *
- * async.auto({
- * get_data: function(callback) {
- * console.log('in get_data');
- * // async code to get some data
- * callback(null, 'data', 'converted to array');
- * },
- * make_folder: function(callback) {
- * console.log('in make_folder');
- * // async code to create a directory to store a file in
- * // this is run at the same time as getting the data
- * callback(null, 'folder');
- * },
- * write_file: ['get_data', 'make_folder', function(results, callback) {
- * console.log('in write_file', JSON.stringify(results));
- * // once there is some data and the directory exists,
- * // write the data to a file in the directory
- * callback(null, 'filename');
- * }],
- * email_link: ['write_file', function(results, callback) {
- * console.log('in email_link', JSON.stringify(results));
- * // once the file is written let's email a link to it...
- * // results.write_file contains the filename returned by write_file.
- * callback(null, {'file':results.write_file, 'email':'user@example.com'});
- * }]
- * }, function(err, results) {
- * console.log('err = ', err);
- * console.log('results = ', results);
- * });
- */
- function auto (tasks, concurrency, callback) {
- if (typeof concurrency === 'function') {
- // concurrency is optional, shift the args.
- callback = concurrency;
- concurrency = null;
- }
- callback = once(callback || noop);
- var keys$$ = keys(tasks);
- var numTasks = keys$$.length;
- if (!numTasks) {
- return callback(null);
- }
- if (!concurrency) {
- concurrency = numTasks;
- }
-
- var results = {};
- var runningTasks = 0;
- var hasError = false;
-
- var listeners = {};
-
- var readyTasks = [];
-
- // for cycle detection:
- var readyToCheck = []; // tasks that have been identified as reachable
- // without the possibility of returning to an ancestor task
- var uncheckedDependencies = {};
-
- baseForOwn(tasks, function (task, key) {
- if (!isArray(task)) {
- // no dependencies
- enqueueTask(key, [task]);
- readyToCheck.push(key);
- return;
- }
-
- var dependencies = task.slice(0, task.length - 1);
- var remainingDependencies = dependencies.length;
- if (remainingDependencies === 0) {
- enqueueTask(key, task);
- readyToCheck.push(key);
- return;
- }
- uncheckedDependencies[key] = remainingDependencies;
-
- arrayEach(dependencies, function (dependencyName) {
- if (!tasks[dependencyName]) {
- throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
- }
- addListener(dependencyName, function () {
- remainingDependencies--;
- if (remainingDependencies === 0) {
- enqueueTask(key, task);
- }
- });
- });
- });
-
- checkForDeadlocks();
- processQueue();
-
- function enqueueTask(key, task) {
- readyTasks.push(function () {
- runTask(key, task);
- });
- }
-
- function processQueue() {
- if (readyTasks.length === 0 && runningTasks === 0) {
- return callback(null, results);
- }
- while (readyTasks.length && runningTasks < concurrency) {
- var run = readyTasks.shift();
- run();
- }
- }
-
- function addListener(taskName, fn) {
- var taskListeners = listeners[taskName];
- if (!taskListeners) {
- taskListeners = listeners[taskName] = [];
- }
-
- taskListeners.push(fn);
- }
+function iterator(coll) {
+ if (isArrayLike(coll)) {
+ return createArrayIterator(coll);
+ }
- function taskComplete(taskName) {
- var taskListeners = listeners[taskName] || [];
- arrayEach(taskListeners, function (fn) {
- fn();
- });
- processQueue();
- }
+ var iterator = getIterator(coll);
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
+}
- function runTask(key, task) {
- if (hasError) return;
-
- var taskCallback = onlyOnce(baseRest(function (err, args) {
- runningTasks--;
- if (args.length <= 1) {
- args = args[0];
- }
- if (err) {
- var safeResults = {};
- baseForOwn(results, function (val, rkey) {
- safeResults[rkey] = val;
- });
- safeResults[key] = args;
- hasError = true;
- listeners = [];
-
- callback(err, safeResults);
- } else {
- results[key] = args;
- taskComplete(key);
- }
- }));
-
- runningTasks++;
- var taskFn = task[task.length - 1];
- if (task.length > 1) {
- taskFn(results, taskCallback);
- } else {
- taskFn(taskCallback);
- }
- }
+function onlyOnce(fn) {
+ return function () {
+ if (fn === null) throw new Error("Callback was already called.");
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
- function checkForDeadlocks() {
- // Kahn's algorithm
- // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
- // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
- var currentTask;
- var counter = 0;
- while (readyToCheck.length) {
- currentTask = readyToCheck.pop();
- counter++;
- arrayEach(getDependents(currentTask), function (dependent) {
- if (--uncheckedDependencies[dependent] === 0) {
- readyToCheck.push(dependent);
- }
- });
- }
-
- if (counter !== numTasks) {
- throw new Error('async.auto cannot execute tasks due to a recursive dependency');
- }
- }
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+var breakLoop = {};
- function getDependents(taskName) {
- var result = [];
- baseForOwn(tasks, function (task, key) {
- if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
- result.push(key);
- }
- });
- return result;
- }
- }
+function _eachOfLimit(limit) {
+ return function (obj, iteratee, callback) {
+ callback = once(callback || noop);
+ if (limit <= 0 || !obj) {
+ return callback(null);
+ }
+ var nextElem = iterator(obj);
+ var done = false;
+ var running = 0;
+
+ function iterateeCallback(err, value) {
+ running -= 1;
+ if (err) {
+ done = true;
+ callback(err);
+ } else if (value === breakLoop || done && running <= 0) {
+ done = true;
+ return callback(null);
+ } else {
+ replenish();
+ }
+ }
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array ? array.length : 0,
- result = Array(length);
+ function replenish() {
+ while (running < limit && !done) {
+ var elem = nextElem();
+ if (elem === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
+ }
+ }
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
+ replenish();
+ };
+}
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, iteratee, callback);
+}
+
+function doLimit(fn, limit) {
+ return function (iterable, iteratee, callback) {
+ return fn(iterable, limit, iteratee, callback);
+ };
+}
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = once(callback || noop);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
}
- return result;
- }
-
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function copyArray(source, array) {
- var index = -1,
- length = source.length;
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
+ function iteratorCallback(err) {
+ if (err) {
+ callback(err);
+ } else if (++completed === length) {
+ callback(null);
+ }
}
- return array;
- }
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
-
- /** Detect free variable `self`. */
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
-
- /** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
-
- /** Built-in value references. */
- var Symbol$1 = root.Symbol;
-
- /** `Object#toString` result references. */
- var symbolTag = '[object Symbol]';
-
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$3 = objectProto$5.toString;
-
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString$3.call(value) == symbolTag);
- }
-
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0;
-
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
- var symbolToString = symbolProto ? symbolProto.toString : undefined;
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
+ for (; index < length; index++) {
+ iteratee(coll[index], index, onlyOnce(iteratorCallback));
}
- if (isSymbol(value)) {
- return symbolToString ? symbolToString.call(value) : '';
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = doLimit(eachOfLimit, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+var eachOf = function (coll, iteratee, callback) {
+ var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, iteratee, callback);
+};
+
+function doParallel(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(eachOf, obj, iteratee, callback);
+ };
+}
+
+function _asyncMap(eachfn, arr, iteratee, callback) {
+ callback = once(callback || noop);
+ arr = arr || [];
+ var results = [];
+ var counter = 0;
+
+ eachfn(arr, function (value, _, callback) {
+ var index = counter++;
+ iteratee(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array. The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines)
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ * // results is now an array of stats for each file
+ * });
+ */
+var map = doParallel(_asyncMap);
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ * buckets,
+ * async.applyEach([enableSearch, updateSchema]),
+ * callback
+ * );
+ */
+var applyEach = applyEach$1(map);
+
+function doParallelLimit(fn) {
+ return function (obj, limit, iteratee, callback) {
+ return fn(_eachOfLimit(limit), obj, iteratee, callback);
+ };
+}
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a transformed
+ * item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapLimit = doParallelLimit(_asyncMap);
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapSeries = doLimit(mapLimit, 1);
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+var applyEachSeries = applyEach$1(mapSeries);
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ * async.apply(fs.writeFile, 'testfile1', 'test1'),
+ * async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ * function(callback) {
+ * fs.writeFile('testfile1', 'test1', callback);
+ * },
+ * function(callback) {
+ * fs.writeFile('testfile2', 'test2', callback);
+ * }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+var apply$2 = baseRest$1(function (fn, args) {
+ return baseRest$1(function (callArgs) {
+ return fn.apply(null, args.concat(callArgs));
+ });
+});
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2016 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function to convert to an
+ * asynchronous function.
+ * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
+ * (callback).
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es6 example
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return initialParams(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if (isObject(result) && typeof result.then === 'function') {
+ result.then(function (value) {
+ callback(null, value);
+ }, function (err) {
+ callback(err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+
+/**
+ * A specialized version of `_.forEach` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+function arrayEach(array, iteratee) {
+ var index = -1,
+ length = array ? array.length : 0;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
}
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
-
- /**
- * The base implementation of `_.slice` without an iteratee call guard.
- *
- * @private
- * @param {Array} array The array to slice.
- * @param {number} [start=0] The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the slice of `array`.
- */
- function baseSlice(array, start, end) {
+ return array;
+}
+
+/**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
var index = -1,
- length = array.length;
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
- if (start < 0) {
- start = -start > length ? 0 : (length + start);
- }
- end = end > length ? length : end;
- if (end < 0) {
- end += length;
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
}
- length = start > end ? 0 : ((end - start) >>> 0);
- start >>>= 0;
-
- var result = Array(length);
- while (++index < length) {
- result[index] = array[index + start];
+ return object;
+ };
+}
+
+/**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+var baseFor = createBaseFor();
+
+/**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+}
+
+/**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
}
- return result;
- }
-
- /**
- * Casts `array` to a slice if it's needed.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {number} start The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the cast slice.
- */
- function castSlice(array, start, end) {
- var length = array.length;
- end = end === undefined ? length : end;
- return (!start && end >= length) ? array : baseSlice(array, start, end);
- }
-
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
- * that is not found in the character symbols.
- *
- * @private
- * @param {Array} strSymbols The string symbols to inspect.
- * @param {Array} chrSymbols The character symbols to find.
- * @returns {number} Returns the index of the last unmatched string symbol.
- */
- function charsEndIndex(strSymbols, chrSymbols) {
- var index = strSymbols.length;
-
- while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
- return index;
- }
-
- /**
- * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
- * that is not found in the character symbols.
- *
- * @private
- * @param {Array} strSymbols The string symbols to inspect.
- * @param {Array} chrSymbols The character symbols to find.
- * @returns {number} Returns the index of the first unmatched string symbol.
- */
- function charsStartIndex(strSymbols, chrSymbols) {
- var index = -1,
- length = strSymbols.length;
-
- while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
- return index;
}
-
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff';
- var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
- var rsComboSymbolsRange = '\\u20d0-\\u20f0';
- var rsVarRange = '\\ufe0e\\ufe0f';
- var rsAstral = '[' + rsAstralRange + ']';
- var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
- var rsFitz = '\\ud83c[\\udffb-\\udfff]';
- var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
- var rsNonAstral = '[^' + rsAstralRange + ']';
- var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
- var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
- var rsZWJ = '\\u200d';
- var reOptMod = rsModifier + '?';
- var rsOptVar = '[' + rsVarRange + ']?';
- var rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
- var rsSeq = rsOptVar + reOptMod + rsOptJoin;
- var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
- /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
- var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
-
- /**
- * Converts `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
- function stringToArray(string) {
- return string.match(reComplexSymbol);
- }
-
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : baseToString(value);
+ return -1;
+}
+
+/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+function baseIsNaN(value) {
+ return value !== value;
+}
+
+/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
}
-
- /** Used to match leading and trailing whitespace. */
- var reTrim = /^\s+|\s+$/g;
-
- /**
- * Removes leading and trailing whitespace or specified characters from `string`.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to trim.
- * @param {string} [chars=whitespace] The characters to trim.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {string} Returns the trimmed string.
- * @example
- *
- * _.trim(' abc ');
- * // => 'abc'
- *
- * _.trim('-_-abc-_-', '_-');
- * // => 'abc'
- *
- * _.map([' foo ', ' bar '], _.trim);
- * // => ['foo', 'bar']
- */
- function trim(string, chars, guard) {
- string = toString(string);
- if (string && (guard || chars === undefined)) {
- return string.replace(reTrim, '');
+ return -1;
+}
+
+/**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+}
+
+/**
+ * Determines the best order for running the functions in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the functions pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * Functions also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the function itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ * functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ * passing an `error` (which can be `null`) and the result of the function's
+ * execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ * // this function will just be passed a callback
+ * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ * showData: ['readData', function(results, cb) {
+ * // results.readData is the file's contents
+ * // ...
+ * }]
+ * }, callback);
+ *
+ * async.auto({
+ * get_data: function(callback) {
+ * console.log('in get_data');
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * console.log('in make_folder');
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
+ * console.log('in write_file', JSON.stringify(results));
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(results, callback) {
+ * console.log('in email_link', JSON.stringify(results));
+ * // once the file is written let's email a link to it...
+ * // results.write_file contains the filename returned by write_file.
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ * }]
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('results = ', results);
+ * });
+ */
+var auto = function (tasks, concurrency, callback) {
+ if (typeof concurrency === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
}
- if (!string || !(chars = baseToString(chars))) {
- return string;
+ callback = once(callback || noop);
+ var keys$$1 = keys(tasks);
+ var numTasks = keys$$1.length;
+ if (!numTasks) {
+ return callback(null);
+ }
+ if (!concurrency) {
+ concurrency = numTasks;
}
- var strSymbols = stringToArray(string),
- chrSymbols = stringToArray(chars),
- start = charsStartIndex(strSymbols, chrSymbols),
- end = charsEndIndex(strSymbols, chrSymbols) + 1;
-
- return castSlice(strSymbols, start, end).join('');
- }
-
- var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
- var FN_ARG_SPLIT = /,/;
- var FN_ARG = /(=.+)?(\s*)$/;
- var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
-
- 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) {
- return trim(arg.replace(FN_ARG, ''));
- });
- return func;
- }
-
- /**
- * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
- * tasks are specified as parameters to the function, after the usual callback
- * parameter, with the parameter names matching the names of the tasks it
- * depends on. This can provide even more readable task graphs which can be
- * easier to maintain.
- *
- * If a final callback is specified, the task results are similarly injected,
- * specified as named parameters after the initial error parameter.
- *
- * The autoInject function is purely syntactic sugar and its semantics are
- * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
- *
- * @name autoInject
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.auto]{@link module:ControlFlow.auto}
- * @category Control Flow
- * @param {Object} tasks - An object, each of whose properties is a function of
- * the form 'func([dependencies...], callback). The object's key of a property
- * serves as the name of the task defined by that property, i.e. can be used
- * when specifying requirements for other tasks.
- * * The `callback` parameter is a `callback(err, result)` which must be called
- * when finished, passing an `error` (which can be `null`) and the result of
- * the function's execution. The remaining parameters name other tasks on
- * which the task is dependent, and the results from those tasks are the
- * arguments of those parameters.
- * @param {Function} [callback] - An optional callback which is called when all
- * the tasks have been completed. It receives the `err` argument if any `tasks`
- * pass an error to their callback, and a `results` object with any completed
- * task results, similar to `auto`.
- * @example
- *
- * // The example from `auto` can be rewritten as follows:
- * async.autoInject({
- * get_data: function(callback) {
- * // async code to get some data
- * callback(null, 'data', 'converted to array');
- * },
- * make_folder: function(callback) {
- * // async code to create a directory to store a file in
- * // this is run at the same time as getting the data
- * callback(null, 'folder');
- * },
- * write_file: function(get_data, make_folder, callback) {
- * // once there is some data and the directory exists,
- * // write the data to a file in the directory
- * callback(null, 'filename');
- * },
- * email_link: function(write_file, callback) {
- * // once the file is written let's email a link to it...
- * // write_file contains the filename returned by write_file.
- * callback(null, {'file':write_file, 'email':'user@example.com'});
- * }
- * }, function(err, results) {
- * console.log('err = ', err);
- * console.log('email_link = ', results.email_link);
- * });
- *
- * // If you are using a JS minifier that mangles parameter names, `autoInject`
- * // will not work with plain functions, since the parameter names will be
- * // collapsed to a single letter identifier. To work around this, you can
- * // explicitly specify the names of the parameters your task function needs
- * // in an array, similar to Angular.js dependency injection.
- *
- * // This still has an advantage over plain `auto`, since the results a task
- * // depends on are still spread into arguments.
- * async.autoInject({
- * //...
- * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
- * callback(null, 'filename');
- * }],
- * email_link: ['write_file', function(write_file, callback) {
- * callback(null, {'file':write_file, 'email':'user@example.com'});
- * }]
- * //...
- * }, function(err, results) {
- * console.log('err = ', err);
- * console.log('email_link = ', results.email_link);
- * });
- */
- function autoInject(tasks, callback) {
- var newTasks = {};
-
- baseForOwn(tasks, function (taskFn, key) {
- var params;
-
- if (isArray(taskFn)) {
- params = copyArray(taskFn);
- taskFn = params.pop();
-
- newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
- } else if (taskFn.length === 1) {
- // no dependencies, use the function as-is
- newTasks[key] = taskFn;
- } else {
- params = parseParams(taskFn);
- if (taskFn.length === 0 && params.length === 0) {
- throw new Error("autoInject task functions require explicit parameters.");
- }
-
- params.pop();
-
- newTasks[key] = params.concat(newTask);
- }
-
- function newTask(results, taskCb) {
- var newArgs = arrayMap(params, function (name) {
- return results[name];
- });
- newArgs.push(taskCb);
- taskFn.apply(null, newArgs);
- }
- });
-
- auto(newTasks, callback);
- }
-
- var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
- var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
-
- function fallback(fn) {
- setTimeout(fn, 0);
- }
-
- function wrap(defer) {
- return baseRest(function (fn, args) {
- defer(function () {
- fn.apply(null, args);
- });
- });
- }
-
- var _defer;
-
- if (hasSetImmediate) {
- _defer = setImmediate;
- } else if (hasNextTick) {
- _defer = process.nextTick;
- } else {
- _defer = fallback;
- }
-
- var setImmediate$1 = wrap(_defer);
-
- // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
- // used for queues. This implementation assumes that the node provided by the user can be modified
- // to adjust the next and last properties. We implement only the minimal functionality
- // for queue support.
- function DLL() {
- this.head = this.tail = null;
- this.length = 0;
- }
-
- function setInitial(dll, node) {
- dll.length = 1;
- 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;
- node.prev = node.next = null;
- this.length -= 1;
- return node;
- };
+ var results = {};
+ var runningTasks = 0;
+ var hasError = false;
- DLL.prototype.empty = DLL;
+ var listeners = {};
- DLL.prototype.insertAfter = function (node, newNode) {
- newNode.prev = node;
- newNode.next = node.next;
- if (node.next) node.next.prev = newNode;else this.tail = newNode;
- node.next = newNode;
- this.length += 1;
- };
+ var readyTasks = [];
- DLL.prototype.insertBefore = function (node, newNode) {
- newNode.prev = node.prev;
- newNode.next = node;
- if (node.prev) node.prev.next = newNode;else this.head = newNode;
- node.prev = newNode;
- this.length += 1;
- };
+ // for cycle detection:
+ var readyToCheck = []; // tasks that have been identified as reachable
+ // without the possibility of returning to an ancestor task
+ var uncheckedDependencies = {};
- 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.shift = function () {
- return this.head && this.removeLink(this.head);
- };
-
- DLL.prototype.pop = function () {
- return this.tail && this.removeLink(this.tail);
- };
+ baseForOwn(tasks, function (task, key) {
+ if (!isArray(task)) {
+ // no dependencies
+ enqueueTask(key, [task]);
+ readyToCheck.push(key);
+ return;
+ }
- function queue(worker, concurrency, payload) {
- if (concurrency == null) {
- concurrency = 1;
- } else if (concurrency === 0) {
- throw new Error('Concurrency must not be zero');
- }
+ var dependencies = task.slice(0, task.length - 1);
+ var remainingDependencies = dependencies.length;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ readyToCheck.push(key);
+ return;
+ }
+ uncheckedDependencies[key] = remainingDependencies;
+
+ arrayEach(dependencies, function (dependencyName) {
+ if (!tasks[dependencyName]) {
+ throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
+ }
+ addListener(dependencyName, function () {
+ remainingDependencies--;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ }
+ });
+ });
+ });
+
+ checkForDeadlocks();
+ processQueue();
+
+ function enqueueTask(key, task) {
+ readyTasks.push(function () {
+ runTask(key, task);
+ });
+ }
- function _insert(data, insertAtFront, callback) {
- if (callback != null && typeof callback !== 'function') {
- throw new Error('task callback must be a function');
- }
- q.started = true;
- if (!isArray(data)) {
- data = [data];
- }
- if (data.length === 0 && q.idle()) {
- // call drain immediately if there are no tasks
- return setImmediate$1(function () {
- q.drain();
- });
- }
- arrayEach(data, function (task) {
- var item = {
- data: task,
- callback: callback || noop
- };
-
- if (insertAtFront) {
- q._tasks.unshift(item);
- } else {
- q._tasks.push(item);
- }
- });
- setImmediate$1(q.process);
- }
+ function processQueue() {
+ if (readyTasks.length === 0 && runningTasks === 0) {
+ return callback(null, results);
+ }
+ while (readyTasks.length && runningTasks < concurrency) {
+ var run = readyTasks.shift();
+ run();
+ }
+ }
- function _next(tasks) {
- return baseRest(function (args) {
- workers -= 1;
-
- arrayEach(tasks, function (task) {
- arrayEach(workersList, function (worker, index) {
- if (worker === task) {
- workersList.splice(index, 1);
- return false;
- }
- });
-
- task.callback.apply(task, args);
-
- if (args[0] != null) {
- q.error(args[0], task.data);
- }
- });
-
- if (workers <= q.concurrency - q.buffer) {
- q.unsaturated();
- }
-
- if (q.idle()) {
- q.drain();
- }
- q.process();
- });
- }
+ function addListener(taskName, fn) {
+ var taskListeners = listeners[taskName];
+ if (!taskListeners) {
+ taskListeners = listeners[taskName] = [];
+ }
- var workers = 0;
- var workersList = [];
- var q = {
- _tasks: new DLL(),
- concurrency: concurrency,
- payload: payload,
- saturated: noop,
- unsaturated: noop,
- buffer: concurrency / 4,
- empty: noop,
- drain: noop,
- error: noop,
- started: false,
- paused: false,
- push: function (data, callback) {
- _insert(data, false, callback);
- },
- kill: function () {
- q.drain = noop;
- q._tasks.empty();
- },
- unshift: function (data, callback) {
- _insert(data, true, callback);
- },
- process: function () {
- while (!q.paused && workers < 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++) {
- var node = q._tasks.shift();
- tasks.push(node);
- data.push(node.data);
- }
-
- if (q._tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- workersList.push(tasks[0]);
-
- if (workers === q.concurrency) {
- q.saturated();
- }
-
- var cb = onlyOnce(_next(tasks));
- worker(data, cb);
- }
- },
- length: function () {
- return q._tasks.length;
- },
- running: function () {
- return workers;
- },
- workersList: function () {
- return workersList;
- },
- idle: function () {
- return q._tasks.length + workers === 0;
- },
- pause: function () {
- q.paused = true;
- },
- resume: function () {
- if (q.paused === false) {
- return;
- }
- q.paused = false;
- var resumeCount = Math.min(q.concurrency, q._tasks.length);
- // Need to call q.process once per concurrent
- // worker to preserve full concurrency after pause
- for (var w = 1; w <= resumeCount; w++) {
- setImmediate$1(q.process);
- }
- }
- };
- return q;
- }
+ taskListeners.push(fn);
+ }
- /**
- * A cargo of tasks for the worker function to complete. Cargo inherits all of
- * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
- * @typedef {Object} CargoObject
- * @memberOf module:ControlFlow
- * @property {Function} length - A function returning the number of items
- * waiting to be processed. Invoke like `cargo.length()`.
- * @property {number} payload - An `integer` for determining how many tasks
- * should be process per round. This property can be changed after a `cargo` is
- * created to alter the payload on-the-fly.
- * @property {Function} push - Adds `task` to the `queue`. The callback is
- * called once the `worker` has finished processing the task. Instead of a
- * single task, an array of `tasks` can be submitted. The respective callback is
- * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
- * @property {Function} saturated - A callback that is called when the
- * `queue.length()` hits the concurrency and further tasks will be queued.
- * @property {Function} empty - A callback that is called when the last item
- * from the `queue` is given to a `worker`.
- * @property {Function} drain - A callback that is called when the last item
- * from the `queue` has returned from the `worker`.
- * @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
- * @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke like `cargo.pause()`.
- * @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
- * @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
- */
-
- /**
- * Creates a `cargo` object with the specified payload. Tasks added to the
- * cargo will be processed altogether (up to the `payload` limit). If the
- * `worker` is in progress, the task is queued until it becomes available. Once
- * the `worker` has completed some tasks, each callback of those tasks is
- * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
- * for how `cargo` and `queue` work.
- *
- * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
- * at a time, cargo passes an array of tasks to a single worker, repeating
- * when the worker is finished.
- *
- * @name cargo
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.queue]{@link module:ControlFlow.queue}
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing an array
- * of queued tasks, which must call its `callback(err)` argument when finished,
- * with an optional `err` argument. Invoked with `(tasks, callback)`.
- * @param {number} [payload=Infinity] - An optional `integer` for determining
- * how many tasks should be processed per round; if omitted, the default is
- * unlimited.
- * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
- * attached as certain properties to listen for specific events during the
- * lifecycle of the cargo and inner queue.
- * @example
- *
- * // create a cargo object with payload 2
- * var cargo = async.cargo(function(tasks, callback) {
- * for (var i=0; i<tasks.length; i++) {
- * console.log('hello ' + tasks[i].name);
- * }
- * callback();
- * }, 2);
- *
- * // add some items
- * cargo.push({name: 'foo'}, function(err) {
- * console.log('finished processing foo');
- * });
- * cargo.push({name: 'bar'}, function(err) {
- * console.log('finished processing bar');
- * });
- * cargo.push({name: 'baz'}, function(err) {
- * console.log('finished processing baz');
- * });
- */
- function cargo(worker, payload) {
- return queue(worker, 1, payload);
- }
+ function taskComplete(taskName) {
+ var taskListeners = listeners[taskName] || [];
+ arrayEach(taskListeners, function (fn) {
+ fn();
+ });
+ processQueue();
+ }
- /**
- * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
- *
- * @name eachOfSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.eachOf]{@link module:Collections.eachOf}
- * @alias forEachOfSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`. The
- * `key` is the item's key, or index in the case of an array. The iteratee is
- * passed a `callback(err)` which must be called once it has completed. If no
- * error has occurred, the callback should be run without arguments or with an
- * explicit `null` argument. Invoked with (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Invoked with (err).
- */
- var eachOfSeries = doLimit(eachOfLimit, 1);
-
- /**
- * Reduces `coll` into a single value using an async `iteratee` to return each
- * successive step. `memo` is the initial state of the reduction. This function
- * only operates in series.
- *
- * For performance reasons, it may make sense to split a call to this function
- * into a parallel map, and then use the normal `Array.prototype.reduce` on the
- * results. This function is for situations where each step in the reduction
- * needs to be async; if you can get the data before reducing it, then it's
- * probably a good idea to do so.
- *
- * @name reduce
- * @static
- * @memberOf module:Collections
- * @method
- * @alias inject
- * @alias foldl
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {*} memo - The initial state of the reduction.
- * @param {Function} iteratee - A function applied to each item in the
- * array to produce the next step in the reduction. The `iteratee` is passed a
- * `callback(err, reduction)` which accepts an optional error as its first
- * argument, and the state of the reduction as the second. If an error is
- * passed to the callback, the reduction is stopped and the main `callback` is
- * immediately called with the error. Invoked with (memo, item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the reduced value. Invoked with
- * (err, result).
- * @example
- *
- * async.reduce([1,2,3], 0, function(memo, item, callback) {
- * // pointless async:
- * process.nextTick(function() {
- * callback(null, memo + item)
- * });
- * }, function(err, result) {
- * // result is now equal to the last value of memo, which is 6
- * });
- */
- function reduce(coll, memo, iteratee, callback) {
- callback = once(callback || noop);
- eachOfSeries(coll, function (x, i, callback) {
- iteratee(memo, x, function (err, v) {
- memo = v;
- callback(err);
- });
- }, function (err) {
- callback(err, memo);
- });
- }
+ function runTask(key, task) {
+ if (hasError) return;
+
+ var taskCallback = onlyOnce(baseRest$1(function (err, args) {
+ runningTasks--;
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ if (err) {
+ var safeResults = {};
+ baseForOwn(results, function (val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[key] = args;
+ hasError = true;
+ listeners = [];
+
+ callback(err, safeResults);
+ } else {
+ results[key] = args;
+ taskComplete(key);
+ }
+ }));
+
+ runningTasks++;
+ var taskFn = task[task.length - 1];
+ if (task.length > 1) {
+ taskFn(results, taskCallback);
+ } else {
+ taskFn(taskCallback);
+ }
+ }
- /**
- * Version of the compose function that is more natural to read. Each function
- * consumes the return value of the previous function. It is the equivalent of
- * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name seq
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.compose]{@link module:ControlFlow.compose}
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @returns {Function} a function that composes the `functions` in order
- * @example
- *
- * // Requires lodash (or underscore), express3 and dresende's orm2.
- * // Part of an app, that fetches cats of the logged user.
- * // This example uses `seq` function to avoid overnesting and error
- * // handling clutter.
- * app.get('/cats', function(request, response) {
- * var User = request.models.User;
- * async.seq(
- * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
- * function(user, fn) {
- * user.getCats(fn); // 'getCats' has signature (callback(err, data))
- * }
- * )(req.session.user_id, function (err, cats) {
- * if (err) {
- * console.error(err);
- * response.json({ status: 'error', message: err.message });
- * } else {
- * response.json({ status: 'ok', message: 'Cats found', data: cats });
- * }
- * });
- * });
- */
- var seq = baseRest(function seq(functions) {
- return baseRest(function (args) {
- var that = this;
-
- var cb = args[args.length - 1];
- if (typeof cb == 'function') {
- args.pop();
- } else {
- cb = noop;
- }
-
- reduce(functions, args, function (newargs, fn, cb) {
- fn.apply(that, newargs.concat([baseRest(function (err, nextargs) {
- cb(err, nextargs);
- })]));
- }, function (err, results) {
- cb.apply(that, [err].concat(results));
- });
- });
- });
+ function checkForDeadlocks() {
+ // Kahn's algorithm
+ // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+ // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+ var currentTask;
+ var counter = 0;
+ while (readyToCheck.length) {
+ currentTask = readyToCheck.pop();
+ counter++;
+ arrayEach(getDependents(currentTask), function (dependent) {
+ if (--uncheckedDependencies[dependent] === 0) {
+ readyToCheck.push(dependent);
+ }
+ });
+ }
- /**
- * Creates a function which is a composition of the passed asynchronous
- * functions. Each function consumes the return value of the function that
- * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
- * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name compose
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @returns {Function} an asynchronous function that is the composed
- * asynchronous `functions`
- * @example
- *
- * function add1(n, callback) {
- * setTimeout(function () {
- * callback(null, n + 1);
- * }, 10);
- * }
- *
- * function mul3(n, callback) {
- * setTimeout(function () {
- * callback(null, n * 3);
- * }, 10);
- * }
- *
- * var add1mul3 = async.compose(mul3, add1);
- * add1mul3(4, function (err, result) {
- * // result now equals 15
- * });
- */
- var compose = baseRest(function (args) {
- return seq.apply(null, args.reverse());
- });
+ if (counter !== numTasks) {
+ throw new Error('async.auto cannot execute tasks due to a recursive dependency');
+ }
+ }
- function concat$1(eachfn, arr, fn, callback) {
- var result = [];
- eachfn(arr, function (x, index, cb) {
- fn(x, function (err, y) {
- result = result.concat(y || []);
- cb(err);
- });
- }, function (err) {
- callback(err, result);
- });
+ function getDependents(taskName) {
+ var result = [];
+ baseForOwn(tasks, function (task, key) {
+ if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
+ result.push(key);
+ }
+ });
+ return result;
+ }
+};
+
+/**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array ? array.length : 0,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
}
-
- /**
- * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
- * the concatenated list. The `iteratee`s are called in parallel, and the
- * results are concatenated as they return. There is no guarantee that the
- * results array will be returned in the original order of `coll` passed to the
- * `iteratee` function.
- *
- * @name concat
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- * @example
- *
- * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
- * // files is now a list of filenames that exist in the 3 directories
- * });
- */
- var concat = doParallel(concat$1);
-
- function doSeries(fn) {
- return function (obj, iteratee, callback) {
- return fn(eachOfSeries, obj, iteratee, callback);
- };
+ return result;
+}
+
+/**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+function copyArray(source, array) {
+ var index = -1,
+ length = source.length;
+
+ array || (array = Array(length));
+ while (++index < length) {
+ array[index] = source[index];
}
-
- /**
- * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
- *
- * @name concatSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.concat]{@link module:Collections.concat}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- */
- var concatSeries = doSeries(concat$1);
-
- /**
- * Returns a function that when called, calls-back with the values provided.
- * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
- * [`auto`]{@link module:ControlFlow.auto}.
- *
- * @name constant
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {...*} arguments... - Any number of arguments to automatically invoke
- * callback with.
- * @returns {Function} Returns a function that when invoked, automatically
- * invokes the callback with the previous given arguments.
- * @example
- *
- * async.waterfall([
- * async.constant(42),
- * function (value, next) {
- * // value === 42
- * },
- * //...
- * ], callback);
- *
- * async.waterfall([
- * async.constant(filename, "utf8"),
- * fs.readFile,
- * function (fileData, next) {
- * //...
- * }
- * //...
- * ], callback);
- *
- * async.auto({
- * hostname: async.constant("https://server.net/"),
- * port: findFreePort,
- * launchServer: ["hostname", "port", function (options, cb) {
- * startServer(options, cb);
- * }],
- * //...
- * }, callback);
- */
- var constant = baseRest(function (values) {
- var args = [null].concat(values);
- return initialParams(function (ignoredArgs, callback) {
- return callback.apply(this, args);
- });
- });
-
- /**
- * This method returns the first argument it receives.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'a': 1 };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
+ return array;
+}
+
+/** Built-in value references. */
+var Symbol$1 = root.Symbol;
+
+/** `Object#toString` result references. */
+var symbolTag = '[object Symbol]';
+
+/** Used for built-in method references. */
+var objectProto$8 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$3 = objectProto$8.toString;
+
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && objectToString$3.call(value) == symbolTag);
+}
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
+var symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+/**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
return value;
}
-
- function _createTester(eachfn, check, getResult) {
- return function (arr, limit, iteratee, cb) {
- function done(err) {
- if (cb) {
- if (err) {
- cb(err);
- } else {
- cb(null, getResult(false));
- }
- }
- }
- function wrappedIteratee(x, _, callback) {
- if (!cb) return callback();
- iteratee(x, function (err, v) {
- if (cb) {
- if (err) {
- cb(err);
- cb = iteratee = false;
- } else if (check(v)) {
- cb(null, getResult(true, x));
- cb = iteratee = false;
- }
- }
- callback();
- });
- }
- if (arguments.length > 3) {
- cb = cb || noop;
- eachfn(arr, limit, wrappedIteratee, done);
- } else {
- cb = iteratee;
- cb = cb || noop;
- iteratee = limit;
- eachfn(arr, wrappedIteratee, done);
- }
- };
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
}
-
- function _findGetResult(v, x) {
- return x;
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
}
-
- /**
- * Returns the first value in `coll` that passes an async truth test. The
- * `iteratee` is applied in parallel, meaning the first iteratee to return
- * `true` will fire the detect `callback` with that result. That means the
- * result might not be the first item in the original `coll` (in terms of order)
- * that passes the test.
-
- * If order within the original `coll` is important, then look at
- * [`detectSeries`]{@link module:Collections.detectSeries}.
- *
- * @name detect
- * @static
- * @memberOf module:Collections
- * @method
- * @alias find
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- * @example
- *
- * async.detect(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // result now equals the first file in the list that exists
- * });
- */
- var detect = _createTester(eachOf, identity, _findGetResult);
-
- /**
- * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name detectLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.detect]{@link module:Collections.detect}
- * @alias findLimit
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
- var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
-
- /**
- * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
- *
- * @name detectSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.detect]{@link module:Collections.detect}
- * @alias findSeries
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
- var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
-
- function consoleFunc(name) {
- return baseRest(function (fn, args) {
- fn.apply(null, args.concat([baseRest(function (err, args) {
- if (typeof console === 'object') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- } else if (console[name]) {
- arrayEach(args, function (x) {
- console[name](x);
- });
- }
- }
- })]));
- });
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+/**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
}
-
- /**
- * Logs the result of an `async` function to the `console` using `console.dir`
- * to display the properties of the resulting object. Only works in Node.js or
- * in browsers that support `console.dir` and `console.error` (such as FF and
- * Chrome). If multiple arguments are returned from the async function,
- * `console.dir` is called on each argument in order.
- *
- * @name dir
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, {hello: name});
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.dir(hello, 'world');
- * {hello: 'world'}
- */
- var dir = consoleFunc('dir');
-
- /**
- * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
- * the order of operations, the arguments `test` and `fn` are switched.
- *
- * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
- * @name doDuring
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.during]{@link module:ControlFlow.during}
- * @category Control Flow
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - asynchronous truth test to perform before each
- * execution of `fn`. Invoked with (...args, callback), where `...args` are the
- * non-error args from the previous callback of `fn`.
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error if one occured, otherwise `null`.
- */
- function doDuring(fn, test, callback) {
- callback = onlyOnce(callback || noop);
-
- var next = baseRest(function (err, args) {
- if (err) return callback(err);
- args.push(check);
- test.apply(this, args);
- });
-
- function check(err, truth) {
- if (err) return callback(err);
- if (!truth) return callback(null);
- fn(next);
- }
-
- check(null, true);
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
}
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
- /**
- * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
- * the order of operations, the arguments `test` and `iteratee` are switched.
- *
- * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
- *
- * @name doWhilst
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.whilst]{@link module:ControlFlow.whilst}
- * @category Control Flow
- * @param {Function} iteratee - A function which is called each time `test`
- * passes. The function is passed a `callback(err)`, which must be called once
- * it has completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - synchronous truth test to perform after each
- * execution of `iteratee`. Invoked with Invoked with the non-error callback
- * results of `iteratee`.
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `iteratee` has stopped.
- * `callback` will be passed an error and any arguments passed to the final
- * `iteratee`'s callback. Invoked with (err, [results]);
- */
- function doWhilst(iteratee, test, callback) {
- callback = onlyOnce(callback || noop);
- var next = baseRest(function (err, args) {
- if (err) return callback(err);
- if (test.apply(this, args)) return iteratee(next);
- callback.apply(null, [null].concat(args));
- });
- iteratee(next);
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
}
-
- /**
- * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
- * argument ordering differs from `until`.
- *
- * @name doUntil
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
- * @category Control Flow
- * @param {Function} fn - A function which is called each time `test` fails.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - synchronous truth test to perform after each
- * execution of `fn`. Invoked with the non-error callback results of `fn`.
- * @param {Function} [callback] - A callback which is called after the test
- * function has passed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function doUntil(fn, test, callback) {
- doWhilst(fn, function () {
- return !test.apply(this, arguments);
- }, callback);
+ return result;
+}
+
+/**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+}
+
+/**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the last unmatched string symbol.
+ */
+function charsEndIndex(strSymbols, chrSymbols) {
+ var index = strSymbols.length;
+
+ while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the first unmatched string symbol.
+ */
+function charsStartIndex(strSymbols, chrSymbols) {
+ var index = -1,
+ length = strSymbols.length;
+
+ while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function asciiToArray(string) {
+ return string.split('');
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff';
+var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
+var rsComboSymbolsRange = '\\u20d0-\\u20f0';
+var rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsZWJ = '\\u200d';
+
+/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
+var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+
+/**
+ * Checks if `string` contains Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
+ */
+function hasUnicode(string) {
+ return reHasUnicode.test(string);
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange$1 = '\\ud800-\\udfff';
+var rsComboMarksRange$1 = '\\u0300-\\u036f\\ufe20-\\ufe23';
+var rsComboSymbolsRange$1 = '\\u20d0-\\u20f0';
+var rsVarRange$1 = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsAstral = '[' + rsAstralRange$1 + ']';
+var rsCombo = '[' + rsComboMarksRange$1 + rsComboSymbolsRange$1 + ']';
+var rsFitz = '\\ud83c[\\udffb-\\udfff]';
+var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
+var rsNonAstral = '[^' + rsAstralRange$1 + ']';
+var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
+var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
+var rsZWJ$1 = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var reOptMod = rsModifier + '?';
+var rsOptVar = '[' + rsVarRange$1 + ']?';
+var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
+var rsSeq = rsOptVar + reOptMod + rsOptJoin;
+var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+/**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+}
+
+/**
+ * Converts `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function stringToArray(string) {
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
+}
+
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+
+/** Used to match leading and trailing whitespace. */
+var reTrim = /^\s+|\s+$/g;
+
+/**
+ * Removes leading and trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trim(' abc ');
+ * // => 'abc'
+ *
+ * _.trim('-_-abc-_-', '_-');
+ * // => 'abc'
+ *
+ * _.map([' foo ', ' bar '], _.trim);
+ * // => ['foo', 'bar']
+ */
+function trim(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrim, '');
}
-
- /**
- * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
- * is passed a callback in the form of `function (err, truth)`. If error is
- * passed to `test` or `fn`, the main callback is immediately called with the
- * value of the error.
- *
- * @name during
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.whilst]{@link module:ControlFlow.whilst}
- * @category Control Flow
- * @param {Function} test - asynchronous truth test to perform before each
- * execution of `fn`. Invoked with (callback).
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error, if one occured, otherwise `null`.
- * @example
- *
- * var count = 0;
- *
- * async.during(
- * function (callback) {
- * return callback(null, count < 5);
- * },
- * function (callback) {
- * count++;
- * setTimeout(callback, 1000);
- * },
- * function (err) {
- * // 5 seconds have passed
- * }
- * );
- */
- function during(test, fn, callback) {
- callback = onlyOnce(callback || noop);
-
- function next(err) {
- if (err) return callback(err);
- test(check);
- }
-
- function check(err, truth) {
- if (err) return callback(err);
- if (!truth) return callback(null);
- fn(next);
- }
-
- test(check);
- }
-
- function _withoutIndex(iteratee) {
- return function (value, index, callback) {
- return iteratee(value, callback);
- };
- }
-
- /**
- * Applies the function `iteratee` to each item in `coll`, in parallel.
- * The `iteratee` is called with an item from the list, and a callback for when
- * it has finished. If the `iteratee` passes an error to its `callback`, the
- * main `callback` (for the `each` function) is immediately called with the
- * error.
- *
- * Note, that since this function applies `iteratee` to each item in parallel,
- * there is no guarantee that the iteratee functions will complete in order.
- *
- * @name each
- * @static
- * @memberOf module:Collections
- * @method
- * @alias forEach
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item
- * in `coll`. The iteratee is passed a `callback(err)` which must be called once
- * it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is not
- * passed to the iteratee. Invoked with (item, callback). If you need the index,
- * use `eachOf`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * // assuming openFiles is an array of file names and saveFile is a function
- * // to save the modified contents of that file:
- *
- * async.each(openFiles, saveFile, function(err){
- * // if any of the saves produced an error, err would equal that error
- * });
- *
- * // assuming openFiles is an array of file names
- * async.each(openFiles, function(file, callback) {
- *
- * // Perform operation on file here.
- * console.log('Processing file ' + file);
- *
- * if( file.length > 32 ) {
- * console.log('This file name is too long');
- * callback('File name too long');
- * } else {
- * // Do work to process file here
- * console.log('File processed');
- * callback();
- * }
- * }, function(err) {
- * // if any of the file processing produced an error, err would equal that error
- * if( err ) {
- * // One of the iterations produced an error.
- * // All processing will now stop.
- * console.log('A file failed to process');
- * } else {
- * console.log('All files have been processed successfully');
- * }
- * });
- */
- function eachLimit(coll, iteratee, callback) {
- eachOf(coll, _withoutIndex(iteratee), callback);
- }
-
- /**
- * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
- *
- * @name eachLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.each]{@link module:Collections.each}
- * @alias forEachLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A colleciton to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each item in `coll`. The
- * iteratee is passed a `callback(err)` which must be called once it has
- * completed. If no error has occurred, the `callback` should be run without
- * arguments or with an explicit `null` argument. The array index is not passed
- * to the iteratee. Invoked with (item, callback). If you need the index, use
- * `eachOfLimit`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- function eachLimit$1(coll, limit, iteratee, callback) {
- _eachOfLimit(limit)(coll, _withoutIndex(iteratee), callback);
- }
-
- /**
- * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
- *
- * @name eachSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.each]{@link module:Collections.each}
- * @alias forEachSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The iteratee is passed a `callback(err)` which must be called
- * once it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is
- * not passed to the iteratee. Invoked with (item, callback). If you need the
- * index, use `eachOfSeries`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- var eachSeries = doLimit(eachLimit$1, 1);
-
- /**
- * Wrap an async function and ensure it calls its callback on a later tick of
- * the event loop. If the function already calls its callback on a next tick,
- * no extra deferral is added. This is useful for preventing stack overflows
- * (`RangeError: Maximum call stack size exceeded`) and generally keeping
- * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
- * contained.
- *
- * @name ensureAsync
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} fn - an async function, one that expects a node-style
- * callback as its last argument.
- * @returns {Function} Returns a wrapped function with the exact same call
- * signature as the function passed in.
- * @example
- *
- * function sometimesAsync(arg, callback) {
- * if (cache[arg]) {
- * return callback(null, cache[arg]); // this would be synchronous!!
- * } else {
- * doSomeIO(arg, callback); // this IO would be asynchronous
- * }
- * }
- *
- * // this has a risk of stack overflows if many results are cached in a row
- * async.mapSeries(args, sometimesAsync, done);
- *
- * // this will defer sometimesAsync's callback if necessary,
- * // preventing stack overflows
- * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
- */
- function ensureAsync(fn) {
- return initialParams(function (args, callback) {
- var sync = true;
- args.push(function () {
- var innerArgs = arguments;
- if (sync) {
- setImmediate$1(function () {
- callback.apply(null, innerArgs);
- });
- } else {
- callback.apply(null, innerArgs);
- }
- });
- fn.apply(this, args);
- sync = false;
- });
- }
-
- function notId(v) {
- return !v;
- }
-
- /**
- * Returns `true` if every element in `coll` satisfies an async test. If any
- * iteratee call returns `false`, the main `callback` is immediately called.
- *
- * @name every
- * @static
- * @memberOf module:Collections
- * @method
- * @alias all
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- * @example
- *
- * async.every(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then every file exists
- * });
- */
- var every = _createTester(eachOf, notId, notId);
-
- /**
- * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
- *
- * @name everyLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.every]{@link module:Collections.every}
- * @alias allLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
- var everyLimit = _createTester(eachOfLimit, notId, notId);
-
- /**
- * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
- *
- * @name everySeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.every]{@link module:Collections.every}
- * @alias allSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
- var everySeries = doLimit(everyLimit, 1);
-
- function _filter(eachfn, arr, iteratee, callback) {
- callback = once(callback || noop);
- var results = [];
- eachfn(arr, function (x, index, callback) {
- iteratee(x, function (err, v) {
- if (err) {
- callback(err);
- } else {
- if (v) {
- results.push({ index: index, value: x });
- }
- callback();
- }
- });
- }, function (err) {
- if (err) {
- callback(err);
- } else {
- callback(null, arrayMap(results.sort(function (a, b) {
- return a.index - b.index;
- }), baseProperty('value')));
- }
- });
- }
-
- /**
- * Returns a new array of all the values in `coll` which pass an async truth
- * test. This operation is performed in parallel, but the results array will be
- * in the same order as the original.
- *
- * @name filter
- * @static
- * @memberOf module:Collections
- * @method
- * @alias select
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.filter(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of the existing files
- * });
- */
- var filter = doParallel(_filter);
-
- /**
- * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name filterLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @alias selectLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var filterLimit = doParallelLimit(_filter);
-
- /**
- * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
- *
- * @name filterSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @alias selectSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results)
- */
- var filterSeries = doLimit(filterLimit, 1);
-
- /**
- * Calls the asynchronous function `fn` with a callback parameter that allows it
- * to call itself again, in series, indefinitely.
-
- * If an error is passed to the
- * callback then `errback` is called with the error, and execution stops,
- * otherwise it will never be called.
- *
- * @name forever
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Function} fn - a function to call repeatedly. Invoked with (next).
- * @param {Function} [errback] - when `fn` passes an error to it's callback,
- * this function will be called, and execution stops. Invoked with (err).
- * @example
- *
- * async.forever(
- * function(next) {
- * // next is suitable for passing to things that need a callback(err [, whatever]);
- * // it will result in this function being called again.
- * },
- * function(err) {
- * // if next is called with a value in its first parameter, it will appear
- * // in here as 'err', and execution will stop.
- * }
- * );
- */
- function forever(fn, errback) {
- var done = onlyOnce(errback || noop);
- var task = ensureAsync(fn);
-
- function next(err) {
- if (err) return done(err);
- task(next);
- }
- next();
- }
-
- /**
- * Logs the result of an `async` function to the `console`. Only works in
- * Node.js or in browsers that support `console.log` and `console.error` (such
- * as FF and Chrome). If multiple arguments are returned from the async
- * function, `console.log` is called on each argument in order.
- *
- * @name log
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, 'hello ' + name);
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.log(hello, 'world');
- * 'hello world'
- */
- var log = consoleFunc('log');
-
- /**
- * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name mapValuesLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.mapValues]{@link module:Collections.mapValues}
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
- */
- function mapValuesLimit(obj, limit, iteratee, callback) {
- callback = once(callback || noop);
- var newObj = {};
- eachOfLimit(obj, limit, function (val, key, next) {
- iteratee(val, key, function (err, result) {
- if (err) return next(err);
- newObj[key] = result;
- next();
- });
- }, function (err) {
- callback(err, newObj);
- });
- }
-
- /**
- * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
- *
- * Produces a new Object by mapping each value of `obj` through the `iteratee`
- * function. The `iteratee` is called each `value` and `key` from `obj` and a
- * callback for when it has finished processing. Each of these callbacks takes
- * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
- * passes an error to its callback, the main `callback` (for the `mapValues`
- * function) is immediately called with the error.
- *
- * Note, the order of the keys in the result is not guaranteed. The keys will
- * be roughly in the order they complete, (but this is very engine-specific)
- *
- * @name mapValues
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value and key in
- * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
- * called once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `obj`. Invoked with (err, result).
- * @example
- *
- * async.mapValues({
- * f1: 'file1',
- * f2: 'file2',
- * f3: 'file3'
- * }, function (file, key, callback) {
- * fs.stat(file, callback);
- * }, function(err, result) {
- * // results is now a map of stats for each file, e.g.
- * // {
- * // f1: [stats for file1],
- * // f2: [stats for file2],
- * // f3: [stats for file3]
- * // }
- * });
- */
-
- var mapValues = doLimit(mapValuesLimit, Infinity);
-
- /**
- * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
- *
- * @name mapValuesSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.mapValues]{@link module:Collections.mapValues}
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
- */
- var mapValuesSeries = doLimit(mapValuesLimit, 1);
-
- function has(obj, key) {
- return key in obj;
- }
-
- /**
- * Caches the results of an `async` function. When creating a hash to store
- * function results against, the callback is omitted from the hash and an
- * optional hash function can be used.
- *
- * If no hash function is specified, the first argument is used as a hash key,
- * which may work reasonably if it is a string or a data type that converts to a
- * distinct string. Note that objects and arrays will not behave reasonably.
- * Neither will cases where the other arguments are significant. In such cases,
- * specify your own hash function.
- *
- * The cache of results is exposed as the `memo` property of the function
- * returned by `memoize`.
- *
- * @name memoize
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} fn - The function to proxy and cache results from.
- * @param {Function} hasher - An optional function for generating a custom hash
- * for storing results. It has all the arguments applied to it apart from the
- * callback, and must be synchronous.
- * @returns {Function} a memoized version of `fn`
- * @example
- *
- * var slow_fn = function(name, callback) {
- * // do something
- * callback(null, result);
- * };
- * var fn = async.memoize(slow_fn);
- *
- * // fn can now be used as if it were slow_fn
- * fn('some name', function() {
- * // callback
- * });
- */
- function memoize(fn, hasher) {
- var memo = Object.create(null);
- var queues = Object.create(null);
- hasher = hasher || identity;
- var memoized = initialParams(function memoized(args, callback) {
- var key = hasher.apply(null, args);
- if (has(memo, key)) {
- 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([baseRest(function (args) {
- memo[key] = args;
- var q = queues[key];
- delete queues[key];
- for (var i = 0, l = q.length; i < l; i++) {
- q[i].apply(null, args);
- }
- })]));
- }
- });
- memoized.memo = memo;
- memoized.unmemoized = fn;
- return memoized;
- }
-
- /**
- * Calls `callback` on a later loop around the event loop. In Node.js this just
- * calls `setImmediate`. In the browser it will use `setImmediate` if
- * available, otherwise `setTimeout(callback, 0)`, which means other higher
- * priority events may precede the execution of `callback`.
- *
- * This is used internally for browser-compatibility purposes.
- *
- * @name nextTick
- * @static
- * @memberOf module:Utils
- * @method
- * @alias setImmediate
- * @category Util
- * @param {Function} callback - The function to call on a later loop around
- * the event loop. Invoked with (args...).
- * @param {...*} args... - any number of additional arguments to pass to the
- * callback on the next tick.
- * @example
- *
- * var call_order = [];
- * async.nextTick(function() {
- * call_order.push('two');
- * // call_order now equals ['one','two']
- * });
- * call_order.push('one');
- *
- * async.setImmediate(function (a, b, c) {
- * // a, b, and c equal 1, 2, and 3
- * }, 1, 2, 3);
- */
- var _defer$1;
-
- if (hasNextTick) {
- _defer$1 = process.nextTick;
- } else if (hasSetImmediate) {
- _defer$1 = setImmediate;
- } else {
- _defer$1 = fallback;
- }
-
- var nextTick = wrap(_defer$1);
-
- function _parallel(eachfn, tasks, callback) {
- callback = callback || noop;
- var results = isArrayLike(tasks) ? [] : {};
-
- eachfn(tasks, function (task, key, callback) {
- task(baseRest(function (err, args) {
- if (args.length <= 1) {
- args = args[0];
- }
- results[key] = args;
- callback(err);
- }));
- }, function (err) {
- callback(err, results);
- });
- }
-
- /**
- * Run the `tasks` collection of functions in parallel, without waiting until
- * the previous function has completed. If any of the functions pass an error to
- * its callback, the main `callback` is immediately called with the value of the
- * error. Once the `tasks` have completed, the results are passed to the final
- * `callback` as an array.
- *
- * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
- * parallel execution of code. If your tasks do not use any timers or perform
- * any I/O, they will actually be executed in series. Any synchronous setup
- * sections for each task will happen one after the other. JavaScript remains
- * single-threaded.
- *
- * It is also possible to use an object instead of an array. Each property will
- * be run as a function and the results will be passed to the final `callback`
- * as an object instead of an array. This can be a more readable way of handling
- * results from {@link async.parallel}.
- *
- * @name parallel
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array|Iterable|Object} tasks - A collection containing functions to run.
- * Each function is passed a `callback(err, result)` which it must call on
- * completion with an error `err` (which can be `null`) and an optional `result`
- * value.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed successfully. This function gets a results array
- * (or object) containing all the result arguments passed to the task callbacks.
- * Invoked with (err, results).
- * @example
- * async.parallel([
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ],
- * // optional callback
- * function(err, results) {
- * // the results array will equal ['one','two'] even though
- * // the second function had a shorter timeout.
- * });
- *
- * // an example using an object instead of an array
- * async.parallel({
- * one: function(callback) {
- * setTimeout(function() {
- * callback(null, 1);
- * }, 200);
- * },
- * two: function(callback) {
- * setTimeout(function() {
- * callback(null, 2);
- * }, 100);
- * }
- * }, function(err, results) {
- * // results is now equals to: {one: 1, two: 2}
- * });
- */
- function parallelLimit(tasks, callback) {
- _parallel(eachOf, tasks, callback);
- }
-
- /**
- * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name parallelLimit
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.parallel]{@link module:ControlFlow.parallel}
- * @category Control Flow
- * @param {Array|Collection} tasks - A collection containing functions to run.
- * Each function is passed a `callback(err, result)` which it must call on
- * completion with an error `err` (which can be `null`) and an optional `result`
- * value.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed successfully. This function gets a results array
- * (or object) containing all the result arguments passed to the task callbacks.
- * Invoked with (err, results).
- */
- function parallelLimit$1(tasks, limit, callback) {
- _parallel(_eachOfLimit(limit), tasks, callback);
- }
-
- /**
- * A queue of tasks for the worker function to complete.
- * @typedef {Object} QueueObject
- * @memberOf module:ControlFlow
- * @property {Function} length - a function returning the number of items
- * waiting to be processed. Invoke with `queue.length()`.
- * @property {boolean} started - a boolean indicating whether or not any
- * items have been pushed and processed by the queue.
- * @property {Function} running - a function returning the number of items
- * currently being processed. Invoke with `queue.running()`.
- * @property {Function} workersList - a function returning the array of items
- * currently being processed. Invoke with `queue.workersList()`.
- * @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with `queue.idle()`.
- * @property {number} concurrency - an integer for determining how many `worker`
- * functions should be run in parallel. This property can be changed after a
- * `queue` is created to alter the concurrency on-the-fly.
- * @property {Function} push - add a new task to the `queue`. Calls `callback`
- * once the `worker` has finished processing the task. Instead of a single task,
- * a `tasks` array can be submitted. The respective callback is used for every
- * task in the list. Invoke with `queue.push(task, [callback])`,
- * @property {Function} unshift - add a new task to the front of the `queue`.
- * Invoke with `queue.unshift(task, [callback])`.
- * @property {Function} saturated - a callback that is called when the number of
- * running workers hits the `concurrency` limit, and further tasks will be
- * queued.
- * @property {Function} unsaturated - a callback that is called when the number
- * of running workers is less than the `concurrency` & `buffer` limits, and
- * further tasks will not be queued.
- * @property {number} buffer - A minimum threshold buffer in order to say that
- * the `queue` is `unsaturated`.
- * @property {Function} empty - a callback that is called when the last item
- * from the `queue` is given to a `worker`.
- * @property {Function} drain - a callback that is called when the last item
- * from the `queue` has returned from the `worker`.
- * @property {Function} error - a callback that is called when a task errors.
- * Has the signature `function(error, task)`.
- * @property {boolean} paused - a boolean for determining whether the queue is
- * in a paused state.
- * @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with `queue.pause()`.
- * @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with `queue.resume()`.
- * @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
- */
-
- /**
- * Creates a `queue` object with the specified `concurrency`. Tasks added to the
- * `queue` are processed in parallel (up to the `concurrency` limit). If all
- * `worker`s are in progress, the task is queued until one becomes available.
- * Once a `worker` completes a `task`, that `task`'s callback is called.
- *
- * @name queue
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} [concurrency=1] - An `integer` for determining how many
- * `worker` functions should be run in parallel. If omitted, the concurrency
- * defaults to `1`. If the concurrency is `0`, an error is thrown.
- * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
- * attached as certain properties to listen for specific events during the
- * lifecycle of the queue.
- * @example
- *
- * // create a queue object with concurrency 2
- * var q = async.queue(function(task, callback) {
- * console.log('hello ' + task.name);
- * callback();
- * }, 2);
- *
- * // assign a callback
- * q.drain = function() {
- * console.log('all items have been processed');
- * };
- *
- * // add some items to the queue
- * q.push({name: 'foo'}, function(err) {
- * console.log('finished processing foo');
- * });
- * q.push({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- *
- * // add some items to the queue (batch-wise)
- * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
- * console.log('finished processing item');
- * });
- *
- * // add some items to the front of the queue
- * q.unshift({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- */
- function queue$1 (worker, concurrency) {
- return queue(function (items, cb) {
- worker(items[0], cb);
- }, concurrency, 1);
- }
-
- /**
- * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
- * completed in ascending priority order.
- *
- * @name priorityQueue
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.queue]{@link module:ControlFlow.queue}
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} concurrency - An `integer` for determining how many `worker`
- * functions should be run in parallel. If omitted, the concurrency defaults to
- * `1`. If the concurrency is `0`, an error is thrown.
- * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
- * differences between `queue` and `priorityQueue` objects:
- * * `push(task, priority, [callback])` - `priority` should be a number. If an
- * array of `tasks` is given, all tasks will be assigned the same priority.
- * * The `unshift` method was removed.
- */
- function priorityQueue (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) {
- if (callback == null) callback = noop;
- if (typeof callback !== 'function') {
- throw new Error('task callback must be a function');
- }
- q.started = true;
- if (!isArray(data)) {
- data = [data];
- }
- if (data.length === 0) {
- // call drain immediately if there are no tasks
- return setImmediate$1(function () {
- q.drain();
- });
- }
-
- priority = priority || 0;
- var nextNode = q._tasks.head;
- while (nextNode && priority >= nextNode.priority) {
- nextNode = nextNode.next;
- }
-
- arrayEach(data, function (task) {
- var item = {
- data: task,
- priority: priority,
- callback: callback
- };
-
- if (nextNode) {
- q._tasks.insertBefore(nextNode, item);
- } else {
- q._tasks.push(item);
- }
- });
- setImmediate$1(q.process);
- };
-
- // Remove unshift function
- delete q.unshift;
-
- return q;
- }
-
- /**
- * Runs the `tasks` array of functions in parallel, without waiting until the
- * previous function has completed. Once any the `tasks` completed or pass an
- * error to its callback, the main `callback` is immediately called. It's
- * equivalent to `Promise.race()`.
- *
- * @name race
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array} tasks - An array containing functions to run. Each function
- * is passed a `callback(err, result)` which it must call on completion with an
- * error `err` (which can be `null`) and an optional `result` value.
- * @param {Function} callback - A callback to run once any of the functions have
- * completed. This function gets an error or result from the first function that
- * completed. Invoked with (err, result).
- * @returns undefined
- * @example
- *
- * async.race([
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ],
- * // main callback
- * function(err, result) {
- * // the result will be equal to 'two' as it finishes earlier
- * });
- */
- function race(tasks, callback) {
- callback = once(callback || noop);
- if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
- if (!tasks.length) return callback();
- arrayEach(tasks, function (task) {
- task(callback);
- });
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
}
+ var strSymbols = stringToArray(string),
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
+
+ return castSlice(strSymbols, start, end).join('');
+}
+
+var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+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) {
+ return trim(arg.replace(FN_ARG, ''));
+ });
+ return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is a function of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ * when finished, passing an `error` (which can be `null`) and the result of
+ * the function's execution. The remaining parameters name other tasks on
+ * which the task is dependent, and the results from those tasks are the
+ * arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * // The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ * get_data: function(callback) {
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: function(get_data, make_folder, callback) {
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * },
+ * email_link: function(write_file, callback) {
+ * // once the file is written let's email a link to it...
+ * // write_file contains the filename returned by write_file.
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier. To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ * //...
+ * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(write_file, callback) {
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }]
+ * //...
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ */
+function autoInject(tasks, callback) {
+ var newTasks = {};
+
+ baseForOwn(tasks, function (taskFn, key) {
+ var params;
+
+ if (isArray(taskFn)) {
+ params = copyArray(taskFn);
+ taskFn = params.pop();
+
+ newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+ } else if (taskFn.length === 1) {
+ // no dependencies, use the function as-is
+ newTasks[key] = taskFn;
+ } else {
+ params = parseParams(taskFn);
+ if (taskFn.length === 0 && params.length === 0) {
+ throw new Error("autoInject task functions require explicit parameters.");
+ }
+
+ params.pop();
+
+ newTasks[key] = params.concat(newTask);
+ }
- var slice = Array.prototype.slice;
-
- /**
- * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
- *
- * @name reduceRight
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.reduce]{@link module:Collections.reduce}
- * @alias foldr
- * @category Collection
- * @param {Array} array - A collection to iterate over.
- * @param {*} memo - The initial state of the reduction.
- * @param {Function} iteratee - A function applied to each item in the
- * array to produce the next step in the reduction. The `iteratee` is passed a
- * `callback(err, reduction)` which accepts an optional error as its first
- * argument, and the state of the reduction as the second. If an error is
- * passed to the callback, the reduction is stopped and the main `callback` is
- * immediately called with the error. Invoked with (memo, item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the reduced value. Invoked with
- * (err, result).
- */
- function reduceRight(array, memo, iteratee, callback) {
- var reversed = slice.call(array).reverse();
- reduce(reversed, memo, iteratee, callback);
- }
+ function newTask(results, taskCb) {
+ var newArgs = arrayMap(params, function (name) {
+ return results[name];
+ });
+ newArgs.push(taskCb);
+ taskFn.apply(null, newArgs);
+ }
+ });
+
+ auto(newTasks, callback);
+}
+
+var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
+var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
+
+function fallback(fn) {
+ setTimeout(fn, 0);
+}
+
+function wrap(defer) {
+ return baseRest$1(function (fn, args) {
+ defer(function () {
+ fn.apply(null, args);
+ });
+ });
+}
+
+var _defer;
+
+if (hasSetImmediate) {
+ _defer = setImmediate;
+} else if (hasNextTick) {
+ _defer = process.nextTick;
+} else {
+ _defer = fallback;
+}
+
+var setImmediate$1 = wrap(_defer);
+
+// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
+// used for queues. This implementation assumes that the node provided by the user can be modified
+// to adjust the next and last properties. We implement only the minimal functionality
+// for queue support.
+function DLL() {
+ this.head = this.tail = null;
+ this.length = 0;
+}
+
+function setInitial(dll, node) {
+ dll.length = 1;
+ 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;
+
+ node.prev = node.next = null;
+ this.length -= 1;
+ return node;
+};
+
+DLL.prototype.empty = DLL;
+
+DLL.prototype.insertAfter = function (node, newNode) {
+ newNode.prev = node;
+ newNode.next = node.next;
+ if (node.next) node.next.prev = newNode;else this.tail = newNode;
+ node.next = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.insertBefore = function (node, newNode) {
+ newNode.prev = node.prev;
+ newNode.next = node;
+ 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.push = function (node) {
+ if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
+};
+
+DLL.prototype.shift = function () {
+ return this.head && this.removeLink(this.head);
+};
+
+DLL.prototype.pop = function () {
+ return this.tail && this.removeLink(this.tail);
+};
+
+function queue(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ } else if (concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
+ }
- /**
- * Wraps the function in another function that always returns data even when it
- * errors.
- *
- * The object returned has either the property `error` or `value`.
- *
- * @name reflect
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} fn - The function you want to wrap
- * @returns {Function} - A function that always passes null to it's callback as
- * the error. The second argument to the callback will be an `object` with
- * either an `error` or a `value` property.
- * @example
- *
- * async.parallel([
- * async.reflect(function(callback) {
- * // do some stuff ...
- * callback(null, 'one');
- * }),
- * async.reflect(function(callback) {
- * // do some more stuff but error ...
- * callback('bad stuff happened');
- * }),
- * async.reflect(function(callback) {
- * // do some more stuff ...
- * callback(null, 'two');
- * })
- * ],
- * // optional callback
- * function(err, results) {
- * // values
- * // results[0].value = 'one'
- * // results[1].error = 'bad stuff happened'
- * // results[2].value = 'two'
- * });
- */
- function reflect(fn) {
- return initialParams(function reflectOn(args, reflectCallback) {
- args.push(baseRest(function callback(err, cbArgs) {
- if (err) {
- reflectCallback(null, {
- error: err
- });
- } else {
- var value = null;
- if (cbArgs.length === 1) {
- value = cbArgs[0];
- } else if (cbArgs.length > 1) {
- value = cbArgs;
- }
- reflectCallback(null, {
- value: value
- });
- }
- }));
-
- return fn.apply(this, args);
- });
- }
+ function _insert(data, insertAtFront, callback) {
+ if (callback != null && typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0 && q.idle()) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function () {
+ q.drain();
+ });
+ }
- function reject$1(eachfn, arr, iteratee, callback) {
- _filter(eachfn, arr, function (value, cb) {
- iteratee(value, function (err, v) {
- if (err) {
- cb(err);
- } else {
- cb(null, !v);
- }
- });
- }, callback);
- }
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ callback: callback || noop
+ };
+
+ if (insertAtFront) {
+ q._tasks.unshift(item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ setImmediate$1(q.process);
+ }
- /**
- * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
- *
- * @name reject
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of missing files
- * createFiles(results);
- * });
- */
- var reject = doParallel(reject$1);
-
- /**
- * A helper function that wraps an array or an object of functions with reflect.
- *
- * @name reflectAll
- * @static
- * @memberOf module:Utils
- * @method
- * @see [async.reflect]{@link module:Utils.reflect}
- * @category Util
- * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
- * @returns {Array} Returns an array of functions, each function wrapped in
- * `async.reflect`
- * @example
- *
- * let tasks = [
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * // do some more stuff but error ...
- * callback(new Error('bad stuff happened'));
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ];
- *
- * async.parallel(async.reflectAll(tasks),
- * // optional callback
- * function(err, results) {
- * // values
- * // results[0].value = 'one'
- * // results[1].error = Error('bad stuff happened')
- * // results[2].value = 'two'
- * });
- *
- * // an example using an object instead of an array
- * let tasks = {
- * one: function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * two: function(callback) {
- * callback('two');
- * },
- * three: function(callback) {
- * setTimeout(function() {
- * callback(null, 'three');
- * }, 100);
- * }
- * };
- *
- * async.parallel(async.reflectAll(tasks),
- * // optional callback
- * function(err, results) {
- * // values
- * // results.one.value = 'one'
- * // results.two.error = 'two'
- * // results.three.value = 'three'
- * });
- */
- function reflectAll(tasks) {
- var results;
- if (isArray(tasks)) {
- results = arrayMap(tasks, reflect);
- } else {
- results = {};
- baseForOwn(tasks, function (task, key) {
- results[key] = reflect.call(this, task);
- });
- }
- return results;
- }
+ function _next(tasks) {
+ return baseRest$1(function (args) {
+ workers -= 1;
+
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ var task = tasks[i];
+ var index = baseIndexOf(workersList, task, 0);
+ if (index >= 0) {
+ workersList.splice(index);
+ }
+
+ task.callback.apply(task, args);
+
+ if (args[0] != null) {
+ q.error(args[0], task.data);
+ }
+ }
+
+ if (workers <= q.concurrency - q.buffer) {
+ q.unsaturated();
+ }
+
+ if (q.idle()) {
+ q.drain();
+ }
+ q.process();
+ });
+ }
- /**
- * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name rejectLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.reject]{@link module:Collections.reject}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var rejectLimit = doParallelLimit(reject$1);
-
- /**
- * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
- *
- * @name rejectSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.reject]{@link module:Collections.reject}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var rejectSeries = doLimit(rejectLimit, 1);
-
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new constant function.
- * @example
- *
- * var objects = _.times(2, _.constant({ 'a': 1 }));
- *
- * console.log(objects);
- * // => [{ 'a': 1 }, { 'a': 1 }]
- *
- * console.log(objects[0] === objects[1]);
- * // => true
- */
- function constant$1(value) {
- return function() {
- return value;
+ var workers = 0;
+ var workersList = [];
+ var q = {
+ _tasks: new DLL(),
+ concurrency: concurrency,
+ payload: payload,
+ saturated: noop,
+ unsaturated: noop,
+ buffer: concurrency / 4,
+ empty: noop,
+ drain: noop,
+ error: noop,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(data, false, callback);
+ },
+ kill: function () {
+ q.drain = noop;
+ q._tasks.empty();
+ },
+ unshift: function (data, callback) {
+ _insert(data, true, callback);
+ },
+ process: function () {
+ while (!q.paused && workers < 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++) {
+ var node = q._tasks.shift();
+ tasks.push(node);
+ data.push(node.data);
+ }
+
+ if (q._tasks.length === 0) {
+ q.empty();
+ }
+ workers += 1;
+ workersList.push(tasks[0]);
+
+ if (workers === q.concurrency) {
+ q.saturated();
+ }
+
+ var cb = onlyOnce(_next(tasks));
+ worker(data, cb);
+ }
+ },
+ length: function () {
+ return q._tasks.length;
+ },
+ running: function () {
+ return workers;
+ },
+ workersList: function () {
+ return workersList;
+ },
+ idle: function () {
+ return q._tasks.length + workers === 0;
+ },
+ pause: function () {
+ q.paused = true;
+ },
+ resume: function () {
+ if (q.paused === false) {
+ return;
+ }
+ q.paused = false;
+ var resumeCount = Math.min(q.concurrency, q._tasks.length);
+ // Need to call q.process once per concurrent
+ // worker to preserve full concurrency after pause
+ for (var w = 1; w <= resumeCount; w++) {
+ setImmediate$1(q.process);
+ }
+ }
};
- }
-
- /**
- * Attempts to get a successful response from `task` no more than `times` times
- * before returning an error. If the task is successful, the `callback` will be
- * passed the result of the successful task. If all attempts fail, the callback
- * will be passed the error and result (if any) of the final attempt.
- *
- * @name retry
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
- * object with `times` and `interval` or a number.
- * * `times` - The number of attempts to make before giving up. The default
- * is `5`.
- * * `interval` - The time to wait between retries, in milliseconds. The
- * default is `0`. The interval may also be specified as a function of the
- * retry count (see example).
- * * If `opts` is a number, the number specifies the number of times to retry,
- * with the default interval of `0`.
- * @param {Function} task - A function which receives two arguments: (1) a
- * `callback(err, result)` which must be called when finished, passing `err`
- * (which can be `null`) and the `result` of the function's execution, and (2)
- * a `results` object, containing the results of the previously executed
- * functions (if nested inside another control flow). Invoked with
- * (callback, results).
- * @param {Function} [callback] - An optional callback which is called when the
- * task has succeeded, or after the final failed attempt. It receives the `err`
- * and `result` arguments of the last attempt at completing the `task`. Invoked
- * with (err, results).
- * @example
- *
- * // The `retry` function can be used as a stand-alone control flow by passing
- * // a callback, as shown below:
- *
- * // try calling apiMethod 3 times
- * async.retry(3, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod 3 times, waiting 200 ms between each retry
- * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod 10 times with exponential backoff
- * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
- * async.retry({
- * times: 10,
- * interval: function(retryCount) {
- * return 50 * Math.pow(2, retryCount);
- * }
- * }, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod the default 5 times no delay between each retry
- * async.retry(apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // It can also be embedded within other control flow functions to retry
- * // individual methods that are not as reliable, like this:
- * async.auto({
- * users: api.getUsers.bind(api),
- * payments: async.retry(3, api.getPayments.bind(api))
- * }, function(err, results) {
- * // do something with the results
- * });
- */
- function retry(opts, task, callback) {
- var DEFAULT_TIMES = 5;
- var DEFAULT_INTERVAL = 0;
-
- var options = {
- times: DEFAULT_TIMES,
- intervalFunc: constant$1(DEFAULT_INTERVAL)
- };
-
- function parseTimes(acc, t) {
- if (typeof t === 'object') {
- acc.times = +t.times || DEFAULT_TIMES;
-
- acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL);
- } else if (typeof t === 'number' || typeof t === 'string') {
- acc.times = +t || DEFAULT_TIMES;
- } else {
- throw new Error("Invalid arguments for async.retry");
- }
- }
-
- if (arguments.length < 3 && typeof opts === 'function') {
- callback = task || noop;
- task = opts;
- } else {
- parseTimes(options, opts);
- callback = callback || noop;
- }
+ return q;
+}
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing an array
+ * of queued tasks, which must call its `callback(err)` argument when finished,
+ * with an optional `err` argument. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ * for (var i=0; i<tasks.length; i++) {
+ * console.log('hello ' + tasks[i].name);
+ * }
+ * callback();
+ * }, 2);
+ *
+ * // add some items
+ * cargo.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * cargo.push({name: 'bar'}, function(err) {
+ * console.log('finished processing bar');
+ * });
+ * cargo.push({name: 'baz'}, function(err) {
+ * console.log('finished processing baz');
+ * });
+ */
+function cargo(worker, payload) {
+ return queue(worker, 1, payload);
+}
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * `key` is the item's key, or index in the case of an array. The iteratee is
+ * passed a `callback(err)` which must be called once it has completed. If no
+ * error has occurred, the callback should be run without arguments or with an
+ * explicit `null` argument. Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+var eachOfSeries = doLimit(eachOfLimit, 1);
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = once(callback || noop);
+ eachOfSeries(coll, function (x, i, callback) {
+ iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ * var User = request.models.User;
+ * async.seq(
+ * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
+ * function(user, fn) {
+ * user.getCats(fn); // 'getCats' has signature (callback(err, data))
+ * }
+ * )(req.session.user_id, function (err, cats) {
+ * if (err) {
+ * console.error(err);
+ * response.json({ status: 'error', message: err.message });
+ * } else {
+ * response.json({ status: 'ok', message: 'Cats found', data: cats });
+ * }
+ * });
+ * });
+ */
+var seq$1 = baseRest$1(function seq(functions) {
+ return baseRest$1(function (args) {
+ var that = this;
+
+ var cb = args[args.length - 1];
+ if (typeof cb == 'function') {
+ args.pop();
+ } else {
+ cb = noop;
+ }
- if (typeof task !== 'function') {
- throw new Error("Invalid arguments for async.retry");
- }
+ reduce(functions, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat([baseRest$1(function (err, nextargs) {
+ cb(err, nextargs);
+ })]));
+ }, function (err, results) {
+ cb.apply(that, [err].concat(results));
+ });
+ });
+});
+
+/**
+ * Creates a function which is a composition of the passed asynchronous
+ * functions. Each function consumes the return value of the function that
+ * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
+ * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name compose
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} an asynchronous function that is the composed
+ * asynchronous `functions`
+ * @example
+ *
+ * function add1(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n + 1);
+ * }, 10);
+ * }
+ *
+ * function mul3(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n * 3);
+ * }, 10);
+ * }
+ *
+ * var add1mul3 = async.compose(mul3, add1);
+ * add1mul3(4, function (err, result) {
+ * // result now equals 15
+ * });
+ */
+var compose = baseRest$1(function (args) {
+ return seq$1.apply(null, args.reverse());
+});
+
+function concat$1(eachfn, arr, fn, callback) {
+ var result = [];
+ eachfn(arr, function (x, index, cb) {
+ fn(x, function (err, y) {
+ result = result.concat(y || []);
+ cb(err);
+ });
+ }, function (err) {
+ callback(err, result);
+ });
+}
+
+/**
+ * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
+ * the concatenated list. The `iteratee`s are called in parallel, and the
+ * results are concatenated as they return. There is no guarantee that the
+ * results array will be returned in the original order of `coll` passed to the
+ * `iteratee` function.
+ *
+ * @name concat
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @example
+ *
+ * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+ * // files is now a list of filenames that exist in the 3 directories
+ * });
+ */
+var concat = doParallel(concat$1);
+
+function doSeries(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(eachOfSeries, obj, iteratee, callback);
+ };
+}
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
+ *
+ * @name concatSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ */
+var concatSeries = doSeries(concat$1);
+
+/**
+ * Returns a function that when called, calls-back with the values provided.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
+ *
+ * @name constant
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {...*} arguments... - Any number of arguments to automatically invoke
+ * callback with.
+ * @returns {Function} Returns a function that when invoked, automatically
+ * invokes the callback with the previous given arguments.
+ * @example
+ *
+ * async.waterfall([
+ * async.constant(42),
+ * function (value, next) {
+ * // value === 42
+ * },
+ * //...
+ * ], callback);
+ *
+ * async.waterfall([
+ * async.constant(filename, "utf8"),
+ * fs.readFile,
+ * function (fileData, next) {
+ * //...
+ * }
+ * //...
+ * ], callback);
+ *
+ * async.auto({
+ * hostname: async.constant("https://server.net/"),
+ * port: findFreePort,
+ * launchServer: ["hostname", "port", function (options, cb) {
+ * startServer(options, cb);
+ * }],
+ * //...
+ * }, callback);
+ */
+var constant$2 = baseRest$1(function (values) {
+ var args = [null].concat(values);
+ return initialParams(function (ignoredArgs, callback) {
+ return callback.apply(this, args);
+ });
+});
+
+function _createTester(eachfn, check, getResult) {
+ return function (arr, limit, iteratee, cb) {
+ function done() {
+ if (cb) {
+ cb(null, getResult(false));
+ }
+ }
+ function wrappedIteratee(x, _, callback) {
+ if (!cb) return callback();
+ iteratee(x, function (err, v) {
+ // Check cb as another iteratee may have resolved with a
+ // value or error since we started this iteratee
+ if (cb && (err || check(v))) {
+ if (err) cb(err);else cb(err, getResult(true, x));
+ cb = iteratee = false;
+ callback(err, breakLoop);
+ } else {
+ callback();
+ }
+ });
+ }
+ if (arguments.length > 3) {
+ cb = cb || noop;
+ eachfn(arr, limit, wrappedIteratee, done);
+ } else {
+ cb = iteratee;
+ cb = cb || noop;
+ iteratee = limit;
+ eachfn(arr, wrappedIteratee, done);
+ }
+ };
+}
+
+function _findGetResult(v, x) {
+ return x;
+}
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // result now equals the first file in the list that exists
+ * });
+ */
+var detect = _createTester(eachOf, identity, _findGetResult);
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
+
+function consoleFunc(name) {
+ return baseRest$1(function (fn, args) {
+ fn.apply(null, args.concat([baseRest$1(function (err, args) {
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ } else if (console[name]) {
+ arrayEach(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ })]));
+ });
+}
+
+/**
+ * Logs the result of an `async` function to the `console` using `console.dir`
+ * to display the properties of the resulting object. Only works in Node.js or
+ * in browsers that support `console.dir` and `console.error` (such as FF and
+ * Chrome). If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, {hello: name});
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+var dir = consoleFunc('dir');
+
+/**
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
+ * the order of operations, the arguments `test` and `fn` are switched.
+ *
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
+ * @name doDuring
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error if one occured, otherwise `null`.
+ */
+function doDuring(fn, test, callback) {
+ callback = onlyOnce(callback || noop);
+
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ args.push(check);
+ test.apply(this, args);
+ });
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
- var attempt = 1;
- function retryAttempt() {
- task(function (err) {
- if (err && attempt++ < options.times) {
- setTimeout(retryAttempt, options.intervalFunc(attempt));
- } else {
- callback.apply(null, arguments);
- }
- });
- }
+ check(null, true);
+}
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} iteratee - A function which is called each time `test`
+ * passes. The function is passed a `callback(err)`, which must be called once
+ * it has completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with the non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ */
+function doWhilst(iteratee, test, callback) {
+ callback = onlyOnce(callback || noop);
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ if (test.apply(this, args)) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `fn`. Invoked with the non-error callback results of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function doUntil(fn, test, callback) {
+ doWhilst(fn, function () {
+ return !test.apply(this, arguments);
+ }, callback);
+}
+
+/**
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
+ * is passed a callback in the form of `function (err, truth)`. If error is
+ * passed to `test` or `fn`, the main callback is immediately called with the
+ * value of the error.
+ *
+ * @name during
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (callback).
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error, if one occured, otherwise `null`.
+ * @example
+ *
+ * var count = 0;
+ *
+ * async.during(
+ * function (callback) {
+ * return callback(null, count < 5);
+ * },
+ * function (callback) {
+ * count++;
+ * setTimeout(callback, 1000);
+ * },
+ * function (err) {
+ * // 5 seconds have passed
+ * }
+ * );
+ */
+function during(test, fn, callback) {
+ callback = onlyOnce(callback || noop);
+
+ function next(err) {
+ if (err) return callback(err);
+ test(check);
+ }
- retryAttempt();
- }
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
- /**
- * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
- * retryable, rather than immediately calling it with retries.
- *
- * @name retryable
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.retry]{@link module:ControlFlow.retry}
- * @category Control Flow
- * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
- * options, exactly the same as from `retry`
- * @param {Function} task - the asynchronous function to wrap
- * @returns {Functions} The wrapped function, which when invoked, will retry on
- * an error, based on the parameters specified in `opts`.
- * @example
- *
- * async.auto({
- * dep1: async.retryable(3, getFromFlakyService),
- * process: ["dep1", async.retryable(3, function (results, cb) {
- * maybeProcessData(results.dep1, cb);
- * })]
- * }, callback);
- */
- function retryable (opts, task) {
- if (!task) {
- task = opts;
- opts = null;
- }
- return initialParams(function (args, callback) {
- function taskFn(cb) {
- task.apply(null, args.concat([cb]));
- }
+ test(check);
+}
- if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
- });
- }
+function _withoutIndex(iteratee) {
+ return function (value, index, callback) {
+ return iteratee(value, callback);
+ };
+}
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item
+ * in `coll`. The iteratee is passed a `callback(err)` which must be called once
+ * it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is not
+ * passed to the iteratee. Invoked with (item, callback). If you need the index,
+ * use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ * // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ * // Perform operation on file here.
+ * console.log('Processing file ' + file);
+ *
+ * if( file.length > 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ eachOf(coll, _withoutIndex(iteratee), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * iteratee is passed a `callback(err)` which must be called once it has
+ * completed. If no error has occurred, the `callback` should be run without
+ * arguments or with an explicit `null` argument. The array index is not passed
+ * to the iteratee. Invoked with (item, callback). If you need the index, use
+ * `eachOfLimit`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit$1(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, _withoutIndex(iteratee), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The iteratee is passed a `callback(err)` which must be called
+ * once it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is
+ * not passed to the iteratee. Invoked with (item, callback). If you need the
+ * index, use `eachOfSeries`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+var eachSeries = doLimit(eachLimit$1, 1);
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop. If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {Function} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ * if (cache[arg]) {
+ * return callback(null, cache[arg]); // this would be synchronous!!
+ * } else {
+ * doSomeIO(arg, callback); // this IO would be asynchronous
+ * }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+function ensureAsync(fn) {
+ return initialParams(function (args, callback) {
+ var sync = true;
+ args.push(function () {
+ var innerArgs = arguments;
+ if (sync) {
+ setImmediate$1(function () {
+ callback.apply(null, innerArgs);
+ });
+ } else {
+ callback.apply(null, innerArgs);
+ }
+ });
+ fn.apply(this, args);
+ sync = false;
+ });
+}
+
+function notId(v) {
+ return !v;
+}
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+var every = _createTester(eachOf, notId, notId);
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everyLimit = _createTester(eachOfLimit, notId, notId);
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everySeries = doLimit(everyLimit, 1);
+
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+function _filter(eachfn, arr, iteratee, callback) {
+ callback = once(callback || noop);
+ var results = [];
+ eachfn(arr, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ if (err) {
+ callback(err);
+ } else {
+ if (v) {
+ results.push({ index: index, value: x });
+ }
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ callback(null, arrayMap(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), baseProperty('value')));
+ }
+ });
+}
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+var filter = doParallel(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var filterLimit = doParallelLimit(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+var filterSeries = doLimit(filterLimit, 1);
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the
+ * callback then `errback` is called with the error, and execution stops,
+ * otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} fn - a function to call repeatedly. Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ * function(next) {
+ * // next is suitable for passing to things that need a callback(err [, whatever]);
+ * // it will result in this function being called again.
+ * },
+ * function(err) {
+ * // if next is called with a value in its first parameter, it will appear
+ * // in here as 'err', and execution will stop.
+ * }
+ * );
+ */
+function forever(fn, errback) {
+ var done = onlyOnce(errback || noop);
+ var task = ensureAsync(fn);
+
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+}
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, 'hello ' + name);
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+var log = consoleFunc('log');
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+ callback = once(callback || noop);
+ var newObj = {};
+ eachOfLimit(obj, limit, function (val, key, next) {
+ iteratee(val, key, function (err, result) {
+ if (err) return next(err);
+ newObj[key] = result;
+ next();
+ });
+ }, function (err) {
+ callback(err, newObj);
+ });
+}
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed. The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value and key in
+ * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
+ * called once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ * f1: 'file1',
+ * f2: 'file2',
+ * f3: 'file3'
+ * }, function (file, key, callback) {
+ * fs.stat(file, callback);
+ * }, function(err, result) {
+ * // result is now a map of stats for each file, e.g.
+ * // {
+ * // f1: [stats for file1],
+ * // f2: [stats for file2],
+ * // f3: [stats for file3]
+ * // }
+ * });
+ */
+
+var mapValues = doLimit(mapValuesLimit, Infinity);
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+var mapValuesSeries = doLimit(mapValuesLimit, 1);
+
+function has(obj, key) {
+ return key in obj;
+}
+
+/**
+ * Caches the results of an `async` function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {Function} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ * // do something
+ * callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ * // callback
+ * });
+ */
+function memoize(fn, hasher) {
+ var memo = Object.create(null);
+ var queues = Object.create(null);
+ hasher = hasher || identity;
+ var memoized = initialParams(function memoized(args, callback) {
+ var key = hasher.apply(null, args);
+ if (has(memo, key)) {
+ 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([baseRest$1(function (args) {
+ memo[key] = args;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, args);
+ }
+ })]));
+ }
+ });
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+}
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias setImmediate
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer$1;
+
+if (hasNextTick) {
+ _defer$1 = process.nextTick;
+} else if (hasSetImmediate) {
+ _defer$1 = setImmediate;
+} else {
+ _defer$1 = fallback;
+}
+
+var nextTick = wrap(_defer$1);
+
+function _parallel(eachfn, tasks, callback) {
+ callback = callback || noop;
+ var results = isArrayLike(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ task(baseRest$1(function (err, args) {
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[key] = args;
+ callback(err);
+ }));
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code. If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series. Any synchronous setup
+ * sections for each task will happen one after the other. JavaScript remains
+ * single-threaded.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ * @example
+ * async.parallel([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // the results array will equal ['one','two'] even though
+ * // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+function parallelLimit(tasks, callback) {
+ _parallel(eachOf, tasks, callback);
+}
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Collection} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+function parallelLimit$1(tasks, limit, callback) {
+ _parallel(_eachOfLimit(limit), tasks, callback);
+}
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel. If omitted, the concurrency
+ * defaults to `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ * console.log('hello ' + task.name);
+ * callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ * console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ * console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ */
+var queue$1 = function (worker, concurrency) {
+ return queue(function (items, cb) {
+ worker(items[0], cb);
+ }, concurrency, 1);
+};
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel. If omitted, the concurrency defaults to
+ * `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ * array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */
+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) {
+ if (callback == null) callback = noop;
+ if (typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function () {
+ q.drain();
+ });
+ }
- /**
- * Run the functions in the `tasks` collection in series, each one running once
- * the previous function has completed. If any functions in the series pass an
- * error to its callback, no more functions are run, and `callback` is
- * immediately called with the value of the error. Otherwise, `callback`
- * receives an array of results when `tasks` have completed.
- *
- * It is also possible to use an object instead of an array. Each property will
- * be run as a function, and the results will be passed to the final `callback`
- * as an object instead of an array. This can be a more readable way of handling
- * results from {@link async.series}.
- *
- * **Note** that while many implementations preserve the order of object
- * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
- * explicitly states that
- *
- * > The mechanics and order of enumerating the properties is not specified.
- *
- * So if you rely on the order in which your series of functions are executed,
- * and want this to work on all platforms, consider using an array.
- *
- * @name series
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each
- * function is passed a `callback(err, result)` it must call on completion with
- * an error `err` (which can be `null`) and an optional `result` value.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed. This function gets a results array (or object)
- * containing all the result arguments passed to the `task` callbacks. Invoked
- * with (err, result).
- * @example
- * async.series([
- * function(callback) {
- * // do some stuff ...
- * callback(null, 'one');
- * },
- * function(callback) {
- * // do some more stuff ...
- * callback(null, 'two');
- * }
- * ],
- * // optional callback
- * function(err, results) {
- * // results is now equal to ['one', 'two']
- * });
- *
- * async.series({
- * one: function(callback) {
- * setTimeout(function() {
- * callback(null, 1);
- * }, 200);
- * },
- * two: function(callback){
- * setTimeout(function() {
- * callback(null, 2);
- * }, 100);
- * }
- * }, function(err, results) {
- * // results is now equal to: {one: 1, two: 2}
- * });
- */
- function series(tasks, callback) {
- _parallel(eachOfSeries, tasks, callback);
- }
+ priority = priority || 0;
+ var nextNode = q._tasks.head;
+ while (nextNode && priority >= nextNode.priority) {
+ nextNode = nextNode.next;
+ }
- /**
- * Returns `true` if at least one element in the `coll` satisfies an async test.
- * If any iteratee call returns `true`, the main `callback` is immediately
- * called.
- *
- * @name some
- * @static
- * @memberOf module:Collections
- * @method
- * @alias any
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- * @example
- *
- * async.some(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then at least one of the files exists
- * });
- */
- var some = _createTester(eachOf, Boolean, identity);
-
- /**
- * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
- *
- * @name someLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.some]{@link module:Collections.some}
- * @alias anyLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
- var someLimit = _createTester(eachOfLimit, Boolean, identity);
-
- /**
- * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
- *
- * @name someSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.some]{@link module:Collections.some}
- * @alias anySeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
- var someSeries = doLimit(someLimit, 1);
-
- /**
- * Sorts a list by the results of running each `coll` value through an async
- * `iteratee`.
- *
- * @name sortBy
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, sortValue)` which must be called once
- * it has completed with an error (which can be `null`) and a value to use as
- * the sort criteria. Invoked with (item, callback).
- * @param {Function} callback - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is the items
- * from the original `coll` sorted by the values returned by the `iteratee`
- * calls. Invoked with (err, results).
- * @example
- *
- * async.sortBy(['file1','file2','file3'], function(file, callback) {
- * fs.stat(file, function(err, stats) {
- * callback(err, stats.mtime);
- * });
- * }, function(err, results) {
- * // results is now the original array of files sorted by
- * // modified date
- * });
- *
- * // By modifying the callback parameter the
- * // sorting order can be influenced:
- *
- * // ascending order
- * async.sortBy([1,9,3,5], function(x, callback) {
- * callback(null, x);
- * }, function(err,result) {
- * // result callback
- * });
- *
- * // descending order
- * async.sortBy([1,9,3,5], function(x, callback) {
- * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
- * }, function(err,result) {
- * // result callback
- * });
- */
- function sortBy(coll, iteratee, callback) {
- map(coll, function (x, callback) {
- iteratee(x, function (err, criteria) {
- if (err) return callback(err);
- callback(null, { value: x, criteria: criteria });
- });
- }, function (err, results) {
- if (err) return callback(err);
- callback(null, arrayMap(results.sort(comparator), baseProperty('value')));
- });
-
- function comparator(left, right) {
- var a = left.criteria,
- b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }
- }
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ priority: priority,
+ callback: callback
+ };
+
+ if (nextNode) {
+ q._tasks.insertBefore(nextNode, item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ setImmediate$1(q.process);
+ };
- /**
- * Sets a time limit on an asynchronous function. If the function does not call
- * its callback within the specified milliseconds, it will be called with a
- * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
- *
- * @name timeout
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} asyncFn - The asynchronous function you want to set the
- * time limit.
- * @param {number} milliseconds - The specified time limit.
- * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
- * to timeout Error for more information..
- * @returns {Function} Returns a wrapped function that can be used with any of
- * the control flow functions.
- * @example
- *
- * async.timeout(function(callback) {
- * doAsyncTask(callback);
- * }, 1000);
- */
- function timeout(asyncFn, milliseconds, info) {
- var originalCallback, timer;
- var timedOut = false;
-
- function injectedCallback() {
- if (!timedOut) {
- originalCallback.apply(null, arguments);
- clearTimeout(timer);
- }
- }
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+};
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing functions to run. Each function
+ * is passed a `callback(err, result)` which it must call on completion with an
+ * error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // main callback
+ * function(err, result) {
+ * // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+ callback = once(callback || noop);
+ if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+ if (!tasks.length) return callback();
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ tasks[i](callback);
+ }
+}
+
+var slice = Array.prototype.slice;
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight(array, memo, iteratee, callback) {
+ var reversed = slice.call(array).reverse();
+ reduce(reversed, memo, iteratee, callback);
+}
+
+/**
+ * Wraps the function in another function that always returns data even when it
+ * errors.
+ *
+ * The object returned has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ * async.reflect(function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff but error ...
+ * callback('bad stuff happened');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = 'bad stuff happened'
+ * // results[2].value = 'two'
+ * });
+ */
+function reflect(fn) {
+ return initialParams(function reflectOn(args, reflectCallback) {
+ args.push(baseRest$1(function callback(err, cbArgs) {
+ if (err) {
+ reflectCallback(null, {
+ error: err
+ });
+ } else {
+ var value = null;
+ if (cbArgs.length === 1) {
+ value = cbArgs[0];
+ } else if (cbArgs.length > 1) {
+ value = cbArgs;
+ }
+ reflectCallback(null, {
+ value: value
+ });
+ }
+ }));
+
+ return fn.apply(this, args);
+ });
+}
+
+function reject$1(eachfn, arr, iteratee, callback) {
+ _filter(eachfn, arr, function (value, cb) {
+ iteratee(value, function (err, v) {
+ if (err) {
+ cb(err);
+ } else {
+ cb(null, !v);
+ }
+ });
+ }, callback);
+}
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of missing files
+ * createFiles(results);
+ * });
+ */
+var reject = doParallel(reject$1);
+
+/**
+ * A helper function that wraps an array or an object of functions with reflect.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of functions, each function wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * // do some more stuff but error ...
+ * callback(new Error('bad stuff happened'));
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = Error('bad stuff happened')
+ * // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * callback('two');
+ * },
+ * three: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'three');
+ * }, 100);
+ * }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results.one.value = 'one'
+ * // results.two.error = 'two'
+ * // results.three.value = 'three'
+ * });
+ */
+function reflectAll(tasks) {
+ var results;
+ if (isArray(tasks)) {
+ results = arrayMap(tasks, reflect);
+ } else {
+ results = {};
+ baseForOwn(tasks, function (task, key) {
+ results[key] = reflect.call(this, task);
+ });
+ }
+ return results;
+}
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectLimit = doParallelLimit(reject$1);
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectSeries = doLimit(rejectLimit, 1);
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up. The default
+ * is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds. The
+ * default is `0`. The interval may also be specified as a function of the
+ * retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ * erroneous result. If it returns `true` the retry attempts will continue;
+ * if the function returns `false` the retry flow is aborted with the current
+ * attempt's error and result being returned to the final callback.
+ * Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ * with the default interval of `0`.
+ * @param {Function} task - A function which receives two arguments: (1) a
+ * `callback(err, result)` which must be called when finished, passing `err`
+ * (which can be `null`) and the `result` of the function's execution, and (2)
+ * a `results` object, containing the results of the previously executed
+ * functions (if nested inside another control flow). Invoked with
+ * (callback, results).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ * times: 10,
+ * interval: function(retryCount) {
+ * return 50 * Math.pow(2, retryCount);
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ * errorFilter: function(err) {
+ * return err.message === 'Temporary error'; // only retry on a specific error
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // It can also be embedded within other control flow functions to retry
+ * // individual methods that are not as reliable, like this:
+ * async.auto({
+ * users: api.getUsers.bind(api),
+ * payments: async.retry(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ * // do something with the results
+ * });
+ *
+ */
+function retry(opts, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
+
+ var options = {
+ times: DEFAULT_TIMES,
+ intervalFunc: constant(DEFAULT_INTERVAL)
+ };
- function timeoutCallback() {
- var name = asyncFn.name || 'anonymous';
- var error = new Error('Callback function "' + name + '" timed out.');
- error.code = 'ETIMEDOUT';
- if (info) {
- error.info = info;
- }
- timedOut = true;
- originalCallback(error);
- }
+ function parseTimes(acc, t) {
+ if (typeof t === 'object') {
+ acc.times = +t.times || DEFAULT_TIMES;
- return initialParams(function (args, origCallback) {
- originalCallback = origCallback;
- // setup timer and call original function
- timer = setTimeout(timeoutCallback, milliseconds);
- asyncFn.apply(null, args.concat(injectedCallback));
- });
- }
+ acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant(+t.interval || DEFAULT_INTERVAL);
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeCeil = Math.ceil;
- var nativeMax$1 = Math.max;
- /**
- * The base implementation of `_.range` and `_.rangeRight` which doesn't
- * coerce arguments.
- *
- * @private
- * @param {number} start The start of the range.
- * @param {number} end The end of the range.
- * @param {number} step The value to increment or decrement by.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Array} Returns the range of numbers.
- */
- function baseRange(start, end, step, fromRight) {
- var index = -1,
- length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
- result = Array(length);
+ acc.errorFilter = t.errorFilter;
+ } else if (typeof t === 'number' || typeof t === 'string') {
+ acc.times = +t || DEFAULT_TIMES;
+ } else {
+ throw new Error("Invalid arguments for async.retry");
+ }
+ }
- while (length--) {
- result[fromRight ? length : ++index] = start;
- start += step;
+ if (arguments.length < 3 && typeof opts === 'function') {
+ callback = task || noop;
+ task = opts;
+ } else {
+ parseTimes(options, opts);
+ callback = callback || noop;
}
- return result;
- }
- /**
- * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name timesLimit
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.times]{@link module:ControlFlow.times}
- * @category Control Flow
- * @param {number} count - The number of times to run the function.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see [async.map]{@link module:Collections.map}.
- */
- function timeLimit(count, limit, iteratee, callback) {
- mapLimit(baseRange(0, count, 1), limit, iteratee, callback);
- }
+ if (typeof task !== 'function') {
+ throw new Error("Invalid arguments for async.retry");
+ }
- /**
- * Calls the `iteratee` function `n` times, and accumulates results in the same
- * manner you would use with [map]{@link module:Collections.map}.
- *
- * @name times
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link module:Collections.map}.
- * @example
- *
- * // Pretend this is some complicated async factory
- * var createUser = function(id, callback) {
- * callback(null, {
- * id: 'user' + id
- * });
- * };
- *
- * // generate 5 users
- * async.times(5, function(n, next) {
- * createUser(n, function(err, user) {
- * next(err, user);
- * });
- * }, function(err, users) {
- * // we should now have 5 users
- * });
- */
- var times = doLimit(timeLimit, Infinity);
-
- /**
- * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
- *
- * @name timesSeries
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.times]{@link module:ControlFlow.times}
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link module:Collections.map}.
- */
- var timesSeries = doLimit(timeLimit, 1);
-
- /**
- * A relative of `reduce`. Takes an Object or Array, and iterates over each
- * element in series, each step potentially mutating an `accumulator` value.
- * The type of the accumulator defaults to the type of collection passed in.
- *
- * @name transform
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {*} [accumulator] - The initial state of the transform. If omitted,
- * it will default to an empty Object or Array, depending on the type of `coll`
- * @param {Function} iteratee - A function applied to each item in the
- * collection that potentially modifies the accumulator. The `iteratee` is
- * passed a `callback(err)` which accepts an optional error as its first
- * argument. If an error is passed to the callback, the transform is stopped
- * and the main `callback` is immediately called with the error.
- * Invoked with (accumulator, item, key, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the transformed accumulator.
- * Invoked with (err, result).
- * @example
- *
- * async.transform([1,2,3], function(acc, item, index, callback) {
- * // pointless async:
- * process.nextTick(function() {
- * acc.push(item * 2)
- * callback(null)
- * });
- * }, function(err, result) {
- * // result is now equal to [2, 4, 6]
- * });
- *
- * @example
- *
- * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
- * setImmediate(function () {
- * obj[key] = val * 2;
- * callback();
- * })
- * }, function (err, result) {
- * // result is equal to {a: 2, b: 4, c: 6}
- * })
- */
- function transform(coll, accumulator, iteratee, callback) {
- if (arguments.length === 3) {
- callback = iteratee;
- iteratee = accumulator;
- accumulator = isArray(coll) ? [] : {};
- }
- callback = once(callback || noop);
+ var attempt = 1;
+ function retryAttempt() {
+ 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);
+ }
+ });
+ }
- eachOf(coll, function (v, k, cb) {
- iteratee(accumulator, v, k, cb);
- }, function (err) {
- callback(err, accumulator);
- });
- }
+ retryAttempt();
+}
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
+ * retryable, rather than immediately calling it with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {Function} task - the asynchronous function to wrap
+ * @returns {Functions} The wrapped function, which when invoked, will retry on
+ * an error, based on the parameters specified in `opts`.
+ * @example
+ *
+ * async.auto({
+ * dep1: async.retryable(3, getFromFlakyService),
+ * process: ["dep1", async.retryable(3, function (results, cb) {
+ * maybeProcessData(results.dep1, cb);
+ * })]
+ * }, callback);
+ */
+var retryable = function (opts, task) {
+ if (!task) {
+ task = opts;
+ opts = null;
+ }
+ return initialParams(function (args, callback) {
+ function taskFn(cb) {
+ task.apply(null, args.concat([cb]));
+ }
- /**
- * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
- * unmemoized form. Handy for testing.
- *
- * @name unmemoize
- * @static
- * @memberOf module:Utils
- * @method
- * @see [async.memoize]{@link module:Utils.memoize}
- * @category Util
- * @param {Function} fn - the memoized function
- * @returns {Function} a function that calls the original unmemoized function
- */
- function unmemoize(fn) {
- return function () {
- return (fn.unmemoized || fn).apply(null, arguments);
- };
- }
+ if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
+ });
+};
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each
+ * function is passed a `callback(err, result)` it must call on completion with
+ * an error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ * function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * },
+ * function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback){
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+function series(tasks, callback) {
+ _parallel(eachOfSeries, tasks, callback);
+}
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+var some = _createTester(eachOf, Boolean, identity);
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someLimit = _createTester(eachOfLimit, Boolean, identity);
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someSeries = doLimit(someLimit, 1);
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, sortValue)` which must be called once
+ * it has completed with an error (which can be `null`) and a value to use as
+ * the sort criteria. Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ * fs.stat(file, function(err, stats) {
+ * callback(err, stats.mtime);
+ * });
+ * }, function(err, results) {
+ * // results is now the original array of files sorted by
+ * // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x);
+ * }, function(err,result) {
+ * // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ * // result callback
+ * });
+ */
+function sortBy(coll, iteratee, callback) {
+ map(coll, function (x, callback) {
+ iteratee(x, function (err, criteria) {
+ if (err) return callback(err);
+ callback(null, { value: x, criteria: criteria });
+ });
+ }, function (err, results) {
+ if (err) return callback(err);
+ callback(null, arrayMap(results.sort(comparator), baseProperty('value')));
+ });
+
+ function comparator(left, right) {
+ var a = left.criteria,
+ b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+}
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} asyncFn - The asynchronous function you want to set the
+ * time limit.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {Function} Returns a wrapped function that can be used with any of
+ * the control flow functions. Invoke this function with the same
+ * parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ * doAsyncTask(foo, function(err, data) {
+ * // handle errors
+ * if (err) return callback(err);
+ *
+ * // do some stuff ...
+ *
+ * // return processed data
+ * return callback(null, data);
+ * });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ * // if `myFunction` takes < 1000 ms to execute, `err`
+ * // and `data` will have their expected values
+ *
+ * // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+function timeout(asyncFn, milliseconds, info) {
+ var originalCallback, timer;
+ var timedOut = false;
+
+ function injectedCallback() {
+ if (!timedOut) {
+ originalCallback.apply(null, arguments);
+ clearTimeout(timer);
+ }
+ }
- /**
- * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when
- * stopped, or an error occurs.
- *
- * @name whilst
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Function} test - synchronous truth test to perform before each
- * execution of `fn`. Invoked with ().
- * @param {Function} iteratee - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- * @returns undefined
- * @example
- *
- * var count = 0;
- * async.whilst(
- * function() { return count < 5; },
- * function(callback) {
- * count++;
- * setTimeout(function() {
- * callback(null, count);
- * }, 1000);
- * },
- * function (err, n) {
- * // 5 seconds have passed, n = 5
- * }
- * );
- */
- function whilst(test, iteratee, callback) {
- callback = onlyOnce(callback || noop);
- if (!test()) return callback(null);
- var next = baseRest(function (err, args) {
- if (err) return callback(err);
- if (test()) return iteratee(next);
- callback.apply(null, [null].concat(args));
- });
- iteratee(next);
- }
+ function timeoutCallback() {
+ var name = asyncFn.name || 'anonymous';
+ var error = new Error('Callback function "' + name + '" timed out.');
+ error.code = 'ETIMEDOUT';
+ if (info) {
+ error.info = info;
+ }
+ timedOut = true;
+ originalCallback(error);
+ }
- /**
- * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
- * stopped, or an error occurs. `callback` will be passed an error and any
- * arguments passed to the final `fn`'s callback.
- *
- * The inverse of [whilst]{@link module:ControlFlow.whilst}.
- *
- * @name until
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.whilst]{@link module:ControlFlow.whilst}
- * @category Control Flow
- * @param {Function} test - synchronous truth test to perform before each
- * execution of `fn`. Invoked with ().
- * @param {Function} fn - A function which is called each time `test` fails.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has passed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function until(test, fn, callback) {
- whilst(function () {
- return !test.apply(this, arguments);
- }, fn, callback);
+ return initialParams(function (args, origCallback) {
+ originalCallback = origCallback;
+ // setup timer and call original function
+ timer = setTimeout(timeoutCallback, milliseconds);
+ asyncFn.apply(null, args.concat(injectedCallback));
+ });
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil;
+var nativeMax$1 = Math.max;
+
+/**
+ * The base implementation of `_.range` and `_.rangeRight` which doesn't
+ * coerce arguments.
+ *
+ * @private
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} step The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the range of numbers.
+ */
+function baseRange(start, end, step, fromRight) {
+ var index = -1,
+ length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
+
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
}
+ return result;
+}
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+function timeLimit(count, limit, iteratee, callback) {
+ mapLimit(baseRange(0, count, 1), limit, iteratee, callback);
+}
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ * callback(null, {
+ * id: 'user' + id
+ * });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ * createUser(n, function(err, user) {
+ * next(err, user);
+ * });
+ * }, function(err, users) {
+ * // we should now have 5 users
+ * });
+ */
+var times = doLimit(timeLimit, Infinity);
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+var timesSeries = doLimit(timeLimit, 1);
+
+/**
+ * A relative of `reduce`. Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform. If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {Function} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator. The `iteratee` is
+ * passed a `callback(err)` which accepts an optional error as its first
+ * argument. If an error is passed to the callback, the transform is stopped
+ * and the main `callback` is immediately called with the error.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * acc.push(item * 2)
+ * callback(null)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ * setImmediate(function () {
+ * obj[key] = val * 2;
+ * callback();
+ * })
+ * }, function (err, result) {
+ * // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+function transform(coll, accumulator, iteratee, callback) {
+ if (arguments.length === 3) {
+ callback = iteratee;
+ iteratee = accumulator;
+ accumulator = isArray(coll) ? [] : {};
+ }
+ callback = once(callback || noop);
+
+ eachOf(coll, function (v, k, cb) {
+ iteratee(accumulator, v, k, cb);
+ }, function (err) {
+ callback(err, accumulator);
+ });
+}
+
+/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {Function} fn - the memoized function
+ * @returns {Function} a function that calls the original unmemoized function
+ */
+function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+}
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {Function} iteratee - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ * function() { return count < 5; },
+ * function(callback) {
+ * count++;
+ * setTimeout(function() {
+ * callback(null, count);
+ * }, 1000);
+ * },
+ * function (err, n) {
+ * // 5 seconds have passed, n = 5
+ * }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+ callback = onlyOnce(callback || noop);
+ if (!test()) return callback(null);
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ if (test()) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+
+/**
+ * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `fn`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `fn`. Invoked with ().
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function until(test, fn, callback) {
+ whilst(function () {
+ return !test.apply(this, arguments);
+ }, fn, callback);
+}
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of functions to run, each function is passed
+ * a `callback(err, result1, result2, ...)` it must call on completion. The
+ * first argument is an error (which can be `null`) and any further arguments
+ * will be passed as arguments in order to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ * function(callback) {
+ * callback(null, 'one', 'two');
+ * },
+ * function(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * },
+ * function(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ * myFirstFunction,
+ * mySecondFunction,
+ * myLastFunction,
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ * callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ */
+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();
+ var taskIndex = 0;
+
+ function nextTask(args) {
+ if (taskIndex === tasks.length) {
+ return callback.apply(null, [null].concat(args));
+ }
- /**
- * Runs the `tasks` array of functions in series, each passing their results to
- * the next in the array. However, if any of the `tasks` pass an error to their
- * own callback, the next function is not executed, and the main `callback` is
- * immediately called with the error.
- *
- * @name waterfall
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array} tasks - An array of functions to run, each function is passed
- * a `callback(err, result1, result2, ...)` it must call on completion. The
- * first argument is an error (which can be `null`) and any further arguments
- * will be passed as arguments in order to the next task.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed. This will be passed the results of the last task's
- * callback. Invoked with (err, [results]).
- * @returns undefined
- * @example
- *
- * async.waterfall([
- * function(callback) {
- * callback(null, 'one', 'two');
- * },
- * function(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * },
- * function(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- *
- * // Or, with named functions:
- * async.waterfall([
- * myFirstFunction,
- * mySecondFunction,
- * myLastFunction,
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- * function myFirstFunction(callback) {
- * callback(null, 'one', 'two');
- * }
- * function mySecondFunction(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * }
- * function myLastFunction(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- */
- function waterfall (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();
- var taskIndex = 0;
-
- function nextTask(args) {
- if (taskIndex === tasks.length) {
- return callback.apply(null, [null].concat(args));
- }
-
- var taskCallback = onlyOnce(baseRest(function (err, args) {
- if (err) {
- return callback.apply(null, [err].concat(args));
- }
- nextTask(args);
- }));
-
- args.push(taskCallback);
-
- var task = tasks[taskIndex++];
- task.apply(null, args);
- }
+ var taskCallback = onlyOnce(baseRest$1(function (err, args) {
+ if (err) {
+ return callback.apply(null, [err].concat(args));
+ }
+ nextTask(args);
+ }));
- nextTask([]);
- }
+ args.push(taskCallback);
- var index = {
- applyEach: applyEach,
- applyEachSeries: applyEachSeries,
- apply: apply$1,
- 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,
- 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,
- 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
- };
+ var task = tasks[taskIndex++];
+ task.apply(null, args);
+ }
- exports['default'] = index;
- exports.applyEach = applyEach;
- exports.applyEachSeries = applyEachSeries;
- exports.apply = apply$1;
- exports.asyncify = asyncify;
- exports.auto = auto;
- exports.autoInject = autoInject;
- exports.cargo = cargo;
- exports.compose = compose;
- exports.concat = concat;
- exports.concatSeries = concatSeries;
- exports.constant = constant;
- exports.detect = detect;
- exports.detectLimit = detectLimit;
- exports.detectSeries = detectSeries;
- exports.dir = dir;
- exports.doDuring = doDuring;
- exports.doUntil = doUntil;
- exports.doWhilst = doWhilst;
- exports.during = during;
- exports.each = eachLimit;
- exports.eachLimit = eachLimit$1;
- exports.eachOf = eachOf;
- exports.eachOfLimit = eachOfLimit;
- exports.eachOfSeries = eachOfSeries;
- exports.eachSeries = eachSeries;
- exports.ensureAsync = ensureAsync;
- exports.every = every;
- exports.everyLimit = everyLimit;
- exports.everySeries = everySeries;
- exports.filter = filter;
- exports.filterLimit = filterLimit;
- exports.filterSeries = filterSeries;
- exports.forever = forever;
- exports.log = log;
- exports.map = map;
- exports.mapLimit = mapLimit;
- exports.mapSeries = mapSeries;
- exports.mapValues = mapValues;
- exports.mapValuesLimit = mapValuesLimit;
- exports.mapValuesSeries = mapValuesSeries;
- exports.memoize = memoize;
- exports.nextTick = nextTick;
- exports.parallel = parallelLimit;
- exports.parallelLimit = parallelLimit$1;
- exports.priorityQueue = priorityQueue;
- exports.queue = queue$1;
- exports.race = race;
- exports.reduce = reduce;
- exports.reduceRight = reduceRight;
- exports.reflect = reflect;
- exports.reflectAll = reflectAll;
- exports.reject = reject;
- exports.rejectLimit = rejectLimit;
- exports.rejectSeries = rejectSeries;
- exports.retry = retry;
- exports.retryable = retryable;
- exports.seq = seq;
- exports.series = series;
- exports.setImmediate = setImmediate$1;
- exports.some = some;
- exports.someLimit = someLimit;
- exports.someSeries = someSeries;
- exports.sortBy = sortBy;
- exports.timeout = timeout;
- exports.times = times;
- exports.timesLimit = timeLimit;
- exports.timesSeries = timesSeries;
- exports.transform = transform;
- exports.unmemoize = unmemoize;
- exports.until = until;
- exports.waterfall = waterfall;
- exports.whilst = whilst;
- exports.all = every;
- exports.allLimit = everyLimit;
- exports.allSeries = everySeries;
- exports.any = some;
- exports.anyLimit = someLimit;
- exports.anySeries = someSeries;
- exports.find = detect;
- exports.findLimit = detectLimit;
- exports.findSeries = detectSeries;
- exports.forEach = eachLimit;
- exports.forEachSeries = eachSeries;
- exports.forEachLimit = eachLimit$1;
- exports.forEachOf = eachOf;
- exports.forEachOfSeries = eachOfSeries;
- exports.forEachOfLimit = eachOfLimit;
- exports.inject = reduce;
- exports.foldl = reduce;
- exports.foldr = reduceRight;
- exports.select = filter;
- exports.selectLimit = filterLimit;
- exports.selectSeries = filterSeries;
- exports.wrapSync = asyncify;
-
-})); \ No newline at end of file
+ nextTask([]);
+};
+
+/**
+ * Async is a utility module which provides straight-forward, powerful functions
+ * for working with asynchronous JavaScript. Although originally designed for
+ * use with [Node.js](http://nodejs.org) and installable via
+ * `npm install --save async`, it can also be used directly in the browser.
+ * @module async
+ */
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+/**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
+var index = {
+ applyEach: applyEach,
+ applyEachSeries: applyEachSeries,
+ apply: apply$2,
+ asyncify: asyncify,
+ auto: auto,
+ autoInject: autoInject,
+ cargo: cargo,
+ compose: compose,
+ concat: concat,
+ concatSeries: concatSeries,
+ constant: constant$2,
+ 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,
+ 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$1,
+ series: series,
+ setImmediate: setImmediate$1,
+ some: some,
+ someLimit: someLimit,
+ someSeries: someSeries,
+ sortBy: sortBy,
+ timeout: timeout,
+ times: times,
+ timesLimit: timeLimit,
+ timesSeries: timesSeries,
+ transform: transform,
+ 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;
+exports.applyEach = applyEach;
+exports.applyEachSeries = applyEachSeries;
+exports.apply = apply$2;
+exports.asyncify = asyncify;
+exports.auto = auto;
+exports.autoInject = autoInject;
+exports.cargo = cargo;
+exports.compose = compose;
+exports.concat = concat;
+exports.concatSeries = concatSeries;
+exports.constant = constant$2;
+exports.detect = detect;
+exports.detectLimit = detectLimit;
+exports.detectSeries = detectSeries;
+exports.dir = dir;
+exports.doDuring = doDuring;
+exports.doUntil = doUntil;
+exports.doWhilst = doWhilst;
+exports.during = during;
+exports.each = eachLimit;
+exports.eachLimit = eachLimit$1;
+exports.eachOf = eachOf;
+exports.eachOfLimit = eachOfLimit;
+exports.eachOfSeries = eachOfSeries;
+exports.eachSeries = eachSeries;
+exports.ensureAsync = ensureAsync;
+exports.every = every;
+exports.everyLimit = everyLimit;
+exports.everySeries = everySeries;
+exports.filter = filter;
+exports.filterLimit = filterLimit;
+exports.filterSeries = filterSeries;
+exports.forever = forever;
+exports.log = log;
+exports.map = map;
+exports.mapLimit = mapLimit;
+exports.mapSeries = mapSeries;
+exports.mapValues = mapValues;
+exports.mapValuesLimit = mapValuesLimit;
+exports.mapValuesSeries = mapValuesSeries;
+exports.memoize = memoize;
+exports.nextTick = nextTick;
+exports.parallel = parallelLimit;
+exports.parallelLimit = parallelLimit$1;
+exports.priorityQueue = priorityQueue;
+exports.queue = queue$1;
+exports.race = race;
+exports.reduce = reduce;
+exports.reduceRight = reduceRight;
+exports.reflect = reflect;
+exports.reflectAll = reflectAll;
+exports.reject = reject;
+exports.rejectLimit = rejectLimit;
+exports.rejectSeries = rejectSeries;
+exports.retry = retry;
+exports.retryable = retryable;
+exports.seq = seq$1;
+exports.series = series;
+exports.setImmediate = setImmediate$1;
+exports.some = some;
+exports.someLimit = someLimit;
+exports.someSeries = someSeries;
+exports.sortBy = sortBy;
+exports.timeout = timeout;
+exports.times = times;
+exports.timesLimit = timeLimit;
+exports.timesSeries = timesSeries;
+exports.transform = transform;
+exports.unmemoize = unmemoize;
+exports.until = until;
+exports.waterfall = waterfall;
+exports.whilst = whilst;
+exports.all = every;
+exports.allLimit = everyLimit;
+exports.allSeries = everySeries;
+exports.any = some;
+exports.anyLimit = someLimit;
+exports.anySeries = someSeries;
+exports.find = detect;
+exports.findLimit = detectLimit;
+exports.findSeries = detectSeries;
+exports.forEach = eachLimit;
+exports.forEachSeries = eachSeries;
+exports.forEachLimit = eachLimit$1;
+exports.forEachOf = eachOf;
+exports.forEachOfSeries = eachOfSeries;
+exports.forEachOfLimit = eachOfLimit;
+exports.inject = reduce;
+exports.foldl = reduce;
+exports.foldr = reduceRight;
+exports.select = filter;
+exports.selectLimit = filterLimit;
+exports.selectSeries = filterSeries;
+exports.wrapSync = asyncify;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
diff --git a/dist/async.min.js b/dist/async.min.js
index af3069a..15c4a33 100644
--- a/dist/async.min.js
+++ b/dist/async.min.js
@@ -1,2 +1,2 @@
-!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function e(n,e){return e=et(void 0===e?n.length-1:e,0),function(){for(var r=arguments,u=-1,i=et(r.length-e,0),o=Array(i);++u<i;)o[u]=r[e+u];u=-1;for(var c=Array(e+1);++u<e;)c[u]=r[u];return c[e]=o,t(n,this,c)}}function r(n){return e(function(t){var e=t.pop();n.call(this,t,e)})}function u(n){return e(function(t,e){var u=r(function(e,r){var u=this;return n(t,function(n,t){n.apply(u,e.concat([t]))},r)});return e.length?u.apply(this,e):u})}function i(n){return function(t){return null==t?void 0:t[n]}}function o(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function c(n){var t=o(n)?ct.call(n):"";return t==ut||t==it}function f(n){return"number"==typeof n&&n>-1&&n%1==0&&ft>=n}function a(n){return null!=n&&f(rt(n))&&!c(n)}function l(){}function s(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function p(n){return at&&n[at]&&n[at]()}function h(n,t){return function(e){return n(t(e))}}function y(n,t){return null!=n&&(ht.call(n,t)||"object"==typeof n&&t in n&&null===st(n))}function v(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}function m(n){return!!n&&"object"==typeof n}function d(n){return m(n)&&a(n)}function g(n){return d(n)&&gt.call(n,"callee")&&(!St.call(n,"callee")||bt.call(n)==mt)}function b(n){return"string"==typeof n||!jt(n)&&m(n)&&Lt.call(n)==kt}function S(n){var t=n?n.length:void 0;return f(t)&&(jt(n)||b(n)||g(n))?v(t,String):null}function j(n,t){return t=null==t?Et:t,!!t&&("number"==typeof n||Ot.test(n))&&n>-1&&n%1==0&&t>n}function k(n){var t=n&&n.constructor,e="function"==typeof t&&t.prototype||xt;return n===e}function w(n){var t=k(n);if(!t&&!a(n))return vt(n);var e=S(n),r=!!e,u=e||[],i=u.length;for(var o in n)!y(n,o)||r&&("length"==o||j(o,i))||t&&"constructor"==o||u.push(o);return u}function L(n){var t=-1,e=n.length;return function(){return++t<e?{value:n[t],key:t}:null}}function E(n){var t=-1;return function(){var e=n.next();return e.done?null:(t++,{value:e.value,key:t})}}function O(n){var t=w(n),e=-1,r=t.length;return function(){var u=t[++e];return r>e?{value:n[u],key:u}:null}}function x(n){if(a(n))return L(n);var t=p(n);return t?E(t):O(n)}function A(n){return function(){if(null===n)throw new Error("Callback was already called.");var t=n;n=null,t.apply(this,arguments)}}function _(n){return function(t,e,r){function u(n){if(f-=1,n)c=!0,r(n);else{if(c&&0>=f)return r(null);i()}}function i(){for(;n>f&&!c;){var t=o();if(null===t)return c=!0,void(0>=f&&r(null));f+=1,e(t.value,t.key,A(u))}}if(r=s(r||l),0>=n||!t)return r(null);var o=x(t),c=!1,f=0;i()}}function I(n,t,e,r){_(t)(n,e,r)}function T(n,t){return function(e,r,u){return n(e,t,r,u)}}function F(n,t,e){function r(n){n?e(n):++i===o&&e(null)}e=s(e||l);var u=0,i=0,o=n.length;for(0===o&&e(null);o>u;u++)t(n[u],u,A(r))}function z(n,t,e){var r=a(n)?F:At;r(n,t,e)}function B(n){return function(t,e,r){return n(z,t,e,r)}}function M(n,t,e,r){r=s(r||l),t=t||[];var u=[],i=0;n(t,function(n,t,r){var o=i++;e(n,function(n,t){u[o]=t,r(n)})},function(n){r(n,u)})}function V(n){return function(t,e,r,u){return n(_(e),t,r,u)}}function q(n){return r(function(t,e){var r;try{r=n.apply(this,t)}catch(u){return e(u)}o(r)&&"function"==typeof r.then?r.then(function(n){e(null,n)},function(n){e(n.message?n:new Error(n))}):e(null,r)})}function $(n,t){for(var e=-1,r=n?n.length:0;++e<r&&t(n[e],e,n)!==!1;);return n}function C(n){return function(t,e,r){for(var u=-1,i=Object(t),o=r(t),c=o.length;c--;){var f=o[n?c:++u];if(e(i[f],f,i)===!1)break}return t}}function D(n,t){return n&&Mt(n,t,w)}function P(n,t,e,r){for(var u=n.length,i=e+(r?1:-1);r?i--:++i<u;)if(t(n[i],i,n))return i;return-1}function R(n){return n!==n}function U(n,t,e){if(t!==t)return P(n,R,e);for(var r=e-1,u=n.length;++r<u;)if(n[r]===t)return r;return-1}function Q(n,t,r){function u(n,t){b.push(function(){f(n,t)})}function i(){if(0===b.length&&0===m)return r(null,v);for(;b.length&&t>m;){var n=b.shift();n()}}function o(n,t){var e=g[n];e||(e=g[n]=[]),e.push(t)}function c(n){var t=g[n]||[];$(t,function(n){n()}),i()}function f(n,t){if(!d){var u=A(e(function(t,e){if(m--,e.length<=1&&(e=e[0]),t){var u={};D(v,function(n,t){u[t]=n}),u[n]=e,d=!0,g=[],r(t,u)}else v[n]=e,c(n)}));m++;var i=t[t.length-1];t.length>1?i(v,u):i(u)}}function a(){for(var n,t=0;S.length;)n=S.pop(),t++,$(p(n),function(n){0===--j[n]&&S.push(n)});if(t!==y)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function p(t){var e=[];return D(n,function(n,r){jt(n)&&U(n,t,0)>=0&&e.push(r)}),e}"function"==typeof t&&(r=t,t=null),r=s(r||l);var h=w(n),y=h.length;if(!y)return r(null);t||(t=y);var v={},m=0,d=!1,g={},b=[],S=[],j={};D(n,function(t,e){if(!jt(t))return u(e,[t]),void S.push(e);var r=t.slice(0,t.length-1),i=r.length;return 0===i?(u(e,t),void S.push(e)):(j[e]=i,void $(r,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency in "+r.join(", "));o(c,function(){i--,0===i&&u(e,t)})}))}),a(),i()}function W(n,t){for(var e=-1,r=n?n.length:0,u=Array(r);++e<r;)u[e]=t(n[e],e,n);return u}function G(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}function H(n){return"symbol"==typeof n||m(n)&&Rt.call(n)==Dt}function J(n){if("string"==typeof n)return n;if(H(n))return Wt?Wt.call(n):"";var t=n+"";return"0"==t&&1/n==-Ut?"-0":t}function K(n,t,e){var r=-1,u=n.length;0>t&&(t=-t>u?0:u+t),e=e>u?u:e,0>e&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(u);++r<u;)i[r]=n[r+t];return i}function N(n,t,e){var r=n.length;return e=void 0===e?r:e,!t&&e>=r?n:K(n,t,e)}function X(n,t){for(var e=n.length;e--&&U(t,n[e],0)>-1;);return e}function Y(n,t){for(var e=-1,r=n.length;++e<r&&U(t,n[e],0)>-1;);return e}function Z(n){return n.match(ae)}function nn(n){return null==n?"":J(n)}function tn(n,t,e){if(n=nn(n),n&&(e||void 0===t))return n.replace(le,"");if(!n||!(t=J(t)))return n;var r=Z(n),u=Z(t),i=Y(r,u),o=X(r,u)+1;return N(r,i,o).join("")}function en(n){return n=n.toString().replace(ye,""),n=n.match(se)[2].replace(" ",""),n=n?n.split(pe):[],n=n.map(function(n){return tn(n.replace(he,""))})}function rn(n,t){var e={};D(n,function(n,t){function r(t,e){var r=W(u,function(n){return t[n]});r.push(e),n.apply(null,r)}var u;if(jt(n))u=G(n),n=u.pop(),e[t]=u.concat(u.length>0?r:n);else if(1===n.length)e[t]=n;else{if(u=en(n),0===n.length&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");u.pop(),e[t]=u.concat(r)}}),Q(e,t)}function un(n){setTimeout(n,0)}function on(n){return e(function(t,e){n(function(){t.apply(null,e)})})}function cn(){this.head=this.tail=null,this.length=0}function fn(n,t){n.length=1,n.head=n.tail=t}function an(n,t,r){function u(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");return f.started=!0,jt(n)||(n=[n]),0===n.length&&f.idle()?de(function(){f.drain()}):($(n,function(n){var r={data:n,callback:e||l};t?f._tasks.unshift(r):f._tasks.push(r)}),void de(f.process))}function i(n){return e(function(t){o-=1,$(n,function(n){$(c,function(t,e){return t===n?(c.splice(e,1),!1):void 0}),n.callback.apply(n,t),null!=t[0]&&f.error(t[0],n.data)}),o<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,c=[],f={_tasks:new cn,concurrency:t,payload:r,saturated:l,unsaturated:l,buffer:t/4,empty:l,drain:l,error:l,started:!1,paused:!1,push:function(n,t){u(n,!1,t)},kill:function(){f.drain=l,f._tasks.empty()},unshift:function(n,t){u(n,!0,t)},process:function(){for(;!f.paused&&o<f.concurrency&&f._tasks.length;){var t=[],e=[],r=f._tasks.length;f.payload&&(r=Math.min(r,f.payload));for(var u=0;r>u;u++){var a=f._tasks.shift();t.push(a),e.push(a.data)}0===f._tasks.length&&f.empty(),o+=1,c.push(t[0]),o===f.concurrency&&f.saturated();var l=A(i(t));n(e,l)}},length:function(){return f._tasks.length},running:function(){return o},workersList:function(){return c},idle:function(){return f._tasks.length+o===0},pause:function(){f.paused=!0},resume:function(){if(f.paused!==!1){f.paused=!1;for(var n=Math.min(f.concurrency,f._tasks.length),t=1;n>=t;t++)de(f.process)}}};return f}function ln(n,t){return an(n,1,t)}function sn(n,t,e,r){r=s(r||l),be(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})}function pn(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function hn(n){return function(t,e,r){return n(be,t,e,r)}}function yn(n){return n}function vn(n,t,e){return function(r,u,i,o){function c(n){o&&(n?o(n):o(null,e(!1)))}function f(n,r,u){return o?void i(n,function(r,c){o&&(r?(o(r),o=i=!1):t(c)&&(o(null,e(!0,n)),o=i=!1)),u()}):u()}arguments.length>3?(o=o||l,n(r,u,f,c)):(o=i,o=o||l,i=u,n(r,f,c))}}function mn(n,t){return t}function dn(n){return e(function(t,r){t.apply(null,r.concat([e(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&$(e,function(t){console[n](t)}))})]))})}function gn(n,t,r){function u(t,e){return t?r(t):e?void n(i):r(null)}r=A(r||l);var i=e(function(n,e){return n?r(n):(e.push(u),void t.apply(this,e))});u(null,!0)}function bn(n,t,r){r=A(r||l);var u=e(function(e,i){return e?r(e):t.apply(this,i)?n(u):void r.apply(null,[null].concat(i))});n(u)}function Sn(n,t,e){bn(n,function(){return!t.apply(this,arguments)},e)}function jn(n,t,e){function r(t){return t?e(t):void n(u)}function u(n,u){return n?e(n):u?void t(r):e(null)}e=A(e||l),n(u)}function kn(n){return function(t,e,r){return n(t,r)}}function wn(n,t,e){z(n,kn(t),e)}function Ln(n,t,e,r){_(t)(n,kn(e),r)}function En(n){return r(function(t,e){var r=!0;t.push(function(){var n=arguments;r?de(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function On(n){return!n}function xn(n,t,e,r){r=s(r||l);var u=[];n(t,function(n,t,r){e(n,function(e,i){e?r(e):(i&&u.push({index:t,value:n}),r())})},function(n){n?r(n):r(null,W(u.sort(function(n,t){return n.index-t.index}),i("value")))})}function An(n,t){function e(n){return n?r(n):void u(e)}var r=A(t||l),u=En(n);e()}function _n(n,t,e,r){r=s(r||l);var u={};I(n,t,function(n,t,r){e(n,t,function(n,e){return n?r(n):(u[t]=e,void r())})},function(n){r(n,u)})}function In(n,t){return t in n}function Tn(n,t){var u=Object.create(null),i=Object.create(null);t=t||yn;var o=r(function(r,o){var c=t.apply(null,r);In(u,c)?de(function(){o.apply(null,u[c])}):In(i,c)?i[c].push(o):(i[c]=[o],n.apply(null,r.concat([e(function(n){u[c]=n;var t=i[c];delete i[c];for(var e=0,r=t.length;r>e;e++)t[e].apply(null,n)})])))});return o.memo=u,o.unmemoized=n,o}function Fn(n,t,r){r=r||l;var u=a(t)?[]:{};n(t,function(n,t,r){n(e(function(n,e){e.length<=1&&(e=e[0]),u[t]=e,r(n)}))},function(n){r(n,u)})}function zn(n,t){Fn(z,n,t)}function Bn(n,t,e){Fn(_(t),n,e)}function Mn(n,t){return an(function(t,e){n(t[0],e)},t,1)}function Vn(n,t){var e=Mn(n,t);return e.push=function(n,t,r){if(null==r&&(r=l),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,jt(n)||(n=[n]),0===n.length)return de(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;$(n,function(n){var i={data:n,priority:t,callback:r};u?e._tasks.insertBefore(u,i):e._tasks.push(i)}),de(e.process)},delete e.unshift,e}function qn(n,t){return t=s(t||l),jt(n)?n.length?void $(n,function(n){n(t)}):t():t(new TypeError("First argument to race must be an array of functions"))}function $n(n,t,e,r){var u=De.call(n).reverse();sn(u,t,e,r)}function Cn(n){return r(function(t,r){return t.push(e(function(n,t){if(n)r(null,{error:n});else{var e=null;1===t.length?e=t[0]:t.length>1&&(e=t),r(null,{value:e})}})),n.apply(this,t)})}function Dn(n,t,e,r){xn(n,t,function(n,t){e(n,function(n,e){n?t(n):t(null,!e)})},r)}function Pn(n){var t;return jt(n)?t=W(n,Cn):(t={},D(n,function(n,e){t[e]=Cn.call(this,n)})),t}function Rn(n){return function(){return n}}function Un(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||i,n.intervalFunc="function"==typeof t.interval?t.interval:Rn(+t.interval||o);else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||i}}function u(){t(function(n){n&&f++<c.times?setTimeout(u,c.intervalFunc(f)):e.apply(null,arguments)})}var i=5,o=0,c={times:i,intervalFunc:Rn(o)};if(arguments.length<3&&"function"==typeof n?(e=t||l,t=n):(r(c,n),e=e||l),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var f=1;u()}function Qn(n,t){return t||(t=n,n=null),r(function(e,r){function u(n){t.apply(null,e.concat([n]))}n?Un(n,u,r):Un(u,r)})}function Wn(n,t){Fn(be,n,t)}function Gn(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0}_t(n,function(n,e){t(n,function(t,r){return t?e(t):void e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,W(t.sort(r),i("value")))})}function Hn(n,t,e){function u(){f||(o.apply(null,arguments),clearTimeout(c))}function i(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),f=!0,o(r)}var o,c,f=!1;return r(function(e,r){o=r,c=setTimeout(i,t),n.apply(null,e.concat(u))})}function Jn(n,t,e,r){for(var u=-1,i=Je(He((t-n)/(e||1)),0),o=Array(i);i--;)o[r?i:++u]=n,n+=e;return o}function Kn(n,t,e,r){Tt(Jn(0,n,1),t,e,r)}function Nn(n,t,e,r){3===arguments.length&&(r=e,e=t,t=jt(n)?[]:{}),r=s(r||l),z(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})}function Xn(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function Yn(n,t,r){if(r=A(r||l),!n())return r(null);var u=e(function(e,i){return e?r(e):n()?t(u):void r.apply(null,[null].concat(i))});t(u)}function Zn(n,t,e){Yn(function(){return!n.apply(this,arguments)},t,e)}function nt(n,t){function r(i){if(u===n.length)return t.apply(null,[null].concat(i));var o=A(e(function(n,e){return n?t.apply(null,[n].concat(e)):void r(e)}));i.push(o);var c=n[u++];c.apply(null,i)}if(t=s(t||l),!jt(n))return t(new Error("First argument to waterfall must be an array of functions"));if(!n.length)return t();var u=0;r([])}var tt,et=Math.max,rt=i("length"),ut="[object Function]",it="[object GeneratorFunction]",ot=Object.prototype,ct=ot.toString,ft=9007199254740991,at="function"==typeof Symbol&&Symbol.iterator,lt=Object.getPrototypeOf,st=h(lt,Object),pt=Object.prototype,ht=pt.hasOwnProperty,yt=Object.keys,vt=h(yt,Object),mt="[object Arguments]",dt=Object.prototype,gt=dt.hasOwnProperty,bt=dt.toString,St=dt.propertyIsEnumerable,jt=Array.isArray,kt="[object String]",wt=Object.prototype,Lt=wt.toString,Et=9007199254740991,Ot=/^(?:0|[1-9]\d*)$/,xt=Object.prototype,At=T(I,1/0),_t=B(M),It=u(_t),Tt=V(M),Ft=T(Tt,1),zt=u(Ft),Bt=e(function(n,t){return e(function(e){return n.apply(null,t.concat(e))})}),Mt=C(),Vt="object"==typeof global&&global&&global.Object===Object&&global,qt="object"==typeof self&&self&&self.Object===Object&&self,$t=Vt||qt||Function("return this")(),Ct=$t.Symbol,Dt="[object Symbol]",Pt=Object.prototype,Rt=Pt.toString,Ut=1/0,Qt=Ct?Ct.prototype:void 0,Wt=Qt?Qt.toString:void 0,Gt="\\ud800-\\udfff",Ht="\\u0300-\\u036f\\ufe20-\\ufe23",Jt="\\u20d0-\\u20f0",Kt="\\ufe0e\\ufe0f",Nt="["+Gt+"]",Xt="["+Ht+Jt+"]",Yt="\\ud83c[\\udffb-\\udfff]",Zt="(?:"+Xt+"|"+Yt+")",ne="[^"+Gt+"]",te="(?:\\ud83c[\\udde6-\\uddff]){2}",ee="[\\ud800-\\udbff][\\udc00-\\udfff]",re="\\u200d",ue=Zt+"?",ie="["+Kt+"]?",oe="(?:"+re+"(?:"+[ne,te,ee].join("|")+")"+ie+ue+")*",ce=ie+ue+oe,fe="(?:"+[ne+Xt+"?",Xt,te,ee,Nt].join("|")+")",ae=RegExp(Yt+"(?="+Yt+")|"+fe+ce,"g"),le=/^\s+|\s+$/g,se=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,pe=/,/,he=/(=.+)?(\s*)$/,ye=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ve="function"==typeof setImmediate&&setImmediate,me="object"==typeof process&&"function"==typeof process.nextTick;tt=ve?setImmediate:me?process.nextTick:un;var de=on(tt);cn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},cn.prototype.empty=cn,cn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},cn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},cn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):fn(this,n)},cn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):fn(this,n)},cn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},cn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var ge,be=T(I,1),Se=e(function(n){return e(function(t){var r=this,u=t[t.length-1];"function"==typeof u?t.pop():u=l,sn(n,t,function(n,t,u){t.apply(r,n.concat([e(function(n,t){u(n,t)})]))},function(n,t){u.apply(r,[n].concat(t))})})}),je=e(function(n){return Se.apply(null,n.reverse())}),ke=B(pn),we=hn(pn),Le=e(function(n){var t=[null].concat(n);return r(function(n,e){return e.apply(this,t)})}),Ee=vn(z,yn,mn),Oe=vn(I,yn,mn),xe=vn(be,yn,mn),Ae=dn("dir"),_e=T(Ln,1),Ie=vn(z,On,On),Te=vn(I,On,On),Fe=T(Te,1),ze=B(xn),Be=V(xn),Me=T(Be,1),Ve=dn("log"),qe=T(_n,1/0),$e=T(_n,1);ge=me?process.nextTick:ve?setImmediate:un;var Ce=on(ge),De=Array.prototype.slice,Pe=B(Dn),Re=V(Dn),Ue=T(Re,1),Qe=vn(z,Boolean,yn),We=vn(I,Boolean,yn),Ge=T(We,1),He=Math.ceil,Je=Math.max,Ke=T(Kn,1/0),Ne=T(Kn,1),Xe={applyEach:It,applyEachSeries:zt,apply:Bt,asyncify:q,auto:Q,autoInject:rn,cargo:ln,compose:je,concat:ke,concatSeries:we,constant:Le,detect:Ee,detectLimit:Oe,detectSeries:xe,dir:Ae,doDuring:gn,doUntil:Sn,doWhilst:bn,during:jn,each:wn,eachLimit:Ln,eachOf:z,eachOfLimit:I,eachOfSeries:be,eachSeries:_e,ensureAsync:En,every:Ie,everyLimit:Te,everySeries:Fe,filter:ze,filterLimit:Be,filterSeries:Me,forever:An,log:Ve,map:_t,mapLimit:Tt,mapSeries:Ft,mapValues:qe,mapValuesLimit:_n,mapValuesSeries:$e,memoize:Tn,nextTick:Ce,parallel:zn,parallelLimit:Bn,priorityQueue:Vn,queue:Mn,race:qn,reduce:sn,reduceRight:$n,reflect:Cn,reflectAll:Pn,reject:Pe,rejectLimit:Re,rejectSeries:Ue,retry:Un,retryable:Qn,seq:Se,series:Wn,setImmediate:de,some:Qe,someLimit:We,someSeries:Ge,sortBy:Gn,timeout:Hn,times:Ke,timesLimit:Kn,timesSeries:Ne,transform:Nn,unmemoize:Xn,until:Zn,waterfall:nt,whilst:Yn,all:Ie,any:Qe,forEach:wn,forEachSeries:_e,forEachLimit:Ln,forEachOf:z,forEachOfSeries:be,forEachOfLimit:I,inject:sn,foldl:sn,foldr:$n,select:ze,selectLimit:Be,selectSeries:Me,wrapSync:q};n["default"]=Xe,n.applyEach=It,n.applyEachSeries=zt,n.apply=Bt,n.asyncify=q,n.auto=Q,n.autoInject=rn,n.cargo=ln,n.compose=je,n.concat=ke,n.concatSeries=we,n.constant=Le,n.detect=Ee,n.detectLimit=Oe,n.detectSeries=xe,n.dir=Ae,n.doDuring=gn,n.doUntil=Sn,n.doWhilst=bn,n.during=jn,n.each=wn,n.eachLimit=Ln,n.eachOf=z,n.eachOfLimit=I,n.eachOfSeries=be,n.eachSeries=_e,n.ensureAsync=En,n.every=Ie,n.everyLimit=Te,n.everySeries=Fe,n.filter=ze,n.filterLimit=Be,n.filterSeries=Me,n.forever=An,n.log=Ve,n.map=_t,n.mapLimit=Tt,n.mapSeries=Ft,n.mapValues=qe,n.mapValuesLimit=_n,n.mapValuesSeries=$e,n.memoize=Tn,n.nextTick=Ce,n.parallel=zn,n.parallelLimit=Bn,n.priorityQueue=Vn,n.queue=Mn,n.race=qn,n.reduce=sn,n.reduceRight=$n,n.reflect=Cn,n.reflectAll=Pn,n.reject=Pe,n.rejectLimit=Re,n.rejectSeries=Ue,n.retry=Un,n.retryable=Qn,n.seq=Se,n.series=Wn,n.setImmediate=de,n.some=Qe,n.someLimit=We,n.someSeries=Ge,n.sortBy=Gn,n.timeout=Hn,n.times=Ke,n.timesLimit=Kn,n.timesSeries=Ne,n.transform=Nn,n.unmemoize=Xn,n.until=Zn,n.waterfall=nt,n.whilst=Yn,n.all=Ie,n.allLimit=Te,n.allSeries=Fe,n.any=Qe,n.anyLimit=We,n.anySeries=Ge,n.find=Ee,n.findLimit=Oe,n.findSeries=xe,n.forEach=wn,n.forEachSeries=_e,n.forEachLimit=Ln,n.forEachOf=z,n.forEachOfSeries=be,n.forEachOfLimit=I,n.inject=sn,n.foldl=sn,n.foldr=$n,n.select=ze,n.selectLimit=Be,n.selectSeries=Me,n.wrapSync=q});
+!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n){return n}function e(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function r(n,t,r){return t=ot(void 0===t?n.length-1:t,0),function(){for(var u=arguments,o=-1,i=ot(u.length-t,0),c=Array(i);++o<i;)c[o]=u[t+o];o=-1;for(var f=Array(t+1);++o<t;)f[o]=u[o];return f[t]=r(c),e(n,this,f)}}function u(n){return function(){return n}}function o(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function i(n){var t=o(n)?lt.call(n):"";return t==it||t==ct||t==ft}function c(n){return!!vt&&vt in n}function f(n){if(null!=n){try{return mt.call(n)}catch(n){}try{return n+""}catch(n){}}return""}function a(n){if(!o(n)||c(n))return!1;var t=i(n)?wt:bt;return t.test(f(n))}function l(n,t){return null==n?void 0:n[t]}function s(n,t){var e=l(n,t);return a(e)?e:void 0}function p(n){var t=0,e=0;return function(){var r=_t(),u=At-(r-e);if(e=r,u>0){if(++t>=Lt)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function h(n,e){return Tt(r(n,e,t),n+"")}function y(n){return h(function(t,e){var r=Ft(function(e,r){var u=this;return n(t,function(n,t){n.apply(u,e.concat([t]))},r)});return e.length?r.apply(this,e):r})}function v(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=It}function d(n){return null!=n&&v(n.length)&&!i(n)}function m(){}function g(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function b(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}function j(n){return null!=n&&"object"==typeof n}function S(n){return j(n)&&zt.call(n)==Mt}function k(){return!1}function O(n,t){return t=null==t?Jt:t,!!t&&("number"==typeof n||Kt.test(n))&&n>-1&&n%1==0&&n<t}function w(n){return j(n)&&v(n.length)&&!!Se[we.call(n)]}function x(n){return function(t){return n(t)}}function E(n,t){var e=qt(n),r=!e&&Dt(n),u=!e&&!r&&Ht(n),o=!e&&!r&&!u&&Fe(n),i=e||r||u||o,c=i?b(n.length,String):[],f=c.length;for(var a in n)!t&&!Be.call(n,a)||i&&("length"==a||u&&("offset"==a||"parent"==a)||o&&("buffer"==a||"byteLength"==a||"byteOffset"==a)||O(a,f))||c.push(a);return c}function L(n){var t=n&&n.constructor,e="function"==typeof t&&t.prototype||$e;return n===e}function A(n,t){return function(e){return n(t(e))}}function _(n){if(!L(n))return Me(n);var t=[];for(var e in Object(n))ze.call(n,e)&&"constructor"!=e&&t.push(e);return t}function T(n){return d(n)?E(n):_(n)}function F(n){var t=-1,e=n.length;return function(){return++t<e?{value:n[t],key:t}:null}}function I(n){var t=-1;return function(){var e=n.next();return e.done?null:(t++,{value:e.value,key:t})}}function B(n){var t=T(n),e=-1,r=t.length;return function(){var u=t[++e];return e<r?{value:n[u],key:u}:null}}function $(n){if(d(n))return F(n);var t=$t(n);return t?I(t):B(n)}function M(n){return function(){if(null===n)throw new Error("Callback was already called.");var t=n;n=null,t.apply(this,arguments)}}function P(n){return function(t,e,r){function u(n,t){if(f-=1,n)c=!0,r(n);else{if(t===Re||c&&f<=0)return c=!0,r(null);o()}}function o(){for(;f<n&&!c;){var t=i();if(null===t)return c=!0,void(f<=0&&r(null));f+=1,e(t.value,t.key,M(u))}}if(r=g(r||m),n<=0||!t)return r(null);var i=$(t),c=!1,f=0;o()}}function z(n,t,e,r){P(t)(n,e,r)}function R(n,t){return function(e,r,u){return n(e,t,r,u)}}function U(n,t,e){function r(n){n?e(n):++o===i&&e(null)}e=g(e||m);var u=0,o=0,i=n.length;for(0===i&&e(null);u<i;u++)t(n[u],u,M(r))}function V(n){return function(t,e,r){return n(Ve,t,e,r)}}function D(n,t,e,r){r=g(r||m),t=t||[];var u=[],o=0;n(t,function(n,t,r){var i=o++;e(n,function(n,t){u[i]=t,r(n)})},function(n){r(n,u)})}function q(n){return function(t,e,r,u){return n(P(e),t,r,u)}}function C(n){return Ft(function(t,e){var r;try{r=n.apply(this,t)}catch(n){return e(n)}o(r)&&"function"==typeof r.then?r.then(function(n){e(null,n)},function(n){e(n.message?n:new Error(n))}):e(null,r)})}function W(n,t){for(var e=-1,r=n?n.length:0;++e<r&&t(n[e],e,n)!==!1;);return n}function Q(n){return function(t,e,r){for(var u=-1,o=Object(t),i=r(t),c=i.length;c--;){var f=i[n?c:++u];if(e(o[f],f,o)===!1)break}return t}}function G(n,t){return n&&Ne(n,t,T)}function N(n,t,e,r){for(var u=n.length,o=e+(r?1:-1);r?o--:++o<u;)if(t(n[o],o,n))return o;return-1}function H(n){return n!==n}function J(n,t,e){for(var r=e-1,u=n.length;++r<u;)if(n[r]===t)return r;return-1}function K(n,t,e){return t===t?J(n,t,e):N(n,H,e)}function X(n,t){for(var e=-1,r=n?n.length:0,u=Array(r);++e<r;)u[e]=t(n[e],e,n);return u}function Y(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}function Z(n){return"symbol"==typeof n||j(n)&&Ye.call(n)==Ke}function nn(n){if("string"==typeof n)return n;if(qt(n))return X(n,nn)+"";if(Z(n))return tr?tr.call(n):"";var t=n+"";return"0"==t&&1/n==-Ze?"-0":t}function tn(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(u);++r<u;)o[r]=n[r+t];return o}function en(n,t,e){var r=n.length;return e=void 0===e?r:e,!t&&e>=r?n:tn(n,t,e)}function rn(n,t){for(var e=n.length;e--&&K(t,n[e],0)>-1;);return e}function un(n,t){for(var e=-1,r=n.length;++e<r&&K(t,n[e],0)>-1;);return e}function on(n){return n.split("")}function cn(n){return cr.test(n)}function fn(n){return n.match(xr)||[]}function an(n){return cn(n)?fn(n):on(n)}function ln(n){return null==n?"":nn(n)}function sn(n,t,e){if(n=ln(n),n&&(e||void 0===t))return n.replace(Er,"");if(!n||!(t=nn(t)))return n;var r=an(n),u=an(t),o=un(r,u),i=rn(r,u)+1;return en(r,o,i).join("")}function pn(n){return n=n.toString().replace(Tr,""),n=n.match(Lr)[2].replace(" ",""),n=n?n.split(Ar):[],n=n.map(function(n){return sn(n.replace(_r,""))})}function hn(n,t){var e={};G(n,function(n,t){function r(t,e){var r=X(u,function(n){return t[n]});r.push(e),n.apply(null,r)}var u;if(qt(n))u=Y(n),n=u.pop(),e[t]=u.concat(u.length>0?r:n);else if(1===n.length)e[t]=n;else{if(u=pn(n),0===n.length&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");u.pop(),e[t]=u.concat(r)}}),He(e,t)}function yn(n){setTimeout(n,0)}function vn(n){return h(function(t,e){n(function(){t.apply(null,e)})})}function dn(){this.head=this.tail=null,this.length=0}function mn(n,t){n.length=1,n.head=n.tail=t}function gn(n,t,e){function r(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");if(c.started=!0,qt(n)||(n=[n]),0===n.length&&c.idle())return Br(function(){c.drain()});for(var r=0,u=n.length;r<u;r++){var o={data:n[r],callback:e||m};t?c._tasks.unshift(o):c._tasks.push(o)}Br(c.process)}function u(n){return h(function(t){o-=1;for(var e=0,r=n.length;e<r;e++){var u=n[e],f=K(i,u,0);f>=0&&i.splice(f),u.callback.apply(u,t),null!=t[0]&&c.error(t[0],u.data)}o<=c.concurrency-c.buffer&&c.unsaturated(),c.idle()&&c.drain(),c.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,i=[],c={_tasks:new dn,concurrency:t,payload:e,saturated:m,unsaturated:m,buffer:t/4,empty:m,drain:m,error:m,started:!1,paused:!1,push:function(n,t){r(n,!1,t)},kill:function(){c.drain=m,c._tasks.empty()},unshift:function(n,t){r(n,!0,t)},process:function(){for(;!c.paused&&o<c.concurrency&&c._tasks.length;){var t=[],e=[],r=c._tasks.length;c.payload&&(r=Math.min(r,c.payload));for(var f=0;f<r;f++){var a=c._tasks.shift();t.push(a),e.push(a.data)}0===c._tasks.length&&c.empty(),o+=1,i.push(t[0]),o===c.concurrency&&c.saturated();var l=M(u(t));n(e,l)}},length:function(){return c._tasks.length},running:function(){return o},workersList:function(){return i},idle:function(){return c._tasks.length+o===0},pause:function(){c.paused=!0},resume:function(){if(c.paused!==!1){c.paused=!1;for(var n=Math.min(c.concurrency,c._tasks.length),t=1;t<=n;t++)Br(c.process)}}};return c}function bn(n,t){return gn(n,1,t)}function jn(n,t,e,r){r=g(r||m),Mr(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})}function Sn(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function kn(n){return function(t,e,r){return n(Mr,t,e,r)}}function On(n,t,e){return function(r,u,o,i){function c(){i&&i(null,e(!1))}function f(n,r,u){return i?void o(n,function(r,c){i&&(r||t(c))?(r?i(r):i(r,e(!0,n)),i=o=!1,u(r,Re)):u()}):u()}arguments.length>3?(i=i||m,n(r,u,f,c)):(i=o,i=i||m,o=u,n(r,f,c))}}function wn(n,t){return t}function xn(n){return h(function(t,e){t.apply(null,e.concat([h(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&W(e,function(t){console[n](t)}))})]))})}function En(n,t,e){function r(t,r){return t?e(t):r?void n(u):e(null)}e=M(e||m);var u=h(function(n,u){return n?e(n):(u.push(r),void t.apply(this,u))});r(null,!0)}function Ln(n,t,e){e=M(e||m);var r=h(function(u,o){return u?e(u):t.apply(this,o)?n(r):void e.apply(null,[null].concat(o))});n(r)}function An(n,t,e){Ln(n,function(){return!t.apply(this,arguments)},e)}function _n(n,t,e){function r(t){return t?e(t):void n(u)}function u(n,u){return n?e(n):u?void t(r):e(null)}e=M(e||m),n(u)}function Tn(n){return function(t,e,r){return n(t,r)}}function Fn(n,t,e){Ve(n,Tn(t),e)}function In(n,t,e,r){P(t)(n,Tn(e),r)}function Bn(n){return Ft(function(t,e){var r=!0;t.push(function(){var n=arguments;r?Br(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function $n(n){return!n}function Mn(n){return function(t){return null==t?void 0:t[n]}}function Pn(n,t,e,r){r=g(r||m);var u=[];n(t,function(n,t,r){e(n,function(e,o){e?r(e):(o&&u.push({index:t,value:n}),r())})},function(n){n?r(n):r(null,X(u.sort(function(n,t){return n.index-t.index}),Mn("value")))})}function zn(n,t){function e(n){return n?r(n):void u(e)}var r=M(t||m),u=Bn(n);e()}function Rn(n,t,e,r){r=g(r||m);var u={};z(n,t,function(n,t,r){e(n,t,function(n,e){return n?r(n):(u[t]=e,void r())})},function(n){r(n,u)})}function Un(n,t){return t in n}function Vn(n,e){var r=Object.create(null),u=Object.create(null);e=e||t;var o=Ft(function(t,o){var i=e.apply(null,t);Un(r,i)?Br(function(){o.apply(null,r[i])}):Un(u,i)?u[i].push(o):(u[i]=[o],n.apply(null,t.concat([h(function(n){r[i]=n;var t=u[i];delete u[i];for(var e=0,o=t.length;e<o;e++)t[e].apply(null,n)})])))});return o.memo=r,o.unmemoized=n,o}function Dn(n,t,e){e=e||m;var r=d(t)?[]:{};n(t,function(n,t,e){n(h(function(n,u){u.length<=1&&(u=u[0]),r[t]=u,e(n)}))},function(n){e(n,r)})}function qn(n,t){Dn(Ve,n,t)}function Cn(n,t,e){Dn(P(t),n,e)}function Wn(n,t){if(t=g(t||m),!qt(n))return t(new TypeError("First argument to race must be an array of functions"));if(!n.length)return t();for(var e=0,r=n.length;e<r;e++)n[e](t)}function Qn(n,t,e,r){var u=uu.call(n).reverse();jn(u,t,e,r)}function Gn(n){return Ft(function(t,e){return t.push(h(function(n,t){if(n)e(null,{error:n});else{var r=null;1===t.length?r=t[0]:t.length>1&&(r=t),e(null,{value:r})}})),n.apply(this,t)})}function Nn(n,t,e,r){Pn(n,t,function(n,t){e(n,function(n,e){n?t(n):t(null,!e)})},r)}function Hn(n){var t;return qt(n)?t=X(n,Gn):(t={},G(n,function(n,e){t[e]=Gn.call(this,n)})),t}function Jn(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||i,n.intervalFunc="function"==typeof t.interval?t.interval:u(+t.interval||c),n.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||i}}function o(){t(function(n){n&&a++<f.times&&("function"!=typeof f.errorFilter||f.errorFilter(n))?setTimeout(o,f.intervalFunc(a)):e.apply(null,arguments)})}var i=5,c=0,f={times:i,intervalFunc:u(c)};if(arguments.length<3&&"function"==typeof n?(e=t||m,t=n):(r(f,n),e=e||m),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var a=1;o()}function Kn(n,t){Dn(Mr,n,t)}function Xn(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return e<r?-1:e>r?1:0}De(n,function(n,e){t(n,function(t,r){return t?e(t):void e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,X(t.sort(r),Mn("value")))})}function Yn(n,t,e){function r(){c||(o.apply(null,arguments),clearTimeout(i))}function u(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),c=!0,o(r)}var o,i,c=!1;return Ft(function(e,c){o=c,i=setTimeout(u,t),n.apply(null,e.concat(r))})}function Zn(n,t,e,r){for(var u=-1,o=hu(pu((t-n)/(e||1)),0),i=Array(o);o--;)i[r?o:++u]=n,n+=e;return i}function nt(n,t,e,r){Ce(Zn(0,n,1),t,e,r)}function tt(n,t,e,r){3===arguments.length&&(r=e,e=t,t=qt(n)?[]:{}),r=g(r||m),Ve(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})}function et(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function rt(n,t,e){if(e=M(e||m),!n())return e(null);var r=h(function(u,o){return u?e(u):n()?t(r):void e.apply(null,[null].concat(o))});t(r)}function ut(n,t,e){rt(function(){return!n.apply(this,arguments)},t,e)}var ot=Math.max,it="[object Function]",ct="[object GeneratorFunction]",ft="[object Proxy]",at=Object.prototype,lt=at.toString,st="object"==typeof global&&global&&global.Object===Object&&global,pt="object"==typeof self&&self&&self.Object===Object&&self,ht=st||pt||Function("return this")(),yt=ht["__core-js_shared__"],vt=function(){var n=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),dt=Function.prototype,mt=dt.toString,gt=/[\\^$.*+?()[\]{}|]/g,bt=/^\[object .+?Constructor\]$/,jt=Function.prototype,St=Object.prototype,kt=jt.toString,Ot=St.hasOwnProperty,wt=RegExp("^"+kt.call(Ot).replace(gt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xt=function(){try{var n=s(Object,"defineProperty");return n({},"",{}),n}catch(n){}}(),Et=xt?function(n,t){return xt(n,"toString",{configurable:!0,enumerable:!1,value:u(t),writable:!0})}:t,Lt=500,At=16,_t=Date.now,Tt=p(Et),Ft=function(n){return h(function(t){var e=t.pop();n.call(this,t,e)})},It=9007199254740991,Bt="function"==typeof Symbol&&Symbol.iterator,$t=function(n){return Bt&&n[Bt]&&n[Bt]()},Mt="[object Arguments]",Pt=Object.prototype,zt=Pt.toString,Rt=Object.prototype,Ut=Rt.hasOwnProperty,Vt=Rt.propertyIsEnumerable,Dt=S(function(){return arguments}())?S:function(n){return j(n)&&Ut.call(n,"callee")&&!Vt.call(n,"callee")},qt=Array.isArray,Ct="object"==typeof n&&n&&!n.nodeType&&n,Wt=Ct&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=Wt&&Wt.exports===Ct,Gt=Qt?ht.Buffer:void 0,Nt=Gt?Gt.isBuffer:void 0,Ht=Nt||k,Jt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/,Xt="[object Arguments]",Yt="[object Array]",Zt="[object Boolean]",ne="[object Date]",te="[object Error]",ee="[object Function]",re="[object Map]",ue="[object Number]",oe="[object Object]",ie="[object RegExp]",ce="[object Set]",fe="[object String]",ae="[object WeakMap]",le="[object ArrayBuffer]",se="[object DataView]",pe="[object Float32Array]",he="[object Float64Array]",ye="[object Int8Array]",ve="[object Int16Array]",de="[object Int32Array]",me="[object Uint8Array]",ge="[object Uint8ClampedArray]",be="[object Uint16Array]",je="[object Uint32Array]",Se={};Se[pe]=Se[he]=Se[ye]=Se[ve]=Se[de]=Se[me]=Se[ge]=Se[be]=Se[je]=!0,Se[Xt]=Se[Yt]=Se[le]=Se[Zt]=Se[se]=Se[ne]=Se[te]=Se[ee]=Se[re]=Se[ue]=Se[oe]=Se[ie]=Se[ce]=Se[fe]=Se[ae]=!1;var ke,Oe=Object.prototype,we=Oe.toString,xe="object"==typeof n&&n&&!n.nodeType&&n,Ee=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Le=Ee&&Ee.exports===xe,Ae=Le&&st.process,_e=function(){try{return Ae&&Ae.binding("util")}catch(n){}}(),Te=_e&&_e.isTypedArray,Fe=Te?x(Te):w,Ie=Object.prototype,Be=Ie.hasOwnProperty,$e=Object.prototype,Me=A(Object.keys,Object),Pe=Object.prototype,ze=Pe.hasOwnProperty,Re={},Ue=R(z,1/0),Ve=function(n,t,e){var r=d(n)?U:Ue;r(n,t,e)},De=V(D),qe=y(De),Ce=q(D),We=R(Ce,1),Qe=y(We),Ge=h(function(n,t){return h(function(e){return n.apply(null,t.concat(e))})}),Ne=Q(),He=function(n,t,e){function r(n,t){b.push(function(){c(n,t)})}function u(){if(0===b.length&&0===y)return e(null,p);for(;b.length&&y<t;){var n=b.shift();n()}}function o(n,t){var e=d[n];e||(e=d[n]=[]),e.push(t)}function i(n){var t=d[n]||[];W(t,function(n){n()}),u()}function c(n,t){if(!v){var r=M(h(function(t,r){if(y--,r.length<=1&&(r=r[0]),t){var u={};G(p,function(n,t){u[t]=n}),u[n]=r,v=!0,d=[],e(t,u)}else p[n]=r,i(n)}));y++;var u=t[t.length-1];t.length>1?u(p,r):u(r)}}function f(){for(var n,t=0;j.length;)n=j.pop(),t++,W(a(n),function(n){0===--S[n]&&j.push(n)});if(t!==s)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function a(t){var e=[];return G(n,function(n,r){qt(n)&&K(n,t,0)>=0&&e.push(r)}),e}"function"==typeof t&&(e=t,t=null),e=g(e||m);var l=T(n),s=l.length;if(!s)return e(null);t||(t=s);var p={},y=0,v=!1,d={},b=[],j=[],S={};G(n,function(t,e){if(!qt(t))return r(e,[t]),void j.push(e);var u=t.slice(0,t.length-1),i=u.length;return 0===i?(r(e,t),void j.push(e)):(S[e]=i,void W(u,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency in "+u.join(", "));o(c,function(){i--,0===i&&r(e,t)})}))}),f(),u()},Je=ht.Symbol,Ke="[object Symbol]",Xe=Object.prototype,Ye=Xe.toString,Ze=1/0,nr=Je?Je.prototype:void 0,tr=nr?nr.toString:void 0,er="\\ud800-\\udfff",rr="\\u0300-\\u036f\\ufe20-\\ufe23",ur="\\u20d0-\\u20f0",or="\\ufe0e\\ufe0f",ir="\\u200d",cr=RegExp("["+ir+er+rr+ur+or+"]"),fr="\\ud800-\\udfff",ar="\\u0300-\\u036f\\ufe20-\\ufe23",lr="\\u20d0-\\u20f0",sr="\\ufe0e\\ufe0f",pr="["+fr+"]",hr="["+ar+lr+"]",yr="\\ud83c[\\udffb-\\udfff]",vr="(?:"+hr+"|"+yr+")",dr="[^"+fr+"]",mr="(?:\\ud83c[\\udde6-\\uddff]){2}",gr="[\\ud800-\\udbff][\\udc00-\\udfff]",br="\\u200d",jr=vr+"?",Sr="["+sr+"]?",kr="(?:"+br+"(?:"+[dr,mr,gr].join("|")+")"+Sr+jr+")*",Or=Sr+jr+kr,wr="(?:"+[dr+hr+"?",hr,mr,gr,pr].join("|")+")",xr=RegExp(yr+"(?="+yr+")|"+wr+Or,"g"),Er=/^\s+|\s+$/g,Lr=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Ar=/,/,_r=/(=.+)?(\s*)$/,Tr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,Fr="function"==typeof setImmediate&&setImmediate,Ir="object"==typeof process&&"function"==typeof process.nextTick;ke=Fr?setImmediate:Ir?process.nextTick:yn;var Br=vn(ke);dn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},dn.prototype.empty=dn,dn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},dn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},dn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):mn(this,n)},dn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):mn(this,n)},dn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},dn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var $r,Mr=R(z,1),Pr=h(function(n){return h(function(t){var e=this,r=t[t.length-1];"function"==typeof r?t.pop():r=m,jn(n,t,function(n,t,r){t.apply(e,n.concat([h(function(n,t){r(n,t)})]))},function(n,t){r.apply(e,[n].concat(t))})})}),zr=h(function(n){return Pr.apply(null,n.reverse())}),Rr=V(Sn),Ur=kn(Sn),Vr=h(function(n){var t=[null].concat(n);return Ft(function(n,e){return e.apply(this,t)})}),Dr=On(Ve,t,wn),qr=On(z,t,wn),Cr=On(Mr,t,wn),Wr=xn("dir"),Qr=R(In,1),Gr=On(Ve,$n,$n),Nr=On(z,$n,$n),Hr=R(Nr,1),Jr=V(Pn),Kr=q(Pn),Xr=R(Kr,1),Yr=xn("log"),Zr=R(Rn,1/0),nu=R(Rn,1);$r=Ir?process.nextTick:Fr?setImmediate:yn;var tu=vn($r),eu=function(n,t){return gn(function(t,e){n(t[0],e)},t,1)},ru=function(n,t){var e=eu(n,t);return e.push=function(n,t,r){if(null==r&&(r=m),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,qt(n)||(n=[n]),0===n.length)return Br(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;for(var o=0,i=n.length;o<i;o++){var c={data:n[o],priority:t,callback:r};u?e._tasks.insertBefore(u,c):e._tasks.push(c)}Br(e.process)},delete e.unshift,e},uu=Array.prototype.slice,ou=V(Nn),iu=q(Nn),cu=R(iu,1),fu=function(n,t){return t||(t=n,n=null),Ft(function(e,r){function u(n){t.apply(null,e.concat([n]))}n?Jn(n,u,r):Jn(u,r)})},au=On(Ve,Boolean,t),lu=On(z,Boolean,t),su=R(lu,1),pu=Math.ceil,hu=Math.max,yu=R(nt,1/0),vu=R(nt,1),du=function(n,t){function e(u){if(r===n.length)return t.apply(null,[null].concat(u));var o=M(h(function(n,r){return n?t.apply(null,[n].concat(r)):void e(r)}));u.push(o);var i=n[r++];i.apply(null,u)}if(t=g(t||m),!qt(n))return t(new Error("First argument to waterfall must be an array of functions"));if(!n.length)return t();var r=0;e([])},mu={applyEach:qe,applyEachSeries:Qe,apply:Ge,asyncify:C,auto:He,autoInject:hn,cargo:bn,compose:zr,concat:Rr,concatSeries:Ur,constant:Vr,detect:Dr,detectLimit:qr,detectSeries:Cr,dir:Wr,doDuring:En,doUntil:An,doWhilst:Ln,during:_n,each:Fn,eachLimit:In,eachOf:Ve,eachOfLimit:z,eachOfSeries:Mr,eachSeries:Qr,ensureAsync:Bn,every:Gr,everyLimit:Nr,everySeries:Hr,filter:Jr,filterLimit:Kr,filterSeries:Xr,forever:zn,log:Yr,map:De,mapLimit:Ce,mapSeries:We,mapValues:Zr,mapValuesLimit:Rn,mapValuesSeries:nu,memoize:Vn,nextTick:tu,parallel:qn,parallelLimit:Cn,priorityQueue:ru,queue:eu,race:Wn,reduce:jn,reduceRight:Qn,reflect:Gn,reflectAll:Hn,reject:ou,rejectLimit:iu,rejectSeries:cu,retry:Jn,retryable:fu,seq:Pr,series:Kn,setImmediate:Br,some:au,someLimit:lu,someSeries:su,sortBy:Xn,timeout:Yn,times:yu,timesLimit:nt,timesSeries:vu,transform:tt,unmemoize:et,until:ut,waterfall:du,whilst:rt,all:Gr,any:au,forEach:Fn,forEachSeries:Qr,forEachLimit:In,forEachOf:Ve,forEachOfSeries:Mr,forEachOfLimit:z,inject:jn,foldl:jn,foldr:Qn,select:Jr,selectLimit:Kr,selectSeries:Xr,wrapSync:C};n.default=mu,n.applyEach=qe,n.applyEachSeries=Qe,n.apply=Ge,n.asyncify=C,n.auto=He,n.autoInject=hn,n.cargo=bn,n.compose=zr,n.concat=Rr,n.concatSeries=Ur,n.constant=Vr,n.detect=Dr,n.detectLimit=qr,n.detectSeries=Cr,n.dir=Wr,n.doDuring=En,n.doUntil=An,n.doWhilst=Ln,n.during=_n,n.each=Fn,n.eachLimit=In,n.eachOf=Ve,n.eachOfLimit=z,n.eachOfSeries=Mr,n.eachSeries=Qr,n.ensureAsync=Bn,n.every=Gr,n.everyLimit=Nr,n.everySeries=Hr,n.filter=Jr,n.filterLimit=Kr,n.filterSeries=Xr,n.forever=zn,n.log=Yr,n.map=De,n.mapLimit=Ce,n.mapSeries=We,n.mapValues=Zr,n.mapValuesLimit=Rn,n.mapValuesSeries=nu,n.memoize=Vn,n.nextTick=tu,n.parallel=qn,n.parallelLimit=Cn,n.priorityQueue=ru,n.queue=eu,n.race=Wn,n.reduce=jn,n.reduceRight=Qn,n.reflect=Gn,n.reflectAll=Hn,n.reject=ou,n.rejectLimit=iu,n.rejectSeries=cu,n.retry=Jn,n.retryable=fu,n.seq=Pr,n.series=Kn,n.setImmediate=Br,n.some=au,n.someLimit=lu,n.someSeries=su,n.sortBy=Xn,n.timeout=Yn,n.times=yu,n.timesLimit=nt,n.timesSeries=vu,n.transform=tt,n.unmemoize=et,n.until=ut,n.waterfall=du,n.whilst=rt,n.all=Gr,n.allLimit=Nr,n.allSeries=Hr,n.any=au,n.anyLimit=lu,n.anySeries=su,n.find=Dr,n.findLimit=qr,n.findSeries=Cr,n.forEach=Fn,n.forEachSeries=Qr,n.forEachLimit=In,n.forEachOf=Ve,n.forEachOfSeries=Mr,n.forEachOfLimit=z,n.inject=jn,n.foldl=jn,n.foldr=Qn,n.select=Jr,n.selectLimit=Kr,n.selectSeries=Xr,n.wrapSync=C,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=async.min.map \ No newline at end of file
diff --git a/dist/async.min.map b/dist/async.min.map
index 121df18..6b215fc 100644
--- a/dist/async.min.map
+++ b/dist/async.min.map
@@ -1 +1 @@
-{"version":3,"file":"build/dist/async.min.js","sources":["build/dist/async.js"],"names":["global","factory","exports","module","define","amd","async","this","apply","func","thisArg","args","length","call","baseRest","start","nativeMax","undefined","arguments","index","array","Array","otherArgs","initialParams","fn","callback","pop","applyEach$1","eachfn","fns","go","that","cb","concat","baseProperty","key","object","isObject","value","type","isFunction","tag","objectToString","funcTag","genTag","isLength","MAX_SAFE_INTEGER","isArrayLike","getLength","noop","once","callFn","getIterator","coll","iteratorSymbol","overArg","transform","arg","baseHas","hasOwnProperty","getPrototype","baseTimes","n","iteratee","result","isObjectLike","isArrayLikeObject","isArguments","hasOwnProperty$1","propertyIsEnumerable","objectToString$1","argsTag","isString","isArray","objectToString$2","stringTag","indexKeys","String","isIndex","MAX_SAFE_INTEGER$1","reIsUint","test","isPrototype","Ctor","constructor","proto","prototype","objectProto$4","keys","isProto","baseKeys","indexes","skipIndexes","push","createArrayIterator","i","len","createES2015Iterator","iterator","item","next","done","createObjectIterator","obj","okeys","onlyOnce","Error","_eachOfLimit","limit","iterateeCallback","err","running","replenish","elem","nextElem","eachOfLimit","doLimit","iterable","eachOfArrayLike","iteratorCallback","completed","eachOf","eachOfImplementation","eachOfGeneric","doParallel","_asyncMap","arr","results","counter","_","v","doParallelLimit","asyncify","e","then","message","arrayEach","createBaseFor","fromRight","keysFunc","Object","props","baseForOwn","baseFor","baseFindIndex","predicate","fromIndex","baseIsNaN","baseIndexOf","auto","tasks","concurrency","enqueueTask","task","readyTasks","runTask","processQueue","runningTasks","run","shift","addListener","taskName","taskListeners","listeners","taskComplete","hasError","taskCallback","safeResults","val","rkey","taskFn","checkForDeadlocks","currentTask","readyToCheck","getDependents","dependent","uncheckedDependencies","numTasks","keys$$","dependencies","slice","remainingDependencies","dependencyName","join","arrayMap","copyArray","source","isSymbol","objectToString$3","symbolTag","baseToString","symbolToString","INFINITY","baseSlice","end","castSlice","charsEndIndex","strSymbols","chrSymbols","charsStartIndex","stringToArray","string","match","reComplexSymbol","toString","trim","chars","guard","replace","reTrim","parseParams","STRIP_COMMENTS","FN_ARGS","split","FN_ARG_SPLIT","map","FN_ARG","autoInject","newTasks","newTask","taskCb","newArgs","params","name","fallback","setTimeout","wrap","defer","DLL","head","tail","setInitial","dll","node","queue","worker","payload","_insert","data","insertAtFront","q","started","idle","setImmediate$1","drain","_tasks","unshift","process","_next","workers","workersList","splice","error","buffer","unsaturated","saturated","empty","paused","kill","l","Math","min","pause","resume","resumeCount","w","cargo","reduce","memo","eachOfSeries","x","concat$1","y","doSeries","identity","_createTester","check","getResult","wrappedIteratee","_findGetResult","consoleFunc","console","doDuring","truth","doWhilst","doUntil","during","_withoutIndex","eachLimit","eachLimit$1","ensureAsync","sync","innerArgs","notId","_filter","sort","a","b","forever","errback","mapValuesLimit","newObj","has","memoize","hasher","create","queues","memoized","unmemoized","_parallel","parallelLimit","parallelLimit$1","queue$1","items","priorityQueue","priority","nextNode","insertBefore","race","TypeError","reduceRight","reversed","reverse","reflect","reflectCallback","cbArgs","reject$1","reflectAll","constant$1","retry","opts","parseTimes","acc","t","times","DEFAULT_TIMES","intervalFunc","interval","DEFAULT_INTERVAL","retryAttempt","attempt","options","retryable","series","sortBy","comparator","left","right","criteria","timeout","asyncFn","milliseconds","info","injectedCallback","timedOut","originalCallback","clearTimeout","timer","timeoutCallback","code","origCallback","baseRange","step","nativeMax$1","nativeCeil","timeLimit","count","mapLimit","accumulator","k","unmemoize","whilst","until","waterfall","nextTask","taskIndex","_defer","max","objectProto","Symbol","nativeGetPrototype","getPrototypeOf","objectProto$1","nativeKeys","objectProto$2","objectProto$3","Infinity","applyEach","mapSeries","applyEachSeries","apply$1","callArgs","freeGlobal","freeSelf","self","root","Function","Symbol$1","objectProto$5","symbolProto","rsAstralRange","rsComboMarksRange","rsComboSymbolsRange","rsVarRange","rsAstral","rsCombo","rsFitz","rsModifier","rsNonAstral","rsRegional","rsSurrPair","rsZWJ","reOptMod","rsOptVar","rsOptJoin","rsSeq","rsSymbol","RegExp","hasSetImmediate","setImmediate","hasNextTick","nextTick","removeLink","prev","insertAfter","newNode","_defer$1","seq","functions","newargs","nextargs","compose","concatSeries","constant","values","ignoredArgs","detect","detectLimit","detectSeries","dir","eachSeries","every","everyLimit","everySeries","filter","filterLimit","filterSeries","log","mapValues","mapValuesSeries","reject","rejectLimit","rejectSeries","some","Boolean","someLimit","someSeries","ceil","timesSeries","each","parallel","timesLimit","all","any","forEach","forEachSeries","forEachLimit","forEachOf","forEachOfSeries","forEachOfLimit","inject","foldl","foldr","select","selectLimit","selectSeries","wrapSync","allLimit","allSeries","anyLimit","anySeries","find","findLimit","findSeries"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,SACrD,kBAAXE,SAAyBA,OAAOC,IAAMD,QAAQ,WAAYH,GAChEA,EAASD,EAAOM,MAAQN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AQsc,WAAaA,GACrBtc,EAAQsV,OAASA,GACjBtV,EAAQ2V,QAAUA,GAClB3V,EAAQ4U,MAAQA,GAChB5U,EAAQ2c,WAAahG,GACrB3W,EAAQwc,YAAcA,GACtBxc,EAAQsD,UAAYA,GACpBtD,EAAQgX,UAAYA,GACpBhX,EAAQkX,MAAQA,GAChBlX,EAAQmX,UAAYA,GACpBnX,EAAQiX,OAASA,GACjBjX,EAAQ4c,IAAMrB,GACdvb,EAAQ2d,SAAWnC,GACnBxb,EAAQ4d,UAAYnC,GACpBzb,EAAQ6c,IAAMV,GACdnc,EAAQ6d,SAAWxB,GACnBrc,EAAQ8d,UAAYxB,GACpBtc,EAAQ+d,KAAO7C,GACflb,EAAQge,UAAY7C,GACpBnb,EAAQie,WAAa7C,GACrBpb,EAAQ8c,QAAUhL,GAClB9R,EAAQ+c,cAAgBzB,GACxBtb,EAAQgd,aAAejL,GACvB/R,EAAQid,UAAY1V,EACpBvH,EAAQkd,gBAAkBvM,GAC1B3Q,EAAQmd,eAAiBlW,EACzBjH,EAAQod,OAAS3M,GACjBzQ,EAAQqd,MAAQ5M,GAChBzQ,EAAQsd,MAAQxJ,GAChB9T,EAAQud,OAAS7B,GACjB1b,EAAQwd,YAAc7B,GACtB3b,EAAQyd,aAAe7B,GACvB5b,EAAQ0d,SAAWxV"} \ No newline at end of file
+{"version":3,"sources":["build/dist/async.js"],"names":["global","factory","exports","module","define","amd","async","this","identity","value","apply","func","thisArg","args","length","call","overRest","start","transform","nativeMax","undefined","arguments","index","array","Array","otherArgs","constant","isObject","type","isFunction","tag","objectToString","funcTag","genTag","proxyTag","isMasked","maskSrcKey","toSource","funcToString$1","e","baseIsNative","pattern","reIsNative","reIsHostCtor","test","getValue","object","key","getNative","shortOut","count","lastCalled","stamp","nativeNow","remaining","HOT_SPAN","HOT_COUNT","baseRest$1","setToString","applyEach$1","eachfn","fns","go","initialParams","callback","that","fn","cb","concat","isLength","MAX_SAFE_INTEGER","isArrayLike","noop","once","callFn","baseTimes","n","iteratee","result","isObjectLike","baseIsArguments","objectToString$1","argsTag","stubFalse","isIndex","MAX_SAFE_INTEGER$1","reIsUint","baseIsTypedArray","typedArrayTags","objectToString$2","baseUnary","arrayLikeKeys","inherited","isArr","isArray","isArg","isArguments","isBuff","isBuffer","isType","isTypedArray","skipIndexes","String","hasOwnProperty$1","push","isPrototype","Ctor","constructor","proto","prototype","objectProto$7","overArg","arg","baseKeys","nativeKeys","Object","hasOwnProperty$3","keys","createArrayIterator","coll","i","len","createES2015Iterator","iterator","item","next","done","createObjectIterator","obj","okeys","getIterator","onlyOnce","Error","_eachOfLimit","limit","iterateeCallback","err","running","breakLoop","replenish","elem","nextElem","eachOfLimit","doLimit","iterable","eachOfArrayLike","iteratorCallback","completed","doParallel","eachOf","_asyncMap","arr","results","counter","_","v","doParallelLimit","asyncify","then","message","arrayEach","createBaseFor","fromRight","keysFunc","props","baseForOwn","baseFor","baseFindIndex","predicate","fromIndex","baseIsNaN","strictIndexOf","baseIndexOf","arrayMap","copyArray","source","isSymbol","objectToString$3","symbolTag","baseToString","symbolToString","INFINITY","baseSlice","end","castSlice","charsEndIndex","strSymbols","chrSymbols","charsStartIndex","asciiToArray","string","split","hasUnicode","reHasUnicode","unicodeToArray","match","reUnicode","stringToArray","toString","trim","chars","guard","replace","reTrim","join","parseParams","STRIP_COMMENTS","FN_ARGS","FN_ARG_SPLIT","map","FN_ARG","autoInject","tasks","newTasks","taskFn","newTask","taskCb","newArgs","params","name","pop","auto","fallback","setTimeout","wrap","defer","DLL","head","tail","setInitial","dll","node","queue","worker","concurrency","payload","_insert","data","insertAtFront","q","started","idle","setImmediate$1","drain","l","_tasks","unshift","process","_next","workers","task","workersList","splice","error","buffer","unsaturated","saturated","empty","paused","kill","Math","min","shift","pause","resume","resumeCount","w","cargo","reduce","memo","eachOfSeries","x","concat$1","y","doSeries","_createTester","check","getResult","wrappedIteratee","_findGetResult","consoleFunc","console","doDuring","truth","doWhilst","doUntil","during","_withoutIndex","eachLimit","eachLimit$1","ensureAsync","sync","innerArgs","notId","baseProperty","_filter","sort","a","b","forever","errback","mapValuesLimit","newObj","val","has","memoize","hasher","create","queues","memoized","unmemoized","_parallel","parallelLimit","parallelLimit$1","race","TypeError","reduceRight","reversed","slice","reverse","reflect","reflectCallback","cbArgs","reject$1","reflectAll","retry","opts","parseTimes","acc","t","times","DEFAULT_TIMES","intervalFunc","interval","DEFAULT_INTERVAL","errorFilter","retryAttempt","attempt","options","series","sortBy","comparator","left","right","criteria","timeout","asyncFn","milliseconds","info","injectedCallback","timedOut","originalCallback","clearTimeout","timer","timeoutCallback","code","origCallback","baseRange","step","nativeMax$1","nativeCeil","timeLimit","mapLimit","accumulator","k","unmemoize","whilst","until","max","objectProto$1","freeGlobal","freeSelf","self","root","Function","coreJsData","uid","exec","IE_PROTO","funcProto$1","reRegExpChar","funcProto","objectProto","funcToString","hasOwnProperty","RegExp","defineProperty","baseSetToString","configurable","enumerable","writable","Date","now","iteratorSymbol","Symbol","objectProto$4","objectProto$3","hasOwnProperty$2","propertyIsEnumerable","freeExports","nodeType","freeModule","moduleExports","Buffer","nativeIsBuffer","argsTag$1","arrayTag","boolTag","dateTag","errorTag","funcTag$1","mapTag","numberTag","objectTag","regexpTag","setTag","stringTag","weakMapTag","arrayBufferTag","dataViewTag","float32Tag","float64Tag","int8Tag","int16Tag","int32Tag","uint8Tag","uint8ClampedTag","uint16Tag","uint32Tag","_defer","objectProto$5","freeExports$1","freeModule$1","moduleExports$1","freeProcess","nodeUtil","binding","nodeIsTypedArray","objectProto$2","objectProto$6","eachOfGeneric","Infinity","eachOfImplementation","applyEach","mapSeries","applyEachSeries","apply$2","callArgs","enqueueTask","readyTasks","runTask","processQueue","runningTasks","run","addListener","taskName","taskListeners","listeners","taskComplete","hasError","taskCallback","safeResults","rkey","checkForDeadlocks","currentTask","readyToCheck","getDependents","dependent","uncheckedDependencies","numTasks","keys$$1","dependencies","remainingDependencies","dependencyName","Symbol$1","objectProto$8","symbolProto","rsAstralRange","rsComboMarksRange","rsComboSymbolsRange","rsVarRange","rsZWJ","rsAstralRange$1","rsComboMarksRange$1","rsComboSymbolsRange$1","rsVarRange$1","rsAstral","rsCombo","rsFitz","rsModifier","rsNonAstral","rsRegional","rsSurrPair","rsZWJ$1","reOptMod","rsOptVar","rsOptJoin","rsSeq","rsSymbol","hasSetImmediate","setImmediate","hasNextTick","nextTick","removeLink","prev","insertAfter","newNode","insertBefore","_defer$1","seq$1","functions","newargs","nextargs","compose","concatSeries","constant$2","values","ignoredArgs","detect","detectLimit","detectSeries","dir","eachSeries","every","everyLimit","everySeries","filter","filterLimit","filterSeries","log","mapValues","mapValuesSeries","queue$1","items","priorityQueue","priority","nextNode","reject","rejectLimit","rejectSeries","retryable","some","Boolean","someLimit","someSeries","ceil","timesSeries","waterfall","nextTask","taskIndex","each","parallel","seq","timesLimit","all","any","forEach","forEachSeries","forEachLimit","forEachOf","forEachOfSeries","forEachOfLimit","inject","foldl","foldr","select","selectLimit","selectSeries","wrapSync","allLimit","allSeries","anyLimit","anySeries","find","findLimit","findSeries"],"mappings":"CAAC,SAAUA,EAAQC,GACI,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,SACrD,kBAAXE,SAAyBA,OAAOC,IAAMD,QAAQ,WAAYH,GAChEA,EAASD,EAAOM,MAAQN,EAAOM,YAClCC,KAAM,SAAWL,GAAW,YAkB9B,SAASM,GAASC,GAChB,MAAOA,GAaT,QAASC,GAAMC,EAAMC,EAASC,GAC5B,OAAQA,EAAKC,QACX,IAAK,GAAG,MAAOH,GAAKI,KAAKH,EACzB,KAAK,GAAG,MAAOD,GAAKI,KAAKH,EAASC,EAAK,GACvC,KAAK,GAAG,MAAOF,GAAKI,KAAKH,EAASC,EAAK,GAAIA,EAAK,GAChD,KAAK,GAAG,MAAOF,GAAKI,KAAKH,EAASC,EAAK,GAAIA,EAAK,GAAIA,EAAK,IAE3D,MAAOF,GAAKD,MAAME,EAASC,GAe7B,QAASG,GAASL,EAA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,EAAQkf,aAAelQ,GACvBhP,EAAQ2hB,KAAOA,GACf3hB,EAAQ6hB,UAAYA,GACpB7hB,EAAQ8hB,WAAaA,GACrB9hB,EAAQkV,OAASA,GACjBlV,EAAQuV,QAAUA,GAClBvV,EAAQwU,MAAQA,GAChBxU,EAAQuiB,WAAahM,GACrBvW,EAAQgiB,YAAcA,GACtBhiB,EAAQgB,UAAYA,GACpBhB,EAAQ2W,UAAYA,GACpB3W,EAAQ6W,MAAQA,GAChB7W,EAAQiiB,UAAYA,GACpBjiB,EAAQ4W,OAASA,GACjB5W,EAAQwiB,IAAM/B,GACdzgB,EAAQujB,SAAW7C,GACnB1gB,EAAQwjB,UAAY7C,GACpB3gB,EAAQyiB,IAAMd,GACd3hB,EAAQyjB,SAAW5B,GACnB7hB,EAAQ0jB,UAAY5B,GACpB9hB,EAAQ2jB,KAAOvD,GACfpgB,EAAQ4jB,UAAYvD,GACpBrgB,EAAQ6jB,WAAavD,GACrBtgB,EAAQ0iB,QAAU5Q,GAClB9R,EAAQ2iB,cAAgBnC,GACxBxgB,EAAQ4iB,aAAe7Q,GACvB/R,EAAQ6iB,UAAY1Z,GACpBnJ,EAAQ8iB,gBAAkBlS,GAC1B5Q,EAAQ+iB,eAAiBna,EACzB5I,EAAQgjB,OAAStS,GACjB1Q,EAAQijB,MAAQvS,GAChB1Q,EAAQkjB,MAAQxP,GAChB1T,EAAQmjB,OAASvC,GACjB5gB,EAAQojB,YAAcvC,GACtB7gB,EAAQqjB,aAAevC,GACvB9gB,EAAQsjB,SAAW3Z,EAEnB1C,OAAO+Q,eAAehY,EAAS,cAAgBO,OAAO","file":"build/dist/async.min.js"} \ No newline at end of file
diff --git a/lib/internal/breakLoop.js b/lib/internal/breakLoop.js
new file mode 100644
index 0000000..6bb216e
--- /dev/null
+++ b/lib/internal/breakLoop.js
@@ -0,0 +1,3 @@
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+export default {}; \ No newline at end of file
diff --git a/lib/internal/createTester.js b/lib/internal/createTester.js
index ac38bf7..b37d0f1 100644
--- a/lib/internal/createTester.js
+++ b/lib/internal/createTester.js
@@ -1,30 +1,27 @@
'use strict';
import noop from 'lodash/noop';
+import breakLoop from './breakLoop';
export default function _createTester(eachfn, check, getResult) {
return function(arr, limit, iteratee, cb) {
- function done(err) {
+ function done() {
if (cb) {
- if (err) {
- cb(err);
- } else {
- cb(null, getResult(false));
- }
+ cb(null, getResult(false));
}
}
function wrappedIteratee(x, _, callback) {
if (!cb) return callback();
iteratee(x, function (err, v) {
- if (cb) {
- if (err) {
- cb(err);
- cb = iteratee = false;
- } else if (check(v)) {
- cb(null, getResult(true, x));
- cb = iteratee = false;
- }
+ // Check cb as another iteratee may have resolved with a
+ // value or error since we started this iteratee
+ if (cb && (err || check(v))) {
+ if (err) cb(err);
+ else cb(err, getResult(true, x));
+ cb = iteratee = false;
+ callback(err, breakLoop);
+ } else {
+ callback();
}
- callback();
});
}
if (arguments.length > 3) {
diff --git a/lib/internal/eachOfLimit.js b/lib/internal/eachOfLimit.js
index 61fd6a4..da46fa4 100644
--- a/lib/internal/eachOfLimit.js
+++ b/lib/internal/eachOfLimit.js
@@ -4,6 +4,8 @@ import once from './once';
import iterator from './iterator';
import onlyOnce from './onlyOnce';
+import breakLoop from './breakLoop';
+
export default function _eachOfLimit(limit) {
return function (obj, iteratee, callback) {
callback = once(callback || noop);
@@ -14,13 +16,14 @@ export default function _eachOfLimit(limit) {
var done = false;
var running = 0;
- function iterateeCallback(err) {
+ function iterateeCallback(err, value) {
running -= 1;
if (err) {
done = true;
callback(err);
}
- else if (done && running <= 0) {
+ else if (value === breakLoop || (done && running <= 0)) {
+ done = true;
return callback(null);
}
else {
diff --git a/lib/mapValues.js b/lib/mapValues.js
index a0a9470..afc43f4 100644
--- a/lib/mapValues.js
+++ b/lib/mapValues.js
@@ -26,8 +26,9 @@ import doLimit from './internal/doLimit';
* called once it has completed with an error (which can be `null`) and a
* transformed value. Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `obj`. Invoked with (err, result).
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
* @example
*
* async.mapValues({
@@ -37,7 +38,7 @@ import doLimit from './internal/doLimit';
* }, function (file, key, callback) {
* fs.stat(file, callback);
* }, function(err, result) {
- * // results is now a map of stats for each file, e.g.
+ * // result is now a map of stats for each file, e.g.
* // {
* // f1: [stats for file1],
* // f2: [stats for file2],
diff --git a/lib/mapValuesLimit.js b/lib/mapValuesLimit.js
index f6e72ff..6c9fe06 100644
--- a/lib/mapValuesLimit.js
+++ b/lib/mapValuesLimit.js
@@ -20,8 +20,9 @@ import once from './internal/once';
* once it has completed with an error (which can be `null`) and a
* transformed value. Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
*/
export default function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback || noop);
diff --git a/lib/mapValuesSeries.js b/lib/mapValuesSeries.js
index b97fcd1..c1530c2 100644
--- a/lib/mapValuesSeries.js
+++ b/lib/mapValuesSeries.js
@@ -16,7 +16,8 @@ import doLimit from './internal/doLimit';
* once it has completed with an error (which can be `null`) and a
* transformed value. Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
*/
export default doLimit(mapValuesLimit, 1);
diff --git a/lib/race.js b/lib/race.js
index 6937627..5547c86 100644
--- a/lib/race.js
+++ b/lib/race.js
@@ -4,7 +4,7 @@ import once from './internal/once';
/**
* Runs the `tasks` array of functions in parallel, without waiting until the
- * previous function has completed. Once any the `tasks` completed or pass an
+ * previous function has completed. Once any of the `tasks` complete or pass an
* error to its callback, the main `callback` is immediately called. It's
* equivalent to `Promise.race()`.
*
diff --git a/mocha_test/detect.js b/mocha_test/detect.js
index f308485..b1ebf24 100644
--- a/mocha_test/detect.js
+++ b/mocha_test/detect.js
@@ -1,5 +1,6 @@
var async = require('../lib');
var expect = require('chai').expect;
+var _ = require('lodash');
describe("detect", function () {
@@ -134,6 +135,31 @@ describe("detect", function () {
});
});
+ it('detectSeries doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.detectSeries(arr, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, true));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(1);
+ done();
+ });
+ });
+
+ it('detectLimit doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.detectLimit(arr, 100, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, true));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(100);
+ done();
+ });
+ });
it('find alias', function(){
expect(async.find).to.equal(async.detect);
diff --git a/mocha_test/every.js b/mocha_test/every.js
index ed4693e..39ae51c 100644
--- a/mocha_test/every.js
+++ b/mocha_test/every.js
@@ -1,5 +1,6 @@
var async = require('../lib');
var expect = require('chai').expect;
+var _ = require('lodash');
describe("every", function () {
@@ -83,6 +84,32 @@ describe("every", function () {
});
});
+ it('everySeries doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.everySeries(arr, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, false));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(1);
+ done();
+ });
+ });
+
+ it('everyLimit doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.everyLimit(arr, 100, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, false));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(100);
+ done();
+ });
+ });
+
it('all alias', function(){
expect(async.all).to.equal(async.every);
});
diff --git a/mocha_test/queue.js b/mocha_test/queue.js
index e4a29e4..6b09ea8 100644
--- a/mocha_test/queue.js
+++ b/mocha_test/queue.js
@@ -4,6 +4,8 @@ var assert = require('assert');
describe('queue', function(){
+ // several tests of these tests are flakey with timing issues
+ this.retries(3);
it('basics', function(done) {
@@ -218,6 +220,8 @@ describe('queue', function(){
});
it('push without callback', function(done) {
+ this.retries(3); // test can be flakey
+
var call_order = [],
delays = [40,20,60,20];
@@ -349,6 +353,8 @@ describe('queue', function(){
});
it('pause', function(done) {
+ this.retries(3); // sometimes can be flakey to timing issues
+
var call_order = [],
task_timeout = 80,
pause_timeout = task_timeout * 2.5,
diff --git a/mocha_test/retry.js b/mocha_test/retry.js
index 757b7ab..d3a5d22 100644
--- a/mocha_test/retry.js
+++ b/mocha_test/retry.js
@@ -55,6 +55,8 @@ describe("retry", function () {
});
it('retry with interval when all attempts fail',function(done) {
+ this.retries(3); // this test is flakey due to timing issues
+
var times = 3;
var interval = 50;
var callCount = 0;
@@ -208,6 +210,8 @@ describe("retry", function () {
});
it('retry with interval when some attempts fail and error test returns false at some invokation',function(done) {
+ this.retries(3); // flakey test
+
var interval = 50;
var callCount = 0;
var error = 'ERROR';
diff --git a/mocha_test/some.js b/mocha_test/some.js
index 0a5a8da..989fecb 100644
--- a/mocha_test/some.js
+++ b/mocha_test/some.js
@@ -1,5 +1,6 @@
var async = require('../lib');
var expect = require('chai').expect;
+var _ = require('lodash');
describe("some", function () {
@@ -83,7 +84,6 @@ describe("some", function () {
});
});
-
it('someLimit short-circuit', function(done){
var calls = 0;
async.someLimit([3,1,2], 1, function(x, callback){
@@ -97,6 +97,33 @@ describe("some", function () {
});
});
+
+ it('someSeries doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.someSeries(arr, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, true));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(1);
+ done();
+ });
+ });
+
+ it('someLimit doesn\'t cause stack overflow (#1293)', function(done) {
+ var arr = _.range(10000);
+ let calls = 0;
+ async.someLimit(arr, 100, function(data, cb) {
+ calls += 1;
+ async.setImmediate(_.partial(cb, null, true));
+ }, function(err) {
+ expect(err).to.equal(null);
+ expect(calls).to.equal(100);
+ done();
+ });
+ });
+
it('any alias', function(){
expect(async.any).to.equal(async.some);
});
diff --git a/package.json b/package.json
index 06f5794..c7f8259 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "async",
"description": "Higher-order functions and common patterns for asynchronous code",
- "version": "2.0.1",
+ "version": "2.1.2",
"main": "dist/async.js",
"author": "Caolan McMahon",
"repository": {
@@ -22,40 +22,42 @@
"lodash-es": "^4.14.0"
},
"devDependencies": {
+ "babel-cli": "^6.16.0",
"babel-core": "^6.3.26",
- "babel-plugin-add-module-exports": "~0.1.2",
- "babel-plugin-istanbul": "^1.0.3",
+ "babel-plugin-add-module-exports": "^0.2.1",
+ "babel-plugin-istanbul": "^2.0.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
"babel-preset-es2015": "^6.3.13",
"babelify": "^7.2.0",
"benchmark": "^2.1.1",
- "bluebird": "^2.9.32",
+ "bluebird": "^3.4.6",
"chai": "^3.1.0",
- "cheerio": "^0.20.0",
+ "cheerio": "^0.22.0",
"coveralls": "^2.11.2",
"es6-promise": "^2.3.0",
- "eslint": "^2.11.1",
+ "eslint": "^2.13.1",
"fs-extra": "^0.26.7",
"gh-pages-deploy": "^0.4.2",
"jsdoc": "^3.4.0",
- "karma": "^0.13.2",
- "karma-browserify": "^4.2.1",
- "karma-firefox-launcher": "^0.1.6",
- "karma-mocha": "^0.2.0",
- "karma-mocha-reporter": "^1.0.2",
- "mocha": "^2.2.5",
+ "karma": "^1.3.0",
+ "karma-browserify": "^5.1.0",
+ "karma-firefox-launcher": "^1.0.0",
+ "karma-mocha": "^1.2.0",
+ "karma-mocha-reporter": "^2.2.0",
+ "mocha": "^3.1.2",
"native-promise-only": "^0.8.0-a",
"nyc": "^7.0.0",
"recursive-readdir": "^1.3.0",
"rimraf": "^2.5.0",
- "rollup": "^0.25.0",
- "rollup-plugin-node-resolve": "^1.5.0",
- "rollup-plugin-npm": "~1.3.0",
+ "rollup": "^0.36.3",
+ "rollup-plugin-node-resolve": "^2.0.0",
+ "rollup-plugin-npm": "^2.0.0",
"rsvp": "^3.0.18",
"semver": "^4.3.6",
- "uglify-js": "~2.4.0",
+ "uglify-js": "~2.7.3",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
+ "watchify": "^3.7.0",
"yargs": "~3.9.1"
},
"scripts": {
@@ -66,7 +68,7 @@
"mocha-browser-test": "karma start",
"mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
"mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
- "test": "npm run-script lint && npm run mocha-node-test"
+ "test": "npm run lint && npm run mocha-node-test"
},
"license": "MIT",
"gh-pages-deploy": {
diff --git a/support/build/aggregate-build.js b/support/build/aggregate-build.js
index 61833b8..7269291 100644
--- a/support/build/aggregate-build.js
+++ b/support/build/aggregate-build.js
@@ -1,10 +1,10 @@
import compileModules from './compile-modules';
-import rollup from 'rollup';
+import {rollup} from 'rollup';
import rimraf from 'rimraf/rimraf';
export default function buildBundle(options) {
function bundle() {
- rollup.rollup({
+ rollup({
entry: options.outpath + '/index.js'
}).then(function ( bundle ) {
bundle.write({
diff --git a/support/jsdoc/jsdoc-custom.js b/support/jsdoc/jsdoc-custom.js
index 0bce1fa..fc22991 100644
--- a/support/jsdoc/jsdoc-custom.js
+++ b/support/jsdoc/jsdoc-custom.js
@@ -96,10 +96,22 @@ $(function initSearchBar() {
location.href = host + suggestion;
// handle searching from one of the source files or the home page
} else if (currentPage !== 'docs.html') {
- location.href = host + 'docs.html#.' + suggestion;
+ location.href = host + 'docs.html#' + suggestion;
} else {
- var $el = document.getElementById('.' + suggestion);
- $('#main').animate({ scrollTop: $el.offsetTop - 60 }, 500);
+ var $el = document.getElementById(suggestion);
+ $('#main-container').animate({ scrollTop: $el.offsetTop - 60 }, 500);
}
});
+
+ function fixOldHash() {
+ var hash = window.location.hash;
+ if (hash) {
+ var hashMatches = hash.match(/^#\.(\w+)$/);
+ if (hashMatches) {
+ window.location.hash = '#'+hashMatches[1];
+ }
+ }
+ }
+
+ fixOldHash();
});
diff --git a/support/jsdoc/jsdoc-fix-html.js b/support/jsdoc/jsdoc-fix-html.js
index a45b383..ef81e55 100644
--- a/support/jsdoc/jsdoc-fix-html.js
+++ b/support/jsdoc/jsdoc-fix-html.js
@@ -10,7 +10,7 @@ var pageTitle = 'Methods:';
var docFilename = 'docs.html';
var mainModuleFile = 'module-async.html';
-var mainSectionId = '#main';
+var mainScrollableSection = '#main-container';
var sectionTitleClass = '.page-title';
var HTMLFileBegin = '<!DOCTYPE html>\n<html lang="en">\n<head>\n';
@@ -21,6 +21,12 @@ var additionalFooterText = ' Documentation has been modified from the original.
' For more information, please see the <a href="https://github.com/caolan/async">async</a> repository.';
function generateHTMLFile(filename, $page, callback) {
+ var methodName = filename.match(/\/(\w+)\.js\.html$/);
+ if (methodName) {
+ var $thisMethodDocLink = $page.find('#toc').find('a[href="'+docFilename+'#'+methodName[1]+'"]');
+ $thisMethodDocLink.parent().addClass('active');
+ }
+
// generate an HTML file from a cheerio object
var HTMLdata = HTMLFileBegin + $page.find('head').html()
+ HTMLFileHeadBodyJoin + $page.find('body').html()
@@ -74,7 +80,7 @@ function combineFakeModules(files, callback) {
var $modulePage = $(moduleData);
var moduleName = $modulePage.find(sectionTitleClass).text();
$modulePage.find(sectionTitleClass).attr('id', moduleName.toLowerCase());
- $mainPage.find(mainSectionId).append($modulePage.find(mainSectionId).html());
+ $mainPage.find(mainScrollableSection).append($modulePage.find(mainScrollableSection).html());
return fileCallback();
});
}, function(err) {
@@ -109,14 +115,44 @@ function applyPreCheerioFixes(data) {
}
-function fixToc($page, moduleFiles) {
+function scrollSpyFix($page, $nav) {
+ // move everything into one big ul (for Bootstrap scroll-spy)
+ var $ul = $nav.children('ul');
+ $ul.addClass('nav').addClass('methods');
+ $ul.find('.methods').each(function() {
+ var $methodsList = $(this);
+ var $methods = $methodsList.find('[data-type="method"]');
+ var $parentLi = $methodsList.parent();
+
+ $methodsList.remove();
+ $methods.remove();
+ $parentLi.after($methods);
+ $parentLi.addClass('toc-header');
+
+ });
+
+ $page.find('[data-type="method"]').addClass("toc-method");
+
+ $page.find('[id^="."]').each(function() {
+ var $ele = $(this);
+ var id = $(this).attr('id');
+ $ele.attr('id', id.replace('.', ''));
+ });
+}
+
+function fixToc(file, $page, moduleFiles) {
// remove `async` listing from toc
- $page.find('li').find('a[href="'+mainModuleFile+'"]').parent().remove();
+ $page.find('a[href="'+mainModuleFile+'"]').parent().remove();
// change toc title
- $page.find('nav').children('h3').text(pageTitle);
- $page.find('nav').children('h2').remove();
+ var $nav = $page.find('nav');
+ $nav.attr('id', 'toc');
+ $nav.children('h3').text(pageTitle);
+ $nav.children('h2').remove();
+
+ scrollSpyFix($page, $nav);
+ var prependFilename = (file === docFilename) ? '' : docFilename;
// make everything point to the same 'docs.html' page
_.each(moduleFiles, function(filename) {
$page.find('[href^="'+filename+'"]').each(function() {
@@ -126,10 +162,10 @@ function fixToc($page, moduleFiles) {
// category titles should sections title, while everything else
// points to the correct listing
if (href === filename) {
- var moduleName = $ele.text().toLowerCase().replace(/\s/g, '');
- $ele.attr('href', docFilename+'#'+moduleName);
+ var moduleName = $ele.text().toLowerCase().replace(/\s/g, '').replace('.', '');
+ $ele.attr('href', prependFilename+'#'+moduleName);
} else {
- $ele.attr('href', href.replace(filename, docFilename));
+ $ele.attr('href', href.replace(filename, prependFilename).replace('#.', '#'));
}
});
});
@@ -139,7 +175,7 @@ function fixFooter($page) {
// add a note to the footer that the documentation has been modified
var $footer = $page.find('footer');
$footer.append(additionalFooterText);
- $page.find('#main').append($footer);
+ $page.find(mainScrollableSection).append($footer);
}
function fixModuleLinks(files, callback) {
@@ -152,7 +188,7 @@ function fixModuleLinks(files, callback) {
if (err) return fileCallback(err);
var $file = $(applyPreCheerioFixes(fileData));
- fixToc($file, moduleFiles);
+ fixToc(file, $file, moduleFiles);
fixFooter($file);
$file.find('[href="'+mainModuleFile+'"]').attr('href', docFilename);
generateHTMLFile(filePath, $file, fileCallback);
diff --git a/support/jsdoc/theme/static/styles/jsdoc-default.css b/support/jsdoc/theme/static/styles/jsdoc-default.css
index 76ade41..fee48f1 100644
--- a/support/jsdoc/theme/static/styles/jsdoc-default.css
+++ b/support/jsdoc/theme/static/styles/jsdoc-default.css
@@ -1,5 +1,3 @@
-@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
-
* {
box-sizing: border-box
}
@@ -112,18 +110,25 @@ tt, code, kbd, samp {
bottom: 0;
float: none;
min-width: 360px;
- overflow-y: auto;
- padding-left: 16px;
- padding-right: 16px;
+ overflow-y: hidden;
}
-#main h1 {
+#main-container {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ overflow-y: scroll;
+ padding-left: 16px;
+ padding-right: 16px;
+}
+
+#main-container h1 {
margin-top: 100px !important;
padding-top: 0px;
border-left: 2px solid #3391FE;
}
-#main h4 {
+#main-container h4 {
margin-top: 120px !important;
padding-top: 0px;
padding-left: 16px;
@@ -141,6 +146,39 @@ section, h1 {
padding: 2em 30px 0;
}
+#toc > h3 {
+ margin-bottom: 0px;
+}
+
+#toc > .methods > li {
+ padding: 0px 10px;
+}
+
+#toc > .methods > li > a {
+ font-size: 12px;
+ padding: 0px;
+}
+
+#toc > .methods > .toc-header {
+ margin-top: 10px;
+}
+
+#toc > .methods > .toc-method {
+ padding: 0px;
+ margin: 0px 10px;
+}
+
+#toc > .methods > .toc-method > a,
+#toc > .methods > .toc-method > a.active {
+ padding: 0px 0px 0px 20px;
+ border-left: 1px solid #D8DCDF;
+ color: #98999A;
+}
+
+#toc > .methods > .toc-method.active {
+ background-color: #E8E8E8;
+}
+
.nav.navbar-right .navbar-form {
padding: 0;
margin: 6px 0px;
diff --git a/support/jsdoc/theme/tmpl/layout.tmpl b/support/jsdoc/theme/tmpl/layout.tmpl
index fd998bb..912097d 100644
--- a/support/jsdoc/theme/tmpl/layout.tmpl
+++ b/support/jsdoc/theme/tmpl/layout.tmpl
@@ -7,22 +7,17 @@
<link rel="icon" href="favicon.ico?v=2" />
- <link src="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css">
- <script src="scripts/async.js"></script>
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css">
+
+ <link rel="stylesheet" href="styles/prettify-tomorrow.css">
+
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,700">
+ <link rel="stylesheet" href="styles/jsdoc-default.css">
- <script src="scripts/prettify/prettify.js"></script>
- <script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
- <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
-
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
-
- <script src="https://cdn.jsdelivr.net/jquery/2.2.4/jquery.min.js"></script>
- <script src="https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- <script src="https://cdn.jsdelivr.net/typeahead.js/0.11.1/typeahead.bundle.min.js"></script>
+ <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/ionicons/2.0.1/css/ionicons.min.css">
</head>
<body>
@@ -66,11 +61,13 @@
<label for="nav-trigger" class="overlay"></label>
<div id="main">
- <?js if (title != 'Home') { ?>
- <h1 class="page-title"><?js= title ?></h1>
- <?js } ?>
+ <div id="main-container" data-spy="scroll" data-target="#toc" data-offset="50">
+ <?js if (title != 'Home') { ?>
+ <h1 class="page-title"><?js= title ?></h1>
+ <?js } ?>
- <?js= content ?>
+ <?js= content ?>
+ </div>
</div>
<nav>
@@ -83,8 +80,17 @@
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc <?js= env.version.number ?></a><?js if(env.conf.templates && env.conf.templates.default && env.conf.templates.default.includeDate !== false) { ?> on <?js= (new Date()) ?><?js } ?> using the Minami theme.
</footer>
+
+<script src="https://cdn.jsdelivr.net/prettify/0.1/prettify.js"></script>
+
+<script src="https://cdn.jsdelivr.net/jquery/2.2.4/jquery.min.js"></script>
+<script src="https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js"></script>
+<script src="https://cdn.jsdelivr.net/typeahead.js/0.11.1/typeahead.bundle.min.js"></script>
+
<script>prettyPrint();</script>
-<script src="scripts/linenumber.js"></script>
-<script src="scripts/jsdoc-custom.js"></script>
+<script src="scripts/linenumber.js" async></script>
+<script src="scripts/jsdoc-custom.js" async></script>
+
+<script src="scripts/async.js" async></script>
</body>
</html>