UNPKG

119 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3 typeof define === 'function' && define.amd ? define(['exports'], factory) :
4 (factory((global.async = global.async || {})));
5}(this, function (exports) { 'use strict';
6
7 /**
8 * A faster alternative to `Function#apply`, this function invokes `func`
9 * with the `this` binding of `thisArg` and the arguments of `args`.
10 *
11 * @private
12 * @param {Function} func The function to invoke.
13 * @param {*} thisArg The `this` binding of `func`.
14 * @param {...*} args The arguments to invoke `func` with.
15 * @returns {*} Returns the result of `func`.
16 */
17 function apply(func, thisArg, args) {
18 var length = args.length;
19 switch (length) {
20 case 0: return func.call(thisArg);
21 case 1: return func.call(thisArg, args[0]);
22 case 2: return func.call(thisArg, args[0], args[1]);
23 case 3: return func.call(thisArg, args[0], args[1], args[2]);
24 }
25 return func.apply(thisArg, args);
26 }
27
28 /**
29 * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
30 * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
31 *
32 * @static
33 * @memberOf _
34 * @category Lang
35 * @param {*} value The value to check.
36 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
37 * @example
38 *
39 * _.isObject({});
40 * // => true
41 *
42 * _.isObject([1, 2, 3]);
43 * // => true
44 *
45 * _.isObject(_.noop);
46 * // => true
47 *
48 * _.isObject(null);
49 * // => false
50 */
51 function isObject(value) {
52 var type = typeof value;
53 return !!value && (type == 'object' || type == 'function');
54 }
55
56 var funcTag = '[object Function]';
57 var genTag = '[object GeneratorFunction]';
58 /** Used for built-in method references. */
59 var objectProto = Object.prototype;
60
61 /**
62 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
63 * of values.
64 */
65 var objectToString = objectProto.toString;
66
67 /**
68 * Checks if `value` is classified as a `Function` object.
69 *
70 * @static
71 * @memberOf _
72 * @category Lang
73 * @param {*} value The value to check.
74 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
75 * @example
76 *
77 * _.isFunction(_);
78 * // => true
79 *
80 * _.isFunction(/abc/);
81 * // => false
82 */
83 function isFunction(value) {
84 // The use of `Object#toString` avoids issues with the `typeof` operator
85 // in Safari 8 which returns 'object' for typed array and weak map constructors,
86 // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
87 var tag = isObject(value) ? objectToString.call(value) : '';
88 return tag == funcTag || tag == genTag;
89 }
90
91 /** Used as references for various `Number` constants. */
92 var NAN = 0 / 0;
93
94 /** Used to match leading and trailing whitespace. */
95 var reTrim = /^\s+|\s+$/g;
96
97 /** Used to detect bad signed hexadecimal string values. */
98 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
99
100 /** Used to detect binary string values. */
101 var reIsBinary = /^0b[01]+$/i;
102
103 /** Used to detect octal string values. */
104 var reIsOctal = /^0o[0-7]+$/i;
105
106 /** Built-in method references without a dependency on `root`. */
107 var freeParseInt = parseInt;
108
109 /**
110 * Converts `value` to a number.
111 *
112 * @static
113 * @memberOf _
114 * @category Lang
115 * @param {*} value The value to process.
116 * @returns {number} Returns the number.
117 * @example
118 *
119 * _.toNumber(3);
120 * // => 3
121 *
122 * _.toNumber(Number.MIN_VALUE);
123 * // => 5e-324
124 *
125 * _.toNumber(Infinity);
126 * // => Infinity
127 *
128 * _.toNumber('3');
129 * // => 3
130 */
131 function toNumber(value) {
132 if (isObject(value)) {
133 var other = isFunction(value.valueOf) ? value.valueOf() : value;
134 value = isObject(other) ? (other + '') : other;
135 }
136 if (typeof value != 'string') {
137 return value === 0 ? value : +value;
138 }
139 value = value.replace(reTrim, '');
140 var isBinary = reIsBinary.test(value);
141 return (isBinary || reIsOctal.test(value))
142 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
143 : (reIsBadHex.test(value) ? NAN : +value);
144 }
145
146 var INFINITY = 1 / 0;
147 var MAX_INTEGER = 1.7976931348623157e+308;
148 /**
149 * Converts `value` to an integer.
150 *
151 * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
152 *
153 * @static
154 * @memberOf _
155 * @category Lang
156 * @param {*} value The value to convert.
157 * @returns {number} Returns the converted integer.
158 * @example
159 *
160 * _.toInteger(3);
161 * // => 3
162 *
163 * _.toInteger(Number.MIN_VALUE);
164 * // => 0
165 *
166 * _.toInteger(Infinity);
167 * // => 1.7976931348623157e+308
168 *
169 * _.toInteger('3');
170 * // => 3
171 */
172 function toInteger(value) {
173 if (!value) {
174 return value === 0 ? value : 0;
175 }
176 value = toNumber(value);
177 if (value === INFINITY || value === -INFINITY) {
178 var sign = (value < 0 ? -1 : 1);
179 return sign * MAX_INTEGER;
180 }
181 var remainder = value % 1;
182 return value === value ? (remainder ? value - remainder : value) : 0;
183 }
184
185 /** Used as the `TypeError` message for "Functions" methods. */
186 var FUNC_ERROR_TEXT = 'Expected a function';
187
188 /* Built-in method references for those with the same name as other `lodash` methods. */
189 var nativeMax = Math.max;
190
191 /**
192 * Creates a function that invokes `func` with the `this` binding of the
193 * created function and arguments from `start` and beyond provided as an array.
194 *
195 * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters).
196 *
197 * @static
198 * @memberOf _
199 * @category Function
200 * @param {Function} func The function to apply a rest parameter to.
201 * @param {number} [start=func.length-1] The start position of the rest parameter.
202 * @returns {Function} Returns the new function.
203 * @example
204 *
205 * var say = _.rest(function(what, names) {
206 * return what + ' ' + _.initial(names).join(', ') +
207 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
208 * });
209 *
210 * say('hello', 'fred', 'barney', 'pebbles');
211 * // => 'hello fred, barney, & pebbles'
212 */
213 function rest(func, start) {
214 if (typeof func != 'function') {
215 throw new TypeError(FUNC_ERROR_TEXT);
216 }
217 start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
218 return function() {
219 var args = arguments,
220 index = -1,
221 length = nativeMax(args.length - start, 0),
222 array = Array(length);
223
224 while (++index < length) {
225 array[index] = args[start + index];
226 }
227 switch (start) {
228 case 0: return func.call(this, array);
229 case 1: return func.call(this, args[0], array);
230 case 2: return func.call(this, args[0], args[1], array);
231 }
232 var otherArgs = Array(start + 1);
233 index = -1;
234 while (++index < start) {
235 otherArgs[index] = args[index];
236 }
237 otherArgs[start] = array;
238 return apply(func, this, otherArgs);
239 };
240 }
241
242 function initialParams (fn) {
243 return rest(function (args /*..., callback*/) {
244 var callback = args.pop();
245 fn(args, callback);
246 });
247 }
248
249 function applyEach$1(eachfn) {
250 return rest(function (fns, args) {
251 var go = initialParams(function (args, callback) {
252 var that = this;
253 return eachfn(fns, function (fn, _, cb) {
254 fn.apply(that, args.concat([cb]));
255 }, callback);
256 });
257 if (args.length) {
258 return go.apply(this, args);
259 } else {
260 return go;
261 }
262 });
263 }
264
265 /**
266 * A no-operation function that returns `undefined` regardless of the
267 * arguments it receives.
268 *
269 * @static
270 * @memberOf _
271 * @category Util
272 * @example
273 *
274 * var object = { 'user': 'fred' };
275 *
276 * _.noop(object) === undefined;
277 * // => true
278 */
279 function noop() {
280 // No operation performed.
281 }
282
283 /** Used as the `TypeError` message for "Functions" methods. */
284 var FUNC_ERROR_TEXT$1 = 'Expected a function';
285
286 /**
287 * Creates a function that invokes `func`, with the `this` binding and arguments
288 * of the created function, while it's called less than `n` times. Subsequent
289 * calls to the created function return the result of the last `func` invocation.
290 *
291 * @static
292 * @memberOf _
293 * @category Function
294 * @param {number} n The number of calls at which `func` is no longer invoked.
295 * @param {Function} func The function to restrict.
296 * @returns {Function} Returns the new restricted function.
297 * @example
298 *
299 * jQuery(element).on('click', _.before(5, addContactToList));
300 * // => allows adding up to 4 contacts to the list
301 */
302 function before(n, func) {
303 var result;
304 if (typeof func != 'function') {
305 throw new TypeError(FUNC_ERROR_TEXT$1);
306 }
307 n = toInteger(n);
308 return function() {
309 if (--n > 0) {
310 result = func.apply(this, arguments);
311 }
312 if (n <= 1) {
313 func = undefined;
314 }
315 return result;
316 };
317 }
318
319 /**
320 * Creates a function that is restricted to invoking `func` once. Repeat calls
321 * to the function return the value of the first invocation. The `func` is
322 * invoked with the `this` binding and arguments of the created function.
323 *
324 * @static
325 * @memberOf _
326 * @category Function
327 * @param {Function} func The function to restrict.
328 * @returns {Function} Returns the new restricted function.
329 * @example
330 *
331 * var initialize = _.once(createApplication);
332 * initialize();
333 * initialize();
334 * // `initialize` invokes `createApplication` once
335 */
336 function once(func) {
337 return before(2, func);
338 }
339
340 /**
341 * The base implementation of `_.property` without support for deep paths.
342 *
343 * @private
344 * @param {string} key The key of the property to get.
345 * @returns {Function} Returns the new function.
346 */
347 function baseProperty(key) {
348 return function(object) {
349 return object == null ? undefined : object[key];
350 };
351 }
352
353 /**
354 * Gets the "length" property value of `object`.
355 *
356 * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
357 * that affects Safari on at least iOS 8.1-8.3 ARM64.
358 *
359 * @private
360 * @param {Object} object The object to query.
361 * @returns {*} Returns the "length" value.
362 */
363 var getLength = baseProperty('length');
364
365 /** Used as references for various `Number` constants. */
366 var MAX_SAFE_INTEGER = 9007199254740991;
367
368 /**
369 * Checks if `value` is a valid array-like length.
370 *
371 * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
372 *
373 * @static
374 * @memberOf _
375 * @category Lang
376 * @param {*} value The value to check.
377 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
378 * @example
379 *
380 * _.isLength(3);
381 * // => true
382 *
383 * _.isLength(Number.MIN_VALUE);
384 * // => false
385 *
386 * _.isLength(Infinity);
387 * // => false
388 *
389 * _.isLength('3');
390 * // => false
391 */
392 function isLength(value) {
393 return typeof value == 'number' &&
394 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
395 }
396
397 /**
398 * Checks if `value` is array-like. A value is considered array-like if it's
399 * not a function and has a `value.length` that's an integer greater than or
400 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
401 *
402 * @static
403 * @memberOf _
404 * @category Lang
405 * @param {*} value The value to check.
406 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
407 * @example
408 *
409 * _.isArrayLike([1, 2, 3]);
410 * // => true
411 *
412 * _.isArrayLike(document.body.children);
413 * // => true
414 *
415 * _.isArrayLike('abc');
416 * // => true
417 *
418 * _.isArrayLike(_.noop);
419 * // => false
420 */
421 function isArrayLike(value) {
422 return value != null && isLength(getLength(value)) && !isFunction(value);
423 }
424
425 var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
426
427 function getIterator (coll) {
428 return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
429 }
430
431 /** Used for built-in method references. */
432 var objectProto$1 = Object.prototype;
433
434 /** Used to check objects for own properties. */
435 var hasOwnProperty = objectProto$1.hasOwnProperty;
436
437 /** Built-in value references. */
438 var getPrototypeOf = Object.getPrototypeOf;
439
440 /**
441 * The base implementation of `_.has` without support for deep paths.
442 *
443 * @private
444 * @param {Object} object The object to query.
445 * @param {Array|string} key The key to check.
446 * @returns {boolean} Returns `true` if `key` exists, else `false`.
447 */
448 function baseHas(object, key) {
449 // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
450 // that are composed entirely of index properties, return `false` for
451 // `hasOwnProperty` checks of them.
452 return hasOwnProperty.call(object, key) ||
453 (typeof object == 'object' && key in object && getPrototypeOf(object) === null);
454 }
455
456 /* Built-in method references for those with the same name as other `lodash` methods. */
457 var nativeKeys = Object.keys;
458
459 /**
460 * The base implementation of `_.keys` which doesn't skip the constructor
461 * property of prototypes or treat sparse arrays as dense.
462 *
463 * @private
464 * @param {Object} object The object to query.
465 * @returns {Array} Returns the array of property names.
466 */
467 function baseKeys(object) {
468 return nativeKeys(Object(object));
469 }
470
471 /**
472 * The base implementation of `_.times` without support for iteratee shorthands
473 * or max array length checks.
474 *
475 * @private
476 * @param {number} n The number of times to invoke `iteratee`.
477 * @param {Function} iteratee The function invoked per iteration.
478 * @returns {Array} Returns the array of results.
479 */
480 function baseTimes(n, iteratee) {
481 var index = -1,
482 result = Array(n);
483
484 while (++index < n) {
485 result[index] = iteratee(index);
486 }
487 return result;
488 }
489
490 /**
491 * Checks if `value` is object-like. A value is object-like if it's not `null`
492 * and has a `typeof` result of "object".
493 *
494 * @static
495 * @memberOf _
496 * @category Lang
497 * @param {*} value The value to check.
498 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
499 * @example
500 *
501 * _.isObjectLike({});
502 * // => true
503 *
504 * _.isObjectLike([1, 2, 3]);
505 * // => true
506 *
507 * _.isObjectLike(_.noop);
508 * // => false
509 *
510 * _.isObjectLike(null);
511 * // => false
512 */
513 function isObjectLike(value) {
514 return !!value && typeof value == 'object';
515 }
516
517 /**
518 * This method is like `_.isArrayLike` except that it also checks if `value`
519 * is an object.
520 *
521 * @static
522 * @memberOf _
523 * @category Lang
524 * @param {*} value The value to check.
525 * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
526 * @example
527 *
528 * _.isArrayLikeObject([1, 2, 3]);
529 * // => true
530 *
531 * _.isArrayLikeObject(document.body.children);
532 * // => true
533 *
534 * _.isArrayLikeObject('abc');
535 * // => false
536 *
537 * _.isArrayLikeObject(_.noop);
538 * // => false
539 */
540 function isArrayLikeObject(value) {
541 return isObjectLike(value) && isArrayLike(value);
542 }
543
544 /** `Object#toString` result references. */
545 var argsTag = '[object Arguments]';
546
547 /** Used for built-in method references. */
548 var objectProto$2 = Object.prototype;
549
550 /** Used to check objects for own properties. */
551 var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
552
553 /**
554 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
555 * of values.
556 */
557 var objectToString$1 = objectProto$2.toString;
558
559 /** Built-in value references. */
560 var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
561
562 /**
563 * Checks if `value` is likely an `arguments` object.
564 *
565 * @static
566 * @memberOf _
567 * @category Lang
568 * @param {*} value The value to check.
569 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
570 * @example
571 *
572 * _.isArguments(function() { return arguments; }());
573 * // => true
574 *
575 * _.isArguments([1, 2, 3]);
576 * // => false
577 */
578 function isArguments(value) {
579 // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
580 return isArrayLikeObject(value) && hasOwnProperty$1.call(value, 'callee') &&
581 (!propertyIsEnumerable.call(value, 'callee') || objectToString$1.call(value) == argsTag);
582 }
583
584 /**
585 * Checks if `value` is classified as an `Array` object.
586 *
587 * @static
588 * @memberOf _
589 * @type {Function}
590 * @category Lang
591 * @param {*} value The value to check.
592 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
593 * @example
594 *
595 * _.isArray([1, 2, 3]);
596 * // => true
597 *
598 * _.isArray(document.body.children);
599 * // => false
600 *
601 * _.isArray('abc');
602 * // => false
603 *
604 * _.isArray(_.noop);
605 * // => false
606 */
607 var isArray = Array.isArray;
608
609 /** `Object#toString` result references. */
610 var stringTag = '[object String]';
611
612 /** Used for built-in method references. */
613 var objectProto$3 = Object.prototype;
614
615 /**
616 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
617 * of values.
618 */
619 var objectToString$2 = objectProto$3.toString;
620
621 /**
622 * Checks if `value` is classified as a `String` primitive or object.
623 *
624 * @static
625 * @memberOf _
626 * @category Lang
627 * @param {*} value The value to check.
628 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
629 * @example
630 *
631 * _.isString('abc');
632 * // => true
633 *
634 * _.isString(1);
635 * // => false
636 */
637 function isString(value) {
638 return typeof value == 'string' ||
639 (!isArray(value) && isObjectLike(value) && objectToString$2.call(value) == stringTag);
640 }
641
642 /**
643 * Creates an array of index keys for `object` values of arrays,
644 * `arguments` objects, and strings, otherwise `null` is returned.
645 *
646 * @private
647 * @param {Object} object The object to query.
648 * @returns {Array|null} Returns index keys, else `null`.
649 */
650 function indexKeys(object) {
651 var length = object ? object.length : undefined;
652 if (isLength(length) &&
653 (isArray(object) || isString(object) || isArguments(object))) {
654 return baseTimes(length, String);
655 }
656 return null;
657 }
658
659 /** Used as references for various `Number` constants. */
660 var MAX_SAFE_INTEGER$1 = 9007199254740991;
661
662 /** Used to detect unsigned integer values. */
663 var reIsUint = /^(?:0|[1-9]\d*)$/;
664
665 /**
666 * Checks if `value` is a valid array-like index.
667 *
668 * @private
669 * @param {*} value The value to check.
670 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
671 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
672 */
673 function isIndex(value, length) {
674 value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
675 length = length == null ? MAX_SAFE_INTEGER$1 : length;
676 return value > -1 && value % 1 == 0 && value < length;
677 }
678
679 /** Used for built-in method references. */
680 var objectProto$4 = Object.prototype;
681
682 /**
683 * Checks if `value` is likely a prototype object.
684 *
685 * @private
686 * @param {*} value The value to check.
687 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
688 */
689 function isPrototype(value) {
690 var Ctor = value && value.constructor,
691 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$4;
692
693 return value === proto;
694 }
695
696 /**
697 * Creates an array of the own enumerable property names of `object`.
698 *
699 * **Note:** Non-object values are coerced to objects. See the
700 * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
701 * for more details.
702 *
703 * @static
704 * @memberOf _
705 * @category Object
706 * @param {Object} object The object to query.
707 * @returns {Array} Returns the array of property names.
708 * @example
709 *
710 * function Foo() {
711 * this.a = 1;
712 * this.b = 2;
713 * }
714 *
715 * Foo.prototype.c = 3;
716 *
717 * _.keys(new Foo);
718 * // => ['a', 'b'] (iteration order is not guaranteed)
719 *
720 * _.keys('hi');
721 * // => ['0', '1']
722 */
723 function keys(object) {
724 var isProto = isPrototype(object);
725 if (!(isProto || isArrayLike(object))) {
726 return baseKeys(object);
727 }
728 var indexes = indexKeys(object),
729 skipIndexes = !!indexes,
730 result = indexes || [],
731 length = result.length;
732
733 for (var key in object) {
734 if (baseHas(object, key) &&
735 !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
736 !(isProto && key == 'constructor')) {
737 result.push(key);
738 }
739 }
740 return result;
741 }
742
743 function iterator(coll) {
744 var i = -1;
745 var len;
746 if (isArrayLike(coll)) {
747 len = coll.length;
748 return function next() {
749 i++;
750 return i < len ? { value: coll[i], key: i } : null;
751 };
752 }
753
754 var iterate = getIterator(coll);
755 if (iterate) {
756 return function next() {
757 var item = iterate.next();
758 if (item.done) return null;
759 i++;
760 return { value: item.value, key: i };
761 };
762 }
763
764 var okeys = keys(coll);
765 len = okeys.length;
766 return function next() {
767 i++;
768 var key = okeys[i];
769 return i < len ? { value: coll[key], key: key } : null;
770 };
771 }
772
773 function onlyOnce(fn) {
774 return function () {
775 if (fn === null) throw new Error("Callback was already called.");
776 fn.apply(this, arguments);
777 fn = null;
778 };
779 }
780
781 function _eachOfLimit(limit) {
782 return function (obj, iteratee, callback) {
783 callback = once(callback || noop);
784 obj = obj || [];
785 var nextElem = iterator(obj);
786 if (limit <= 0) {
787 return callback(null);
788 }
789 var done = false;
790 var running = 0;
791 var errored = false;
792
793 (function replenish() {
794 if (done && running <= 0) {
795 return callback(null);
796 }
797
798 while (running < limit && !errored) {
799 var elem = nextElem();
800 if (elem === null) {
801 done = true;
802 if (running <= 0) {
803 callback(null);
804 }
805 return;
806 }
807 running += 1;
808 iteratee(elem.value, elem.key, onlyOnce(function (err) {
809 running -= 1;
810 if (err) {
811 callback(err);
812 errored = true;
813 } else {
814 replenish();
815 }
816 }));
817 }
818 })();
819 };
820 }
821
822 function eachOfLimit(obj, limit, iteratee, cb) {
823 _eachOfLimit(limit)(obj, iteratee, cb);
824 }
825
826 function doLimit(fn, limit) {
827 return function (iterable, iteratee, callback) {
828 return fn(iterable, limit, iteratee, callback);
829 };
830 }
831
832 var eachOf = doLimit(eachOfLimit, Infinity);
833
834 var applyEach = applyEach$1(eachOf);
835
836 var eachOfSeries = doLimit(eachOfLimit, 1);
837
838 var applyEachSeries = applyEach$1(eachOfSeries);
839
840 var apply$1 = rest(function (fn, args) {
841 return rest(function (callArgs) {
842 return fn.apply(null, args.concat(callArgs));
843 });
844 });
845
846 function asyncify(func) {
847 return initialParams(function (args, callback) {
848 var result;
849 try {
850 result = func.apply(this, args);
851 } catch (e) {
852 return callback(e);
853 }
854 // if result is Promise object
855 if (isObject(result) && typeof result.then === 'function') {
856 result.then(function (value) {
857 callback(null, value);
858 })['catch'](function (err) {
859 callback(err.message ? err : new Error(err));
860 });
861 } else {
862 callback(null, result);
863 }
864 });
865 }
866
867 /**
868 * A specialized version of `_.forEach` for arrays without support for
869 * iteratee shorthands.
870 *
871 * @private
872 * @param {Array} array The array to iterate over.
873 * @param {Function} iteratee The function invoked per iteration.
874 * @returns {Array} Returns `array`.
875 */
876 function arrayEach(array, iteratee) {
877 var index = -1,
878 length = array.length;
879
880 while (++index < length) {
881 if (iteratee(array[index], index, array) === false) {
882 break;
883 }
884 }
885 return array;
886 }
887
888 /**
889 * This method returns the first argument given to it.
890 *
891 * @static
892 * @memberOf _
893 * @category Util
894 * @param {*} value Any value.
895 * @returns {*} Returns `value`.
896 * @example
897 *
898 * var object = { 'user': 'fred' };
899 *
900 * _.identity(object) === object;
901 * // => true
902 */
903 function identity(value) {
904 return value;
905 }
906
907 /**
908 * Casts `value` to `identity` if it's not a function.
909 *
910 * @private
911 * @param {*} value The value to inspect.
912 * @returns {Array} Returns the array-like object.
913 */
914 function baseCastFunction(value) {
915 return typeof value == 'function' ? value : identity;
916 }
917
918 /**
919 * Creates a base function for methods like `_.forIn`.
920 *
921 * @private
922 * @param {boolean} [fromRight] Specify iterating from right to left.
923 * @returns {Function} Returns the new base function.
924 */
925 function createBaseFor(fromRight) {
926 return function(object, iteratee, keysFunc) {
927 var index = -1,
928 iterable = Object(object),
929 props = keysFunc(object),
930 length = props.length;
931
932 while (length--) {
933 var key = props[fromRight ? length : ++index];
934 if (iteratee(iterable[key], key, iterable) === false) {
935 break;
936 }
937 }
938 return object;
939 };
940 }
941
942 /**
943 * The base implementation of `baseForIn` and `baseForOwn` which iterates
944 * over `object` properties returned by `keysFunc` invoking `iteratee` for
945 * each property. Iteratee functions may exit iteration early by explicitly
946 * returning `false`.
947 *
948 * @private
949 * @param {Object} object The object to iterate over.
950 * @param {Function} iteratee The function invoked per iteration.
951 * @param {Function} keysFunc The function to get the keys of `object`.
952 * @returns {Object} Returns `object`.
953 */
954 var baseFor = createBaseFor();
955
956 /**
957 * The base implementation of `_.forOwn` without support for iteratee shorthands.
958 *
959 * @private
960 * @param {Object} object The object to iterate over.
961 * @param {Function} iteratee The function invoked per iteration.
962 * @returns {Object} Returns `object`.
963 */
964 function baseForOwn(object, iteratee) {
965 return object && baseFor(object, iteratee, keys);
966 }
967
968 /**
969 * Iterates over own enumerable properties of an object invoking `iteratee`
970 * for each property. The iteratee is invoked with three arguments:
971 * (value, key, object). Iteratee functions may exit iteration early by
972 * explicitly returning `false`.
973 *
974 * @static
975 * @memberOf _
976 * @category Object
977 * @param {Object} object The object to iterate over.
978 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
979 * @returns {Object} Returns `object`.
980 * @example
981 *
982 * function Foo() {
983 * this.a = 1;
984 * this.b = 2;
985 * }
986 *
987 * Foo.prototype.c = 3;
988 *
989 * _.forOwn(new Foo, function(value, key) {
990 * console.log(key);
991 * });
992 * // => logs 'a' then 'b' (iteration order is not guaranteed)
993 */
994 function forOwn(object, iteratee) {
995 return object && baseForOwn(object, baseCastFunction(iteratee));
996 }
997
998 /**
999 * Gets the index at which the first occurrence of `NaN` is found in `array`.
1000 *
1001 * @private
1002 * @param {Array} array The array to search.
1003 * @param {number} fromIndex The index to search from.
1004 * @param {boolean} [fromRight] Specify iterating from right to left.
1005 * @returns {number} Returns the index of the matched `NaN`, else `-1`.
1006 */
1007 function indexOfNaN(array, fromIndex, fromRight) {
1008 var length = array.length,
1009 index = fromIndex + (fromRight ? 0 : -1);
1010
1011 while ((fromRight ? index-- : ++index < length)) {
1012 var other = array[index];
1013 if (other !== other) {
1014 return index;
1015 }
1016 }
1017 return -1;
1018 }
1019
1020 /**
1021 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1022 *
1023 * @private
1024 * @param {Array} array The array to search.
1025 * @param {*} value The value to search for.
1026 * @param {number} fromIndex The index to search from.
1027 * @returns {number} Returns the index of the matched value, else `-1`.
1028 */
1029 function baseIndexOf(array, value, fromIndex) {
1030 if (value !== value) {
1031 return indexOfNaN(array, fromIndex);
1032 }
1033 var index = fromIndex - 1,
1034 length = array.length;
1035
1036 while (++index < length) {
1037 if (array[index] === value) {
1038 return index;
1039 }
1040 }
1041 return -1;
1042 }
1043
1044 /* Built-in method references for those with the same name as other `lodash` methods. */
1045 var nativeMax$1 = Math.max;
1046
1047 /**
1048 * Gets the index at which the first occurrence of `value` is found in `array`
1049 * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
1050 * for equality comparisons. If `fromIndex` is negative, it's used as the offset
1051 * from the end of `array`.
1052 *
1053 * @static
1054 * @memberOf _
1055 * @category Array
1056 * @param {Array} array The array to search.
1057 * @param {*} value The value to search for.
1058 * @param {number} [fromIndex=0] The index to search from.
1059 * @returns {number} Returns the index of the matched value, else `-1`.
1060 * @example
1061 *
1062 * _.indexOf([1, 2, 1, 2], 2);
1063 * // => 1
1064 *
1065 * // Search from the `fromIndex`.
1066 * _.indexOf([1, 2, 1, 2], 2, 2);
1067 * // => 3
1068 */
1069 function indexOf(array, value, fromIndex) {
1070 var length = array ? array.length : 0;
1071 if (!length) {
1072 return -1;
1073 }
1074 fromIndex = toInteger(fromIndex);
1075 if (fromIndex < 0) {
1076 fromIndex = nativeMax$1(length + fromIndex, 0);
1077 }
1078 return baseIndexOf(array, value, fromIndex);
1079 }
1080
1081 function auto (tasks, concurrency, callback) {
1082 if (typeof concurrency === 'function') {
1083 // concurrency is optional, shift the args.
1084 callback = concurrency;
1085 concurrency = null;
1086 }
1087 callback = once(callback || noop);
1088 var keys$$ = keys(tasks);
1089 var numTasks = keys$$.length;
1090 if (!numTasks) {
1091 return callback(null);
1092 }
1093 if (!concurrency) {
1094 concurrency = numTasks;
1095 }
1096
1097 var results = {};
1098 var runningTasks = 0;
1099 var hasError = false;
1100
1101 var listeners = {};
1102
1103 var readyTasks = [];
1104
1105 forOwn(tasks, function (task, key) {
1106 if (!isArray(task)) {
1107 // no dependencies
1108 enqueueTask(key, [task]);
1109 return;
1110 }
1111
1112 var dependencies = task.slice(0, task.length - 1);
1113 var remainingDependencies = dependencies.length;
1114
1115 checkForDeadlocks();
1116
1117 function checkForDeadlocks() {
1118 var len = dependencies.length;
1119 var dep;
1120 while (len--) {
1121 if (!(dep = tasks[dependencies[len]])) {
1122 throw new Error('async.auto task `' + key + '` has non-existent dependency in ' + dependencies.join(', '));
1123 }
1124 if (isArray(dep) && indexOf(dep, key) >= 0) {
1125 throw new Error('async.auto task `' + key + '`Has cyclic dependencies');
1126 }
1127 }
1128 }
1129
1130 arrayEach(dependencies, function (dependencyName) {
1131 addListener(dependencyName, function () {
1132 remainingDependencies--;
1133 if (remainingDependencies === 0) {
1134 enqueueTask(key, task);
1135 }
1136 });
1137 });
1138 });
1139
1140 processQueue();
1141
1142 function enqueueTask(key, task) {
1143 readyTasks.push(function () {
1144 runTask(key, task);
1145 });
1146 }
1147
1148 function processQueue() {
1149 if (readyTasks.length === 0 && runningTasks === 0) {
1150 return callback(null, results);
1151 }
1152 while (readyTasks.length && runningTasks < concurrency) {
1153 var run = readyTasks.shift();
1154 run();
1155 }
1156 }
1157
1158 function addListener(taskName, fn) {
1159 var taskListeners = listeners[taskName];
1160 if (!taskListeners) {
1161 taskListeners = listeners[taskName] = [];
1162 }
1163
1164 taskListeners.push(fn);
1165 }
1166
1167 function taskComplete(taskName) {
1168 var taskListeners = listeners[taskName] || [];
1169 arrayEach(taskListeners, function (fn) {
1170 fn();
1171 });
1172 processQueue();
1173 }
1174
1175 function runTask(key, task) {
1176 if (hasError) return;
1177
1178 var taskCallback = onlyOnce(rest(function (err, args) {
1179 runningTasks--;
1180 if (args.length <= 1) {
1181 args = args[0];
1182 }
1183 if (err) {
1184 var safeResults = {};
1185 forOwn(results, function (val, rkey) {
1186 safeResults[rkey] = val;
1187 });
1188 safeResults[key] = args;
1189 hasError = true;
1190 listeners = [];
1191
1192 callback(err, safeResults);
1193 } else {
1194 results[key] = args;
1195 taskComplete(key);
1196 }
1197 }));
1198
1199 runningTasks++;
1200 var taskFn = task[task.length - 1];
1201 if (task.length > 1) {
1202 taskFn(results, taskCallback);
1203 } else {
1204 taskFn(taskCallback);
1205 }
1206 }
1207 }
1208
1209 /**
1210 * A specialized version of `_.map` for arrays without support for iteratee
1211 * shorthands.
1212 *
1213 * @private
1214 * @param {Array} array The array to iterate over.
1215 * @param {Function} iteratee The function invoked per iteration.
1216 * @returns {Array} Returns the new mapped array.
1217 */
1218 function arrayMap(array, iteratee) {
1219 var index = -1,
1220 length = array.length,
1221 result = Array(length);
1222
1223 while (++index < length) {
1224 result[index] = iteratee(array[index], index, array);
1225 }
1226 return result;
1227 }
1228
1229 /**
1230 * Removes all key-value entries from the stack.
1231 *
1232 * @private
1233 * @name clear
1234 * @memberOf Stack
1235 */
1236 function stackClear() {
1237 this.__data__ = { 'array': [], 'map': null };
1238 }
1239
1240 /**
1241 * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
1242 * comparison between two values to determine if they are equivalent.
1243 *
1244 * @static
1245 * @memberOf _
1246 * @category Lang
1247 * @param {*} value The value to compare.
1248 * @param {*} other The other value to compare.
1249 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1250 * @example
1251 *
1252 * var object = { 'user': 'fred' };
1253 * var other = { 'user': 'fred' };
1254 *
1255 * _.eq(object, object);
1256 * // => true
1257 *
1258 * _.eq(object, other);
1259 * // => false
1260 *
1261 * _.eq('a', 'a');
1262 * // => true
1263 *
1264 * _.eq('a', Object('a'));
1265 * // => false
1266 *
1267 * _.eq(NaN, NaN);
1268 * // => true
1269 */
1270 function eq(value, other) {
1271 return value === other || (value !== value && other !== other);
1272 }
1273
1274 /**
1275 * Gets the index at which the first occurrence of `key` is found in `array`
1276 * of key-value pairs.
1277 *
1278 * @private
1279 * @param {Array} array The array to search.
1280 * @param {*} key The key to search for.
1281 * @returns {number} Returns the index of the matched value, else `-1`.
1282 */
1283 function assocIndexOf(array, key) {
1284 var length = array.length;
1285 while (length--) {
1286 if (eq(array[length][0], key)) {
1287 return length;
1288 }
1289 }
1290 return -1;
1291 }
1292
1293 /** Used for built-in method references. */
1294 var arrayProto = Array.prototype;
1295
1296 /** Built-in value references. */
1297 var splice = arrayProto.splice;
1298
1299 /**
1300 * Removes `key` and its value from the associative array.
1301 *
1302 * @private
1303 * @param {Array} array The array to query.
1304 * @param {string} key The key of the value to remove.
1305 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1306 */
1307 function assocDelete(array, key) {
1308 var index = assocIndexOf(array, key);
1309 if (index < 0) {
1310 return false;
1311 }
1312 var lastIndex = array.length - 1;
1313 if (index == lastIndex) {
1314 array.pop();
1315 } else {
1316 splice.call(array, index, 1);
1317 }
1318 return true;
1319 }
1320
1321 /**
1322 * Removes `key` and its value from the stack.
1323 *
1324 * @private
1325 * @name delete
1326 * @memberOf Stack
1327 * @param {string} key The key of the value to remove.
1328 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1329 */
1330 function stackDelete(key) {
1331 var data = this.__data__,
1332 array = data.array;
1333
1334 return array ? assocDelete(array, key) : data.map['delete'](key);
1335 }
1336
1337 /**
1338 * Gets the associative array value for `key`.
1339 *
1340 * @private
1341 * @param {Array} array The array to query.
1342 * @param {string} key The key of the value to get.
1343 * @returns {*} Returns the entry value.
1344 */
1345 function assocGet(array, key) {
1346 var index = assocIndexOf(array, key);
1347 return index < 0 ? undefined : array[index][1];
1348 }
1349
1350 /**
1351 * Gets the stack value for `key`.
1352 *
1353 * @private
1354 * @name get
1355 * @memberOf Stack
1356 * @param {string} key The key of the value to get.
1357 * @returns {*} Returns the entry value.
1358 */
1359 function stackGet(key) {
1360 var data = this.__data__,
1361 array = data.array;
1362
1363 return array ? assocGet(array, key) : data.map.get(key);
1364 }
1365
1366 /**
1367 * Checks if an associative array value for `key` exists.
1368 *
1369 * @private
1370 * @param {Array} array The array to query.
1371 * @param {string} key The key of the entry to check.
1372 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1373 */
1374 function assocHas(array, key) {
1375 return assocIndexOf(array, key) > -1;
1376 }
1377
1378 /**
1379 * Checks if a stack value for `key` exists.
1380 *
1381 * @private
1382 * @name has
1383 * @memberOf Stack
1384 * @param {string} key The key of the entry to check.
1385 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1386 */
1387 function stackHas(key) {
1388 var data = this.__data__,
1389 array = data.array;
1390
1391 return array ? assocHas(array, key) : data.map.has(key);
1392 }
1393
1394 /**
1395 * Checks if `value` is a host object in IE < 9.
1396 *
1397 * @private
1398 * @param {*} value The value to check.
1399 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
1400 */
1401 function isHostObject(value) {
1402 // Many host objects are `Object` objects that can coerce to strings
1403 // despite having improperly defined `toString` methods.
1404 var result = false;
1405 if (value != null && typeof value.toString != 'function') {
1406 try {
1407 result = !!(value + '');
1408 } catch (e) {}
1409 }
1410 return result;
1411 }
1412
1413 /** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
1414 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1415
1416 /** Used to detect host constructors (Safari > 5). */
1417 var reIsHostCtor = /^\[object .+?Constructor\]$/;
1418
1419 /** Used for built-in method references. */
1420 var objectProto$6 = Object.prototype;
1421
1422 /** Used to resolve the decompiled source of functions. */
1423 var funcToString = Function.prototype.toString;
1424
1425 /** Used to check objects for own properties. */
1426 var hasOwnProperty$2 = objectProto$6.hasOwnProperty;
1427
1428 /** Used to detect if a method is native. */
1429 var reIsNative = RegExp('^' +
1430 funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
1431 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1432 );
1433
1434 /**
1435 * Checks if `value` is a native function.
1436 *
1437 * @static
1438 * @memberOf _
1439 * @category Lang
1440 * @param {*} value The value to check.
1441 * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
1442 * @example
1443 *
1444 * _.isNative(Array.prototype.push);
1445 * // => true
1446 *
1447 * _.isNative(_);
1448 * // => false
1449 */
1450 function isNative(value) {
1451 if (value == null) {
1452 return false;
1453 }
1454 if (isFunction(value)) {
1455 return reIsNative.test(funcToString.call(value));
1456 }
1457 return isObjectLike(value) &&
1458 (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
1459 }
1460
1461 /**
1462 * Gets the native function at `key` of `object`.
1463 *
1464 * @private
1465 * @param {Object} object The object to query.
1466 * @param {string} key The key of the method to get.
1467 * @returns {*} Returns the function if it's native, else `undefined`.
1468 */
1469 function getNative(object, key) {
1470 var value = object[key];
1471 return isNative(value) ? value : undefined;
1472 }
1473
1474 /* Built-in method references that are verified to be native. */
1475 var nativeCreate = getNative(Object, 'create');
1476
1477 /** Used for built-in method references. */
1478 var objectProto$5 = Object.prototype;
1479
1480 /**
1481 * Creates an hash object.
1482 *
1483 * @private
1484 * @constructor
1485 * @returns {Object} Returns the new hash object.
1486 */
1487 function Hash() {}
1488
1489 // Avoid inheriting from `Object.prototype` when possible.
1490 Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto$5;
1491
1492 /**
1493 * Checks if `value` is a global object.
1494 *
1495 * @private
1496 * @param {*} value The value to check.
1497 * @returns {null|Object} Returns `value` if it's a global object, else `null`.
1498 */
1499 function checkGlobal(value) {
1500 return (value && value.Object === Object) ? value : null;
1501 }
1502
1503 /** Used to determine if values are of the language type `Object`. */
1504 var objectTypes = {
1505 'function': true,
1506 'object': true
1507 };
1508
1509 /** Detect free variable `exports`. */
1510 var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
1511 ? exports
1512 : undefined;
1513
1514 /** Detect free variable `module`. */
1515 var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
1516 ? module
1517 : undefined;
1518
1519 /** Detect free variable `global` from Node.js. */
1520 var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
1521
1522 /** Detect free variable `self`. */
1523 var freeSelf = checkGlobal(objectTypes[typeof self] && self);
1524
1525 /** Detect free variable `window`. */
1526 var freeWindow = checkGlobal(objectTypes[typeof window] && window);
1527
1528 /** Detect `this` as the global object. */
1529 var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
1530
1531 /**
1532 * Used as a reference to the global object.
1533 *
1534 * The `this` value is used if it's the global object to avoid Greasemonkey's
1535 * restricted `window` object, otherwise the `window` object is used.
1536 */
1537 var root = freeGlobal ||
1538 ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
1539 freeSelf || thisGlobal || Function('return this')();
1540
1541 /* Built-in method references that are verified to be native. */
1542 var Map = getNative(root, 'Map');
1543
1544 /**
1545 * Removes all key-value entries from the map.
1546 *
1547 * @private
1548 * @name clear
1549 * @memberOf MapCache
1550 */
1551 function mapClear() {
1552 this.__data__ = {
1553 'hash': new Hash,
1554 'map': Map ? new Map : [],
1555 'string': new Hash
1556 };
1557 }
1558
1559 /** Used for built-in method references. */
1560 var objectProto$7 = Object.prototype;
1561
1562 /** Used to check objects for own properties. */
1563 var hasOwnProperty$3 = objectProto$7.hasOwnProperty;
1564
1565 /**
1566 * Checks if a hash value for `key` exists.
1567 *
1568 * @private
1569 * @param {Object} hash The hash to query.
1570 * @param {string} key The key of the entry to check.
1571 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1572 */
1573 function hashHas(hash, key) {
1574 return nativeCreate ? hash[key] !== undefined : hasOwnProperty$3.call(hash, key);
1575 }
1576
1577 /**
1578 * Removes `key` and its value from the hash.
1579 *
1580 * @private
1581 * @param {Object} hash The hash to modify.
1582 * @param {string} key The key of the value to remove.
1583 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1584 */
1585 function hashDelete(hash, key) {
1586 return hashHas(hash, key) && delete hash[key];
1587 }
1588
1589 /**
1590 * Checks if `value` is suitable for use as unique object key.
1591 *
1592 * @private
1593 * @param {*} value The value to check.
1594 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1595 */
1596 function isKeyable(value) {
1597 var type = typeof value;
1598 return type == 'number' || type == 'boolean' ||
1599 (type == 'string' && value != '__proto__') || value == null;
1600 }
1601
1602 /**
1603 * Removes `key` and its value from the map.
1604 *
1605 * @private
1606 * @name delete
1607 * @memberOf MapCache
1608 * @param {string} key The key of the value to remove.
1609 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1610 */
1611 function mapDelete(key) {
1612 var data = this.__data__;
1613 if (isKeyable(key)) {
1614 return hashDelete(typeof key == 'string' ? data.string : data.hash, key);
1615 }
1616 return Map ? data.map['delete'](key) : assocDelete(data.map, key);
1617 }
1618
1619 /** Used to stand-in for `undefined` hash values. */
1620 var HASH_UNDEFINED = '__lodash_hash_undefined__';
1621
1622 /** Used for built-in method references. */
1623 var objectProto$8 = Object.prototype;
1624
1625 /** Used to check objects for own properties. */
1626 var hasOwnProperty$4 = objectProto$8.hasOwnProperty;
1627
1628 /**
1629 * Gets the hash value for `key`.
1630 *
1631 * @private
1632 * @param {Object} hash The hash to query.
1633 * @param {string} key The key of the value to get.
1634 * @returns {*} Returns the entry value.
1635 */
1636 function hashGet(hash, key) {
1637 if (nativeCreate) {
1638 var result = hash[key];
1639 return result === HASH_UNDEFINED ? undefined : result;
1640 }
1641 return hasOwnProperty$4.call(hash, key) ? hash[key] : undefined;
1642 }
1643
1644 /**
1645 * Gets the map value for `key`.
1646 *
1647 * @private
1648 * @name get
1649 * @memberOf MapCache
1650 * @param {string} key The key of the value to get.
1651 * @returns {*} Returns the entry value.
1652 */
1653 function mapGet(key) {
1654 var data = this.__data__;
1655 if (isKeyable(key)) {
1656 return hashGet(typeof key == 'string' ? data.string : data.hash, key);
1657 }
1658 return Map ? data.map.get(key) : assocGet(data.map, key);
1659 }
1660
1661 /**
1662 * Checks if a map value for `key` exists.
1663 *
1664 * @private
1665 * @name has
1666 * @memberOf MapCache
1667 * @param {string} key The key of the entry to check.
1668 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1669 */
1670 function mapHas(key) {
1671 var data = this.__data__;
1672 if (isKeyable(key)) {
1673 return hashHas(typeof key == 'string' ? data.string : data.hash, key);
1674 }
1675 return Map ? data.map.has(key) : assocHas(data.map, key);
1676 }
1677
1678 /**
1679 * Sets the associative array `key` to `value`.
1680 *
1681 * @private
1682 * @param {Array} array The array to modify.
1683 * @param {string} key The key of the value to set.
1684 * @param {*} value The value to set.
1685 */
1686 function assocSet(array, key, value) {
1687 var index = assocIndexOf(array, key);
1688 if (index < 0) {
1689 array.push([key, value]);
1690 } else {
1691 array[index][1] = value;
1692 }
1693 }
1694
1695 /** Used to stand-in for `undefined` hash values. */
1696 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1697
1698 /**
1699 * Sets the hash `key` to `value`.
1700 *
1701 * @private
1702 * @param {Object} hash The hash to modify.
1703 * @param {string} key The key of the value to set.
1704 * @param {*} value The value to set.
1705 */
1706 function hashSet(hash, key, value) {
1707 hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
1708 }
1709
1710 /**
1711 * Sets the map `key` to `value`.
1712 *
1713 * @private
1714 * @name set
1715 * @memberOf MapCache
1716 * @param {string} key The key of the value to set.
1717 * @param {*} value The value to set.
1718 * @returns {Object} Returns the map cache object.
1719 */
1720 function mapSet(key, value) {
1721 var data = this.__data__;
1722 if (isKeyable(key)) {
1723 hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
1724 } else if (Map) {
1725 data.map.set(key, value);
1726 } else {
1727 assocSet(data.map, key, value);
1728 }
1729 return this;
1730 }
1731
1732 /**
1733 * Creates a map cache object to store key-value pairs.
1734 *
1735 * @private
1736 * @constructor
1737 * @param {Array} [values] The values to cache.
1738 */
1739 function MapCache(values) {
1740 var index = -1,
1741 length = values ? values.length : 0;
1742
1743 this.clear();
1744 while (++index < length) {
1745 var entry = values[index];
1746 this.set(entry[0], entry[1]);
1747 }
1748 }
1749
1750 // Add functions to the `MapCache`.
1751 MapCache.prototype.clear = mapClear;
1752 MapCache.prototype['delete'] = mapDelete;
1753 MapCache.prototype.get = mapGet;
1754 MapCache.prototype.has = mapHas;
1755 MapCache.prototype.set = mapSet;
1756
1757 /** Used as the size to enable large array optimizations. */
1758 var LARGE_ARRAY_SIZE = 200;
1759
1760 /**
1761 * Sets the stack `key` to `value`.
1762 *
1763 * @private
1764 * @name set
1765 * @memberOf Stack
1766 * @param {string} key The key of the value to set.
1767 * @param {*} value The value to set.
1768 * @returns {Object} Returns the stack cache object.
1769 */
1770 function stackSet(key, value) {
1771 var data = this.__data__,
1772 array = data.array;
1773
1774 if (array) {
1775 if (array.length < (LARGE_ARRAY_SIZE - 1)) {
1776 assocSet(array, key, value);
1777 } else {
1778 data.array = null;
1779 data.map = new MapCache(array);
1780 }
1781 }
1782 var map = data.map;
1783 if (map) {
1784 map.set(key, value);
1785 }
1786 return this;
1787 }
1788
1789 /**
1790 * Creates a stack cache object to store key-value pairs.
1791 *
1792 * @private
1793 * @constructor
1794 * @param {Array} [values] The values to cache.
1795 */
1796 function Stack(values) {
1797 var index = -1,
1798 length = values ? values.length : 0;
1799
1800 this.clear();
1801 while (++index < length) {
1802 var entry = values[index];
1803 this.set(entry[0], entry[1]);
1804 }
1805 }
1806
1807 // Add functions to the `Stack` cache.
1808 Stack.prototype.clear = stackClear;
1809 Stack.prototype['delete'] = stackDelete;
1810 Stack.prototype.get = stackGet;
1811 Stack.prototype.has = stackHas;
1812 Stack.prototype.set = stackSet;
1813
1814 /** Used for built-in method references. */
1815 var objectProto$9 = Object.prototype;
1816
1817 /** Used to check objects for own properties. */
1818 var hasOwnProperty$5 = objectProto$9.hasOwnProperty;
1819
1820 /**
1821 * Assigns `value` to `key` of `object` if the existing value is not equivalent
1822 * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
1823 * for equality comparisons.
1824 *
1825 * @private
1826 * @param {Object} object The object to modify.
1827 * @param {string} key The key of the property to assign.
1828 * @param {*} value The value to assign.
1829 */
1830 function assignValue(object, key, value) {
1831 var objValue = object[key];
1832 if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) ||
1833 (value === undefined && !(key in object))) {
1834 object[key] = value;
1835 }
1836 }
1837
1838 /**
1839 * This function is like `copyObject` except that it accepts a function to
1840 * customize copied values.
1841 *
1842 * @private
1843 * @param {Object} source The object to copy properties from.
1844 * @param {Array} props The property names to copy.
1845 * @param {Object} [object={}] The object to copy properties to.
1846 * @param {Function} [customizer] The function to customize copied values.
1847 * @returns {Object} Returns `object`.
1848 */
1849 function copyObjectWith(source, props, object, customizer) {
1850 object || (object = {});
1851
1852 var index = -1,
1853 length = props.length;
1854
1855 while (++index < length) {
1856 var key = props[index];
1857
1858 var newValue = customizer
1859 ? customizer(object[key], source[key], key, object, source)
1860 : source[key];
1861
1862 assignValue(object, key, newValue);
1863 }
1864 return object;
1865 }
1866
1867 /**
1868 * Copies properties of `source` to `object`.
1869 *
1870 * @private
1871 * @param {Object} source The object to copy properties from.
1872 * @param {Array} props The property names to copy.
1873 * @param {Object} [object={}] The object to copy properties to.
1874 * @returns {Object} Returns `object`.
1875 */
1876 function copyObject(source, props, object) {
1877 return copyObjectWith(source, props, object);
1878 }
1879
1880 /**
1881 * The base implementation of `_.assign` without support for multiple sources
1882 * or `customizer` functions.
1883 *
1884 * @private
1885 * @param {Object} object The destination object.
1886 * @param {Object} source The source object.
1887 * @returns {Object} Returns `object`.
1888 */
1889 function baseAssign(object, source) {
1890 return object && copyObject(source, keys(source), object);
1891 }
1892
1893 /**
1894 * Creates a clone of `buffer`.
1895 *
1896 * @private
1897 * @param {Buffer} buffer The buffer to clone.
1898 * @param {boolean} [isDeep] Specify a deep clone.
1899 * @returns {Buffer} Returns the cloned buffer.
1900 */
1901 function cloneBuffer(buffer, isDeep) {
1902 if (isDeep) {
1903 return buffer.slice();
1904 }
1905 var result = new buffer.constructor(buffer.length);
1906 buffer.copy(result);
1907 return result;
1908 }
1909
1910 /**
1911 * Copies the values of `source` to `array`.
1912 *
1913 * @private
1914 * @param {Array} source The array to copy values from.
1915 * @param {Array} [array=[]] The array to copy values to.
1916 * @returns {Array} Returns `array`.
1917 */
1918 function copyArray(source, array) {
1919 var index = -1,
1920 length = source.length;
1921
1922 array || (array = Array(length));
1923 while (++index < length) {
1924 array[index] = source[index];
1925 }
1926 return array;
1927 }
1928
1929 /** Built-in value references. */
1930 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1931
1932 /**
1933 * Creates an array of the own symbol properties of `object`.
1934 *
1935 * @private
1936 * @param {Object} object The object to query.
1937 * @returns {Array} Returns the array of symbols.
1938 */
1939 var getSymbols = getOwnPropertySymbols || function() {
1940 return [];
1941 };
1942
1943 /**
1944 * Copies own symbol properties of `source` to `object`.
1945 *
1946 * @private
1947 * @param {Object} source The object to copy symbols from.
1948 * @param {Object} [object={}] The object to copy symbols to.
1949 * @returns {Object} Returns `object`.
1950 */
1951 function copySymbols(source, object) {
1952 return copyObject(source, getSymbols(source), object);
1953 }
1954
1955 /* Built-in method references that are verified to be native. */
1956 var Set = getNative(root, 'Set');
1957
1958 /* Built-in method references that are verified to be native. */
1959 var WeakMap = getNative(root, 'WeakMap');
1960
1961 var mapTag$1 = '[object Map]';
1962 var objectTag$1 = '[object Object]';
1963 var setTag$1 = '[object Set]';
1964 var weakMapTag$1 = '[object WeakMap]';
1965 /** Used for built-in method references. */
1966 var objectProto$10 = Object.prototype;
1967
1968 /** Used to resolve the decompiled source of functions. */
1969 var funcToString$1 = Function.prototype.toString;
1970
1971 /**
1972 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
1973 * of values.
1974 */
1975 var objectToString$3 = objectProto$10.toString;
1976
1977 /** Used to detect maps, sets, and weakmaps. */
1978 var mapCtorString = Map ? funcToString$1.call(Map) : '';
1979 var setCtorString = Set ? funcToString$1.call(Set) : '';
1980 var weakMapCtorString = WeakMap ? funcToString$1.call(WeakMap) : '';
1981 /**
1982 * Gets the `toStringTag` of `value`.
1983 *
1984 * @private
1985 * @param {*} value The value to query.
1986 * @returns {string} Returns the `toStringTag`.
1987 */
1988 function getTag(value) {
1989 return objectToString$3.call(value);
1990 }
1991
1992 // Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
1993 if ((Map && getTag(new Map) != mapTag$1) ||
1994 (Set && getTag(new Set) != setTag$1) ||
1995 (WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
1996 getTag = function(value) {
1997 var result = objectToString$3.call(value),
1998 Ctor = result == objectTag$1 ? value.constructor : null,
1999 ctorString = typeof Ctor == 'function' ? funcToString$1.call(Ctor) : '';
2000
2001 if (ctorString) {
2002 switch (ctorString) {
2003 case mapCtorString: return mapTag$1;
2004 case setCtorString: return setTag$1;
2005 case weakMapCtorString: return weakMapTag$1;
2006 }
2007 }
2008 return result;
2009 };
2010 }
2011
2012 var getTag$1 = getTag;
2013
2014 /** Used for built-in method references. */
2015 var objectProto$11 = Object.prototype;
2016
2017 /** Used to check objects for own properties. */
2018 var hasOwnProperty$6 = objectProto$11.hasOwnProperty;
2019
2020 /**
2021 * Initializes an array clone.
2022 *
2023 * @private
2024 * @param {Array} array The array to clone.
2025 * @returns {Array} Returns the initialized clone.
2026 */
2027 function initCloneArray(array) {
2028 var length = array.length,
2029 result = array.constructor(length);
2030
2031 // Add properties assigned by `RegExp#exec`.
2032 if (length && typeof array[0] == 'string' && hasOwnProperty$6.call(array, 'index')) {
2033 result.index = array.index;
2034 result.input = array.input;
2035 }
2036 return result;
2037 }
2038
2039 /** Built-in value references. */
2040 var Uint8Array = root.Uint8Array;
2041
2042 /**
2043 * Creates a clone of `arrayBuffer`.
2044 *
2045 * @private
2046 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2047 * @returns {ArrayBuffer} Returns the cloned array buffer.
2048 */
2049 function cloneArrayBuffer(arrayBuffer) {
2050 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2051 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2052 return result;
2053 }
2054
2055 /**
2056 * Adds the key-value `pair` to `map`.
2057 *
2058 * @private
2059 * @param {Object} map The map to modify.
2060 * @param {Array} pair The key-value pair to add.
2061 * @returns {Object} Returns `map`.
2062 */
2063 function addMapEntry(map, pair) {
2064 // Don't return `Map#set` because it doesn't return the map instance in IE 11.
2065 map.set(pair[0], pair[1]);
2066 return map;
2067 }
2068
2069 /**
2070 * A specialized version of `_.reduce` for arrays without support for
2071 * iteratee shorthands.
2072 *
2073 * @private
2074 * @param {Array} array The array to iterate over.
2075 * @param {Function} iteratee The function invoked per iteration.
2076 * @param {*} [accumulator] The initial value.
2077 * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
2078 * @returns {*} Returns the accumulated value.
2079 */
2080 function arrayReduce(array, iteratee, accumulator, initAccum) {
2081 var index = -1,
2082 length = array.length;
2083
2084 if (initAccum && length) {
2085 accumulator = array[++index];
2086 }
2087 while (++index < length) {
2088 accumulator = iteratee(accumulator, array[index], index, array);
2089 }
2090 return accumulator;
2091 }
2092
2093 /**
2094 * Converts `map` to an array.
2095 *
2096 * @private
2097 * @param {Object} map The map to convert.
2098 * @returns {Array} Returns the converted array.
2099 */
2100 function mapToArray(map) {
2101 var index = -1,
2102 result = Array(map.size);
2103
2104 map.forEach(function(value, key) {
2105 result[++index] = [key, value];
2106 });
2107 return result;
2108 }
2109
2110 /**
2111 * Creates a clone of `map`.
2112 *
2113 * @private
2114 * @param {Object} map The map to clone.
2115 * @returns {Object} Returns the cloned map.
2116 */
2117 function cloneMap(map) {
2118 return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
2119 }
2120
2121 /** Used to match `RegExp` flags from their coerced string values. */
2122 var reFlags = /\w*$/;
2123
2124 /**
2125 * Creates a clone of `regexp`.
2126 *
2127 * @private
2128 * @param {Object} regexp The regexp to clone.
2129 * @returns {Object} Returns the cloned regexp.
2130 */
2131 function cloneRegExp(regexp) {
2132 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2133 result.lastIndex = regexp.lastIndex;
2134 return result;
2135 }
2136
2137 /**
2138 * Adds `value` to `set`.
2139 *
2140 * @private
2141 * @param {Object} set The set to modify.
2142 * @param {*} value The value to add.
2143 * @returns {Object} Returns `set`.
2144 */
2145 function addSetEntry(set, value) {
2146 set.add(value);
2147 return set;
2148 }
2149
2150 /**
2151 * Converts `set` to an array.
2152 *
2153 * @private
2154 * @param {Object} set The set to convert.
2155 * @returns {Array} Returns the converted array.
2156 */
2157 function setToArray(set) {
2158 var index = -1,
2159 result = Array(set.size);
2160
2161 set.forEach(function(value) {
2162 result[++index] = value;
2163 });
2164 return result;
2165 }
2166
2167 /**
2168 * Creates a clone of `set`.
2169 *
2170 * @private
2171 * @param {Object} set The set to clone.
2172 * @returns {Object} Returns the cloned set.
2173 */
2174 function cloneSet(set) {
2175 return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
2176 }
2177
2178 /** Built-in value references. */
2179 var Symbol$1 = root.Symbol;
2180
2181 var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
2182 var symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
2183 /**
2184 * Creates a clone of the `symbol` object.
2185 *
2186 * @private
2187 * @param {Object} symbol The symbol object to clone.
2188 * @returns {Object} Returns the cloned symbol object.
2189 */
2190 function cloneSymbol(symbol) {
2191 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2192 }
2193
2194 /**
2195 * Creates a clone of `typedArray`.
2196 *
2197 * @private
2198 * @param {Object} typedArray The typed array to clone.
2199 * @param {boolean} [isDeep] Specify a deep clone.
2200 * @returns {Object} Returns the cloned typed array.
2201 */
2202 function cloneTypedArray(typedArray, isDeep) {
2203 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
2204 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2205 }
2206
2207 var boolTag$1 = '[object Boolean]';
2208 var dateTag$1 = '[object Date]';
2209 var mapTag$2 = '[object Map]';
2210 var numberTag$1 = '[object Number]';
2211 var regexpTag$1 = '[object RegExp]';
2212 var setTag$2 = '[object Set]';
2213 var stringTag$2 = '[object String]';
2214 var symbolTag$1 = '[object Symbol]';
2215 var arrayBufferTag$1 = '[object ArrayBuffer]';
2216 var float32Tag$1 = '[object Float32Array]';
2217 var float64Tag$1 = '[object Float64Array]';
2218 var int8Tag$1 = '[object Int8Array]';
2219 var int16Tag$1 = '[object Int16Array]';
2220 var int32Tag$1 = '[object Int32Array]';
2221 var uint8Tag$1 = '[object Uint8Array]';
2222 var uint8ClampedTag$1 = '[object Uint8ClampedArray]';
2223 var uint16Tag$1 = '[object Uint16Array]';
2224 var uint32Tag$1 = '[object Uint32Array]';
2225 /**
2226 * Initializes an object clone based on its `toStringTag`.
2227 *
2228 * **Note:** This function only supports cloning values with tags of
2229 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
2230 *
2231 * @private
2232 * @param {Object} object The object to clone.
2233 * @param {string} tag The `toStringTag` of the object to clone.
2234 * @param {boolean} [isDeep] Specify a deep clone.
2235 * @returns {Object} Returns the initialized clone.
2236 */
2237 function initCloneByTag(object, tag, isDeep) {
2238 var Ctor = object.constructor;
2239 switch (tag) {
2240 case arrayBufferTag$1:
2241 return cloneArrayBuffer(object);
2242
2243 case boolTag$1:
2244 case dateTag$1:
2245 return new Ctor(+object);
2246
2247 case float32Tag$1: case float64Tag$1:
2248 case int8Tag$1: case int16Tag$1: case int32Tag$1:
2249 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
2250 return cloneTypedArray(object, isDeep);
2251
2252 case mapTag$2:
2253 return cloneMap(object);
2254
2255 case numberTag$1:
2256 case stringTag$2:
2257 return new Ctor(object);
2258
2259 case regexpTag$1:
2260 return cloneRegExp(object);
2261
2262 case setTag$2:
2263 return cloneSet(object);
2264
2265 case symbolTag$1:
2266 return cloneSymbol(object);
2267 }
2268 }
2269
2270 /** Built-in value references. */
2271 var objectCreate = Object.create;
2272
2273 /**
2274 * The base implementation of `_.create` without support for assigning
2275 * properties to the created object.
2276 *
2277 * @private
2278 * @param {Object} prototype The object to inherit from.
2279 * @returns {Object} Returns the new object.
2280 */
2281 function baseCreate(proto) {
2282 return isObject(proto) ? objectCreate(proto) : {};
2283 }
2284
2285 /** Built-in value references. */
2286 var getPrototypeOf$1 = Object.getPrototypeOf;
2287
2288 /**
2289 * Initializes an object clone.
2290 *
2291 * @private
2292 * @param {Object} object The object to clone.
2293 * @returns {Object} Returns the initialized clone.
2294 */
2295 function initCloneObject(object) {
2296 return (typeof object.constructor == 'function' && !isPrototype(object))
2297 ? baseCreate(getPrototypeOf$1(object))
2298 : {};
2299 }
2300
2301 /**
2302 * Creates a function that returns `value`.
2303 *
2304 * @static
2305 * @memberOf _
2306 * @category Util
2307 * @param {*} value The value to return from the new function.
2308 * @returns {Function} Returns the new function.
2309 * @example
2310 *
2311 * var object = { 'user': 'fred' };
2312 * var getter = _.constant(object);
2313 *
2314 * getter() === object;
2315 * // => true
2316 */
2317 function constant(value) {
2318 return function() {
2319 return value;
2320 };
2321 }
2322
2323 /** Used to determine if values are of the language type `Object`. */
2324 var objectTypes$1 = {
2325 'function': true,
2326 'object': true
2327 };
2328
2329 /** Detect free variable `exports`. */
2330 var freeExports$1 = (objectTypes$1[typeof exports] && exports && !exports.nodeType)
2331 ? exports
2332 : undefined;
2333
2334 /** Detect free variable `module`. */
2335 var freeModule$1 = (objectTypes$1[typeof module] && module && !module.nodeType)
2336 ? module
2337 : undefined;
2338
2339 /** Detect the popular CommonJS extension `module.exports`. */
2340 var moduleExports = (freeModule$1 && freeModule$1.exports === freeExports$1)
2341 ? freeExports$1
2342 : undefined;
2343
2344 /** Built-in value references. */
2345 var Buffer = moduleExports ? root.Buffer : undefined;
2346
2347 /**
2348 * Checks if `value` is a buffer.
2349 *
2350 * @static
2351 * @memberOf _
2352 * @category Lang
2353 * @param {*} value The value to check.
2354 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
2355 * @example
2356 *
2357 * _.isBuffer(new Buffer(2));
2358 * // => true
2359 *
2360 * _.isBuffer(new Uint8Array(2));
2361 * // => false
2362 */
2363 var isBuffer = !Buffer ? constant(false) : function(value) {
2364 return value instanceof Buffer;
2365 };
2366
2367 var argsTag$1 = '[object Arguments]';
2368 var arrayTag = '[object Array]';
2369 var boolTag = '[object Boolean]';
2370 var dateTag = '[object Date]';
2371 var errorTag = '[object Error]';
2372 var funcTag$1 = '[object Function]';
2373 var genTag$1 = '[object GeneratorFunction]';
2374 var mapTag = '[object Map]';
2375 var numberTag = '[object Number]';
2376 var objectTag = '[object Object]';
2377 var regexpTag = '[object RegExp]';
2378 var setTag = '[object Set]';
2379 var stringTag$1 = '[object String]';
2380 var symbolTag = '[object Symbol]';
2381 var weakMapTag = '[object WeakMap]';
2382 var arrayBufferTag = '[object ArrayBuffer]';
2383 var float32Tag = '[object Float32Array]';
2384 var float64Tag = '[object Float64Array]';
2385 var int8Tag = '[object Int8Array]';
2386 var int16Tag = '[object Int16Array]';
2387 var int32Tag = '[object Int32Array]';
2388 var uint8Tag = '[object Uint8Array]';
2389 var uint8ClampedTag = '[object Uint8ClampedArray]';
2390 var uint16Tag = '[object Uint16Array]';
2391 var uint32Tag = '[object Uint32Array]';
2392 /** Used to identify `toStringTag` values supported by `_.clone`. */
2393 var cloneableTags = {};
2394 cloneableTags[argsTag$1] = cloneableTags[arrayTag] =
2395 cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
2396 cloneableTags[dateTag] = cloneableTags[float32Tag] =
2397 cloneableTags[float64Tag] = cloneableTags[int8Tag] =
2398 cloneableTags[int16Tag] = cloneableTags[int32Tag] =
2399 cloneableTags[mapTag] = cloneableTags[numberTag] =
2400 cloneableTags[objectTag] = cloneableTags[regexpTag] =
2401 cloneableTags[setTag] = cloneableTags[stringTag$1] =
2402 cloneableTags[symbolTag] = cloneableTags[uint8Tag] =
2403 cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] =
2404 cloneableTags[uint32Tag] = true;
2405 cloneableTags[errorTag] = cloneableTags[funcTag$1] =
2406 cloneableTags[weakMapTag] = false;
2407
2408 /**
2409 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2410 * traversed objects.
2411 *
2412 * @private
2413 * @param {*} value The value to clone.
2414 * @param {boolean} [isDeep] Specify a deep clone.
2415 * @param {boolean} [isFull] Specify a clone including symbols.
2416 * @param {Function} [customizer] The function to customize cloning.
2417 * @param {string} [key] The key of `value`.
2418 * @param {Object} [object] The parent object of `value`.
2419 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2420 * @returns {*} Returns the cloned value.
2421 */
2422 function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
2423 var result;
2424 if (customizer) {
2425 result = object ? customizer(value, key, object, stack) : customizer(value);
2426 }
2427 if (result !== undefined) {
2428 return result;
2429 }
2430 if (!isObject(value)) {
2431 return value;
2432 }
2433 var isArr = isArray(value);
2434 if (isArr) {
2435 result = initCloneArray(value);
2436 if (!isDeep) {
2437 return copyArray(value, result);
2438 }
2439 } else {
2440 var tag = getTag$1(value),
2441 isFunc = tag == funcTag$1 || tag == genTag$1;
2442
2443 if (isBuffer(value)) {
2444 return cloneBuffer(value, isDeep);
2445 }
2446 if (tag == objectTag || tag == argsTag$1 || (isFunc && !object)) {
2447 if (isHostObject(value)) {
2448 return object ? value : {};
2449 }
2450 result = initCloneObject(isFunc ? {} : value);
2451 if (!isDeep) {
2452 result = baseAssign(result, value);
2453 return isFull ? copySymbols(value, result) : result;
2454 }
2455 } else {
2456 if (!cloneableTags[tag]) {
2457 return object ? value : {};
2458 }
2459 result = initCloneByTag(value, tag, isDeep);
2460 }
2461 }
2462 // Check for circular references and return its corresponding clone.
2463 stack || (stack = new Stack);
2464 var stacked = stack.get(value);
2465 if (stacked) {
2466 return stacked;
2467 }
2468 stack.set(value, result);
2469
2470 // Recursively populate clone (susceptible to call stack limits).
2471 (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
2472 assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
2473 });
2474 return (isFull && !isArr) ? copySymbols(value, result) : result;
2475 }
2476
2477 var argsRegex = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
2478
2479 function parseParams(func) {
2480 return func.toString().match(argsRegex)[1].split(/\s*\,\s*/);
2481 }
2482
2483 function autoInject(tasks, callback) {
2484 var newTasks = {};
2485
2486 forOwn(tasks, function (taskFn, key) {
2487 var params;
2488
2489 if (isArray(taskFn)) {
2490 params = baseClone(taskFn);
2491 taskFn = params.pop();
2492
2493 newTasks[key] = params.concat(newTask);
2494 } else if (taskFn.length === 0) {
2495 throw new Error("autoInject task functions require explicit parameters.");
2496 } else if (taskFn.length === 1) {
2497 // no dependencies, use the function as-is
2498 newTasks[key] = taskFn;
2499 } else {
2500 params = parseParams(taskFn);
2501 params.pop();
2502
2503 newTasks[key] = params.concat(newTask);
2504 }
2505
2506 function newTask(results, taskCb) {
2507 var newArgs = arrayMap(params, function (name) {
2508 return results[name];
2509 });
2510 newArgs.push(taskCb);
2511 taskFn.apply(null, newArgs);
2512 }
2513 });
2514
2515 auto(newTasks, callback);
2516 }
2517
2518 var _setImmediate = typeof setImmediate === 'function' && setImmediate;
2519
2520 var _defer;
2521 if (_setImmediate) {
2522 _defer = _setImmediate;
2523 } else if (typeof process === 'object' && typeof process.nextTick === 'function') {
2524 _defer = process.nextTick;
2525 } else {
2526 _defer = function (fn) {
2527 setTimeout(fn, 0);
2528 };
2529 }
2530
2531 var setImmediate$1 = rest(function (fn, args) {
2532 _defer(function () {
2533 fn.apply(null, args);
2534 });
2535 });
2536
2537 function queue(worker, concurrency, payload) {
2538 if (concurrency == null) {
2539 concurrency = 1;
2540 } else if (concurrency === 0) {
2541 throw new Error('Concurrency must not be zero');
2542 }
2543 function _insert(q, data, pos, callback) {
2544 if (callback != null && typeof callback !== 'function') {
2545 throw new Error('task callback must be a function');
2546 }
2547 q.started = true;
2548 if (!isArray(data)) {
2549 data = [data];
2550 }
2551 if (data.length === 0 && q.idle()) {
2552 // call drain immediately if there are no tasks
2553 return setImmediate$1(function () {
2554 q.drain();
2555 });
2556 }
2557 arrayEach(data, function (task) {
2558 var item = {
2559 data: task,
2560 callback: callback || noop
2561 };
2562
2563 if (pos) {
2564 q.tasks.unshift(item);
2565 } else {
2566 q.tasks.push(item);
2567 }
2568 });
2569 setImmediate$1(q.process);
2570 }
2571 function _next(q, tasks) {
2572 return function () {
2573 workers -= 1;
2574
2575 var removed = false;
2576 var args = arguments;
2577 arrayEach(tasks, function (task) {
2578 arrayEach(workersList, function (worker, index) {
2579 if (worker === task && !removed) {
2580 workersList.splice(index, 1);
2581 removed = true;
2582 }
2583 });
2584
2585 task.callback.apply(task, args);
2586 });
2587
2588 if (workers <= q.concurrency - q.buffer) {
2589 q.unsaturated();
2590 }
2591
2592 if (q.tasks.length + workers === 0) {
2593 q.drain();
2594 }
2595 q.process();
2596 };
2597 }
2598
2599 var workers = 0;
2600 var workersList = [];
2601 var q = {
2602 tasks: [],
2603 concurrency: concurrency,
2604 payload: payload,
2605 saturated: noop,
2606 unsaturated: noop,
2607 buffer: concurrency / 4,
2608 empty: noop,
2609 drain: noop,
2610 started: false,
2611 paused: false,
2612 push: function (data, callback) {
2613 _insert(q, data, false, callback);
2614 },
2615 kill: function () {
2616 q.drain = noop;
2617 q.tasks = [];
2618 },
2619 unshift: function (data, callback) {
2620 _insert(q, data, true, callback);
2621 },
2622 process: function () {
2623 while (!q.paused && workers < q.concurrency && q.tasks.length) {
2624
2625 var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
2626
2627 var data = arrayMap(tasks, baseProperty('data'));
2628
2629 if (q.tasks.length === 0) {
2630 q.empty();
2631 }
2632 workers += 1;
2633 workersList.push(tasks[0]);
2634
2635 if (workers === q.concurrency) {
2636 q.saturated();
2637 }
2638
2639 var cb = onlyOnce(_next(q, tasks));
2640 worker(data, cb);
2641 }
2642 },
2643 length: function () {
2644 return q.tasks.length;
2645 },
2646 running: function () {
2647 return workers;
2648 },
2649 workersList: function () {
2650 return workersList;
2651 },
2652 idle: function () {
2653 return q.tasks.length + workers === 0;
2654 },
2655 pause: function () {
2656 q.paused = true;
2657 },
2658 resume: function () {
2659 if (q.paused === false) {
2660 return;
2661 }
2662 q.paused = false;
2663 var resumeCount = Math.min(q.concurrency, q.tasks.length);
2664 // Need to call q.process once per concurrent
2665 // worker to preserve full concurrency after pause
2666 for (var w = 1; w <= resumeCount; w++) {
2667 setImmediate$1(q.process);
2668 }
2669 }
2670 };
2671 return q;
2672 }
2673
2674 function cargo(worker, payload) {
2675 return queue(worker, 1, payload);
2676 }
2677
2678 function reduce(arr, memo, iteratee, cb) {
2679 eachOfSeries(arr, function (x, i, cb) {
2680 iteratee(memo, x, function (err, v) {
2681 memo = v;
2682 cb(err);
2683 });
2684 }, function (err) {
2685 cb(err, memo);
2686 });
2687 }
2688
2689 function seq() /* functions... */{
2690 var fns = arguments;
2691 return rest(function (args) {
2692 var that = this;
2693
2694 var cb = args[args.length - 1];
2695 if (typeof cb == 'function') {
2696 args.pop();
2697 } else {
2698 cb = noop;
2699 }
2700
2701 reduce(fns, args, function (newargs, fn, cb) {
2702 fn.apply(that, newargs.concat([rest(function (err, nextargs) {
2703 cb(err, nextargs);
2704 })]));
2705 }, function (err, results) {
2706 cb.apply(that, [err].concat(results));
2707 });
2708 });
2709 }
2710
2711 var reverse = Array.prototype.reverse;
2712
2713 function compose() /* functions... */{
2714 return seq.apply(null, reverse.call(arguments));
2715 }
2716
2717 function concat$1(eachfn, arr, fn, callback) {
2718 var result = [];
2719 eachfn(arr, function (x, index, cb) {
2720 fn(x, function (err, y) {
2721 result = result.concat(y || []);
2722 cb(err);
2723 });
2724 }, function (err) {
2725 callback(err, result);
2726 });
2727 }
2728
2729 function doParallel(fn) {
2730 return function (obj, iteratee, callback) {
2731 return fn(eachOf, obj, iteratee, callback);
2732 };
2733 }
2734
2735 var concat = doParallel(concat$1);
2736
2737 function doSeries(fn) {
2738 return function (obj, iteratee, callback) {
2739 return fn(eachOfSeries, obj, iteratee, callback);
2740 };
2741 }
2742
2743 var concatSeries = doSeries(concat$1);
2744
2745 var constant$1 = rest(function (values) {
2746 var args = [null].concat(values);
2747 return initialParams(function (ignoredArgs, callback) {
2748 return callback.apply(this, args);
2749 });
2750 });
2751
2752 function _createTester(eachfn, check, getResult) {
2753 return function (arr, limit, iteratee, cb) {
2754 function done(err) {
2755 if (cb) {
2756 if (err) {
2757 cb(err);
2758 } else {
2759 cb(null, getResult(false));
2760 }
2761 }
2762 }
2763 function wrappedIteratee(x, _, callback) {
2764 if (!cb) return callback();
2765 iteratee(x, function (err, v) {
2766 if (cb) {
2767 if (err) {
2768 cb(err);
2769 cb = iteratee = false;
2770 } else if (check(v)) {
2771 cb(null, getResult(true, x));
2772 cb = iteratee = false;
2773 }
2774 }
2775 callback();
2776 });
2777 }
2778 if (arguments.length > 3) {
2779 eachfn(arr, limit, wrappedIteratee, done);
2780 } else {
2781 cb = iteratee;
2782 iteratee = limit;
2783 eachfn(arr, wrappedIteratee, done);
2784 }
2785 };
2786 }
2787
2788 function _findGetResult(v, x) {
2789 return x;
2790 }
2791
2792 var detect = _createTester(eachOf, identity, _findGetResult);
2793
2794 var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
2795
2796 var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
2797
2798 function consoleFunc(name) {
2799 return rest(function (fn, args) {
2800 fn.apply(null, args.concat([rest(function (err, args) {
2801 if (typeof console === 'object') {
2802 if (err) {
2803 if (console.error) {
2804 console.error(err);
2805 }
2806 } else if (console[name]) {
2807 arrayEach(args, function (x) {
2808 console[name](x);
2809 });
2810 }
2811 }
2812 })]));
2813 });
2814 }
2815
2816 var dir = consoleFunc('dir');
2817
2818 function during(test, iteratee, cb) {
2819 cb = cb || noop;
2820
2821 var next = rest(function (err, args) {
2822 if (err) {
2823 cb(err);
2824 } else {
2825 args.push(check);
2826 test.apply(this, args);
2827 }
2828 });
2829
2830 var check = function (err, truth) {
2831 if (err) return cb(err);
2832 if (!truth) return cb(null);
2833 iteratee(next);
2834 };
2835
2836 test(check);
2837 }
2838
2839 function doDuring(iteratee, test, cb) {
2840 var calls = 0;
2841
2842 during(function (next) {
2843 if (calls++ < 1) return next(null, true);
2844 test.apply(this, arguments);
2845 }, iteratee, cb);
2846 }
2847
2848 function whilst(test, iteratee, cb) {
2849 cb = cb || noop;
2850 if (!test()) return cb(null);
2851 var next = rest(function (err, args) {
2852 if (err) return cb(err);
2853 if (test.apply(this, args)) return iteratee(next);
2854 cb.apply(null, [null].concat(args));
2855 });
2856 iteratee(next);
2857 }
2858
2859 function doWhilst(iteratee, test, cb) {
2860 var calls = 0;
2861 return whilst(function () {
2862 return ++calls <= 1 || test.apply(this, arguments);
2863 }, iteratee, cb);
2864 }
2865
2866 function doUntil(iteratee, test, cb) {
2867 return doWhilst(iteratee, function () {
2868 return !test.apply(this, arguments);
2869 }, cb);
2870 }
2871
2872 function _withoutIndex(iteratee) {
2873 return function (value, index, callback) {
2874 return iteratee(value, callback);
2875 };
2876 }
2877
2878 function eachLimit(arr, limit, iteratee, cb) {
2879 return _eachOfLimit(limit)(arr, _withoutIndex(iteratee), cb);
2880 }
2881
2882 var each = doLimit(eachLimit, Infinity);
2883
2884 var eachSeries = doLimit(eachLimit, 1);
2885
2886 function ensureAsync(fn) {
2887 return initialParams(function (args, callback) {
2888 var sync = true;
2889 args.push(function () {
2890 var innerArgs = arguments;
2891 if (sync) {
2892 setImmediate$1(function () {
2893 callback.apply(null, innerArgs);
2894 });
2895 } else {
2896 callback.apply(null, innerArgs);
2897 }
2898 });
2899 fn.apply(this, args);
2900 sync = false;
2901 });
2902 }
2903
2904 function notId(v) {
2905 return !v;
2906 }
2907
2908 var everyLimit = _createTester(eachOfLimit, notId, notId);
2909
2910 var every = doLimit(everyLimit, Infinity);
2911
2912 var everySeries = doLimit(everyLimit, 1);
2913
2914 function _filter(eachfn, arr, iteratee, callback) {
2915 var results = [];
2916 eachfn(arr, function (x, index, callback) {
2917 iteratee(x, function (err, v) {
2918 if (err) {
2919 callback(err);
2920 } else {
2921 if (v) {
2922 results.push({ index: index, value: x });
2923 }
2924 callback();
2925 }
2926 });
2927 }, function (err) {
2928 if (err) {
2929 callback(err);
2930 } else {
2931 callback(null, arrayMap(results.sort(function (a, b) {
2932 return a.index - b.index;
2933 }), baseProperty('value')));
2934 }
2935 });
2936 }
2937
2938 function doParallelLimit(fn) {
2939 return function (obj, limit, iteratee, callback) {
2940 return fn(_eachOfLimit(limit), obj, iteratee, callback);
2941 };
2942 }
2943
2944 var filterLimit = doParallelLimit(_filter);
2945
2946 var filter = doLimit(filterLimit, Infinity);
2947
2948 var filterSeries = doLimit(filterLimit, 1);
2949
2950 function forever(fn, cb) {
2951 var done = onlyOnce(cb || noop);
2952 var task = ensureAsync(fn);
2953
2954 function next(err) {
2955 if (err) return done(err);
2956 task(next);
2957 }
2958 next();
2959 }
2960
2961 function iterator$1 (tasks) {
2962 function makeCallback(index) {
2963 function fn() {
2964 if (tasks.length) {
2965 tasks[index].apply(null, arguments);
2966 }
2967 return fn.next();
2968 }
2969 fn.next = function () {
2970 return index < tasks.length - 1 ? makeCallback(index + 1) : null;
2971 };
2972 return fn;
2973 }
2974 return makeCallback(0);
2975 }
2976
2977 var log = consoleFunc('log');
2978
2979 function _asyncMap(eachfn, arr, iteratee, callback) {
2980 callback = once(callback || noop);
2981 arr = arr || [];
2982 var results = isArrayLike(arr) || getIterator(arr) ? [] : {};
2983 eachfn(arr, function (value, index, callback) {
2984 iteratee(value, function (err, v) {
2985 results[index] = v;
2986 callback(err);
2987 });
2988 }, function (err) {
2989 callback(err, results);
2990 });
2991 }
2992
2993 var mapLimit = doParallelLimit(_asyncMap);
2994
2995 var map = doLimit(mapLimit, Infinity);
2996
2997 var mapSeries = doLimit(mapLimit, 1);
2998
2999 /** `Object#toString` result references. */
3000 var symbolTag$2 = '[object Symbol]';
3001
3002 /** Used for built-in method references. */
3003 var objectProto$12 = Object.prototype;
3004
3005 /**
3006 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
3007 * of values.
3008 */
3009 var objectToString$4 = objectProto$12.toString;
3010
3011 /**
3012 * Checks if `value` is classified as a `Symbol` primitive or object.
3013 *
3014 * @static
3015 * @memberOf _
3016 * @category Lang
3017 * @param {*} value The value to check.
3018 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
3019 * @example
3020 *
3021 * _.isSymbol(Symbol.iterator);
3022 * // => true
3023 *
3024 * _.isSymbol('abc');
3025 * // => false
3026 */
3027 function isSymbol(value) {
3028 return typeof value == 'symbol' ||
3029 (isObjectLike(value) && objectToString$4.call(value) == symbolTag$2);
3030 }
3031
3032 /** Used as references for various `Number` constants. */
3033 var INFINITY$1 = 1 / 0;
3034
3035 /** Used to convert symbols to primitives and strings. */
3036 var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined;
3037 var symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
3038 /**
3039 * Converts `value` to a string if it's not one. An empty string is returned
3040 * for `null` and `undefined` values. The sign of `-0` is preserved.
3041 *
3042 * @static
3043 * @memberOf _
3044 * @category Lang
3045 * @param {*} value The value to process.
3046 * @returns {string} Returns the string.
3047 * @example
3048 *
3049 * _.toString(null);
3050 * // => ''
3051 *
3052 * _.toString(-0);
3053 * // => '-0'
3054 *
3055 * _.toString([1, 2, 3]);
3056 * // => '1,2,3'
3057 */
3058 function toString(value) {
3059 // Exit early for strings to avoid a performance hit in some environments.
3060 if (typeof value == 'string') {
3061 return value;
3062 }
3063 if (value == null) {
3064 return '';
3065 }
3066 if (isSymbol(value)) {
3067 return symbolToString ? symbolToString.call(value) : '';
3068 }
3069 var result = (value + '');
3070 return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
3071 }
3072
3073 /** Used to match property names within property paths. */
3074 var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
3075
3076 /** Used to match backslashes in property paths. */
3077 var reEscapeChar = /\\(\\)?/g;
3078
3079 /**
3080 * Converts `string` to a property path array.
3081 *
3082 * @private
3083 * @param {string} string The string to convert.
3084 * @returns {Array} Returns the property path array.
3085 */
3086 function stringToPath(string) {
3087 var result = [];
3088 toString(string).replace(rePropName, function(match, number, quote, string) {
3089 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
3090 });
3091 return result;
3092 }
3093
3094 /**
3095 * Casts `value` to a path array if it's not one.
3096 *
3097 * @private
3098 * @param {*} value The value to inspect.
3099 * @returns {Array} Returns the cast property path array.
3100 */
3101 function baseCastPath(value) {
3102 return isArray(value) ? value : stringToPath(value);
3103 }
3104
3105 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
3106 var reIsPlainProp = /^\w*$/;
3107 /**
3108 * Checks if `value` is a property name and not a property path.
3109 *
3110 * @private
3111 * @param {*} value The value to check.
3112 * @param {Object} [object] The object to query keys on.
3113 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
3114 */
3115 function isKey(value, object) {
3116 if (typeof value == 'number') {
3117 return true;
3118 }
3119 return !isArray(value) &&
3120 (reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
3121 (object != null && value in Object(object)));
3122 }
3123
3124 /**
3125 * Gets the last element of `array`.
3126 *
3127 * @static
3128 * @memberOf _
3129 * @category Array
3130 * @param {Array} array The array to query.
3131 * @returns {*} Returns the last element of `array`.
3132 * @example
3133 *
3134 * _.last([1, 2, 3]);
3135 * // => 3
3136 */
3137 function last(array) {
3138 var length = array ? array.length : 0;
3139 return length ? array[length - 1] : undefined;
3140 }
3141
3142 /**
3143 * The base implementation of `_.slice` without an iteratee call guard.
3144 *
3145 * @private
3146 * @param {Array} array The array to slice.
3147 * @param {number} [start=0] The start position.
3148 * @param {number} [end=array.length] The end position.
3149 * @returns {Array} Returns the slice of `array`.
3150 */
3151 function baseSlice(array, start, end) {
3152 var index = -1,
3153 length = array.length;
3154
3155 if (start < 0) {
3156 start = -start > length ? 0 : (length + start);
3157 }
3158 end = end > length ? length : end;
3159 if (end < 0) {
3160 end += length;
3161 }
3162 length = start > end ? 0 : ((end - start) >>> 0);
3163 start >>>= 0;
3164
3165 var result = Array(length);
3166 while (++index < length) {
3167 result[index] = array[index + start];
3168 }
3169 return result;
3170 }
3171
3172 /**
3173 * The base implementation of `_.get` without support for default values.
3174 *
3175 * @private
3176 * @param {Object} object The object to query.
3177 * @param {Array|string} path The path of the property to get.
3178 * @returns {*} Returns the resolved value.
3179 */
3180 function baseGet(object, path) {
3181 path = isKey(path, object) ? [path + ''] : baseCastPath(path);
3182
3183 var index = 0,
3184 length = path.length;
3185
3186 while (object != null && index < length) {
3187 object = object[path[index++]];
3188 }
3189 return (index && index == length) ? object : undefined;
3190 }
3191
3192 /**
3193 * Gets the value at `path` of `object`. If the resolved value is
3194 * `undefined` the `defaultValue` is used in its place.
3195 *
3196 * @static
3197 * @memberOf _
3198 * @category Object
3199 * @param {Object} object The object to query.
3200 * @param {Array|string} path The path of the property to get.
3201 * @param {*} [defaultValue] The value returned if the resolved value is `undefined`.
3202 * @returns {*} Returns the resolved value.
3203 * @example
3204 *
3205 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
3206 *
3207 * _.get(object, 'a[0].b.c');
3208 * // => 3
3209 *
3210 * _.get(object, ['a', '0', 'b', 'c']);
3211 * // => 3
3212 *
3213 * _.get(object, 'a.b.c', 'default');
3214 * // => 'default'
3215 */
3216 function get(object, path, defaultValue) {
3217 var result = object == null ? undefined : baseGet(object, path);
3218 return result === undefined ? defaultValue : result;
3219 }
3220
3221 /**
3222 * Gets the parent value at `path` of `object`.
3223 *
3224 * @private
3225 * @param {Object} object The object to query.
3226 * @param {Array} path The path to get the parent value of.
3227 * @returns {*} Returns the parent value.
3228 */
3229 function parent(object, path) {
3230 return path.length == 1 ? object : get(object, baseSlice(path, 0, -1));
3231 }
3232
3233 /**
3234 * Checks if `path` exists on `object`.
3235 *
3236 * @private
3237 * @param {Object} object The object to query.
3238 * @param {Array|string} path The path to check.
3239 * @param {Function} hasFunc The function to check properties.
3240 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3241 */
3242 function hasPath(object, path, hasFunc) {
3243 if (object == null) {
3244 return false;
3245 }
3246 var result = hasFunc(object, path);
3247 if (!result && !isKey(path)) {
3248 path = baseCastPath(path);
3249 object = parent(object, path);
3250 if (object != null) {
3251 path = last(path);
3252 result = hasFunc(object, path);
3253 }
3254 }
3255 var length = object ? object.length : undefined;
3256 return result || (
3257 !!length && isLength(length) && isIndex(path, length) &&
3258 (isArray(object) || isString(object) || isArguments(object))
3259 );
3260 }
3261
3262 /**
3263 * Checks if `path` is a direct property of `object`.
3264 *
3265 * @static
3266 * @memberOf _
3267 * @category Object
3268 * @param {Object} object The object to query.
3269 * @param {Array|string} path The path to check.
3270 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3271 * @example
3272 *
3273 * var object = { 'a': { 'b': { 'c': 3 } } };
3274 * var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
3275 *
3276 * _.has(object, 'a');
3277 * // => true
3278 *
3279 * _.has(object, 'a.b.c');
3280 * // => true
3281 *
3282 * _.has(object, ['a', 'b', 'c']);
3283 * // => true
3284 *
3285 * _.has(other, 'a');
3286 * // => false
3287 */
3288 function has(object, path) {
3289 return hasPath(object, path, baseHas);
3290 }
3291
3292 function memoize(fn, hasher) {
3293 var memo = Object.create(null);
3294 var queues = Object.create(null);
3295 hasher = hasher || identity;
3296 var memoized = initialParams(function memoized(args, callback) {
3297 var key = hasher.apply(null, args);
3298 if (has(memo, key)) {
3299 setImmediate$1(function () {
3300 callback.apply(null, memo[key]);
3301 });
3302 } else if (has(queues, key)) {
3303 queues[key].push(callback);
3304 } else {
3305 queues[key] = [callback];
3306 fn.apply(null, args.concat([rest(function (args) {
3307 memo[key] = args;
3308 var q = queues[key];
3309 delete queues[key];
3310 for (var i = 0, l = q.length; i < l; i++) {
3311 q[i].apply(null, args);
3312 }
3313 })]));
3314 }
3315 });
3316 memoized.memo = memo;
3317 memoized.unmemoized = fn;
3318 return memoized;
3319 }
3320
3321 function _parallel(eachfn, tasks, callback) {
3322 callback = callback || noop;
3323 var results = isArrayLike(tasks) ? [] : {};
3324
3325 eachfn(tasks, function (task, key, callback) {
3326 task(rest(function (err, args) {
3327 if (args.length <= 1) {
3328 args = args[0];
3329 }
3330 results[key] = args;
3331 callback(err);
3332 }));
3333 }, function (err) {
3334 callback(err, results);
3335 });
3336 }
3337
3338 function parallelLimit(tasks, limit, cb) {
3339 return _parallel(_eachOfLimit(limit), tasks, cb);
3340 }
3341
3342 var parallel = doLimit(parallelLimit, Infinity);
3343
3344 function queue$1 (worker, concurrency) {
3345 return queue(function (items, cb) {
3346 worker(items[0], cb);
3347 }, concurrency, 1);
3348 }
3349
3350 function priorityQueue (worker, concurrency) {
3351 function _compareTasks(a, b) {
3352 return a.priority - b.priority;
3353 }
3354
3355 function _binarySearch(sequence, item, compare) {
3356 var beg = -1,
3357 end = sequence.length - 1;
3358 while (beg < end) {
3359 var mid = beg + (end - beg + 1 >>> 1);
3360 if (compare(item, sequence[mid]) >= 0) {
3361 beg = mid;
3362 } else {
3363 end = mid - 1;
3364 }
3365 }
3366 return beg;
3367 }
3368
3369 function _insert(q, data, priority, callback) {
3370 if (callback != null && typeof callback !== 'function') {
3371 throw new Error('task callback must be a function');
3372 }
3373 q.started = true;
3374 if (!isArray(data)) {
3375 data = [data];
3376 }
3377 if (data.length === 0) {
3378 // call drain immediately if there are no tasks
3379 return setImmediate$1(function () {
3380 q.drain();
3381 });
3382 }
3383 arrayEach(data, function (task) {
3384 var item = {
3385 data: task,
3386 priority: priority,
3387 callback: typeof callback === 'function' ? callback : noop
3388 };
3389
3390 q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);
3391
3392 if (q.tasks.length === q.concurrency) {
3393 q.saturated();
3394 }
3395 if (q.tasks.length <= q.concurrency - q.buffer) {
3396 q.unsaturated();
3397 }
3398 setImmediate$1(q.process);
3399 });
3400 }
3401
3402 // Start with a normal queue
3403 var q = queue$1(worker, concurrency);
3404
3405 // Override push to accept second parameter representing priority
3406 q.push = function (data, priority, callback) {
3407 _insert(q, data, priority, callback);
3408 };
3409
3410 // Remove unshift function
3411 delete q.unshift;
3412
3413 return q;
3414 }
3415
3416 /**
3417 * Creates a `baseEach` or `baseEachRight` function.
3418 *
3419 * @private
3420 * @param {Function} eachFunc The function to iterate over a collection.
3421 * @param {boolean} [fromRight] Specify iterating from right to left.
3422 * @returns {Function} Returns the new base function.
3423 */
3424 function createBaseEach(eachFunc, fromRight) {
3425 return function(collection, iteratee) {
3426 if (collection == null) {
3427 return collection;
3428 }
3429 if (!isArrayLike(collection)) {
3430 return eachFunc(collection, iteratee);
3431 }
3432 var length = collection.length,
3433 index = fromRight ? length : -1,
3434 iterable = Object(collection);
3435
3436 while ((fromRight ? index-- : ++index < length)) {
3437 if (iteratee(iterable[index], index, iterable) === false) {
3438 break;
3439 }
3440 }
3441 return collection;
3442 };
3443 }
3444
3445 /**
3446 * The base implementation of `_.forEach` without support for iteratee shorthands.
3447 *
3448 * @private
3449 * @param {Array|Object} collection The collection to iterate over.
3450 * @param {Function} iteratee The function invoked per iteration.
3451 * @returns {Array|Object} Returns `collection`.
3452 */
3453 var baseEach = createBaseEach(baseForOwn);
3454
3455 /**
3456 * Iterates over elements of `collection` invoking `iteratee` for each element.
3457 * The iteratee is invoked with three arguments: (value, index|key, collection).
3458 * Iteratee functions may exit iteration early by explicitly returning `false`.
3459 *
3460 * **Note:** As with other "Collections" methods, objects with a "length" property
3461 * are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn`
3462 * for object iteration.
3463 *
3464 * @static
3465 * @memberOf _
3466 * @alias each
3467 * @category Collection
3468 * @param {Array|Object} collection The collection to iterate over.
3469 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
3470 * @returns {Array|Object} Returns `collection`.
3471 * @example
3472 *
3473 * _([1, 2]).forEach(function(value) {
3474 * console.log(value);
3475 * });
3476 * // => logs `1` then `2`
3477 *
3478 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
3479 * console.log(key);
3480 * });
3481 * // => logs 'a' then 'b' (iteration order is not guaranteed)
3482 */
3483 function forEach(collection, iteratee) {
3484 return (typeof iteratee == 'function' && isArray(collection))
3485 ? arrayEach(collection, iteratee)
3486 : baseEach(collection, baseCastFunction(iteratee));
3487 }
3488
3489 function race(tasks, cb) {
3490 cb = once(cb || noop);
3491 if (!isArray(tasks)) return cb(new TypeError('First argument to race must be an array of functions'));
3492 if (!tasks.length) return cb();
3493 forEach(tasks, function (task) {
3494 task(cb);
3495 });
3496 }
3497
3498 var slice = Array.prototype.slice;
3499
3500 function reduceRight(arr, memo, iteratee, cb) {
3501 var reversed = slice.call(arr).reverse();
3502 reduce(reversed, memo, iteratee, cb);
3503 }
3504
3505 function reject$1(eachfn, arr, iteratee, callback) {
3506 _filter(eachfn, arr, function (value, cb) {
3507 iteratee(value, function (err, v) {
3508 if (err) {
3509 cb(err);
3510 } else {
3511 cb(null, !v);
3512 }
3513 });
3514 }, callback);
3515 }
3516
3517 var rejectLimit = doParallelLimit(reject$1);
3518
3519 var reject = doLimit(rejectLimit, Infinity);
3520
3521 var rejectSeries = doLimit(rejectLimit, 1);
3522
3523 function series(tasks, cb) {
3524 return _parallel(eachOfSeries, tasks, cb);
3525 }
3526
3527 function retry(times, task, callback) {
3528 var DEFAULT_TIMES = 5;
3529 var DEFAULT_INTERVAL = 0;
3530
3531 var opts = {
3532 times: DEFAULT_TIMES,
3533 interval: DEFAULT_INTERVAL
3534 };
3535
3536 function parseTimes(acc, t) {
3537 if (typeof t === 'object') {
3538 acc.times = +t.times || DEFAULT_TIMES;
3539 acc.interval = +t.interval || DEFAULT_INTERVAL;
3540 } else if (typeof t === 'number' || typeof t === 'string') {
3541 acc.times = +t || DEFAULT_TIMES;
3542 } else {
3543 throw new Error("Invalid arguments for async.retry");
3544 }
3545 }
3546
3547 if (arguments.length < 3 && typeof times === 'function') {
3548 callback = task || noop;
3549 task = times;
3550 } else {
3551 parseTimes(opts, times);
3552 callback = callback || noop;
3553 }
3554
3555 if (typeof task !== 'function') {
3556 throw new Error("Invalid arguments for async.retry");
3557 }
3558
3559 var attempts = [];
3560 while (opts.times) {
3561 var isFinalAttempt = !(opts.times -= 1);
3562 attempts.push(retryAttempt(isFinalAttempt));
3563 if (!isFinalAttempt && opts.interval > 0) {
3564 attempts.push(retryInterval(opts.interval));
3565 }
3566 }
3567
3568 series(attempts, function (done, data) {
3569 data = data[data.length - 1];
3570 callback(data.err, data.result);
3571 });
3572
3573 function retryAttempt(isFinalAttempt) {
3574 return function (seriesCallback) {
3575 task(function (err, result) {
3576 seriesCallback(!err || isFinalAttempt, {
3577 err: err,
3578 result: result
3579 });
3580 });
3581 };
3582 }
3583
3584 function retryInterval(interval) {
3585 return function (seriesCallback) {
3586 setTimeout(function () {
3587 seriesCallback(null);
3588 }, interval);
3589 };
3590 }
3591 }
3592
3593 function retryable (opts, task) {
3594 if (!task) {
3595 task = opts;
3596 opts = null;
3597 }
3598 return initialParams(function (args, callback) {
3599 function taskFn(cb) {
3600 task.apply(null, args.concat([cb]));
3601 }
3602
3603 if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
3604 });
3605 }
3606
3607 var someLimit = _createTester(eachOfLimit, Boolean, identity);
3608
3609 var some = doLimit(someLimit, Infinity);
3610
3611 var someSeries = doLimit(someLimit, 1);
3612
3613 function sortBy(arr, iteratee, cb) {
3614 map(arr, function (x, cb) {
3615 iteratee(x, function (err, criteria) {
3616 if (err) return cb(err);
3617 cb(null, { value: x, criteria: criteria });
3618 });
3619 }, function (err, results) {
3620 if (err) return cb(err);
3621 cb(null, arrayMap(results.sort(comparator), baseProperty('value')));
3622 });
3623
3624 function comparator(left, right) {
3625 var a = left.criteria,
3626 b = right.criteria;
3627 return a < b ? -1 : a > b ? 1 : 0;
3628 }
3629 }
3630
3631 function timeout(asyncFn, miliseconds) {
3632 var originalCallback, timer;
3633 var timedOut = false;
3634
3635 function injectedCallback() {
3636 if (!timedOut) {
3637 originalCallback.apply(null, arguments);
3638 clearTimeout(timer);
3639 }
3640 }
3641
3642 function timeoutCallback() {
3643 var error = new Error('Callback function timed out.');
3644 error.code = 'ETIMEDOUT';
3645 timedOut = true;
3646 originalCallback(error);
3647 }
3648
3649 return initialParams(function (args, origCallback) {
3650 originalCallback = origCallback;
3651 // setup timer and call original function
3652 timer = setTimeout(timeoutCallback, miliseconds);
3653 asyncFn.apply(null, args.concat(injectedCallback));
3654 });
3655 }
3656
3657 /* Built-in method references for those with the same name as other `lodash` methods. */
3658 var nativeCeil = Math.ceil;
3659 var nativeMax$2 = Math.max;
3660 /**
3661 * The base implementation of `_.range` and `_.rangeRight` which doesn't
3662 * coerce arguments to numbers.
3663 *
3664 * @private
3665 * @param {number} start The start of the range.
3666 * @param {number} end The end of the range.
3667 * @param {number} step The value to increment or decrement by.
3668 * @param {boolean} [fromRight] Specify iterating from right to left.
3669 * @returns {Array} Returns the new array of numbers.
3670 */
3671 function baseRange(start, end, step, fromRight) {
3672 var index = -1,
3673 length = nativeMax$2(nativeCeil((end - start) / (step || 1)), 0),
3674 result = Array(length);
3675
3676 while (length--) {
3677 result[fromRight ? length : ++index] = start;
3678 start += step;
3679 }
3680 return result;
3681 }
3682
3683 function timeLimit(count, limit, iteratee, cb) {
3684 return mapLimit(baseRange(0, count, 1), limit, iteratee, cb);
3685 }
3686
3687 var times = doLimit(timeLimit, Infinity);
3688
3689 var timesSeries = doLimit(timeLimit, 1);
3690
3691 function transform(arr, memo, iteratee, callback) {
3692 if (arguments.length === 3) {
3693 callback = iteratee;
3694 iteratee = memo;
3695 memo = isArray(arr) ? [] : {};
3696 }
3697
3698 eachOf(arr, function (v, k, cb) {
3699 iteratee(memo, v, k, cb);
3700 }, function (err) {
3701 callback(err, memo);
3702 });
3703 }
3704
3705 function unmemoize(fn) {
3706 return function () {
3707 return (fn.unmemoized || fn).apply(null, arguments);
3708 };
3709 }
3710
3711 function until(test, iteratee, cb) {
3712 return whilst(function () {
3713 return !test.apply(this, arguments);
3714 }, iteratee, cb);
3715 }
3716
3717 function waterfall (tasks, cb) {
3718 cb = once(cb || noop);
3719 if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
3720 if (!tasks.length) return cb();
3721 var taskIndex = 0;
3722
3723 function nextTask(args) {
3724 if (taskIndex === tasks.length) {
3725 return cb.apply(null, [null].concat(args));
3726 }
3727
3728 var taskCallback = onlyOnce(rest(function (err, args) {
3729 if (err) {
3730 return cb.apply(null, [err].concat(args));
3731 }
3732 nextTask(args);
3733 }));
3734
3735 args.push(taskCallback);
3736
3737 var task = tasks[taskIndex++];
3738 task.apply(null, args);
3739 }
3740
3741 nextTask([]);
3742 }
3743
3744 var index = {
3745 applyEach: applyEach,
3746 applyEachSeries: applyEachSeries,
3747 apply: apply$1,
3748 asyncify: asyncify,
3749 auto: auto,
3750 autoInject: autoInject,
3751 cargo: cargo,
3752 compose: compose,
3753 concat: concat,
3754 concatSeries: concatSeries,
3755 constant: constant$1,
3756 detect: detect,
3757 detectLimit: detectLimit,
3758 detectSeries: detectSeries,
3759 dir: dir,
3760 doDuring: doDuring,
3761 doUntil: doUntil,
3762 doWhilst: doWhilst,
3763 during: during,
3764 each: each,
3765 eachLimit: eachLimit,
3766 eachOf: eachOf,
3767 eachOfLimit: eachOfLimit,
3768 eachOfSeries: eachOfSeries,
3769 eachSeries: eachSeries,
3770 ensureAsync: ensureAsync,
3771 every: every,
3772 everyLimit: everyLimit,
3773 everySeries: everySeries,
3774 filter: filter,
3775 filterLimit: filterLimit,
3776 filterSeries: filterSeries,
3777 forever: forever,
3778 iterator: iterator$1,
3779 log: log,
3780 map: map,
3781 mapLimit: mapLimit,
3782 mapSeries: mapSeries,
3783 memoize: memoize,
3784 nextTick: setImmediate$1,
3785 parallel: parallel,
3786 parallelLimit: parallelLimit,
3787 priorityQueue: priorityQueue,
3788 queue: queue$1,
3789 race: race,
3790 reduce: reduce,
3791 reduceRight: reduceRight,
3792 reject: reject,
3793 rejectLimit: rejectLimit,
3794 rejectSeries: rejectSeries,
3795 retry: retry,
3796 retryable: retryable,
3797 seq: seq,
3798 series: series,
3799 setImmediate: setImmediate$1,
3800 some: some,
3801 someLimit: someLimit,
3802 someSeries: someSeries,
3803 sortBy: sortBy,
3804 timeout: timeout,
3805 times: times,
3806 timesLimit: timeLimit,
3807 timesSeries: timesSeries,
3808 transform: transform,
3809 unmemoize: unmemoize,
3810 until: until,
3811 waterfall: waterfall,
3812 whilst: whilst,
3813
3814 // aliases
3815 all: every,
3816 any: some,
3817 forEach: each,
3818 forEachSeries: eachSeries,
3819 forEachLimit: eachLimit,
3820 forEachOf: eachOf,
3821 forEachOfSeries: eachOfSeries,
3822 forEachOfLimit: eachOfLimit,
3823 inject: reduce,
3824 foldl: reduce,
3825 foldr: reduceRight,
3826 select: filter,
3827 selectLimit: filterLimit,
3828 selectSeries: filterSeries,
3829 wrapSync: asyncify
3830 };
3831
3832 exports['default'] = index;
3833 exports.applyEach = applyEach;
3834 exports.applyEachSeries = applyEachSeries;
3835 exports.apply = apply$1;
3836 exports.asyncify = asyncify;
3837 exports.auto = auto;
3838 exports.autoInject = autoInject;
3839 exports.cargo = cargo;
3840 exports.compose = compose;
3841 exports.concat = concat;
3842 exports.concatSeries = concatSeries;
3843 exports.constant = constant$1;
3844 exports.detect = detect;
3845 exports.detectLimit = detectLimit;
3846 exports.detectSeries = detectSeries;
3847 exports.dir = dir;
3848 exports.doDuring = doDuring;
3849 exports.doUntil = doUntil;
3850 exports.doWhilst = doWhilst;
3851 exports.during = during;
3852 exports.each = each;
3853 exports.eachLimit = eachLimit;
3854 exports.eachOf = eachOf;
3855 exports.eachOfLimit = eachOfLimit;
3856 exports.eachOfSeries = eachOfSeries;
3857 exports.eachSeries = eachSeries;
3858 exports.ensureAsync = ensureAsync;
3859 exports.every = every;
3860 exports.everyLimit = everyLimit;
3861 exports.everySeries = everySeries;
3862 exports.filter = filter;
3863 exports.filterLimit = filterLimit;
3864 exports.filterSeries = filterSeries;
3865 exports.forever = forever;
3866 exports.iterator = iterator$1;
3867 exports.log = log;
3868 exports.map = map;
3869 exports.mapLimit = mapLimit;
3870 exports.mapSeries = mapSeries;
3871 exports.memoize = memoize;
3872 exports.nextTick = setImmediate$1;
3873 exports.parallel = parallel;
3874 exports.parallelLimit = parallelLimit;
3875 exports.priorityQueue = priorityQueue;
3876 exports.queue = queue$1;
3877 exports.race = race;
3878 exports.reduce = reduce;
3879 exports.reduceRight = reduceRight;
3880 exports.reject = reject;
3881 exports.rejectLimit = rejectLimit;
3882 exports.rejectSeries = rejectSeries;
3883 exports.retry = retry;
3884 exports.retryable = retryable;
3885 exports.seq = seq;
3886 exports.series = series;
3887 exports.setImmediate = setImmediate$1;
3888 exports.some = some;
3889 exports.someLimit = someLimit;
3890 exports.someSeries = someSeries;
3891 exports.sortBy = sortBy;
3892 exports.timeout = timeout;
3893 exports.times = times;
3894 exports.timesLimit = timeLimit;
3895 exports.timesSeries = timesSeries;
3896 exports.transform = transform;
3897 exports.unmemoize = unmemoize;
3898 exports.until = until;
3899 exports.waterfall = waterfall;
3900 exports.whilst = whilst;
3901 exports.all = every;
3902 exports.allLimit = everyLimit;
3903 exports.allSeries = everySeries;
3904 exports.any = some;
3905 exports.anyLimit = someLimit;
3906 exports.anySeries = someSeries;
3907 exports.find = detect;
3908 exports.findLimit = detectLimit;
3909 exports.findSeries = detectSeries;
3910 exports.forEach = each;
3911 exports.forEachSeries = eachSeries;
3912 exports.forEachLimit = eachLimit;
3913 exports.forEachOf = eachOf;
3914 exports.forEachOfSeries = eachOfSeries;
3915 exports.forEachOfLimit = eachOfLimit;
3916 exports.inject = reduce;
3917 exports.foldl = reduce;
3918 exports.foldr = reduceRight;
3919 exports.select = filter;
3920 exports.selectLimit = filterLimit;
3921 exports.selectSeries = filterSeries;
3922 exports.wrapSync = asyncify;
3923
3924}));
\No newline at end of file