summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--build/async-bundle.js4874
-rw-r--r--build/async-cjs.js32
-rw-r--r--build/modules/auto.js10
-rw-r--r--build/modules/ensureAsync.js2
-rw-r--r--build/modules/internal/applyEach.js4
-rw-r--r--build/modules/internal/filter.js6
-rw-r--r--build/modules/internal/queue.js6
-rw-r--r--build/modules/reduceRight.js8
-rw-r--r--build/modules/sortBy.js6
-rw-r--r--build/modules/times.js6
-rw-r--r--build/modules/timesLimit.js6
-rw-r--r--build/modules/timesSeries.js6
-rw-r--r--lib/auto.js8
-rw-r--r--lib/ensureAsync.js2
-rw-r--r--lib/internal/applyEach.js2
-rw-r--r--lib/internal/filter.js2
-rw-r--r--lib/internal/queue.js2
-rw-r--r--lib/reduceRight.js5
-rw-r--r--lib/sortBy.js2
-rw-r--r--lib/times.js4
-rw-r--r--lib/timesLimit.js4
-rw-r--r--lib/timesSeries.js4
23 files changed, 2243 insertions, 2770 deletions
diff --git a/Makefile b/Makefile
index d8cd746..3aa53ba 100644
--- a/Makefile
+++ b/Makefile
@@ -11,13 +11,6 @@ SRC = lib/index.js
all: lint test clean build
-build: $(wildcard lib/*.js)
- mkdir -p $(BUILDDIR)
- browserify $(SRC) -o $(BUILDDIR)/async.js -s $(REQUIRE_NAME)
- uglifyjs $(BUILDDIR)/async.js -mc \
- --source-map $(BUILDDIR)/async.min.map \
- -o $(BUILDDIR)/async.min.js
-
test:
npm test
@@ -31,11 +24,14 @@ lint:
submodule-clone:
git submodule update --init --recursive
-build-bundle: #submodule-clone lint test
+build-bundle: submodule-clone
$(NODE) scripts/build/modules-cjs.js
$(NODE) scripts/build/aggregate-bundle.js
$(NODE) scripts/build/aggregate-cjs.js
+
+build: build-bundle
+
.PHONY: test lint build all clean
.PHONY: release-major release-minor release-patch
diff --git a/build/async-bundle.js b/build/async-bundle.js
index f73ad6e..d19ad20 100644
--- a/build/async-bundle.js
+++ b/build/async-bundle.js
@@ -1,2837 +1,2307 @@
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- factory((global.async = {}));
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ factory((global.async = {}));
}(this, function (exports) { 'use strict';
- /**
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @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) {
- // Avoid a V8 JIT bug in Chrome 19-20.
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
-
- /**
- * 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 {...*} [args] The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply$1(func, thisArg, args) {
- var length = args ? args.length : 0;
- switch (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);
- }
-
- /**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
-
- /** Used to determine if values are of the language type `Object`. */
- var objectTypes = {
- 'function': true,
- 'object': true
- };
-
- /** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
-
- /** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
-
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
-
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(objectTypes[typeof self] && self);
-
- /** Detect free variable `window`. */
- var freeWindow = checkGlobal(objectTypes[typeof window] && window);
-
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
-
- /**
- * Used as a reference to the global object.
- *
- * The `this` value is used if it's the global object to avoid Greasemonkey's
- * restricted `window` object, otherwise the `window` object is used.
- */
- var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
-
- /**
- * Used by `trimmedStartIndex` and `trimmedEndIndex` to determine if a
- * character code is whitespace.
- *
- * @private
- * @param {number} charCode The character code to inspect.
- * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.
- */
- function isSpace(charCode) {
- return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||
- (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));
- }
-
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
- * character of `string`.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {number} Returns the index of the last non-whitespace character.
- */
- function trimmedEndIndex(string) {
- var index = string.length;
-
- while (index-- && isSpace(string.charCodeAt(index))) {}
- return index;
- }
+ /**
+ * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
+ * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @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) {
+ // Avoid a V8 JIT bug in Chrome 19-20.
+ // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
+ var type = typeof value;
+ return !!value && (type == 'object' || type == 'function');
+ }
+
+ /**
+ * 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 {...*} [args] The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+ function apply$1(func, thisArg, args) {
+ var length = args ? args.length : 0;
+ switch (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);
+ }
+
+ /**
+ * Checks if `value` is a global object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {null|Object} Returns `value` if it's a global object, else `null`.
+ */
+ function checkGlobal(value) {
+ return (value && value.Object === Object) ? value : null;
+ }
+
+ /** Used to determine if values are of the language type `Object`. */
+ var objectTypes = {
+ 'function': true,
+ 'object': true
+ };
+
+ /** Detect free variable `exports`. */
+ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
+
+ /** Detect free variable `module`. */
+ var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
+
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
+
+ /** Detect free variable `self`. */
+ var freeSelf = checkGlobal(objectTypes[typeof self] && self);
+
+ /** Detect free variable `window`. */
+ var freeWindow = checkGlobal(objectTypes[typeof window] && window);
+
+ /** Detect `this` as the global object. */
+ var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
+
+ /**
+ * Used as a reference to the global object.
+ *
+ * The `this` value is used if it's the global object to avoid Greasemonkey's
+ * restricted `window` object, otherwise the `window` object is used.
+ */
+ var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
+
+ /**
+ * Used by `trimmedStartIndex` and `trimmedEndIndex` to determine if a
+ * character code is whitespace.
+ *
+ * @private
+ * @param {number} charCode The character code to inspect.
+ * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.
+ */
+ function isSpace(charCode) {
+ return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||
+ (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));
+ }
+
+ /**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
+ * character of `string`.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {number} Returns the index of the last non-whitespace character.
+ */
+ function trimmedEndIndex(string) {
+ var index = string.length;
+
+ while (index-- && isSpace(string.charCodeAt(index))) {}
+ return index;
+ }
+
+ /**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first non-whitespace
+ * character of `string`.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {number} Returns the index of the first non-whitespace character.
+ */
+ function trimmedStartIndex(string) {
+ var index = -1,
+ length = string.length;
+
+ while (++index < length && isSpace(string.charCodeAt(index))) {}
+ return index;
+ }
+
+ /**
+ * The base implementation of `_.trim` without support trimming non-whitespace
+ * characters.
+ *
+ * @private
+ * @param {string} string The string to trim.
+ * @returns {string} Returns the trimmed string.
+ */
+ function baseTrim(string) {
+ return string
+ ? string.slice(trimmedStartIndex(string), trimmedEndIndex(string) + 1)
+ : string;
+ }
+
+ var funcTag = '[object Function]';
+ var genTag = '[object GeneratorFunction]';
+ /** Used for built-in method references. */
+ var objectProto$4 = 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$4.toString;
+
+ /**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is correctly classified, 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 constructors, and
+ // PhantomJS 1.9 which returns 'function' for `NodeList` instances.
+ var tag = isObject(value) ? objectToString$2.call(value) : '';
+ return tag == funcTag || tag == genTag;
+ }
+
+ /**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @type Function
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+ var isArray = Array.isArray;
+
+ /**
+ * 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 _
+ * @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';
+ }
+
+ /** `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$1 = objectProto$3.toString;
+
+ /**
+ * Checks if `value` is classified as a `String` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
+ * @example
+ *
+ * _.isString('abc');
+ * // => true
+ *
+ * _.isString(1);
+ * // => false
+ */
+ function isString(value) {
+ return typeof value == 'string' ||
+ (!isArray(value) && isObjectLike(value) && objectToString$1.call(value) == stringTag);
+ }
+
+ /** Used as references for various `Number` constants. */
+ var NAN = 0 / 0;
+
+ /** Used to detect bad signed hexadecimal string values. */
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
+
+ /** Used to detect binary string values. */
+ var reIsBinary = /^0b[01]+$/i;
+
+ /** Used to detect octal string values. */
+ var reIsOctal = /^0o[0-7]+$/i;
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeParseInt = root.parseInt;
+
+ /**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3);
+ * // => 3
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3');
+ * // => 3
+ */
+ function toNumber(value) {
+ if (!value) {
+ return value === 0 ? value : +value;
+ }
+ if (isObject(value)) {
+ var other = isFunction(value.valueOf) ? value.valueOf() : value;
+ value = isObject(other) ? (other + '') : other;
+ }
+ if (typeof value == 'number' || !isString(value)) {
+ return +value;
+ }
+ value = baseTrim(value);
+ var isBinary = reIsBinary.test(value);
+ return (isBinary || reIsOctal.test(value))
+ ? nativeParseInt(value.slice(2), isBinary ? 2 : 8)
+ : (reIsBadHex.test(value) ? NAN : +value);
+ }
+
+ var INFINITY = 1 / 0;
+ var MAX_INTEGER = 1.7976931348623157e+308;
+ /**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3');
+ * // => 3
+ */
+ function toInteger(value) {
+ if (!value) {
+ return value === 0 ? value : 0;
+ }
+ value = toNumber(value);
+ if (value === INFINITY || value === -INFINITY) {
+ var sign = (value < 0 ? -1 : 1);
+ return sign * MAX_INTEGER;
+ }
+ var remainder = value % 1;
+ return value === value ? (remainder ? value - remainder : value) : 0;
+ }
+
+ /** Used as the `TypeError` message for "Functions" methods. */
+ var FUNC_ERROR_TEXT = 'Expected a function';
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeMax = Math.max;
+
+ /**
+ * Creates a function that invokes `func` with the `this` binding of the
+ * created function and arguments from `start` and beyond provided as an array.
+ *
+ * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters).
+ *
+ * @static
+ * @memberOf _
+ * @category Function
+ * @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.
+ * @example
+ *
+ * var say = _.rest(function(what, names) {
+ * return what + ' ' + _.initial(names).join(', ') +
+ * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
+ * });
+ *
+ * say('hello', 'fred', 'barney', 'pebbles');
+ * // => 'hello fred, barney, & pebbles'
+ */
+ function rest(func, start) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
- /**
- * Used by `_.trim` and `_.trimStart` to get the index of the first non-whitespace
- * character of `string`.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {number} Returns the index of the first non-whitespace character.
- */
- function trimmedStartIndex(string) {
- var index = -1,
- length = string.length;
-
- while (++index < length && isSpace(string.charCodeAt(index))) {}
- return index;
- }
-
- /**
- * The base implementation of `_.trim` without support trimming non-whitespace
- * characters.
- *
- * @private
- * @param {string} string The string to trim.
- * @returns {string} Returns the trimmed string.
- */
- function baseTrim(string) {
- return string
- ? string.slice(trimmedStartIndex(string), trimmedEndIndex(string) + 1)
- : string;
- }
-
- var funcTag = '[object Function]';
- var genTag = '[object GeneratorFunction]';
- /** 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 `Function` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, 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 constructors, and
- // PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString$3.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
-
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
-
- /**
- * 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 _
- * @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';
- }
-
- /** `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$1 = objectProto$3.toString;
-
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString$1.call(value) == stringTag);
- }
-
- /** Used as references for various `Number` constants. */
- var NAN = 0 / 0;
-
- /** Used to detect bad signed hexadecimal string values. */
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
-
- /** Used to detect binary string values. */
- var reIsBinary = /^0b[01]+$/i;
-
- /** Used to detect octal string values. */
- var reIsOctal = /^0o[0-7]+$/i;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeParseInt = root.parseInt;
-
- /**
- * Converts `value` to a number.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to process.
- * @returns {number} Returns the number.
- * @example
- *
- * _.toNumber(3);
- * // => 3
- *
- * _.toNumber(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toNumber(Infinity);
- * // => Infinity
- *
- * _.toNumber('3');
- * // => 3
- */
- function toNumber(value) {
- if (!value) {
- return value === 0 ? value : +value;
+ while (++index < length) {
+ array[index] = args[start + index];
}
- if (isObject(value)) {
- var other = isFunction(value.valueOf) ? value.valueOf() : value;
- value = isObject(other) ? (other + '') : other;
+ switch (start) {
+ case 0: return func.call(this, array);
+ case 1: return func.call(this, args[0], array);
+ case 2: return func.call(this, args[0], args[1], array);
}
- if (typeof value == 'number' || !isString(value)) {
- return +value;
+ var otherArgs = Array(start + 1);
+ index = -1;
+ while (++index < start) {
+ otherArgs[index] = args[index];
}
- value = baseTrim(value);
- var isBinary = reIsBinary.test(value);
- return (isBinary || reIsOctal.test(value))
- ? nativeParseInt(value.slice(2), isBinary ? 2 : 8)
- : (reIsBadHex.test(value) ? NAN : +value);
- }
-
- var INFINITY = 1 / 0;
- var MAX_INTEGER = 1.7976931348623157e+308;
- /**
- * Converts `value` to an integer.
- *
- * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted integer.
- * @example
- *
- * _.toInteger(3);
- * // => 3
- *
- * _.toInteger(Number.MIN_VALUE);
- * // => 0
- *
- * _.toInteger(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toInteger('3');
- * // => 3
- */
- function toInteger(value) {
- if (!value) {
- return value === 0 ? value : 0;
+ otherArgs[start] = array;
+ return apply$1(func, this, otherArgs);
+ };
+ }
+
+ function asyncify(func) {
+ return rest(function (args) {
+ var callback = args.pop();
+ 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);
+ })['catch'](function (err) {
+ callback(err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+ }
+
+ /**
+ * A specialized version of `_.map` for arrays without support for callback
+ * 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.length,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+ }
+
+ /**
+ * 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 function.
+ */
+ function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ function _filter(eachfn, arr, iterator, callback) {
+ var results = [];
+ eachfn(arr, function (x, index, callback) {
+ iterator(x, function (v) {
+ if (v) {
+ results.push({ index: index, value: x });
+ }
+ callback();
+ });
+ }, function () {
+ callback(arrayMap(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), baseProperty('value')));
+ });
+ }
+
+ /** Used as the `TypeError` message for "Functions" methods. */
+ var FUNC_ERROR_TEXT$1 = 'Expected a function';
+
+ /**
+ * Creates a function that invokes `func`, with the `this` binding and arguments
+ * of the created function, while it's called less than `n` times. Subsequent
+ * calls to the created function return the result of the last `func` invocation.
+ *
+ * @static
+ * @memberOf _
+ * @category Function
+ * @param {number} n The number of calls at which `func` is no longer invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * jQuery(element).on('click', _.before(5, addContactToList));
+ * // => allows adding up to 4 contacts to the list
+ */
+ function before(n, func) {
+ var result;
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT$1);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n > 0) {
+ result = func.apply(this, arguments);
}
- value = toNumber(value);
- if (value === INFINITY || value === -INFINITY) {
- var sign = (value < 0 ? -1 : 1);
- return sign * MAX_INTEGER;
+ if (n <= 1) {
+ func = undefined;
}
- var remainder = value % 1;
- return value === value ? (remainder ? value - remainder : value) : 0;
- }
-
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
-
- /**
- * Creates a function that invokes `func` with the `this` binding of the
- * created function and arguments from `start` and beyond provided as an array.
- *
- * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters).
- *
- * @static
- * @memberOf _
- * @category Function
- * @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.
- * @example
- *
- * var say = _.rest(function(what, names) {
- * return what + ' ' + _.initial(names).join(', ') +
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
- * });
- *
- * say('hello', 'fred', 'barney', 'pebbles');
- * // => 'hello fred, barney, & pebbles'
- */
- function rest(func, start) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
+ return result;
+ };
+ }
+
+ /**
+ * Creates a function that is restricted to invoking `func` once. Repeat calls
+ * to the function return the value of the first invocation. The `func` is
+ * invoked with the `this` binding and arguments of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @category Function
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var initialize = _.once(createApplication);
+ * initialize();
+ * initialize();
+ * // `initialize` invokes `createApplication` once
+ */
+ function once(func) {
+ return before(2, func);
+ }
+
+ /**
+ * A no-operation function that returns `undefined` regardless of the
+ * arguments it receives.
+ *
+ * @static
+ * @memberOf _
+ * @category Utility
+ * @example
+ *
+ * var object = { 'user': 'fred' };
+ *
+ * _.noop(object) === undefined;
+ * // => true
+ */
+ function noop() {
+ // No operation performed.
+ }
+
+ /**
+ * 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');
+
+ /** Used as references for various `Number` constants. */
+ var MAX_SAFE_INTEGER$1 = 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 _
+ * @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$1;
+ }
+
+ /**
+ * 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 _
+ * @type Function
+ * @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 &&
+ !(typeof value == 'function' && isFunction(value)) && isLength(getLength(value));
+ }
+
+ /** Used for built-in method references. */
+ var objectProto = Object.prototype;
+
+ /** Used to check objects for own properties. */
+ var hasOwnProperty = objectProto.hasOwnProperty;
+
+ /** Built-in value references. */
+ var getPrototypeOf = Object.getPrototypeOf;
+
+ /**
+ * 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 hasOwnProperty.call(object, key) ||
+ (typeof object == 'object' && key in object && getPrototypeOf(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
+ * @type Function
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function baseKeys(object) {
+ return nativeKeys(Object(object));
+ }
+
+ /**
+ * The base implementation of `_.times` without support for callback 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;
+ }
+
+ /**
+ * This method is like `_.isArrayLike` except that it also checks if `value`
+ * is an object.
+ *
+ * @static
+ * @memberOf _
+ * @type Function
+ * @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 = objectProto$2.toString;
+
+ /** Built-in value references. */
+ var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
+
+ /**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is correctly classified, 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.call(value) == argsTag);
+ }
+
+ /**
+ * 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;
+ return (isLength(length) && (isArray(object) || isString(object) || isArguments(object)))
+ ? baseTimes(length, String)
+ : null;
+ }
+
+ /** Used as references for various `Number` constants. */
+ var MAX_SAFE_INTEGER = 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) {
+ value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return value > -1 && value % 1 == 0 && value < length;
+ }
+
+ /** Used for built-in method references. */
+ var objectProto$1 = 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$1;
+
+ 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
+ * @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);
+ }
+ 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);
}
- start = nativeMax(start === undefined ? (func.length - 1) : toInteger(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];
- }
- switch (start) {
- case 0: return func.call(this, array);
- case 1: return func.call(this, args[0], array);
- case 2: return func.call(this, args[0], args[1], array);
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = array;
- return apply$1(func, this, otherArgs);
- };
- }
-
- function asyncify(func) {
- return rest(function (args) {
- var callback = args.pop();
- 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);
- })['catch'](function (err) {
- callback(err.message ? err : new Error(err));
- });
- } else {
- callback(null, result);
- }
- });
}
-
- /**
- * A specialized version of `_.map` for arrays without support for callback
- * 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.length,
- result = Array(length);
-
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
+ return result;
+ }
+
+ function keyIterator(coll) {
+ var i = -1;
+ var len;
+ if (isArrayLike(coll)) {
+ len = coll.length;
+ return function next() {
+ i++;
+ return i < len ? i : null;
+ };
+ } else {
+ var okeys = keys(coll);
+ len = okeys.length;
+ return function next() {
+ i++;
+ return i < len ? okeys[i] : null;
+ };
}
- return result;
- }
+ }
- /**
- * 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 function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
+ function onlyOnce(fn) {
+ return function () {
+ if (fn === null) throw new Error("Callback was already called.");
+ fn.apply(this, arguments);
+ fn = null;
};
- }
+ }
- /** Used as references for various `Number` constants. */
- var INFINITY$1 = 1 / 0;
-
- /**
- * Converts `value` to a string if it's not one. An empty string is returned
- * for `null` and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @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) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- var result = value == null ? '' : (value + '');
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
- }
-
- /** Used to match property names within property paths. */
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
+ var _setImmediate = typeof setImmediate === 'function' && setImmediate;
- /** Used to match backslashes in property paths. */
- var reEscapeChar = /\\(\\)?/g;
-
- /**
- * Converts `string` to a property path array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the property path array.
- */
- function stringToPath(string) {
- var result = [];
- toString(string).replace(rePropName, function(match, number, quote, string) {
- result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
- });
- return result;
- }
+ var _delay;
+ if (_setImmediate) {
+ _delay = function (fn) {
+ // not a direct alias for IE10 compatibility
+ _setImmediate(fn);
+ };
+ } else if (typeof process === 'object' && typeof process.nextTick === 'function') {
+ _delay = process.nextTick;
+ } else {
+ _delay = function (fn) {
+ setTimeout(fn, 0);
+ };
+ }
- /**
- * The base implementation of `_.toPath` which only converts `value` to a
- * path if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Array} Returns the property path array.
- */
- function baseToPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
+ var setImmediate$1 = _delay;
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
- var reIsPlainProp = /^\w*$/;
- /**
- * Checks if `value` is a property name and not a property path.
- *
- * @private
- * @param {*} value The value to check.
- * @param {Object} [object] The object to query keys on.
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
- */
- function isKey(value, object) {
- if (typeof value == 'number') {
- return true;
- }
- return !isArray(value) &&
- (reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
- (object != null && value in Object(object)));
- }
+ function eachOfSeries(obj, iterator, callback) {
+ callback = once(callback || noop);
+ obj = obj || [];
+ var nextKey = keyIterator(obj);
+ var key = nextKey();
- /**
- * The base implementation of `_.get` without support for default values.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @returns {*} Returns the resolved value.
- */
- function baseGet(object, path) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
-
- var index = 0,
- length = path.length;
-
- while (object != null && index < length) {
- object = object[path[index++]];
+ function iterate() {
+ var sync = true;
+ if (key === null) {
+ return callback(null);
+ }
+ iterator(obj[key], key, onlyOnce(function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ key = nextKey();
+ if (key === null) {
+ return callback(null);
+ } else {
+ if (sync) {
+ setImmediate$1(iterate);
+ } else {
+ iterate();
+ }
+ }
+ }
+ }));
+ sync = false;
}
- return (index && index == length) ? object : undefined;
- }
+ iterate();
+ }
- /**
- * A specialized version of `baseProperty` which supports deep paths.
- *
- * @private
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new function.
- */
- function basePropertyDeep(path) {
- return function(object) {
- return baseGet(object, path);
+ function doSeries(fn) {
+ return function (obj, iterator, callback) {
+ return fn(eachOfSeries, obj, iterator, callback);
};
- }
+ }
- /**
- * Creates a function that returns the value at `path` of a given object.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var objects = [
- * { 'a': { 'b': { 'c': 2 } } },
- * { 'a': { 'b': { 'c': 1 } } }
- * ];
- *
- * _.map(objects, _.property('a.b.c'));
- * // => [2, 1]
- *
- * _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
- * // => [1, 2]
- */
- function property(path) {
- return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
- }
+ var filterSeries = doSeries(_filter);
- function _filter(eachfn, arr, iterator, callback) {
- var results = [];
- eachfn(arr, function (x, index, callback) {
- iterator(x, function (v) {
- if (v) {
- results.push({ index: index, value: x });
- }
- callback();
- });
- }, function () {
- callback(arrayMap(results.sort(function (a, b) {
- return a.index - b.index;
- }), property('value')));
- });
- }
-
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
-
- /**
- * Creates a function that invokes `func`, with the `this` binding and arguments
- * of the created function, while it's called less than `n` times. Subsequent
- * calls to the created function return the result of the last `func` invocation.
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {number} n The number of calls at which `func` is no longer invoked.
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new restricted function.
- * @example
- *
- * jQuery(element).on('click', _.before(5, addContactToList));
- * // => allows adding up to 4 contacts to the list
- */
- function before(n, func) {
- var result;
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT$1);
- }
- n = toInteger(n);
- return function() {
- if (--n > 0) {
- result = func.apply(this, arguments);
- }
- if (n <= 1) {
- func = undefined;
- }
- return result;
+ function _eachOfLimit(limit) {
+ return function (obj, iterator, callback) {
+ callback = once(callback || noop);
+ obj = obj || [];
+ var nextKey = keyIterator(obj);
+ if (limit <= 0) {
+ return callback(null);
+ }
+ var done = false;
+ var running = 0;
+ var errored = false;
+
+ (function replenish() {
+ if (done && running <= 0) {
+ return callback(null);
+ }
+
+ while (running < limit && !errored) {
+ var key = nextKey();
+ if (key === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iterator(obj[key], key, onlyOnce(function (err) {
+ running -= 1;
+ if (err) {
+ callback(err);
+ errored = true;
+ } else {
+ replenish();
+ }
+ }));
+ }
+ })();
};
- }
-
- /**
- * Creates a function that is restricted to invoking `func` once. Repeat calls
- * to the function return the value of the first invocation. The `func` is
- * invoked with the `this` binding and arguments of the created function.
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new restricted function.
- * @example
- *
- * var initialize = _.once(createApplication);
- * initialize();
- * initialize();
- * // `initialize` invokes `createApplication` once
- */
- function once(func) {
- return before(2, func);
- }
-
- /**
- * A no-operation function that returns `undefined` regardless of the
- * arguments it receives.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.noop(object) === undefined;
- * // => true
- */
- function noop() {
- // No operation performed.
- }
+ }
- /**
- * 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');
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 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 _
- * @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$1;
- }
-
- /**
- * 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 _
- * @type Function
- * @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 &&
- !(typeof value == 'function' && isFunction(value)) && isLength(getLength(value));
- }
-
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
-
- /** Built-in value references. */
- var getPrototypeOf = Object.getPrototypeOf;
-
- /**
- * 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 hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototypeOf(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
- * @type Function
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- return nativeKeys(Object(object));
- }
-
- /**
- * The base implementation of `_.times` without support for callback 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;
- }
-
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @type Function
- * @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$4 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$4.hasOwnProperty;
-
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$2 = objectProto$4.toString;
-
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
-
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, 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$2.call(value) == argsTag);
- }
+ function doParallelLimit(fn) {
+ return function (obj, limit, iterator, callback) {
+ return fn(_eachOfLimit(limit), obj, iterator, callback);
+ };
+ }
- /**
- * 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;
- return (isLength(length) && (isArray(object) || isString(object) || isArguments(object)))
- ? baseTimes(length, String)
- : null;
- }
+ var filterLimit = doParallelLimit(_filter);
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 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) {
- value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
- length = length == null ? MAX_SAFE_INTEGER : length;
- return value > -1 && value % 1 == 0 && value < length;
- }
+ function eachOf(object, iterator, callback) {
+ callback = once(callback || noop);
+ object = object || [];
- /** Used for built-in method references. */
- var objectProto$1 = 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$1;
-
- return value === proto;
- }
+ var iter = keyIterator(object);
+ var key,
+ completed = 0;
- /**
- * 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
- * @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);
- }
- 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);
- }
+ while ((key = iter()) != null) {
+ completed += 1;
+ iterator(object[key], key, onlyOnce(done));
}
- return result;
- }
-
- function keyIterator(coll) {
- var i = -1;
- var len;
- if (isArrayLike(coll)) {
- len = coll.length;
- return function next() {
- i++;
- return i < len ? i : null;
- };
- } else {
- var okeys = keys(coll);
- len = okeys.length;
- return function next() {
- i++;
- return i < len ? okeys[i] : null;
- };
- }
- }
-
- function onlyOnce(fn) {
- return function () {
- if (fn === null) throw new Error("Callback was already called.");
- fn.apply(this, arguments);
- fn = null;
- };
- }
-
- var _setImmediate = typeof setImmediate === 'function' && setImmediate;
-
- var _delay;
- if (_setImmediate) {
- _delay = function (fn) {
- // not a direct alias for IE10 compatibility
- _setImmediate(fn);
- };
- } else if (typeof process === 'object' && typeof process.nextTick === 'function') {
- _delay = process.nextTick;
- } else {
- _delay = function (fn) {
- setTimeout(fn, 0);
- };
- }
- var setImmediate$1 = _delay;
-
- function eachOfSeries(obj, iterator, callback) {
- callback = once(callback || noop);
- obj = obj || [];
- var nextKey = keyIterator(obj);
- var key = nextKey();
-
- function iterate() {
- var sync = true;
- if (key === null) {
- return callback(null);
- }
- iterator(obj[key], key, onlyOnce(function (err) {
- if (err) {
- callback(err);
- } else {
- key = nextKey();
- if (key === null) {
- return callback(null);
- } else {
- if (sync) {
- setImmediate$1(iterate);
- } else {
- iterate();
- }
- }
- }
- }));
- sync = false;
- }
- iterate();
- }
-
- function doSeries(fn) {
- return function (obj, iterator, callback) {
- return fn(eachOfSeries, obj, iterator, callback);
- };
- }
-
- var filterSeries = doSeries(_filter);
-
- function _eachOfLimit(limit) {
- return function (obj, iterator, callback) {
- callback = once(callback || noop);
- obj = obj || [];
- var nextKey = keyIterator(obj);
- if (limit <= 0) {
- return callback(null);
- }
- var done = false;
- var running = 0;
- var errored = false;
-
- (function replenish() {
- if (done && running <= 0) {
- return callback(null);
- }
-
- while (running < limit && !errored) {
- var key = nextKey();
- if (key === null) {
- done = true;
- if (running <= 0) {
- callback(null);
- }
- return;
- }
- running += 1;
- iterator(obj[key], key, onlyOnce(function (err) {
- running -= 1;
- if (err) {
- callback(err);
- errored = true;
- } else {
- replenish();
- }
- }));
- }
- })();
- };
- }
-
- function doParallelLimit(fn) {
- return function (obj, limit, iterator, callback) {
- return fn(_eachOfLimit(limit), obj, iterator, callback);
- };
- }
-
- var filterLimit = doParallelLimit(_filter);
-
- function eachOf(object, iterator, callback) {
- callback = once(callback || noop);
- object = object || [];
-
- var iter = keyIterator(object);
- var key,
- completed = 0;
-
- while ((key = iter()) != null) {
- completed += 1;
- iterator(object[key], key, onlyOnce(done));
- }
-
- if (completed === 0) callback(null);
-
- function done(err) {
- completed--;
- if (err) {
- callback(err);
- }
- // Check key is null in case iterator isn't exhausted
- // and done resolved synchronously.
- else if (key === null && completed <= 0) {
- callback(null);
- }
- }
- }
-
- function doParallel(fn) {
- return function (obj, iterator, callback) {
- return fn(eachOf, obj, iterator, callback);
- };
- }
-
- var filter = doParallel(_filter);
-
- /** Built-in value references. */
- var Symbol = root.Symbol;
-
- /**
- * 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;
+ if (completed === 0) callback(null);
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
+ function done(err) {
+ completed--;
+ if (err) {
+ callback(err);
+ }
+ // Check key is null in case iterator isn't exhausted
+ // and done resolved synchronously.
+ else if (key === null && completed <= 0) {
+ callback(null);
+ }
}
- return array;
- }
+ }
- /**
- * Checks if `value` is a host object in IE < 9.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
- */
- function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
- }
- return result;
- }
-
- /** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
-
- /** Used to detect host constructors (Safari > 5). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
-
- /** Used for built-in method references. */
- var objectProto$6 = Object.prototype;
-
- /** Used to resolve the decompiled source of functions. */
- var funcToString$1 = Function.prototype.toString;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$6.hasOwnProperty;
-
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
-
- /**
- * Checks if `value` is a native function.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
- * @example
- *
- * _.isNative(Array.prototype.push);
- * // => true
- *
- * _.isNative(_);
- * // => false
- */
- function isNative(value) {
- if (value == null) {
- return false;
- }
- if (isFunction(value)) {
- return reIsNative.test(funcToString$1.call(value));
- }
- return isObjectLike(value) &&
- (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
- }
+ function doParallel(fn) {
+ return function (obj, iterator, callback) {
+ return fn(eachOf, obj, iterator, callback);
+ };
+ }
+
+ var filter = doParallel(_filter);
+
+ function reduce(arr, memo, iterator, cb) {
+ eachOfSeries(arr, function (x, i, cb) {
+ iterator(memo, x, function (err, v) {
+ memo = v;
+ cb(err);
+ });
+ }, function (err) {
+ cb(err, memo);
+ });
+ }
- /**
- * 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 = object == null ? undefined : object[key];
- return isNative(value) ? value : undefined;
- }
+ var slice = Array.prototype.slice;
- /* Built-in method references that are verified to be native. */
- var Map = getNative(root, 'Map');
-
- /* Built-in method references that are verified to be native. */
- var Set = getNative(root, 'Set');
-
- var mapTag$1 = '[object Map]';
- var objectTag = '[object Object]';
- var setTag$1 = '[object Set]';
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
-
- /** Used to resolve the decompiled source of functions. */
- var funcToString = Function.prototype.toString;
-
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto$2.toString;
-
- /** Used to detect maps and sets. */
- var mapCtorString = Map ? funcToString.call(Map) : '';
- var setCtorString = Set ? funcToString.call(Set) : '';
- /**
- * Gets the `toStringTag` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function getTag(value) {
- return objectToString.call(value);
- }
+ function reduceRight(arr, memo, iterator, cb) {
+ var reversed = slice.call(arr).reverse();
+ reduce(reversed, memo, iterator, cb);
+ }
- // Fallback for IE 11 providing `toStringTag` values for maps and sets.
- if ((Map && getTag(new Map) != mapTag$1) || (Set && getTag(new Set) != setTag$1)) {
- getTag = function(value) {
- var result = objectToString.call(value),
- Ctor = result == objectTag ? value.constructor : null,
- ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
+ function eachOfLimit(obj, limit, iterator, cb) {
+ _eachOfLimit(limit)(obj, iterator, cb);
+ }
- if (ctorString) {
- if (ctorString == mapCtorString) {
- return mapTag$1;
+ function _withoutIndex(iterator) {
+ return function (value, index, callback) {
+ return iterator(value, callback);
+ };
+ }
+
+ function eachLimit(arr, limit, iterator, cb) {
+ return _eachOfLimit(limit)(arr, _withoutIndex(iterator), cb);
+ }
+
+ function eachSeries(arr, iterator, cb) {
+ return eachOfSeries(arr, _withoutIndex(iterator), cb);
+ }
+
+ function each(arr, iterator, cb) {
+ return eachOf(arr, _withoutIndex(iterator), cb);
+ }
+
+ /**
+ * This method returns the first argument provided to it.
+ *
+ * @static
+ * @memberOf _
+ * @category Utility
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'user': 'fred' };
+ *
+ * _.identity(object) === object;
+ * // => true
+ */
+ function identity(value) {
+ return value;
+ }
+
+ function _createTester(eachfn, check, getResult) {
+ return function (arr, limit, iterator, cb) {
+ function done() {
+ if (cb) cb(getResult(false, void 0));
}
- if (ctorString == setCtorString) {
- return setTag$1;
+ function iteratee(x, _, callback) {
+ if (!cb) return callback();
+ iterator(x, function (v) {
+ if (cb && check(v)) {
+ cb(getResult(true, x));
+ cb = iterator = false;
+ }
+ callback();
+ });
+ }
+ if (arguments.length > 3) {
+ eachfn(arr, limit, iteratee, done);
+ } else {
+ cb = iterator;
+ iterator = limit;
+ eachfn(arr, iteratee, done);
}
- }
- return result;
};
- }
-
- var getTag$1 = getTag;
-
- /**
- * Converts `iterator` to an array.
- *
- * @private
- * @param {Object} iterator The iterator to convert.
- * @returns {Array} Returns the converted array.
- */
- function iteratorToArray(iterator) {
- var data,
- result = [];
-
- while (!(data = iterator.next()).done) {
- result.push(data.value);
- }
- return result;
- }
+ }
- /**
- * Converts `map` to an array.
- *
- * @private
- * @param {Object} map The map to convert.
- * @returns {Array} Returns the converted array.
- */
- function mapToArray(map) {
- var index = -1,
- result = Array(map.size);
+ var some = _createTester(eachOf, Boolean, identity);
- map.forEach(function(value, key) {
- result[++index] = [key, value];
- });
- return result;
- }
+ function notId(v) {
+ return !v;
+ }
- /**
- * Converts `set` to an array.
- *
- * @private
- * @param {Object} set The set to convert.
- * @returns {Array} Returns the converted array.
- */
- function setToArray(set) {
- var index = -1,
- result = Array(set.size);
+ var every = _createTester(eachOf, notId, notId);
- set.forEach(function(value) {
- result[++index] = value;
+ function whilst(test, iterator, cb) {
+ cb = cb || noop;
+ if (!test()) return cb(null);
+ var next = rest(function (err, args) {
+ if (err) return cb(err);
+ if (test.apply(this, args)) return iterator(next);
+ cb.apply(null, [null].concat(args));
});
- return result;
- }
-
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff';
- var rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
- var rsVarRange = '\\ufe0e\\ufe0f';
- var rsAstral = '[' + rsAstralRange + ']';
- var rsCombo = '[' + rsComboRange + ']';
- var rsModifier = '(?:\\ud83c[\\udffb-\\udfff])';
- 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(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 ? string.match(reComplexSymbol) : [];
- }
-
- /**
- * The base implementation of `_.values` and `_.valuesIn` which creates an
- * array of `object` property values corresponding to the property names
- * of `props`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array} props The property names to get values for.
- * @returns {Object} Returns the array of property values.
- */
- function baseValues(object, props) {
- return arrayMap(props, function(key) {
- return object[key];
+ iterator(next);
+ }
+
+ function ensureAsync(fn) {
+ return rest(function (args) {
+ var callback = args.pop();
+ 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;
});
- }
-
- /**
- * Creates an array of the own enumerable property values of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property values.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.values(new Foo);
- * // => [1, 2] (iteration order is not guaranteed)
- *
- * _.values('hi');
- * // => ['h', 'i']
- */
- function values(object) {
- return object ? baseValues(object, keys(object)) : [];
- }
-
- var mapTag = '[object Map]';
- var setTag = '[object Set]';
- /** Built-in value references. */
- var iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined;
-
- /**
- * Converts `value` to an array.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {Array} Returns the converted array.
- * @example
- *
- * (function() {
- * return _.toArray(arguments).slice(1);
- * }(1, 2, 3));
- * // => [2, 3]
- */
- function toArray(value) {
- if (!value) {
- return [];
- }
- if (isArrayLike(value)) {
- return isString(value) ? stringToArray(value) : copyArray(value);
+ }
+
+ function iterator (tasks) {
+ function makeCallback(index) {
+ function fn() {
+ if (tasks.length) {
+ tasks[index].apply(null, arguments);
+ }
+ return fn.next();
+ }
+ fn.next = function () {
+ return index < tasks.length - 1 ? makeCallback(index + 1) : null;
+ };
+ return fn;
}
- if (iteratorSymbol && value[iteratorSymbol]) {
- return iteratorToArray(value[iteratorSymbol]());
+ return makeCallback(0);
+ }
+
+ function waterfall (tasks, cb) {
+ cb = once(cb || noop);
+ if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
+ if (!tasks.length) return cb();
+
+ function wrapIterator(iterator) {
+ return rest(function (err, args) {
+ if (err) {
+ cb.apply(null, [err].concat(args));
+ } else {
+ var next = iterator.next();
+ if (next) {
+ args.push(wrapIterator(next));
+ } else {
+ args.push(cb);
+ }
+ ensureAsync(iterator).apply(null, args);
+ }
+ });
}
- var tag = getTag$1(value),
- func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
-
- return func(value);
- }
+ wrapIterator(iterator(tasks))();
+ }
+
+ function until(test, iterator, cb) {
+ return whilst(function () {
+ return !test.apply(this, arguments);
+ }, iterator, cb);
+ }
+
+ function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+ }
- function reduce(arr, memo, iterator, cb) {
- eachOfSeries(arr, function (x, i, cb) {
- iterator(memo, x, function (err, v) {
- memo = v;
- cb(err);
- });
- }, function (err) {
- cb(err, memo);
- });
- }
+ function transform(arr, memo, iterator, callback) {
+ if (arguments.length === 3) {
+ callback = iterator;
+ iterator = memo;
+ memo = isArray(arr) ? [] : {};
+ }
- function reduceRight(arr, memo, iterator, cb) {
- var reversed = toArray(arr).reverse();
- reduce(reversed, memo, iterator, cb);
+ eachOf(arr, function (v, k, cb) {
+ iterator(memo, v, k, cb);
+ }, function (err) {
+ callback(err, memo);
+ });
+ }
+
+ function _asyncMap(eachfn, arr, iterator, callback) {
+ callback = once(callback || noop);
+ arr = arr || [];
+ var results = isArrayLike(arr) ? [] : {};
+ eachfn(arr, function (value, index, callback) {
+ iterator(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+ }
+
+ var mapSeries = doSeries(_asyncMap);
+
+ var nativeCeil = Math.ceil;
+ var nativeMax$2 = Math.max;
+ /**
+ * The base implementation of `_.range` and `_.rangeRight`.
+ *
+ * @private
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the new array of numbers.
+ */
+ function baseRange(start, end, step, fromRight) {
+ start = toNumber(start);
+ start = start === start ? start : 0;
+
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ } else {
+ end = toNumber(end) || 0;
}
+ step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0);
- function eachOfLimit(obj, limit, iterator, cb) {
- _eachOfLimit(limit)(obj, iterator, cb);
- }
+ var index = -1,
+ length = nativeMax$2(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
- function _withoutIndex(iterator) {
- return function (value, index, callback) {
- return iterator(value, callback);
- };
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
}
+ return result;
+ }
- function eachLimit(arr, limit, iterator, cb) {
- return _eachOfLimit(limit)(arr, _withoutIndex(iterator), cb);
- }
+ function timesSeries (count, iterator, callback) {
+ mapSeries(baseRange(0, count, 1), iterator, callback);
+ }
- function eachSeries(arr, iterator, cb) {
- return eachOfSeries(arr, _withoutIndex(iterator), cb);
- }
+ var mapLimit = doParallelLimit(_asyncMap);
- function each(arr, iterator, cb) {
- return eachOf(arr, _withoutIndex(iterator), cb);
- }
+ function timeLimit(count, limit, iterator, cb) {
+ return mapLimit(baseRange(0, count, 1), limit, iterator, cb);
+ }
- /**
- * This method returns the first argument provided to it.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.identity(object) === object;
- * // => true
- */
- function identity(value) {
- return value;
- }
+ var map = doParallel(_asyncMap);
- function _createTester(eachfn, check, getResult) {
- return function (arr, limit, iterator, cb) {
- function done() {
- if (cb) cb(getResult(false, void 0));
- }
- function iteratee(x, _, callback) {
- if (!cb) return callback();
- iterator(x, function (v) {
- if (cb && check(v)) {
- cb(getResult(true, x));
- cb = iterator = false;
- }
- callback();
- });
- }
- if (arguments.length > 3) {
- eachfn(arr, limit, iteratee, done);
- } else {
- cb = iterator;
- iterator = limit;
- eachfn(arr, iteratee, done);
- }
- };
- }
+ function times (count, iterator, callback) {
+ map(baseRange(0, count, 1), iterator, callback);
+ }
- var some = _createTester(eachOf, Boolean, identity);
+ function sortBy(arr, iterator, cb) {
+ map(arr, function (x, cb) {
+ iterator(x, function (err, criteria) {
+ if (err) return cb(err);
+ cb(null, { value: x, criteria: criteria });
+ });
+ }, function (err, results) {
+ if (err) return cb(err);
+ cb(null, arrayMap(results.sort(comparator), baseProperty('value')));
+ });
- function notId(v) {
- return !v;
- }
+ function comparator(left, right) {
+ var a = left.criteria,
+ b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+ }
+
+ var someLimit = _createTester(eachOfLimit, Boolean, identity);
+
+ function _parallel(eachfn, tasks, callback) {
+ callback = callback || noop;
+ var results = isArrayLike(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ task(rest(function (err, args) {
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[key] = args;
+ callback(err);
+ }));
+ }, function (err) {
+ callback(err, results);
+ });
+ }
+
+ function series(tasks, cb) {
+ return _parallel(eachOfSeries, tasks, cb);
+ }
+
+ function seq() /* functions... */{
+ var fns = arguments;
+ return rest(function (args) {
+ var that = this;
+
+ var cb = args[args.length - 1];
+ if (typeof cb == 'function') {
+ args.pop();
+ } else {
+ cb = noop;
+ }
- var every = _createTester(eachOf, notId, notId);
-
- function whilst(test, iterator, cb) {
- cb = cb || noop;
- if (!test()) return cb(null);
- var next = rest(function (err, args) {
- if (err) return cb(err);
- if (test.apply(this, args)) return iterator(next);
- cb.apply(null, [null].concat(args));
- });
- iterator(next);
- }
+ reduce(fns, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat([rest(function (err, nextargs) {
+ cb(err, nextargs);
+ })]));
+ }, function (err, results) {
+ cb.apply(that, [err].concat(results));
+ });
+ });
+ }
- function ensureAsync(fn) {
- return rest(function (args) {
- var callback = args.pop();
- args.push(function () {
- var innerArgs = arguments;
- if (sync) {
- setImmediate$1(function () {
- callback.apply(null, innerArgs);
- });
- } else {
- callback.apply(null, innerArgs);
- }
- });
- var sync = true;
- fn.apply(this, args);
- sync = false;
- });
- }
+ function retry(times, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
- function iterator (tasks) {
- function makeCallback(index) {
- function fn() {
- if (tasks.length) {
- tasks[index].apply(null, arguments);
- }
- return fn.next();
- }
- fn.next = function () {
- return index < tasks.length - 1 ? makeCallback(index + 1) : null;
- };
- return fn;
- }
- return makeCallback(0);
- }
+ var attempts = [];
- function waterfall (tasks, cb) {
- cb = once(cb || noop);
- if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
- if (!tasks.length) return cb();
-
- function wrapIterator(iterator) {
- return rest(function (err, args) {
- if (err) {
- cb.apply(null, [err].concat(args));
- } else {
- var next = iterator.next();
- if (next) {
- args.push(wrapIterator(next));
- } else {
- args.push(cb);
- }
- ensureAsync(iterator).apply(null, args);
- }
- });
- }
- wrapIterator(iterator(tasks))();
- }
+ var opts = {
+ times: DEFAULT_TIMES,
+ interval: DEFAULT_INTERVAL
+ };
- function until(test, iterator, cb) {
- return whilst(function () {
- return !test.apply(this, arguments);
- }, iterator, cb);
- }
+ function parseTimes(acc, t) {
+ if (typeof t === 'number') {
+ acc.times = parseInt(t, 10) || DEFAULT_TIMES;
+ } else if (typeof t === 'object') {
+ acc.times = parseInt(t.times, 10) || DEFAULT_TIMES;
+ acc.interval = parseInt(t.interval, 10) || DEFAULT_INTERVAL;
+ } else {
+ throw new Error('Unsupported argument type for \'times\': ' + typeof t);
+ }
+ }
- function unmemoize(fn) {
- return function () {
- return (fn.unmemoized || fn).apply(null, arguments);
- };
- }
+ var length = arguments.length;
+ if (length < 1 || length > 3) {
+ throw new Error('Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)');
+ } else if (length <= 2 && typeof times === 'function') {
+ callback = task;
+ task = times;
+ }
+ if (typeof times !== 'function') {
+ parseTimes(opts, times);
+ }
+ opts.callback = callback;
+ opts.task = task;
+
+ function wrappedTask(wrappedCallback, wrappedResults) {
+ function retryAttempt(task, finalAttempt) {
+ return function (seriesCallback) {
+ task(function (err, result) {
+ seriesCallback(!err || finalAttempt, {
+ err: err,
+ result: result
+ });
+ }, wrappedResults);
+ };
+ }
- function transform(arr, memo, iterator, callback) {
- if (arguments.length === 3) {
- callback = iterator;
- iterator = memo;
- memo = isArray(arr) ? [] : {};
- }
+ function retryInterval(interval) {
+ return function (seriesCallback) {
+ setTimeout(function () {
+ seriesCallback(null);
+ }, interval);
+ };
+ }
- eachOf(arr, function (v, k, cb) {
- iterator(memo, v, k, cb);
- }, function (err) {
- callback(err, memo);
- });
- }
+ while (opts.times) {
- function _asyncMap(eachfn, arr, iterator, callback) {
- callback = once(callback || noop);
- arr = arr || [];
- var results = isArrayLike(arr) ? [] : {};
- eachfn(arr, function (value, index, callback) {
- iterator(value, function (err, v) {
- results[index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
+ var finalAttempt = !(opts.times -= 1);
+ attempts.push(retryAttempt(opts.task, finalAttempt));
+ if (!finalAttempt && opts.interval > 0) {
+ attempts.push(retryInterval(opts.interval));
+ }
+ }
- var mapSeries = doSeries(_asyncMap);
-
- var nativeCeil = Math.ceil;
- var nativeMax$2 = Math.max;
- /**
- * The base implementation of `_.range` and `_.rangeRight`.
- *
- * @private
- * @param {number} [start=0] The start of the range.
- * @param {number} end The end of the range.
- * @param {number} [step=1] The value to increment or decrement by.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Array} Returns the new array of numbers.
- */
- function baseRange(start, end, step, fromRight) {
- start = toNumber(start);
- start = start === start ? start : 0;
-
- if (end === undefined) {
- end = start;
- start = 0;
- } else {
- end = toNumber(end) || 0;
+ series(attempts, function (done, data) {
+ data = data[data.length - 1];
+ (wrappedCallback || opts.callback)(data.err, data.result);
+ });
}
- step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0);
-
- var index = -1,
- length = nativeMax$2(nativeCeil((end - start) / (step || 1)), 0),
- result = Array(length);
- while (length--) {
- result[fromRight ? length : ++index] = start;
- start += step;
+ // If a callback is passed, run this as a controll flow
+ return opts.callback ? wrappedTask() : wrappedTask;
+ }
+
+ function reject$1(eachfn, arr, iterator, callback) {
+ _filter(eachfn, arr, function (value, cb) {
+ iterator(value, function (v) {
+ cb(!v);
+ });
+ }, callback);
+ }
+
+ var rejectSeries = doSeries(reject$1);
+
+ var rejectLimit = doParallelLimit(reject$1);
+
+ var reject = doParallel(reject$1);
+
+ /**
+ * A specialized version of `_.forEach` for arrays without support for
+ * callback 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.length;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
}
- return result;
}
+ return array;
+ }
- /**
- * Checks if the provided arguments are from an iteratee call.
- *
- * @private
- * @param {*} value The potential iteratee value argument.
- * @param {*} index The potential iteratee index or key argument.
- * @param {*} object The potential iteratee object argument.
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
- */
- function isIterateeCall(value, index, object) {
- if (!isObject(object)) {
- return false;
+ function queue$1(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ } else if (concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
}
- var type = typeof index;
- if (type == 'number'
- ? (isArrayLike(object) && isIndex(index, object.length))
- : (type == 'string' && index in object)) {
- var other = object[index];
- return value === value ? (value === other) : (other !== other);
+ function _insert(q, data, pos, 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 (pos) {
+ q.tasks.unshift(item);
+ } else {
+ q.tasks.push(item);
+ }
+
+ if (q.tasks.length === q.concurrency) {
+ q.saturated();
+ }
+ });
+ setImmediate$1(q.process);
}
- return false;
- }
-
- /**
- * Creates an array of numbers (positive and/or negative) progressing from
- * `start` up to, but not including, `end`. A step of `-1` is used if a negative
- * `start` is specified without an `end` or `step`. If `end` is not specified
- * it's set to `start` with `start` then set to `0`. If `end` is less than
- * `start` a zero-length range is created unless a negative `step` is specified.
- *
- * **Note:** JavaScript follows the IEEE-754 standard for resolving
- * floating-point values which can produce unexpected results.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {number} [start=0] The start of the range.
- * @param {number} end The end of the range.
- * @param {number} [step=1] The value to increment or decrement by.
- * @returns {Array} Returns the new array of numbers.
- * @example
- *
- * _.range(4);
- * // => [0, 1, 2, 3]
- *
- * _.range(-4);
- * // => [0, -1, -2, -3]
- *
- * _.range(1, 5);
- * // => [1, 2, 3, 4]
- *
- * _.range(0, 20, 5);
- * // => [0, 5, 10, 15]
- *
- * _.range(0, -4, -1);
- * // => [0, -1, -2, -3]
- *
- * _.range(1, 4, 0);
- * // => [1, 1, 1]
- *
- * _.range(0);
- * // => []
- */
- function range(start, end, step) {
- if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
- end = step = undefined;
+ function _next(q, tasks) {
+ return function () {
+ workers -= 1;
+
+ var removed = false;
+ var args = arguments;
+ arrayEach(tasks, function (task) {
+ arrayEach(workersList, function (worker, index) {
+ if (worker === task && !removed) {
+ workersList.splice(index, 1);
+ removed = true;
+ }
+ });
+
+ task.callback.apply(task, args);
+ });
+ if (q.tasks.length + workers === 0) {
+ q.drain();
+ }
+ q.process();
+ };
}
- return baseRange(start, end, step);
- }
-
- function timesSeries (count, iterator, callback) {
- mapSeries(range(0, count), iterator, callback);
- }
-
- var mapLimit = doParallelLimit(_asyncMap);
-
- function timeLimit(count, limit, iterator, cb) {
- return mapLimit(range(0, count), limit, iterator, cb);
- }
-
- var map = doParallel(_asyncMap);
-
- function times (count, iterator, callback) {
- map(range(0, count), iterator, callback);
- }
-
- function sortBy(arr, iterator, cb) {
- map(arr, function (x, cb) {
- iterator(x, function (err, criteria) {
- if (err) return cb(err);
- cb(null, { value: x, criteria: criteria });
- });
- }, function (err, results) {
- if (err) return cb(err);
- cb(null, arrayMap(results.sort(comparator), property('value')));
- });
-
- function comparator(left, right) {
- var a = left.criteria,
- b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }
- }
- var someLimit = _createTester(eachOfLimit, Boolean, identity);
-
- function _parallel(eachfn, tasks, callback) {
- callback = callback || noop;
- var results = isArrayLike(tasks) ? [] : {};
-
- eachfn(tasks, function (task, key, callback) {
- task(rest(function (err, args) {
- if (args.length <= 1) {
- args = args[0];
- }
- results[key] = args;
- callback(err);
- }));
- }, function (err) {
- callback(err, results);
- });
- }
-
- function series(tasks, cb) {
- return _parallel(eachOfSeries, tasks, cb);
- }
-
- function seq() /* functions... */{
- var fns = arguments;
- return rest(function (args) {
- var that = this;
-
- var cb = args[args.length - 1];
- if (typeof cb == 'function') {
- args.pop();
- } else {
- cb = noop;
- }
-
- reduce(fns, args, function (newargs, fn, cb) {
- fn.apply(that, newargs.concat([rest(function (err, nextargs) {
- cb(err, nextargs);
- })]));
- }, function (err, results) {
- cb.apply(that, [err].concat(results));
- });
- });
- }
-
- function retry(times, task, callback) {
- var DEFAULT_TIMES = 5;
- var DEFAULT_INTERVAL = 0;
-
- var attempts = [];
-
- var opts = {
- times: DEFAULT_TIMES,
- interval: DEFAULT_INTERVAL
- };
-
- function parseTimes(acc, t) {
- if (typeof t === 'number') {
- acc.times = parseInt(t, 10) || DEFAULT_TIMES;
- } else if (typeof t === 'object') {
- acc.times = parseInt(t.times, 10) || DEFAULT_TIMES;
- acc.interval = parseInt(t.interval, 10) || DEFAULT_INTERVAL;
- } else {
- throw new Error('Unsupported argument type for \'times\': ' + typeof t);
- }
- }
-
- var length = arguments.length;
- if (length < 1 || length > 3) {
- throw new Error('Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)');
- } else if (length <= 2 && typeof times === 'function') {
- callback = task;
- task = times;
- }
- if (typeof times !== 'function') {
- parseTimes(opts, times);
- }
- opts.callback = callback;
- opts.task = task;
-
- function wrappedTask(wrappedCallback, wrappedResults) {
- function retryAttempt(task, finalAttempt) {
- return function (seriesCallback) {
- task(function (err, result) {
- seriesCallback(!err || finalAttempt, {
- err: err,
- result: result
- });
- }, wrappedResults);
- };
- }
-
- function retryInterval(interval) {
- return function (seriesCallback) {
- setTimeout(function () {
- seriesCallback(null);
- }, interval);
- };
- }
-
- while (opts.times) {
-
- var finalAttempt = !(opts.times -= 1);
- attempts.push(retryAttempt(opts.task, finalAttempt));
- if (!finalAttempt && opts.interval > 0) {
- attempts.push(retryInterval(opts.interval));
- }
- }
-
- series(attempts, function (done, data) {
- data = data[data.length - 1];
- (wrappedCallback || opts.callback)(data.err, data.result);
- });
- }
-
- // If a callback is passed, run this as a controll flow
- return opts.callback ? wrappedTask() : wrappedTask;
- }
-
- function reject$1(eachfn, arr, iterator, callback) {
- _filter(eachfn, arr, function (value, cb) {
- iterator(value, function (v) {
- cb(!v);
- });
- }, callback);
- }
-
- var rejectSeries = doSeries(reject$1);
-
- var rejectLimit = doParallelLimit(reject$1);
-
- var reject = doParallel(reject$1);
-
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * callback 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.length;
-
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
+ var workers = 0;
+ var workersList = [];
+ var q = {
+ tasks: [],
+ concurrency: concurrency,
+ payload: payload,
+ saturated: noop,
+ empty: noop,
+ drain: noop,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(q, data, false, callback);
+ },
+ kill: function () {
+ q.drain = noop;
+ q.tasks = [];
+ },
+ unshift: function (data, callback) {
+ _insert(q, data, true, callback);
+ },
+ process: function () {
+ while (!q.paused && workers < q.concurrency && q.tasks.length) {
+
+ var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
+
+ var data = arrayMap(tasks, baseProperty('data'));
+
+ if (q.tasks.length === 0) {
+ q.empty();
+ }
+ workers += 1;
+ workersList.push(tasks[0]);
+ var cb = onlyOnce(_next(q, 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;
+ }
+
+ function queue (worker, concurrency) {
+ return queue$1(function (items, cb) {
+ worker(items[0], cb);
+ }, concurrency, 1);
+ }
+
+ function priorityQueue (worker, concurrency) {
+ function _compareTasks(a, b) {
+ return a.priority - b.priority;
}
- return array;
- }
-
- function queue$1(worker, concurrency, payload) {
- if (concurrency == null) {
- concurrency = 1;
- } else if (concurrency === 0) {
- throw new Error('Concurrency must not be zero');
- }
- function _insert(q, data, pos, 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 (pos) {
- q.tasks.unshift(item);
- } else {
- q.tasks.push(item);
- }
-
- if (q.tasks.length === q.concurrency) {
- q.saturated();
- }
- });
- setImmediate$1(q.process);
- }
- function _next(q, tasks) {
- return function () {
- workers -= 1;
-
- var removed = false;
- var args = arguments;
- arrayEach(tasks, function (task) {
- arrayEach(workersList, function (worker, index) {
- if (worker === task && !removed) {
- workersList.splice(index, 1);
- removed = true;
- }
- });
-
- task.callback.apply(task, args);
- });
- if (q.tasks.length + workers === 0) {
- q.drain();
- }
- q.process();
- };
- }
-
- var workers = 0;
- var workersList = [];
- var q = {
- tasks: [],
- concurrency: concurrency,
- payload: payload,
- saturated: noop,
- empty: noop,
- drain: noop,
- started: false,
- paused: false,
- push: function (data, callback) {
- _insert(q, data, false, callback);
- },
- kill: function () {
- q.drain = noop;
- q.tasks = [];
- },
- unshift: function (data, callback) {
- _insert(q, data, true, callback);
- },
- process: function () {
- while (!q.paused && workers < q.concurrency && q.tasks.length) {
-
- var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
-
- var data = arrayMap(tasks, property('data'));
-
- if (q.tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- workersList.push(tasks[0]);
- var cb = onlyOnce(_next(q, 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;
- }
- function queue (worker, concurrency) {
- return queue$1(function (items, cb) {
- worker(items[0], cb);
- }, concurrency, 1);
- }
-
- function priorityQueue (worker, concurrency) {
- function _compareTasks(a, b) {
- return a.priority - b.priority;
- }
+ function _binarySearch(sequence, item, compare) {
+ var beg = -1,
+ end = sequence.length - 1;
+ while (beg < end) {
+ var mid = beg + (end - beg + 1 >>> 1);
+ if (compare(item, sequence[mid]) >= 0) {
+ beg = mid;
+ } else {
+ end = mid - 1;
+ }
+ }
+ return beg;
+ }
- function _binarySearch(sequence, item, compare) {
- var beg = -1,
- end = sequence.length - 1;
- while (beg < end) {
- var mid = beg + (end - beg + 1 >>> 1);
- if (compare(item, sequence[mid]) >= 0) {
- beg = mid;
- } else {
- end = mid - 1;
- }
- }
- return beg;
- }
+ function _insert(q, data, priority, 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) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function () {
+ q.drain();
+ });
+ }
+ arrayEach(data, function (task) {
+ var item = {
+ data: task,
+ priority: priority,
+ callback: typeof callback === 'function' ? callback : noop
+ };
+
+ q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);
+
+ if (q.tasks.length === q.concurrency) {
+ q.saturated();
+ }
+ setImmediate$1(q.process);
+ });
+ }
- function _insert(q, data, priority, 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) {
- // call drain immediately if there are no tasks
- return setImmediate$1(function () {
- q.drain();
- });
- }
- arrayEach(data, function (task) {
- var item = {
- data: task,
- priority: priority,
- callback: typeof callback === 'function' ? callback : noop
- };
-
- q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);
-
- if (q.tasks.length === q.concurrency) {
- q.saturated();
- }
- setImmediate$1(q.process);
- });
- }
+ // Start with a normal queue
+ var q = queue(worker, concurrency);
- // Start with a normal queue
- var q = queue(worker, concurrency);
+ // Override push to accept second parameter representing priority
+ q.push = function (data, priority, callback) {
+ _insert(q, data, priority, callback);
+ };
- // Override push to accept second parameter representing priority
- q.push = function (data, priority, callback) {
- _insert(q, data, priority, callback);
- };
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+ }
+
+ function parallelLimit(tasks, limit, cb) {
+ return _parallel(_eachOfLimit(limit), tasks, cb);
+ }
+
+ function parallel(tasks, cb) {
+ return _parallel(eachOf, tasks, cb);
+ }
+
+ var nexTick = typeof process === 'object' && typeof process.nextTick === 'function' ? process.nextTick : setImmediate$1;
+
+ function memoize(fn, hasher) {
+ var memo = {};
+ var queues = {};
+ hasher = hasher || identity;
+ var memoized = rest(function memoized(args) {
+ var callback = args.pop();
+ var key = hasher.apply(null, args);
+ if (key in memo) {
+ setImmediate$1(function () {
+ callback.apply(null, memo[key]);
+ });
+ } else if (key in queues) {
+ queues[key].push(callback);
+ } else {
+ queues[key] = [callback];
+ fn.apply(null, args.concat([rest(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;
+ }
+
+ function consoleFunc(name) {
+ return rest(function (fn, args) {
+ fn.apply(null, args.concat([rest(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);
+ });
+ }
+ }
+ })]));
+ });
+ }
- // Remove unshift function
- delete q.unshift;
+ var log = consoleFunc('log');
- return q;
- }
+ function forever(fn, cb) {
+ var done = onlyOnce(cb || noop);
+ var task = ensureAsync(fn);
- function parallelLimit(tasks, limit, cb) {
- return _parallel(_eachOfLimit(limit), tasks, cb);
- }
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+ }
- function parallel(tasks, cb) {
- return _parallel(eachOf, tasks, cb);
- }
+ var everyLimit = _createTester(eachOfLimit, notId, notId);
- var nexTick = typeof process === 'object' && typeof process.nextTick === 'function' ? process.nextTick : setImmediate$1;
-
- function memoize(fn, hasher) {
- var memo = {};
- var queues = {};
- hasher = hasher || identity;
- var memoized = rest(function memoized(args) {
- var callback = args.pop();
- var key = hasher.apply(null, args);
- if (key in memo) {
- setImmediate$1(function () {
- callback.apply(null, memo[key]);
- });
- } else if (key in queues) {
- queues[key].push(callback);
- } else {
- queues[key] = [callback];
- fn.apply(null, args.concat([rest(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;
- }
+ function during(test, iterator, cb) {
+ cb = cb || noop;
- function consoleFunc(name) {
- return rest(function (fn, args) {
- fn.apply(null, args.concat([rest(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 next = rest(function (err, args) {
+ if (err) {
+ cb(err);
+ } else {
+ args.push(check);
+ test.apply(this, args);
+ }
+ });
- var log = consoleFunc('log');
+ var check = function (err, truth) {
+ if (err) return cb(err);
+ if (!truth) return cb(null);
+ iterator(next);
+ };
- function forever(fn, cb) {
- var done = onlyOnce(cb || noop);
- var task = ensureAsync(fn);
+ test(check);
+ }
- function next(err) {
- if (err) return done(err);
- task(next);
- }
- next();
- }
+ function doWhilst(iterator, test, cb) {
+ var calls = 0;
+ return whilst(function () {
+ return ++calls <= 1 || test.apply(this, arguments);
+ }, iterator, cb);
+ }
- var everyLimit = _createTester(eachOfLimit, notId, notId);
+ function doUntil(iterator, test, cb) {
+ return doWhilst(iterator, function () {
+ return !test.apply(this, arguments);
+ }, cb);
+ }
- function during(test, iterator, cb) {
- cb = cb || noop;
+ function doDuring(iterator, test, cb) {
+ var calls = 0;
- var next = rest(function (err, args) {
- if (err) {
- cb(err);
- } else {
- args.push(check);
- test.apply(this, args);
- }
- });
+ during(function (next) {
+ if (calls++ < 1) return next(null, true);
+ test.apply(this, arguments);
+ }, iterator, cb);
+ }
- var check = function (err, truth) {
- if (err) return cb(err);
- if (!truth) return cb(null);
- iterator(next);
- };
+ var dir = consoleFunc('dir');
- test(check);
- }
+ function _findGetResult(v, x) {
+ return x;
+ }
- function doWhilst(iterator, test, cb) {
- var calls = 0;
- return whilst(function () {
- return ++calls <= 1 || test.apply(this, arguments);
- }, iterator, cb);
- }
+ var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
- function doUntil(iterator, test, cb) {
- return doWhilst(iterator, function () {
- return !test.apply(this, arguments);
- }, cb);
- }
+ var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
- function doDuring(iterator, test, cb) {
- var calls = 0;
+ var detect = _createTester(eachOf, identity, _findGetResult);
- during(function (next) {
- if (calls++ < 1) return next(null, true);
- test.apply(this, arguments);
- }, iterator, cb);
- }
+ var constant = rest(function (values) {
+ var args = [null].concat(values);
+ return function (cb) {
+ return cb.apply(this, args);
+ };
+ });
- var dir = consoleFunc('dir');
+ 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 _findGetResult(v, x) {
- return x;
- }
+ var concatSeries = doSeries(concat$1);
- var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
-
- var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
-
- var detect = _createTester(eachOf, identity, _findGetResult);
-
- var constant = rest(function (values) {
- var args = [null].concat(values);
- return function (cb) {
- return cb.apply(this, args);
- };
- });
-
- 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);
- });
- }
+ var concat = doParallel(concat$1);
- var concatSeries = doSeries(concat$1);
+ var reverse = Array.prototype.reverse;
- var concat = doParallel(concat$1);
+ function compose() /* functions... */{
+ return seq.apply(null, reverse.call(arguments));
+ }
- var reverse = Array.prototype.reverse;
+ function cargo(worker, payload) {
+ return queue$1(worker, 1, payload);
+ }
- function compose() /* functions... */{
- return seq.apply(null, reverse.call(arguments));
- }
+ /**
+ * A specialized version of `_.every` for arrays without support for
+ * callback shorthands.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`.
+ */
+ function arrayEvery(array, predicate) {
+ var index = -1,
+ length = array.length;
- function cargo(worker, payload) {
- return queue$1(worker, 1, payload);
+ while (++index < length) {
+ if (!predicate(array[index], index, array)) {
+ return false;
+ }
}
-
- /**
- * A specialized version of `_.every` for arrays without support for
- * callback shorthands.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`.
- */
- function arrayEvery(array, predicate) {
+ return true;
+ }
+
+ /**
+ * Creates a base function for methods like `_.forIn`.
+ *
+ * @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;
- while (++index < length) {
- if (!predicate(array[index], index, array)) {
- return false;
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
}
}
- return true;
- }
-
- /**
- * Creates a base function for methods like `_.forIn`.
- *
- * @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 object;
- };
+ return object;
+ };
+ }
+
+ /**
+ * The base implementation of `baseForIn` and `baseForOwn` which iterates
+ * over `object` properties returned by `keysFunc` invoking `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 callback 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);
+ }
+
+ /**
+ * Converts `value` to a function if it's not one.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {Function} Returns the function.
+ */
+ function toFunction(value) {
+ return typeof value == 'function' ? value : identity;
+ }
+
+ /**
+ * Iterates over own enumerable properties of an object invoking `iteratee`
+ * for each property. The iteratee is invoked with three arguments:
+ * (value, key, object). Iteratee functions may exit iteration early by
+ * explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forOwn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => logs 'a' then 'b' (iteration order is not guaranteed)
+ */
+ function forOwn(object, iteratee) {
+ return object && baseForOwn(object, toFunction(iteratee));
+ }
+
+ /**
+ * Gets the index at which the first occurrence of `NaN` is found in `array`.
+ *
+ * @private
+ * @param {Array} array The array to search.
+ * @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 `NaN`, else `-1`.
+ */
+ function indexOfNaN(array, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 0 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ var other = array[index];
+ if (other !== other) {
+ return index;
+ }
}
-
- /**
- * The base implementation of `baseForIn` and `baseForOwn` which iterates
- * over `object` properties returned by `keysFunc` invoking `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 callback 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);
+ return -1;
+ }
+
+ /**
+ * 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 indexOfNaN(array, fromIndex);
+ }
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
}
-
- /**
- * Converts `value` to a function if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Function} Returns the function.
- */
- function toFunction(value) {
- return typeof value == 'function' ? value : identity;
+ return -1;
+ }
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeMax$1 = Math.max;
+
+ /**
+ * Gets the index at which the first occurrence of `value` is found in `array`
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * for equality comparisons. If `fromIndex` is negative, it's used as the offset
+ * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
+ * performs a faster binary search.
+ *
+ * @static
+ * @memberOf _
+ * @category Array
+ * @param {Array} array The array to search.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.indexOf([1, 2, 1, 2], 2);
+ * // => 1
+ *
+ * // using `fromIndex`
+ * _.indexOf([1, 2, 1, 2], 2, 2);
+ * // => 3
+ */
+ function indexOf(array, value, fromIndex) {
+ var length = array ? array.length : 0;
+ if (!length) {
+ return -1;
}
-
- /**
- * Iterates over own enumerable properties of an object invoking `iteratee`
- * for each property. The iteratee is invoked with three arguments:
- * (value, key, object). Iteratee functions may exit iteration early by
- * explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Object} Returns `object`.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.forOwn(new Foo, function(value, key) {
- * console.log(key);
- * });
- * // => logs 'a' then 'b' (iteration order is not guaranteed)
- */
- function forOwn(object, iteratee) {
- return object && baseForOwn(object, toFunction(iteratee));
+ fromIndex = toInteger(fromIndex);
+ if (fromIndex < 0) {
+ fromIndex = nativeMax$1(length + fromIndex, 0);
}
+ return baseIndexOf(array, value, fromIndex);
+ }
- /**
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
- *
- * @private
- * @param {Array} array The array to search.
- * @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 `NaN`, else `-1`.
- */
- function indexOfNaN(array, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 0 : -1);
-
- while ((fromRight ? index-- : ++index < length)) {
- var other = array[index];
- if (other !== other) {
- return index;
- }
+ function auto (tasks, concurrency, callback) {
+ if (typeof arguments[1] === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
}
- return -1;
- }
-
- /**
- * 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 indexOfNaN(array, fromIndex);
+ callback = once(callback || noop);
+ var keys$$ = keys(tasks);
+ var remainingTasks = keys$$.length;
+ if (!remainingTasks) {
+ return callback(null);
}
- var index = fromIndex - 1,
- length = array.length;
-
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
+ if (!concurrency) {
+ concurrency = remainingTasks;
}
- return -1;
- }
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax$1 = Math.max;
-
- /**
- * Gets the index at which the first occurrence of `value` is found in `array`
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons. If `fromIndex` is negative, it's used as the offset
- * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
- * performs a faster binary search.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to search.
- * @param {*} value The value to search for.
- * @param {number} [fromIndex=0] The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- * @example
- *
- * _.indexOf([1, 2, 1, 2], 2);
- * // => 1
- *
- * // using `fromIndex`
- * _.indexOf([1, 2, 1, 2], 2, 2);
- * // => 3
- */
- function indexOf(array, value, fromIndex) {
- var length = array ? array.length : 0;
- if (!length) {
- return -1;
+ var results = {};
+ var runningTasks = 0;
+
+ var listeners = [];
+ function addListener(fn) {
+ listeners.unshift(fn);
}
- fromIndex = toInteger(fromIndex);
- if (fromIndex < 0) {
- fromIndex = nativeMax$1(length + fromIndex, 0);
+ function removeListener(fn) {
+ var idx = indexOf(listeners, fn);
+ if (idx >= 0) listeners.splice(idx, 1);
+ }
+ function taskComplete() {
+ remainingTasks--;
+ arrayEach(listeners.slice(), function (fn) {
+ fn();
+ });
}
- return baseIndexOf(array, value, fromIndex);
- }
-
- function auto (tasks, concurrency, callback) {
- if (typeof arguments[1] === 'function') {
- // concurrency is optional, shift the args.
- callback = concurrency;
- concurrency = null;
- }
- callback = once(callback || noop);
- var keys$$ = keys(tasks);
- var remainingTasks = keys$$.length;
- if (!remainingTasks) {
- return callback(null);
- }
- if (!concurrency) {
- concurrency = remainingTasks;
- }
-
- var results = {};
- var runningTasks = 0;
-
- var listeners = [];
- function addListener(fn) {
- listeners.unshift(fn);
- }
- function removeListener(fn) {
- var idx = indexOf(listeners, fn);
- if (idx >= 0) listeners.splice(idx, 1);
- }
- function taskComplete() {
- remainingTasks--;
- arrayEach(listeners.slice(), function (fn) {
- fn();
- });
- }
-
- addListener(function () {
- if (!remainingTasks) {
- callback(null, results);
- }
- });
-
- arrayEach(keys$$, function (k) {
- var task = isArray(tasks[k]) ? tasks[k] : [tasks[k]];
- var taskCallback = rest(function (err, args) {
- runningTasks--;
- if (args.length <= 1) {
- args = args[0];
- }
- if (err) {
- var safeResults = {};
- forOwn(results, function (val, rkey) {
- safeResults[rkey] = val;
- });
- safeResults[k] = args;
- callback(err, safeResults);
- } else {
- results[k] = args;
- setImmediate$1(taskComplete);
- }
- });
- var requires = task.slice(0, task.length - 1);
- // prevent dead-locks
- var len = requires.length;
- var dep;
- while (len--) {
- if (!(dep = tasks[requires[len]])) {
- throw new Error('Has inexistant dependency');
- }
- if (isArray(dep) && indexOf(dep, k) >= 0) {
- throw new Error('Has cyclic dependencies');
- }
- }
- function ready() {
- return runningTasks < concurrency && arrayEvery(requires, function (x) {
- return results.hasOwnProperty(x);
- }) && !results.hasOwnProperty(k);
- }
- if (ready()) {
- runningTasks++;
- task[task.length - 1](taskCallback, results);
- } else {
- addListener(listener);
- }
- function listener() {
- if (ready()) {
- runningTasks++;
- removeListener(listener);
- task[task.length - 1](taskCallback, results);
- }
- }
- });
- }
- var apply = rest(function (fn, args) {
- return rest(function (callArgs) {
- return fn.apply(null, args.concat(callArgs));
- });
- });
-
- function _applyEach(eachfn) {
- return rest(function (fns, args) {
- var go = rest(function (args) {
- var that = this;
- var callback = args.pop();
- return eachfn(fns, function (fn, _, cb) {
- fn.apply(that, args.concat([cb]));
- }, callback);
- });
- if (args.length) {
- return go.apply(this, args);
- } else {
- return go;
- }
- });
- }
+ addListener(function () {
+ if (!remainingTasks) {
+ callback(null, results);
+ }
+ });
- var applyEachSeries = _applyEach(eachOfSeries);
-
- var applyEach = _applyEach(eachOf);
-
- var index = {
- applyEach: applyEach,
- applyEachSeries: applyEachSeries,
- apply: apply,
- asyncify: asyncify,
- auto: auto,
- 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: each,
- eachLimit: eachLimit,
- eachOf: eachOf,
- eachOfLimit: eachOfLimit,
- eachOfSeries: eachOfSeries,
- eachSeries: eachSeries,
- ensureAsync: ensureAsync,
- every: every,
- everyLimit: everyLimit,
- filter: filter,
- filterLimit: filterLimit,
- filterSeries: filterSeries,
- forever: forever,
- iterator: iterator,
- log: log,
- map: map,
- mapLimit: mapLimit,
- mapSeries: mapSeries,
- memoize: memoize,
- nextTick: nexTick,
- parallel: parallel,
- parallelLimit: parallelLimit,
- priorityQueue: priorityQueue,
- queue: queue,
- reduce: reduce,
- reduceRight: reduceRight,
- reject: reject,
- rejectLimit: rejectLimit,
- rejectSeries: rejectSeries,
- retry: retry,
- seq: seq,
- series: series,
- setImmediate: setImmediate$1,
- some: some,
- someLimit: someLimit,
- sortBy: sortBy,
- times: times,
- timesLimit: timeLimit,
- timesSeries: timesSeries,
- transform: transform,
- unmemoize: unmemoize,
- until: until,
- waterfall: waterfall,
- whilst: whilst,
-
- // aliases
- all: every,
- any: some,
- forEach: each,
- forEachSeries: eachSeries,
- forEachLimit: eachLimit,
- forEachOf: eachOf,
- forEachOfSeries: eachOfSeries,
- forEachOfLimit: eachOfLimit,
- inject: reduce,
- foldl: reduce,
- foldr: reduceRight,
- select: filter,
- selectLimit: filterLimit,
- selectSeries: filterSeries,
- wrapSync: asyncify
- };
+ arrayEach(keys$$, function (k) {
+ var task = isArray(tasks[k]) ? tasks[k] : [tasks[k]];
+ var taskCallback = rest(function (err, args) {
+ runningTasks--;
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ if (err) {
+ var safeResults = {};
+ forOwn(results, function (val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[k] = args;
+ callback(err, safeResults);
+ } else {
+ results[k] = args;
+ setImmediate$1(taskComplete);
+ }
+ });
+ var requires = task.slice(0, task.length - 1);
+ // prevent dead-locks
+ var len = requires.length;
+ var dep;
+ while (len--) {
+ if (!(dep = tasks[requires[len]])) {
+ throw new Error('Has inexistant dependency');
+ }
+ if (isArray(dep) && indexOf(dep, k) >= 0) {
+ throw new Error('Has cyclic dependencies');
+ }
+ }
+ function ready() {
+ return runningTasks < concurrency && !baseHas(results, k) && arrayEvery(requires, function (x) {
+ return baseHas(results, x);
+ });
+ }
+ if (ready()) {
+ runningTasks++;
+ task[task.length - 1](taskCallback, results);
+ } else {
+ addListener(listener);
+ }
+ function listener() {
+ if (ready()) {
+ runningTasks++;
+ removeListener(listener);
+ task[task.length - 1](taskCallback, results);
+ }
+ }
+ });
+ }
- exports['default'] = index;
- exports.applyEach = applyEach;
- exports.applyEachSeries = applyEachSeries;
- exports.apply = apply;
- exports.asyncify = asyncify;
- exports.auto = auto;
- 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 = each;
- exports.eachLimit = eachLimit;
- exports.eachOf = eachOf;
- exports.eachOfLimit = eachOfLimit;
- exports.eachOfSeries = eachOfSeries;
- exports.eachSeries = eachSeries;
- exports.ensureAsync = ensureAsync;
- exports.every = every;
- exports.everyLimit = everyLimit;
- exports.filter = filter;
- exports.filterLimit = filterLimit;
- exports.filterSeries = filterSeries;
- exports.forever = forever;
- exports.iterator = iterator;
- exports.log = log;
- exports.map = map;
- exports.mapLimit = mapLimit;
- exports.mapSeries = mapSeries;
- exports.memoize = memoize;
- exports.nextTick = nexTick;
- exports.parallel = parallel;
- exports.parallelLimit = parallelLimit;
- exports.priorityQueue = priorityQueue;
- exports.queue = queue;
- exports.reduce = reduce;
- exports.reduceRight = reduceRight;
- exports.reject = reject;
- exports.rejectLimit = rejectLimit;
- exports.rejectSeries = rejectSeries;
- exports.retry = retry;
- exports.seq = seq;
- exports.series = series;
- exports.setImmediate = setImmediate$1;
- exports.some = some;
- exports.someLimit = someLimit;
- exports.sortBy = sortBy;
- 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.any = some;
- exports.forEach = each;
- exports.forEachSeries = eachSeries;
- exports.forEachLimit = eachLimit;
- 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;
+ var apply = rest(function (fn, args) {
+ return rest(function (callArgs) {
+ return fn.apply(null, args.concat(callArgs));
+ });
+ });
+
+ function applyEach$1(eachfn) {
+ return rest(function (fns, args) {
+ var go = rest(function (args) {
+ var that = this;
+ var callback = args.pop();
+ return eachfn(fns, function (fn, _, cb) {
+ fn.apply(that, args.concat([cb]));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ } else {
+ return go;
+ }
+ });
+ }
+
+ var applyEachSeries = applyEach$1(eachOfSeries);
+
+ var applyEach = applyEach$1(eachOf);
+
+ var index = {
+ applyEach: applyEach,
+ applyEachSeries: applyEachSeries,
+ apply: apply,
+ asyncify: asyncify,
+ auto: auto,
+ 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: each,
+ eachLimit: eachLimit,
+ eachOf: eachOf,
+ eachOfLimit: eachOfLimit,
+ eachOfSeries: eachOfSeries,
+ eachSeries: eachSeries,
+ ensureAsync: ensureAsync,
+ every: every,
+ everyLimit: everyLimit,
+ filter: filter,
+ filterLimit: filterLimit,
+ filterSeries: filterSeries,
+ forever: forever,
+ iterator: iterator,
+ log: log,
+ map: map,
+ mapLimit: mapLimit,
+ mapSeries: mapSeries,
+ memoize: memoize,
+ nextTick: nexTick,
+ parallel: parallel,
+ parallelLimit: parallelLimit,
+ priorityQueue: priorityQueue,
+ queue: queue,
+ reduce: reduce,
+ reduceRight: reduceRight,
+ reject: reject,
+ rejectLimit: rejectLimit,
+ rejectSeries: rejectSeries,
+ retry: retry,
+ seq: seq,
+ series: series,
+ setImmediate: setImmediate$1,
+ some: some,
+ someLimit: someLimit,
+ sortBy: sortBy,
+ times: times,
+ timesLimit: timeLimit,
+ timesSeries: timesSeries,
+ transform: transform,
+ unmemoize: unmemoize,
+ until: until,
+ waterfall: waterfall,
+ whilst: whilst,
+
+ // aliases
+ all: every,
+ any: some,
+ forEach: each,
+ forEachSeries: eachSeries,
+ forEachLimit: eachLimit,
+ 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;
+ exports.asyncify = asyncify;
+ exports.auto = auto;
+ 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 = each;
+ exports.eachLimit = eachLimit;
+ exports.eachOf = eachOf;
+ exports.eachOfLimit = eachOfLimit;
+ exports.eachOfSeries = eachOfSeries;
+ exports.eachSeries = eachSeries;
+ exports.ensureAsync = ensureAsync;
+ exports.every = every;
+ exports.everyLimit = everyLimit;
+ exports.filter = filter;
+ exports.filterLimit = filterLimit;
+ exports.filterSeries = filterSeries;
+ exports.forever = forever;
+ exports.iterator = iterator;
+ exports.log = log;
+ exports.map = map;
+ exports.mapLimit = mapLimit;
+ exports.mapSeries = mapSeries;
+ exports.memoize = memoize;
+ exports.nextTick = nexTick;
+ exports.parallel = parallel;
+ exports.parallelLimit = parallelLimit;
+ exports.priorityQueue = priorityQueue;
+ exports.queue = queue;
+ exports.reduce = reduce;
+ exports.reduceRight = reduceRight;
+ exports.reject = reject;
+ exports.rejectLimit = rejectLimit;
+ exports.rejectSeries = rejectSeries;
+ exports.retry = retry;
+ exports.seq = seq;
+ exports.series = series;
+ exports.setImmediate = setImmediate$1;
+ exports.some = some;
+ exports.someLimit = someLimit;
+ exports.sortBy = sortBy;
+ 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.any = some;
+ exports.forEach = each;
+ exports.forEachSeries = eachSeries;
+ exports.forEachLimit = eachLimit;
+ 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
diff --git a/build/async-cjs.js b/build/async-cjs.js
index 0dc28c5..7c0daa6 100644
--- a/build/async-cjs.js
+++ b/build/async-cjs.js
@@ -8,6 +8,8 @@ var arrayEach = require('lodash/internal/arrayEach');
arrayEach = 'default' in arrayEach ? arrayEach['default'] : arrayEach;
var arrayEvery = require('lodash/internal/arrayEvery');
arrayEvery = 'default' in arrayEvery ? arrayEvery['default'] : arrayEvery;
+var baseHas = require('lodash/internal/baseHas');
+baseHas = 'default' in baseHas ? baseHas['default'] : baseHas;
var forOwn = require('lodash/object/forOwn');
forOwn = 'default' in forOwn ? forOwn['default'] : forOwn;
var indexOf = require('lodash/array/indexOf');
@@ -22,13 +24,11 @@ var once = require('lodash/function/once');
once = 'default' in once ? once['default'] : once;
var identity = require('lodash/utility/identity');
identity = 'default' in identity ? identity['default'] : identity;
-var toArray = require('lodash/lang/toArray');
-toArray = 'default' in toArray ? toArray['default'] : toArray;
var arrayMap = require('lodash/internal/arrayMap');
arrayMap = 'default' in arrayMap ? arrayMap['default'] : arrayMap;
-var property = require('lodash/utility/property');
+var property = require('lodash/internal/baseProperty');
property = 'default' in property ? property['default'] : property;
-var range = require('lodash/utility/range');
+var range = require('lodash/internal/baseRange');
range = 'default' in range ? range['default'] : range;
var isArrayLike = require('lodash/lang/isArrayLike');
isArrayLike = 'default' in isArrayLike ? isArrayLike['default'] : isArrayLike;
@@ -252,8 +252,10 @@ function reduce(arr, memo, iterator, cb) {
});
}
+var slice = Array.prototype.slice;
+
function reduceRight(arr, memo, iterator, cb) {
- var reversed = toArray(arr).reverse();
+ var reversed = slice.call(arr).reverse();
reduce(reversed, memo, iterator, cb);
}
@@ -326,6 +328,7 @@ function whilst(test, iterator, cb) {
function ensureAsync(fn) {
return rest(function (args) {
var callback = args.pop();
+ var sync = true;
args.push(function () {
var innerArgs = arguments;
if (sync) {
@@ -336,7 +339,6 @@ function ensureAsync(fn) {
callback.apply(null, innerArgs);
}
});
- var sync = true;
fn.apply(this, args);
sync = false;
});
@@ -424,19 +426,19 @@ function _asyncMap(eachfn, arr, iterator, callback) {
var mapSeries = doSeries(_asyncMap);
function timesSeries (count, iterator, callback) {
- mapSeries(range(0, count), iterator, callback);
+ mapSeries(range(0, count, 1), iterator, callback);
}
var mapLimit = doParallelLimit(_asyncMap);
function timeLimit(count, limit, iterator, cb) {
- return mapLimit(range(0, count), limit, iterator, cb);
+ return mapLimit(range(0, count, 1), limit, iterator, cb);
}
var map = doParallel(_asyncMap);
function times (count, iterator, callback) {
- map(range(0, count), iterator, callback);
+ map(range(0, count, 1), iterator, callback);
}
function sortBy(arr, iterator, cb) {
@@ -1021,9 +1023,9 @@ function auto (tasks, concurrency, callback) {
}
}
function ready() {
- return runningTasks < concurrency && arrayEvery(requires, function (x) {
- return results.hasOwnProperty(x);
- }) && !results.hasOwnProperty(k);
+ return runningTasks < concurrency && !baseHas(results, k) && arrayEvery(requires, function (x) {
+ return baseHas(results, x);
+ });
}
if (ready()) {
runningTasks++;
@@ -1047,7 +1049,7 @@ var apply = rest(function (fn, args) {
});
});
-function _applyEach(eachfn) {
+function applyEach$1(eachfn) {
return rest(function (fns, args) {
var go = rest(function (args) {
var that = this;
@@ -1064,9 +1066,9 @@ function _applyEach(eachfn) {
});
}
-var applyEachSeries = _applyEach(eachOfSeries);
+var applyEachSeries = applyEach$1(eachOfSeries);
-var applyEach = _applyEach(eachOf);
+var applyEach = applyEach$1(eachOf);
var index = {
applyEach: applyEach,
diff --git a/build/modules/auto.js b/build/modules/auto.js
index 09e7a64..542bd45 100644
--- a/build/modules/auto.js
+++ b/build/modules/auto.js
@@ -76,9 +76,9 @@ exports.default = function (tasks, concurrency, callback) {
}
}
function ready() {
- return runningTasks < concurrency && (0, _arrayEvery2.default)(requires, function (x) {
- return results.hasOwnProperty(x);
- }) && !results.hasOwnProperty(k);
+ return runningTasks < concurrency && !(0, _baseHas2.default)(results, k) && (0, _arrayEvery2.default)(requires, function (x) {
+ return (0, _baseHas2.default)(results, x);
+ });
}
if (ready()) {
runningTasks++;
@@ -104,6 +104,10 @@ var _arrayEvery = require('lodash/internal/arrayEvery');
var _arrayEvery2 = _interopRequireDefault(_arrayEvery);
+var _baseHas = require('lodash/internal/baseHas');
+
+var _baseHas2 = _interopRequireDefault(_baseHas);
+
var _forOwn = require('lodash/object/forOwn');
var _forOwn2 = _interopRequireDefault(_forOwn);
diff --git a/build/modules/ensureAsync.js b/build/modules/ensureAsync.js
index 7421922..edd5644 100644
--- a/build/modules/ensureAsync.js
+++ b/build/modules/ensureAsync.js
@@ -18,6 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function ensureAsync(fn) {
return (0, _rest2.default)(function (args) {
var callback = args.pop();
+ var sync = true;
args.push(function () {
var innerArgs = arguments;
if (sync) {
@@ -28,7 +29,6 @@ function ensureAsync(fn) {
callback.apply(null, innerArgs);
}
});
- var sync = true;
fn.apply(this, args);
sync = false;
});
diff --git a/build/modules/internal/applyEach.js b/build/modules/internal/applyEach.js
index d085ea1..3ed9476 100644
--- a/build/modules/internal/applyEach.js
+++ b/build/modules/internal/applyEach.js
@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-exports.default = _applyEach;
+exports.default = applyEach;
var _rest = require('lodash/function/rest');
@@ -11,7 +11,7 @@ var _rest2 = _interopRequireDefault(_rest);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-function _applyEach(eachfn) {
+function applyEach(eachfn) {
return (0, _rest2.default)(function (fns, args) {
var go = (0, _rest2.default)(function (args) {
var that = this;
diff --git a/build/modules/internal/filter.js b/build/modules/internal/filter.js
index 6af3c01..de83504 100644
--- a/build/modules/internal/filter.js
+++ b/build/modules/internal/filter.js
@@ -9,9 +9,9 @@ var _arrayMap = require('lodash/internal/arrayMap');
var _arrayMap2 = _interopRequireDefault(_arrayMap);
-var _property = require('lodash/utility/property');
+var _baseProperty = require('lodash/internal/baseProperty');
-var _property2 = _interopRequireDefault(_property);
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -27,6 +27,6 @@ function _filter(eachfn, arr, iterator, callback) {
}, function () {
callback((0, _arrayMap2.default)(results.sort(function (a, b) {
return a.index - b.index;
- }), (0, _property2.default)('value')));
+ }), (0, _baseProperty2.default)('value')));
});
} \ No newline at end of file
diff --git a/build/modules/internal/queue.js b/build/modules/internal/queue.js
index 1ae7c95..da9ad24 100644
--- a/build/modules/internal/queue.js
+++ b/build/modules/internal/queue.js
@@ -21,9 +21,9 @@ var _noop = require('lodash/utility/noop');
var _noop2 = _interopRequireDefault(_noop);
-var _property = require('lodash/utility/property');
+var _baseProperty = require('lodash/internal/baseProperty');
-var _property2 = _interopRequireDefault(_property);
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
var _onlyOnce = require('./onlyOnce');
@@ -122,7 +122,7 @@ function queue(worker, concurrency, payload) {
var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
- var data = (0, _arrayMap2.default)(tasks, (0, _property2.default)('data'));
+ var data = (0, _arrayMap2.default)(tasks, (0, _baseProperty2.default)('data'));
if (q.tasks.length === 0) {
q.empty();
diff --git a/build/modules/reduceRight.js b/build/modules/reduceRight.js
index 7970b9a..d52a2d7 100644
--- a/build/modules/reduceRight.js
+++ b/build/modules/reduceRight.js
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = reduceRight;
-var _toArray = require('lodash/lang/toArray');
-
-var _toArray2 = _interopRequireDefault(_toArray);
-
var _reduce = require('./reduce');
var _reduce2 = _interopRequireDefault(_reduce);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+var slice = Array.prototype.slice;
+
function reduceRight(arr, memo, iterator, cb) {
- var reversed = (0, _toArray2.default)(arr).reverse();
+ var reversed = slice.call(arr).reverse();
(0, _reduce2.default)(reversed, memo, iterator, cb);
} \ No newline at end of file
diff --git a/build/modules/sortBy.js b/build/modules/sortBy.js
index b901f16..0599b91 100644
--- a/build/modules/sortBy.js
+++ b/build/modules/sortBy.js
@@ -9,9 +9,9 @@ var _arrayMap = require('lodash/internal/arrayMap');
var _arrayMap2 = _interopRequireDefault(_arrayMap);
-var _property = require('lodash/utility/property');
+var _baseProperty = require('lodash/internal/baseProperty');
-var _property2 = _interopRequireDefault(_property);
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
var _map = require('./map');
@@ -27,7 +27,7 @@ function sortBy(arr, iterator, cb) {
});
}, function (err, results) {
if (err) return cb(err);
- cb(null, (0, _arrayMap2.default)(results.sort(comparator), (0, _property2.default)('value')));
+ cb(null, (0, _arrayMap2.default)(results.sort(comparator), (0, _baseProperty2.default)('value')));
});
function comparator(left, right) {
diff --git a/build/modules/times.js b/build/modules/times.js
index d2d72be..938b627 100644
--- a/build/modules/times.js
+++ b/build/modules/times.js
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = function (count, iterator, callback) {
- (0, _map2.default)((0, _range2.default)(0, count), iterator, callback);
+ (0, _map2.default)((0, _baseRange2.default)(0, count, 1), iterator, callback);
};
var _map = require('./map');
var _map2 = _interopRequireDefault(_map);
-var _range = require('lodash/utility/range');
+var _baseRange = require('lodash/internal/baseRange');
-var _range2 = _interopRequireDefault(_range);
+var _baseRange2 = _interopRequireDefault(_baseRange);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file
diff --git a/build/modules/timesLimit.js b/build/modules/timesLimit.js
index a48e6a4..ebe687c 100644
--- a/build/modules/timesLimit.js
+++ b/build/modules/timesLimit.js
@@ -9,12 +9,12 @@ var _mapLimit = require('./mapLimit');
var _mapLimit2 = _interopRequireDefault(_mapLimit);
-var _range = require('lodash/utility/range');
+var _baseRange = require('lodash/internal/baseRange');
-var _range2 = _interopRequireDefault(_range);
+var _baseRange2 = _interopRequireDefault(_baseRange);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function timeLimit(count, limit, iterator, cb) {
- return (0, _mapLimit2.default)((0, _range2.default)(0, count), limit, iterator, cb);
+ return (0, _mapLimit2.default)((0, _baseRange2.default)(0, count, 1), limit, iterator, cb);
} \ No newline at end of file
diff --git a/build/modules/timesSeries.js b/build/modules/timesSeries.js
index 66d1471..cd655ec 100644
--- a/build/modules/timesSeries.js
+++ b/build/modules/timesSeries.js
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = function (count, iterator, callback) {
- (0, _mapSeries2.default)((0, _range2.default)(0, count), iterator, callback);
+ (0, _mapSeries2.default)((0, _baseRange2.default)(0, count, 1), iterator, callback);
};
var _mapSeries = require('./mapSeries');
var _mapSeries2 = _interopRequireDefault(_mapSeries);
-var _range = require('lodash/utility/range');
+var _baseRange = require('lodash/internal/baseRange');
-var _range2 = _interopRequireDefault(_range);
+var _baseRange2 = _interopRequireDefault(_baseRange);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file
diff --git a/lib/auto.js b/lib/auto.js
index 35fd012..262e59b 100644
--- a/lib/auto.js
+++ b/lib/auto.js
@@ -2,6 +2,7 @@
import arrayEach from 'lodash/internal/arrayEach';
import arrayEvery from 'lodash/internal/arrayEvery';
+import baseHas from 'lodash/internal/baseHas';
import forOwn from 'lodash/object/forOwn';
import indexOf from 'lodash/array/indexOf';
import isArray from 'lodash/lang/isArray';
@@ -85,9 +86,10 @@ export default function (tasks, concurrency, callback) {
}
}
function ready() {
- return runningTasks < concurrency && arrayEvery(requires, function (x) {
- return results.hasOwnProperty(x);
- }) && !results.hasOwnProperty(k);
+ return runningTasks < concurrency && !baseHas(results, k) &&
+ arrayEvery(requires, function (x) {
+ return baseHas(results, x);
+ });
}
if (ready()) {
runningTasks++;
diff --git a/lib/ensureAsync.js b/lib/ensureAsync.js
index 8b7b208..ae5f131 100644
--- a/lib/ensureAsync.js
+++ b/lib/ensureAsync.js
@@ -7,6 +7,7 @@ import setImmediate from './internal/setImmediate';
export default function ensureAsync(fn) {
return rest(function (args) {
var callback = args.pop();
+ var sync = true;
args.push(function () {
var innerArgs = arguments;
if (sync) {
@@ -17,7 +18,6 @@ export default function ensureAsync(fn) {
callback.apply(null, innerArgs);
}
});
- var sync = true;
fn.apply(this, args);
sync = false;
});
diff --git a/lib/internal/applyEach.js b/lib/internal/applyEach.js
index aa13cc2..bb18978 100644
--- a/lib/internal/applyEach.js
+++ b/lib/internal/applyEach.js
@@ -2,7 +2,7 @@
import rest from 'lodash/function/rest';
-export default function _applyEach(eachfn) {
+export default function applyEach(eachfn) {
return rest(function(fns, args) {
var go = rest(function(args) {
var that = this;
diff --git a/lib/internal/filter.js b/lib/internal/filter.js
index 83242fa..9f2ba87 100644
--- a/lib/internal/filter.js
+++ b/lib/internal/filter.js
@@ -1,7 +1,7 @@
'use strict';
import arrayMap from 'lodash/internal/arrayMap';
-import property from 'lodash/utility/property';
+import property from 'lodash/internal/baseProperty';
export default function _filter(eachfn, arr, iterator, callback) {
var results = [];
diff --git a/lib/internal/queue.js b/lib/internal/queue.js
index 8d5c081..7dce0e5 100644
--- a/lib/internal/queue.js
+++ b/lib/internal/queue.js
@@ -4,7 +4,7 @@ import arrayEach from 'lodash/internal/arrayEach';
import arrayMap from 'lodash/internal/arrayMap';
import isArray from 'lodash/lang/isArray';
import noop from 'lodash/utility/noop';
-import property from 'lodash/utility/property';
+import property from 'lodash/internal/baseProperty';
import onlyOnce from './onlyOnce';
import setImmediate from './setImmediate';
diff --git a/lib/reduceRight.js b/lib/reduceRight.js
index f465dbe..730e320 100644
--- a/lib/reduceRight.js
+++ b/lib/reduceRight.js
@@ -1,9 +1,10 @@
'use strict';
-import toArray from 'lodash/lang/toArray';
import reduce from './reduce';
+var slice = Array.prototype.slice;
+
export default function reduceRight (arr, memo, iterator, cb) {
- var reversed = toArray(arr).reverse();
+ var reversed = slice.call(arr).reverse();
reduce(reversed, memo, iterator, cb);
}
diff --git a/lib/sortBy.js b/lib/sortBy.js
index 033a6c8..8507c89 100644
--- a/lib/sortBy.js
+++ b/lib/sortBy.js
@@ -1,7 +1,7 @@
'use strict';
import arrayMap from 'lodash/internal/arrayMap';
-import property from 'lodash/utility/property';
+import property from 'lodash/internal/baseProperty';
import map from './map';
diff --git a/lib/times.js b/lib/times.js
index 48430d4..493d3c1 100644
--- a/lib/times.js
+++ b/lib/times.js
@@ -1,8 +1,8 @@
'use strict';
import map from './map';
-import range from 'lodash/utility/range';
+import range from 'lodash/internal/baseRange';
export default function (count, iterator, callback) {
- map(range(0, count), iterator, callback);
+ map(range(0, count, 1), iterator, callback);
}
diff --git a/lib/timesLimit.js b/lib/timesLimit.js
index d2af3d9..2f3559e 100644
--- a/lib/timesLimit.js
+++ b/lib/timesLimit.js
@@ -1,8 +1,8 @@
'use strict';
import mapLimit from './mapLimit';
-import range from 'lodash/utility/range';
+import range from 'lodash/internal/baseRange';
export default function timeLimit(count, limit, iterator, cb) {
- return mapLimit(range(0, count), limit, iterator, cb);
+ return mapLimit(range(0, count, 1), limit, iterator, cb);
}
diff --git a/lib/timesSeries.js b/lib/timesSeries.js
index 410d942..4377acb 100644
--- a/lib/timesSeries.js
+++ b/lib/timesSeries.js
@@ -1,8 +1,8 @@
'use strict';
import mapSeries from './mapSeries';
-import range from 'lodash/utility/range';
+import range from 'lodash/internal/baseRange';
export default function (count, iterator, callback) {
- mapSeries(range(0, count), iterator, callback);
+ mapSeries(range(0, count, 1), iterator, callback);
}