Initial commit
[yaffs-website] / node_modules / lodash.mapvalues / index.js
1 /**
2  * lodash (Custom Build) <https://lodash.com/>
3  * Build: `lodash modularize exports="npm" -o ./`
4  * Copyright jQuery Foundation and other contributors <https://jquery.org/>
5  * Released under MIT license <https://lodash.com/license>
6  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8  */
9
10 /** Used as the size to enable large array optimizations. */
11 var LARGE_ARRAY_SIZE = 200;
12
13 /** Used as the `TypeError` message for "Functions" methods. */
14 var FUNC_ERROR_TEXT = 'Expected a function';
15
16 /** Used to stand-in for `undefined` hash values. */
17 var HASH_UNDEFINED = '__lodash_hash_undefined__';
18
19 /** Used to compose bitmasks for comparison styles. */
20 var UNORDERED_COMPARE_FLAG = 1,
21     PARTIAL_COMPARE_FLAG = 2;
22
23 /** Used as references for various `Number` constants. */
24 var INFINITY = 1 / 0,
25     MAX_SAFE_INTEGER = 9007199254740991;
26
27 /** `Object#toString` result references. */
28 var argsTag = '[object Arguments]',
29     arrayTag = '[object Array]',
30     boolTag = '[object Boolean]',
31     dateTag = '[object Date]',
32     errorTag = '[object Error]',
33     funcTag = '[object Function]',
34     genTag = '[object GeneratorFunction]',
35     mapTag = '[object Map]',
36     numberTag = '[object Number]',
37     objectTag = '[object Object]',
38     promiseTag = '[object Promise]',
39     regexpTag = '[object RegExp]',
40     setTag = '[object Set]',
41     stringTag = '[object String]',
42     symbolTag = '[object Symbol]',
43     weakMapTag = '[object WeakMap]';
44
45 var arrayBufferTag = '[object ArrayBuffer]',
46     dataViewTag = '[object DataView]',
47     float32Tag = '[object Float32Array]',
48     float64Tag = '[object Float64Array]',
49     int8Tag = '[object Int8Array]',
50     int16Tag = '[object Int16Array]',
51     int32Tag = '[object Int32Array]',
52     uint8Tag = '[object Uint8Array]',
53     uint8ClampedTag = '[object Uint8ClampedArray]',
54     uint16Tag = '[object Uint16Array]',
55     uint32Tag = '[object Uint32Array]';
56
57 /** Used to match property names within property paths. */
58 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
59     reIsPlainProp = /^\w*$/,
60     reLeadingDot = /^\./,
61     rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
62
63 /**
64  * Used to match `RegExp`
65  * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
66  */
67 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
68
69 /** Used to match backslashes in property paths. */
70 var reEscapeChar = /\\(\\)?/g;
71
72 /** Used to detect host constructors (Safari). */
73 var reIsHostCtor = /^\[object .+?Constructor\]$/;
74
75 /** Used to detect unsigned integer values. */
76 var reIsUint = /^(?:0|[1-9]\d*)$/;
77
78 /** Used to identify `toStringTag` values of typed arrays. */
79 var typedArrayTags = {};
80 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
81 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
82 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
83 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
84 typedArrayTags[uint32Tag] = true;
85 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
86 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
87 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
88 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
89 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
90 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
91 typedArrayTags[setTag] = typedArrayTags[stringTag] =
92 typedArrayTags[weakMapTag] = false;
93
94 /** Detect free variable `global` from Node.js. */
95 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
96
97 /** Detect free variable `self`. */
98 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
99
100 /** Used as a reference to the global object. */
101 var root = freeGlobal || freeSelf || Function('return this')();
102
103 /** Detect free variable `exports`. */
104 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
105
106 /** Detect free variable `module`. */
107 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
108
109 /** Detect the popular CommonJS extension `module.exports`. */
110 var moduleExports = freeModule && freeModule.exports === freeExports;
111
112 /** Detect free variable `process` from Node.js. */
113 var freeProcess = moduleExports && freeGlobal.process;
114
115 /** Used to access faster Node.js helpers. */
116 var nodeUtil = (function() {
117   try {
118     return freeProcess && freeProcess.binding('util');
119   } catch (e) {}
120 }());
121
122 /* Node.js helper references. */
123 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
124
125 /**
126  * A specialized version of `_.some` for arrays without support for iteratee
127  * shorthands.
128  *
129  * @private
130  * @param {Array} [array] The array to iterate over.
131  * @param {Function} predicate The function invoked per iteration.
132  * @returns {boolean} Returns `true` if any element passes the predicate check,
133  *  else `false`.
134  */
135 function arraySome(array, predicate) {
136   var index = -1,
137       length = array ? array.length : 0;
138
139   while (++index < length) {
140     if (predicate(array[index], index, array)) {
141       return true;
142     }
143   }
144   return false;
145 }
146
147 /**
148  * The base implementation of `_.property` without support for deep paths.
149  *
150  * @private
151  * @param {string} key The key of the property to get.
152  * @returns {Function} Returns the new accessor function.
153  */
154 function baseProperty(key) {
155   return function(object) {
156     return object == null ? undefined : object[key];
157   };
158 }
159
160 /**
161  * The base implementation of `_.times` without support for iteratee shorthands
162  * or max array length checks.
163  *
164  * @private
165  * @param {number} n The number of times to invoke `iteratee`.
166  * @param {Function} iteratee The function invoked per iteration.
167  * @returns {Array} Returns the array of results.
168  */
169 function baseTimes(n, iteratee) {
170   var index = -1,
171       result = Array(n);
172
173   while (++index < n) {
174     result[index] = iteratee(index);
175   }
176   return result;
177 }
178
179 /**
180  * The base implementation of `_.unary` without support for storing metadata.
181  *
182  * @private
183  * @param {Function} func The function to cap arguments for.
184  * @returns {Function} Returns the new capped function.
185  */
186 function baseUnary(func) {
187   return function(value) {
188     return func(value);
189   };
190 }
191
192 /**
193  * Gets the value at `key` of `object`.
194  *
195  * @private
196  * @param {Object} [object] The object to query.
197  * @param {string} key The key of the property to get.
198  * @returns {*} Returns the property value.
199  */
200 function getValue(object, key) {
201   return object == null ? undefined : object[key];
202 }
203
204 /**
205  * Checks if `value` is a host object in IE < 9.
206  *
207  * @private
208  * @param {*} value The value to check.
209  * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
210  */
211 function isHostObject(value) {
212   // Many host objects are `Object` objects that can coerce to strings
213   // despite having improperly defined `toString` methods.
214   var result = false;
215   if (value != null && typeof value.toString != 'function') {
216     try {
217       result = !!(value + '');
218     } catch (e) {}
219   }
220   return result;
221 }
222
223 /**
224  * Converts `map` to its key-value pairs.
225  *
226  * @private
227  * @param {Object} map The map to convert.
228  * @returns {Array} Returns the key-value pairs.
229  */
230 function mapToArray(map) {
231   var index = -1,
232       result = Array(map.size);
233
234   map.forEach(function(value, key) {
235     result[++index] = [key, value];
236   });
237   return result;
238 }
239
240 /**
241  * Creates a unary function that invokes `func` with its argument transformed.
242  *
243  * @private
244  * @param {Function} func The function to wrap.
245  * @param {Function} transform The argument transform.
246  * @returns {Function} Returns the new function.
247  */
248 function overArg(func, transform) {
249   return function(arg) {
250     return func(transform(arg));
251   };
252 }
253
254 /**
255  * Converts `set` to an array of its values.
256  *
257  * @private
258  * @param {Object} set The set to convert.
259  * @returns {Array} Returns the values.
260  */
261 function setToArray(set) {
262   var index = -1,
263       result = Array(set.size);
264
265   set.forEach(function(value) {
266     result[++index] = value;
267   });
268   return result;
269 }
270
271 /** Used for built-in method references. */
272 var arrayProto = Array.prototype,
273     funcProto = Function.prototype,
274     objectProto = Object.prototype;
275
276 /** Used to detect overreaching core-js shims. */
277 var coreJsData = root['__core-js_shared__'];
278
279 /** Used to detect methods masquerading as native. */
280 var maskSrcKey = (function() {
281   var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
282   return uid ? ('Symbol(src)_1.' + uid) : '';
283 }());
284
285 /** Used to resolve the decompiled source of functions. */
286 var funcToString = funcProto.toString;
287
288 /** Used to check objects for own properties. */
289 var hasOwnProperty = objectProto.hasOwnProperty;
290
291 /**
292  * Used to resolve the
293  * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
294  * of values.
295  */
296 var objectToString = objectProto.toString;
297
298 /** Used to detect if a method is native. */
299 var reIsNative = RegExp('^' +
300   funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
301   .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
302 );
303
304 /** Built-in value references. */
305 var Symbol = root.Symbol,
306     Uint8Array = root.Uint8Array,
307     propertyIsEnumerable = objectProto.propertyIsEnumerable,
308     splice = arrayProto.splice;
309
310 /* Built-in method references for those with the same name as other `lodash` methods. */
311 var nativeKeys = overArg(Object.keys, Object);
312
313 /* Built-in method references that are verified to be native. */
314 var DataView = getNative(root, 'DataView'),
315     Map = getNative(root, 'Map'),
316     Promise = getNative(root, 'Promise'),
317     Set = getNative(root, 'Set'),
318     WeakMap = getNative(root, 'WeakMap'),
319     nativeCreate = getNative(Object, 'create');
320
321 /** Used to detect maps, sets, and weakmaps. */
322 var dataViewCtorString = toSource(DataView),
323     mapCtorString = toSource(Map),
324     promiseCtorString = toSource(Promise),
325     setCtorString = toSource(Set),
326     weakMapCtorString = toSource(WeakMap);
327
328 /** Used to convert symbols to primitives and strings. */
329 var symbolProto = Symbol ? Symbol.prototype : undefined,
330     symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
331     symbolToString = symbolProto ? symbolProto.toString : undefined;
332
333 /**
334  * Creates a hash object.
335  *
336  * @private
337  * @constructor
338  * @param {Array} [entries] The key-value pairs to cache.
339  */
340 function Hash(entries) {
341   var index = -1,
342       length = entries ? entries.length : 0;
343
344   this.clear();
345   while (++index < length) {
346     var entry = entries[index];
347     this.set(entry[0], entry[1]);
348   }
349 }
350
351 /**
352  * Removes all key-value entries from the hash.
353  *
354  * @private
355  * @name clear
356  * @memberOf Hash
357  */
358 function hashClear() {
359   this.__data__ = nativeCreate ? nativeCreate(null) : {};
360 }
361
362 /**
363  * Removes `key` and its value from the hash.
364  *
365  * @private
366  * @name delete
367  * @memberOf Hash
368  * @param {Object} hash The hash to modify.
369  * @param {string} key The key of the value to remove.
370  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
371  */
372 function hashDelete(key) {
373   return this.has(key) && delete this.__data__[key];
374 }
375
376 /**
377  * Gets the hash value for `key`.
378  *
379  * @private
380  * @name get
381  * @memberOf Hash
382  * @param {string} key The key of the value to get.
383  * @returns {*} Returns the entry value.
384  */
385 function hashGet(key) {
386   var data = this.__data__;
387   if (nativeCreate) {
388     var result = data[key];
389     return result === HASH_UNDEFINED ? undefined : result;
390   }
391   return hasOwnProperty.call(data, key) ? data[key] : undefined;
392 }
393
394 /**
395  * Checks if a hash value for `key` exists.
396  *
397  * @private
398  * @name has
399  * @memberOf Hash
400  * @param {string} key The key of the entry to check.
401  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
402  */
403 function hashHas(key) {
404   var data = this.__data__;
405   return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
406 }
407
408 /**
409  * Sets the hash `key` to `value`.
410  *
411  * @private
412  * @name set
413  * @memberOf Hash
414  * @param {string} key The key of the value to set.
415  * @param {*} value The value to set.
416  * @returns {Object} Returns the hash instance.
417  */
418 function hashSet(key, value) {
419   var data = this.__data__;
420   data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
421   return this;
422 }
423
424 // Add methods to `Hash`.
425 Hash.prototype.clear = hashClear;
426 Hash.prototype['delete'] = hashDelete;
427 Hash.prototype.get = hashGet;
428 Hash.prototype.has = hashHas;
429 Hash.prototype.set = hashSet;
430
431 /**
432  * Creates an list cache object.
433  *
434  * @private
435  * @constructor
436  * @param {Array} [entries] The key-value pairs to cache.
437  */
438 function ListCache(entries) {
439   var index = -1,
440       length = entries ? entries.length : 0;
441
442   this.clear();
443   while (++index < length) {
444     var entry = entries[index];
445     this.set(entry[0], entry[1]);
446   }
447 }
448
449 /**
450  * Removes all key-value entries from the list cache.
451  *
452  * @private
453  * @name clear
454  * @memberOf ListCache
455  */
456 function listCacheClear() {
457   this.__data__ = [];
458 }
459
460 /**
461  * Removes `key` and its value from the list cache.
462  *
463  * @private
464  * @name delete
465  * @memberOf ListCache
466  * @param {string} key The key of the value to remove.
467  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
468  */
469 function listCacheDelete(key) {
470   var data = this.__data__,
471       index = assocIndexOf(data, key);
472
473   if (index < 0) {
474     return false;
475   }
476   var lastIndex = data.length - 1;
477   if (index == lastIndex) {
478     data.pop();
479   } else {
480     splice.call(data, index, 1);
481   }
482   return true;
483 }
484
485 /**
486  * Gets the list cache value for `key`.
487  *
488  * @private
489  * @name get
490  * @memberOf ListCache
491  * @param {string} key The key of the value to get.
492  * @returns {*} Returns the entry value.
493  */
494 function listCacheGet(key) {
495   var data = this.__data__,
496       index = assocIndexOf(data, key);
497
498   return index < 0 ? undefined : data[index][1];
499 }
500
501 /**
502  * Checks if a list cache value for `key` exists.
503  *
504  * @private
505  * @name has
506  * @memberOf ListCache
507  * @param {string} key The key of the entry to check.
508  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
509  */
510 function listCacheHas(key) {
511   return assocIndexOf(this.__data__, key) > -1;
512 }
513
514 /**
515  * Sets the list cache `key` to `value`.
516  *
517  * @private
518  * @name set
519  * @memberOf ListCache
520  * @param {string} key The key of the value to set.
521  * @param {*} value The value to set.
522  * @returns {Object} Returns the list cache instance.
523  */
524 function listCacheSet(key, value) {
525   var data = this.__data__,
526       index = assocIndexOf(data, key);
527
528   if (index < 0) {
529     data.push([key, value]);
530   } else {
531     data[index][1] = value;
532   }
533   return this;
534 }
535
536 // Add methods to `ListCache`.
537 ListCache.prototype.clear = listCacheClear;
538 ListCache.prototype['delete'] = listCacheDelete;
539 ListCache.prototype.get = listCacheGet;
540 ListCache.prototype.has = listCacheHas;
541 ListCache.prototype.set = listCacheSet;
542
543 /**
544  * Creates a map cache object to store key-value pairs.
545  *
546  * @private
547  * @constructor
548  * @param {Array} [entries] The key-value pairs to cache.
549  */
550 function MapCache(entries) {
551   var index = -1,
552       length = entries ? entries.length : 0;
553
554   this.clear();
555   while (++index < length) {
556     var entry = entries[index];
557     this.set(entry[0], entry[1]);
558   }
559 }
560
561 /**
562  * Removes all key-value entries from the map.
563  *
564  * @private
565  * @name clear
566  * @memberOf MapCache
567  */
568 function mapCacheClear() {
569   this.__data__ = {
570     'hash': new Hash,
571     'map': new (Map || ListCache),
572     'string': new Hash
573   };
574 }
575
576 /**
577  * Removes `key` and its value from the map.
578  *
579  * @private
580  * @name delete
581  * @memberOf MapCache
582  * @param {string} key The key of the value to remove.
583  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
584  */
585 function mapCacheDelete(key) {
586   return getMapData(this, key)['delete'](key);
587 }
588
589 /**
590  * Gets the map value for `key`.
591  *
592  * @private
593  * @name get
594  * @memberOf MapCache
595  * @param {string} key The key of the value to get.
596  * @returns {*} Returns the entry value.
597  */
598 function mapCacheGet(key) {
599   return getMapData(this, key).get(key);
600 }
601
602 /**
603  * Checks if a map value for `key` exists.
604  *
605  * @private
606  * @name has
607  * @memberOf MapCache
608  * @param {string} key The key of the entry to check.
609  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
610  */
611 function mapCacheHas(key) {
612   return getMapData(this, key).has(key);
613 }
614
615 /**
616  * Sets the map `key` to `value`.
617  *
618  * @private
619  * @name set
620  * @memberOf MapCache
621  * @param {string} key The key of the value to set.
622  * @param {*} value The value to set.
623  * @returns {Object} Returns the map cache instance.
624  */
625 function mapCacheSet(key, value) {
626   getMapData(this, key).set(key, value);
627   return this;
628 }
629
630 // Add methods to `MapCache`.
631 MapCache.prototype.clear = mapCacheClear;
632 MapCache.prototype['delete'] = mapCacheDelete;
633 MapCache.prototype.get = mapCacheGet;
634 MapCache.prototype.has = mapCacheHas;
635 MapCache.prototype.set = mapCacheSet;
636
637 /**
638  *
639  * Creates an array cache object to store unique values.
640  *
641  * @private
642  * @constructor
643  * @param {Array} [values] The values to cache.
644  */
645 function SetCache(values) {
646   var index = -1,
647       length = values ? values.length : 0;
648
649   this.__data__ = new MapCache;
650   while (++index < length) {
651     this.add(values[index]);
652   }
653 }
654
655 /**
656  * Adds `value` to the array cache.
657  *
658  * @private
659  * @name add
660  * @memberOf SetCache
661  * @alias push
662  * @param {*} value The value to cache.
663  * @returns {Object} Returns the cache instance.
664  */
665 function setCacheAdd(value) {
666   this.__data__.set(value, HASH_UNDEFINED);
667   return this;
668 }
669
670 /**
671  * Checks if `value` is in the array cache.
672  *
673  * @private
674  * @name has
675  * @memberOf SetCache
676  * @param {*} value The value to search for.
677  * @returns {number} Returns `true` if `value` is found, else `false`.
678  */
679 function setCacheHas(value) {
680   return this.__data__.has(value);
681 }
682
683 // Add methods to `SetCache`.
684 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
685 SetCache.prototype.has = setCacheHas;
686
687 /**
688  * Creates a stack cache object to store key-value pairs.
689  *
690  * @private
691  * @constructor
692  * @param {Array} [entries] The key-value pairs to cache.
693  */
694 function Stack(entries) {
695   this.__data__ = new ListCache(entries);
696 }
697
698 /**
699  * Removes all key-value entries from the stack.
700  *
701  * @private
702  * @name clear
703  * @memberOf Stack
704  */
705 function stackClear() {
706   this.__data__ = new ListCache;
707 }
708
709 /**
710  * Removes `key` and its value from the stack.
711  *
712  * @private
713  * @name delete
714  * @memberOf Stack
715  * @param {string} key The key of the value to remove.
716  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
717  */
718 function stackDelete(key) {
719   return this.__data__['delete'](key);
720 }
721
722 /**
723  * Gets the stack value for `key`.
724  *
725  * @private
726  * @name get
727  * @memberOf Stack
728  * @param {string} key The key of the value to get.
729  * @returns {*} Returns the entry value.
730  */
731 function stackGet(key) {
732   return this.__data__.get(key);
733 }
734
735 /**
736  * Checks if a stack value for `key` exists.
737  *
738  * @private
739  * @name has
740  * @memberOf Stack
741  * @param {string} key The key of the entry to check.
742  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
743  */
744 function stackHas(key) {
745   return this.__data__.has(key);
746 }
747
748 /**
749  * Sets the stack `key` to `value`.
750  *
751  * @private
752  * @name set
753  * @memberOf Stack
754  * @param {string} key The key of the value to set.
755  * @param {*} value The value to set.
756  * @returns {Object} Returns the stack cache instance.
757  */
758 function stackSet(key, value) {
759   var cache = this.__data__;
760   if (cache instanceof ListCache) {
761     var pairs = cache.__data__;
762     if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
763       pairs.push([key, value]);
764       return this;
765     }
766     cache = this.__data__ = new MapCache(pairs);
767   }
768   cache.set(key, value);
769   return this;
770 }
771
772 // Add methods to `Stack`.
773 Stack.prototype.clear = stackClear;
774 Stack.prototype['delete'] = stackDelete;
775 Stack.prototype.get = stackGet;
776 Stack.prototype.has = stackHas;
777 Stack.prototype.set = stackSet;
778
779 /**
780  * Creates an array of the enumerable property names of the array-like `value`.
781  *
782  * @private
783  * @param {*} value The value to query.
784  * @param {boolean} inherited Specify returning inherited property names.
785  * @returns {Array} Returns the array of property names.
786  */
787 function arrayLikeKeys(value, inherited) {
788   // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
789   // Safari 9 makes `arguments.length` enumerable in strict mode.
790   var result = (isArray(value) || isArguments(value))
791     ? baseTimes(value.length, String)
792     : [];
793
794   var length = result.length,
795       skipIndexes = !!length;
796
797   for (var key in value) {
798     if ((inherited || hasOwnProperty.call(value, key)) &&
799         !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
800       result.push(key);
801     }
802   }
803   return result;
804 }
805
806 /**
807  * Gets the index at which the `key` is found in `array` of key-value pairs.
808  *
809  * @private
810  * @param {Array} array The array to inspect.
811  * @param {*} key The key to search for.
812  * @returns {number} Returns the index of the matched value, else `-1`.
813  */
814 function assocIndexOf(array, key) {
815   var length = array.length;
816   while (length--) {
817     if (eq(array[length][0], key)) {
818       return length;
819     }
820   }
821   return -1;
822 }
823
824 /**
825  * The base implementation of `baseForOwn` which iterates over `object`
826  * properties returned by `keysFunc` and invokes `iteratee` for each property.
827  * Iteratee functions may exit iteration early by explicitly returning `false`.
828  *
829  * @private
830  * @param {Object} object The object to iterate over.
831  * @param {Function} iteratee The function invoked per iteration.
832  * @param {Function} keysFunc The function to get the keys of `object`.
833  * @returns {Object} Returns `object`.
834  */
835 var baseFor = createBaseFor();
836
837 /**
838  * The base implementation of `_.forOwn` without support for iteratee shorthands.
839  *
840  * @private
841  * @param {Object} object The object to iterate over.
842  * @param {Function} iteratee The function invoked per iteration.
843  * @returns {Object} Returns `object`.
844  */
845 function baseForOwn(object, iteratee) {
846   return object && baseFor(object, iteratee, keys);
847 }
848
849 /**
850  * The base implementation of `_.get` without support for default values.
851  *
852  * @private
853  * @param {Object} object The object to query.
854  * @param {Array|string} path The path of the property to get.
855  * @returns {*} Returns the resolved value.
856  */
857 function baseGet(object, path) {
858   path = isKey(path, object) ? [path] : castPath(path);
859
860   var index = 0,
861       length = path.length;
862
863   while (object != null && index < length) {
864     object = object[toKey(path[index++])];
865   }
866   return (index && index == length) ? object : undefined;
867 }
868
869 /**
870  * The base implementation of `getTag`.
871  *
872  * @private
873  * @param {*} value The value to query.
874  * @returns {string} Returns the `toStringTag`.
875  */
876 function baseGetTag(value) {
877   return objectToString.call(value);
878 }
879
880 /**
881  * The base implementation of `_.hasIn` without support for deep paths.
882  *
883  * @private
884  * @param {Object} [object] The object to query.
885  * @param {Array|string} key The key to check.
886  * @returns {boolean} Returns `true` if `key` exists, else `false`.
887  */
888 function baseHasIn(object, key) {
889   return object != null && key in Object(object);
890 }
891
892 /**
893  * The base implementation of `_.isEqual` which supports partial comparisons
894  * and tracks traversed objects.
895  *
896  * @private
897  * @param {*} value The value to compare.
898  * @param {*} other The other value to compare.
899  * @param {Function} [customizer] The function to customize comparisons.
900  * @param {boolean} [bitmask] The bitmask of comparison flags.
901  *  The bitmask may be composed of the following flags:
902  *     1 - Unordered comparison
903  *     2 - Partial comparison
904  * @param {Object} [stack] Tracks traversed `value` and `other` objects.
905  * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
906  */
907 function baseIsEqual(value, other, customizer, bitmask, stack) {
908   if (value === other) {
909     return true;
910   }
911   if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
912     return value !== value && other !== other;
913   }
914   return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
915 }
916
917 /**
918  * A specialized version of `baseIsEqual` for arrays and objects which performs
919  * deep comparisons and tracks traversed objects enabling objects with circular
920  * references to be compared.
921  *
922  * @private
923  * @param {Object} object The object to compare.
924  * @param {Object} other The other object to compare.
925  * @param {Function} equalFunc The function to determine equivalents of values.
926  * @param {Function} [customizer] The function to customize comparisons.
927  * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
928  *  for more details.
929  * @param {Object} [stack] Tracks traversed `object` and `other` objects.
930  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
931  */
932 function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
933   var objIsArr = isArray(object),
934       othIsArr = isArray(other),
935       objTag = arrayTag,
936       othTag = arrayTag;
937
938   if (!objIsArr) {
939     objTag = getTag(object);
940     objTag = objTag == argsTag ? objectTag : objTag;
941   }
942   if (!othIsArr) {
943     othTag = getTag(other);
944     othTag = othTag == argsTag ? objectTag : othTag;
945   }
946   var objIsObj = objTag == objectTag && !isHostObject(object),
947       othIsObj = othTag == objectTag && !isHostObject(other),
948       isSameTag = objTag == othTag;
949
950   if (isSameTag && !objIsObj) {
951     stack || (stack = new Stack);
952     return (objIsArr || isTypedArray(object))
953       ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
954       : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
955   }
956   if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
957     var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
958         othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
959
960     if (objIsWrapped || othIsWrapped) {
961       var objUnwrapped = objIsWrapped ? object.value() : object,
962           othUnwrapped = othIsWrapped ? other.value() : other;
963
964       stack || (stack = new Stack);
965       return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
966     }
967   }
968   if (!isSameTag) {
969     return false;
970   }
971   stack || (stack = new Stack);
972   return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
973 }
974
975 /**
976  * The base implementation of `_.isMatch` without support for iteratee shorthands.
977  *
978  * @private
979  * @param {Object} object The object to inspect.
980  * @param {Object} source The object of property values to match.
981  * @param {Array} matchData The property names, values, and compare flags to match.
982  * @param {Function} [customizer] The function to customize comparisons.
983  * @returns {boolean} Returns `true` if `object` is a match, else `false`.
984  */
985 function baseIsMatch(object, source, matchData, customizer) {
986   var index = matchData.length,
987       length = index,
988       noCustomizer = !customizer;
989
990   if (object == null) {
991     return !length;
992   }
993   object = Object(object);
994   while (index--) {
995     var data = matchData[index];
996     if ((noCustomizer && data[2])
997           ? data[1] !== object[data[0]]
998           : !(data[0] in object)
999         ) {
1000       return false;
1001     }
1002   }
1003   while (++index < length) {
1004     data = matchData[index];
1005     var key = data[0],
1006         objValue = object[key],
1007         srcValue = data[1];
1008
1009     if (noCustomizer && data[2]) {
1010       if (objValue === undefined && !(key in object)) {
1011         return false;
1012       }
1013     } else {
1014       var stack = new Stack;
1015       if (customizer) {
1016         var result = customizer(objValue, srcValue, key, object, source, stack);
1017       }
1018       if (!(result === undefined
1019             ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
1020             : result
1021           )) {
1022         return false;
1023       }
1024     }
1025   }
1026   return true;
1027 }
1028
1029 /**
1030  * The base implementation of `_.isNative` without bad shim checks.
1031  *
1032  * @private
1033  * @param {*} value The value to check.
1034  * @returns {boolean} Returns `true` if `value` is a native function,
1035  *  else `false`.
1036  */
1037 function baseIsNative(value) {
1038   if (!isObject(value) || isMasked(value)) {
1039     return false;
1040   }
1041   var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1042   return pattern.test(toSource(value));
1043 }
1044
1045 /**
1046  * The base implementation of `_.isTypedArray` without Node.js optimizations.
1047  *
1048  * @private
1049  * @param {*} value The value to check.
1050  * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1051  */
1052 function baseIsTypedArray(value) {
1053   return isObjectLike(value) &&
1054     isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
1055 }
1056
1057 /**
1058  * The base implementation of `_.iteratee`.
1059  *
1060  * @private
1061  * @param {*} [value=_.identity] The value to convert to an iteratee.
1062  * @returns {Function} Returns the iteratee.
1063  */
1064 function baseIteratee(value) {
1065   // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
1066   // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
1067   if (typeof value == 'function') {
1068     return value;
1069   }
1070   if (value == null) {
1071     return identity;
1072   }
1073   if (typeof value == 'object') {
1074     return isArray(value)
1075       ? baseMatchesProperty(value[0], value[1])
1076       : baseMatches(value);
1077   }
1078   return property(value);
1079 }
1080
1081 /**
1082  * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1083  *
1084  * @private
1085  * @param {Object} object The object to query.
1086  * @returns {Array} Returns the array of property names.
1087  */
1088 function baseKeys(object) {
1089   if (!isPrototype(object)) {
1090     return nativeKeys(object);
1091   }
1092   var result = [];
1093   for (var key in Object(object)) {
1094     if (hasOwnProperty.call(object, key) && key != 'constructor') {
1095       result.push(key);
1096     }
1097   }
1098   return result;
1099 }
1100
1101 /**
1102  * The base implementation of `_.matches` which doesn't clone `source`.
1103  *
1104  * @private
1105  * @param {Object} source The object of property values to match.
1106  * @returns {Function} Returns the new spec function.
1107  */
1108 function baseMatches(source) {
1109   var matchData = getMatchData(source);
1110   if (matchData.length == 1 && matchData[0][2]) {
1111     return matchesStrictComparable(matchData[0][0], matchData[0][1]);
1112   }
1113   return function(object) {
1114     return object === source || baseIsMatch(object, source, matchData);
1115   };
1116 }
1117
1118 /**
1119  * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
1120  *
1121  * @private
1122  * @param {string} path The path of the property to get.
1123  * @param {*} srcValue The value to match.
1124  * @returns {Function} Returns the new spec function.
1125  */
1126 function baseMatchesProperty(path, srcValue) {
1127   if (isKey(path) && isStrictComparable(srcValue)) {
1128     return matchesStrictComparable(toKey(path), srcValue);
1129   }
1130   return function(object) {
1131     var objValue = get(object, path);
1132     return (objValue === undefined && objValue === srcValue)
1133       ? hasIn(object, path)
1134       : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
1135   };
1136 }
1137
1138 /**
1139  * A specialized version of `baseProperty` which supports deep paths.
1140  *
1141  * @private
1142  * @param {Array|string} path The path of the property to get.
1143  * @returns {Function} Returns the new accessor function.
1144  */
1145 function basePropertyDeep(path) {
1146   return function(object) {
1147     return baseGet(object, path);
1148   };
1149 }
1150
1151 /**
1152  * The base implementation of `_.toString` which doesn't convert nullish
1153  * values to empty strings.
1154  *
1155  * @private
1156  * @param {*} value The value to process.
1157  * @returns {string} Returns the string.
1158  */
1159 function baseToString(value) {
1160   // Exit early for strings to avoid a performance hit in some environments.
1161   if (typeof value == 'string') {
1162     return value;
1163   }
1164   if (isSymbol(value)) {
1165     return symbolToString ? symbolToString.call(value) : '';
1166   }
1167   var result = (value + '');
1168   return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1169 }
1170
1171 /**
1172  * Casts `value` to a path array if it's not one.
1173  *
1174  * @private
1175  * @param {*} value The value to inspect.
1176  * @returns {Array} Returns the cast property path array.
1177  */
1178 function castPath(value) {
1179   return isArray(value) ? value : stringToPath(value);
1180 }
1181
1182 /**
1183  * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1184  *
1185  * @private
1186  * @param {boolean} [fromRight] Specify iterating from right to left.
1187  * @returns {Function} Returns the new base function.
1188  */
1189 function createBaseFor(fromRight) {
1190   return function(object, iteratee, keysFunc) {
1191     var index = -1,
1192         iterable = Object(object),
1193         props = keysFunc(object),
1194         length = props.length;
1195
1196     while (length--) {
1197       var key = props[fromRight ? length : ++index];
1198       if (iteratee(iterable[key], key, iterable) === false) {
1199         break;
1200       }
1201     }
1202     return object;
1203   };
1204 }
1205
1206 /**
1207  * A specialized version of `baseIsEqualDeep` for arrays with support for
1208  * partial deep comparisons.
1209  *
1210  * @private
1211  * @param {Array} array The array to compare.
1212  * @param {Array} other The other array to compare.
1213  * @param {Function} equalFunc The function to determine equivalents of values.
1214  * @param {Function} customizer The function to customize comparisons.
1215  * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1216  *  for more details.
1217  * @param {Object} stack Tracks traversed `array` and `other` objects.
1218  * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1219  */
1220 function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
1221   var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1222       arrLength = array.length,
1223       othLength = other.length;
1224
1225   if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1226     return false;
1227   }
1228   // Assume cyclic values are equal.
1229   var stacked = stack.get(array);
1230   if (stacked && stack.get(other)) {
1231     return stacked == other;
1232   }
1233   var index = -1,
1234       result = true,
1235       seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
1236
1237   stack.set(array, other);
1238   stack.set(other, array);
1239
1240   // Ignore non-index properties.
1241   while (++index < arrLength) {
1242     var arrValue = array[index],
1243         othValue = other[index];
1244
1245     if (customizer) {
1246       var compared = isPartial
1247         ? customizer(othValue, arrValue, index, other, array, stack)
1248         : customizer(arrValue, othValue, index, array, other, stack);
1249     }
1250     if (compared !== undefined) {
1251       if (compared) {
1252         continue;
1253       }
1254       result = false;
1255       break;
1256     }
1257     // Recursively compare arrays (susceptible to call stack limits).
1258     if (seen) {
1259       if (!arraySome(other, function(othValue, othIndex) {
1260             if (!seen.has(othIndex) &&
1261                 (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
1262               return seen.add(othIndex);
1263             }
1264           })) {
1265         result = false;
1266         break;
1267       }
1268     } else if (!(
1269           arrValue === othValue ||
1270             equalFunc(arrValue, othValue, customizer, bitmask, stack)
1271         )) {
1272       result = false;
1273       break;
1274     }
1275   }
1276   stack['delete'](array);
1277   stack['delete'](other);
1278   return result;
1279 }
1280
1281 /**
1282  * A specialized version of `baseIsEqualDeep` for comparing objects of
1283  * the same `toStringTag`.
1284  *
1285  * **Note:** This function only supports comparing values with tags of
1286  * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1287  *
1288  * @private
1289  * @param {Object} object The object to compare.
1290  * @param {Object} other The other object to compare.
1291  * @param {string} tag The `toStringTag` of the objects to compare.
1292  * @param {Function} equalFunc The function to determine equivalents of values.
1293  * @param {Function} customizer The function to customize comparisons.
1294  * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1295  *  for more details.
1296  * @param {Object} stack Tracks traversed `object` and `other` objects.
1297  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1298  */
1299 function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
1300   switch (tag) {
1301     case dataViewTag:
1302       if ((object.byteLength != other.byteLength) ||
1303           (object.byteOffset != other.byteOffset)) {
1304         return false;
1305       }
1306       object = object.buffer;
1307       other = other.buffer;
1308
1309     case arrayBufferTag:
1310       if ((object.byteLength != other.byteLength) ||
1311           !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1312         return false;
1313       }
1314       return true;
1315
1316     case boolTag:
1317     case dateTag:
1318     case numberTag:
1319       // Coerce booleans to `1` or `0` and dates to milliseconds.
1320       // Invalid dates are coerced to `NaN`.
1321       return eq(+object, +other);
1322
1323     case errorTag:
1324       return object.name == other.name && object.message == other.message;
1325
1326     case regexpTag:
1327     case stringTag:
1328       // Coerce regexes to strings and treat strings, primitives and objects,
1329       // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1330       // for more details.
1331       return object == (other + '');
1332
1333     case mapTag:
1334       var convert = mapToArray;
1335
1336     case setTag:
1337       var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
1338       convert || (convert = setToArray);
1339
1340       if (object.size != other.size && !isPartial) {
1341         return false;
1342       }
1343       // Assume cyclic values are equal.
1344       var stacked = stack.get(object);
1345       if (stacked) {
1346         return stacked == other;
1347       }
1348       bitmask |= UNORDERED_COMPARE_FLAG;
1349
1350       // Recursively compare objects (susceptible to call stack limits).
1351       stack.set(object, other);
1352       var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
1353       stack['delete'](object);
1354       return result;
1355
1356     case symbolTag:
1357       if (symbolValueOf) {
1358         return symbolValueOf.call(object) == symbolValueOf.call(other);
1359       }
1360   }
1361   return false;
1362 }
1363
1364 /**
1365  * A specialized version of `baseIsEqualDeep` for objects with support for
1366  * partial deep comparisons.
1367  *
1368  * @private
1369  * @param {Object} object The object to compare.
1370  * @param {Object} other The other object to compare.
1371  * @param {Function} equalFunc The function to determine equivalents of values.
1372  * @param {Function} customizer The function to customize comparisons.
1373  * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1374  *  for more details.
1375  * @param {Object} stack Tracks traversed `object` and `other` objects.
1376  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1377  */
1378 function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
1379   var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1380       objProps = keys(object),
1381       objLength = objProps.length,
1382       othProps = keys(other),
1383       othLength = othProps.length;
1384
1385   if (objLength != othLength && !isPartial) {
1386     return false;
1387   }
1388   var index = objLength;
1389   while (index--) {
1390     var key = objProps[index];
1391     if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1392       return false;
1393     }
1394   }
1395   // Assume cyclic values are equal.
1396   var stacked = stack.get(object);
1397   if (stacked && stack.get(other)) {
1398     return stacked == other;
1399   }
1400   var result = true;
1401   stack.set(object, other);
1402   stack.set(other, object);
1403
1404   var skipCtor = isPartial;
1405   while (++index < objLength) {
1406     key = objProps[index];
1407     var objValue = object[key],
1408         othValue = other[key];
1409
1410     if (customizer) {
1411       var compared = isPartial
1412         ? customizer(othValue, objValue, key, other, object, stack)
1413         : customizer(objValue, othValue, key, object, other, stack);
1414     }
1415     // Recursively compare objects (susceptible to call stack limits).
1416     if (!(compared === undefined
1417           ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
1418           : compared
1419         )) {
1420       result = false;
1421       break;
1422     }
1423     skipCtor || (skipCtor = key == 'constructor');
1424   }
1425   if (result && !skipCtor) {
1426     var objCtor = object.constructor,
1427         othCtor = other.constructor;
1428
1429     // Non `Object` object instances with different constructors are not equal.
1430     if (objCtor != othCtor &&
1431         ('constructor' in object && 'constructor' in other) &&
1432         !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1433           typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1434       result = false;
1435     }
1436   }
1437   stack['delete'](object);
1438   stack['delete'](other);
1439   return result;
1440 }
1441
1442 /**
1443  * Gets the data for `map`.
1444  *
1445  * @private
1446  * @param {Object} map The map to query.
1447  * @param {string} key The reference key.
1448  * @returns {*} Returns the map data.
1449  */
1450 function getMapData(map, key) {
1451   var data = map.__data__;
1452   return isKeyable(key)
1453     ? data[typeof key == 'string' ? 'string' : 'hash']
1454     : data.map;
1455 }
1456
1457 /**
1458  * Gets the property names, values, and compare flags of `object`.
1459  *
1460  * @private
1461  * @param {Object} object The object to query.
1462  * @returns {Array} Returns the match data of `object`.
1463  */
1464 function getMatchData(object) {
1465   var result = keys(object),
1466       length = result.length;
1467
1468   while (length--) {
1469     var key = result[length],
1470         value = object[key];
1471
1472     result[length] = [key, value, isStrictComparable(value)];
1473   }
1474   return result;
1475 }
1476
1477 /**
1478  * Gets the native function at `key` of `object`.
1479  *
1480  * @private
1481  * @param {Object} object The object to query.
1482  * @param {string} key The key of the method to get.
1483  * @returns {*} Returns the function if it's native, else `undefined`.
1484  */
1485 function getNative(object, key) {
1486   var value = getValue(object, key);
1487   return baseIsNative(value) ? value : undefined;
1488 }
1489
1490 /**
1491  * Gets the `toStringTag` of `value`.
1492  *
1493  * @private
1494  * @param {*} value The value to query.
1495  * @returns {string} Returns the `toStringTag`.
1496  */
1497 var getTag = baseGetTag;
1498
1499 // Fallback for data views, maps, sets, and weak maps in IE 11,
1500 // for data views in Edge < 14, and promises in Node.js.
1501 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1502     (Map && getTag(new Map) != mapTag) ||
1503     (Promise && getTag(Promise.resolve()) != promiseTag) ||
1504     (Set && getTag(new Set) != setTag) ||
1505     (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1506   getTag = function(value) {
1507     var result = objectToString.call(value),
1508         Ctor = result == objectTag ? value.constructor : undefined,
1509         ctorString = Ctor ? toSource(Ctor) : undefined;
1510
1511     if (ctorString) {
1512       switch (ctorString) {
1513         case dataViewCtorString: return dataViewTag;
1514         case mapCtorString: return mapTag;
1515         case promiseCtorString: return promiseTag;
1516         case setCtorString: return setTag;
1517         case weakMapCtorString: return weakMapTag;
1518       }
1519     }
1520     return result;
1521   };
1522 }
1523
1524 /**
1525  * Checks if `path` exists on `object`.
1526  *
1527  * @private
1528  * @param {Object} object The object to query.
1529  * @param {Array|string} path The path to check.
1530  * @param {Function} hasFunc The function to check properties.
1531  * @returns {boolean} Returns `true` if `path` exists, else `false`.
1532  */
1533 function hasPath(object, path, hasFunc) {
1534   path = isKey(path, object) ? [path] : castPath(path);
1535
1536   var result,
1537       index = -1,
1538       length = path.length;
1539
1540   while (++index < length) {
1541     var key = toKey(path[index]);
1542     if (!(result = object != null && hasFunc(object, key))) {
1543       break;
1544     }
1545     object = object[key];
1546   }
1547   if (result) {
1548     return result;
1549   }
1550   var length = object ? object.length : 0;
1551   return !!length && isLength(length) && isIndex(key, length) &&
1552     (isArray(object) || isArguments(object));
1553 }
1554
1555 /**
1556  * Checks if `value` is a valid array-like index.
1557  *
1558  * @private
1559  * @param {*} value The value to check.
1560  * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1561  * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1562  */
1563 function isIndex(value, length) {
1564   length = length == null ? MAX_SAFE_INTEGER : length;
1565   return !!length &&
1566     (typeof value == 'number' || reIsUint.test(value)) &&
1567     (value > -1 && value % 1 == 0 && value < length);
1568 }
1569
1570 /**
1571  * Checks if `value` is a property name and not a property path.
1572  *
1573  * @private
1574  * @param {*} value The value to check.
1575  * @param {Object} [object] The object to query keys on.
1576  * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1577  */
1578 function isKey(value, object) {
1579   if (isArray(value)) {
1580     return false;
1581   }
1582   var type = typeof value;
1583   if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1584       value == null || isSymbol(value)) {
1585     return true;
1586   }
1587   return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1588     (object != null && value in Object(object));
1589 }
1590
1591 /**
1592  * Checks if `value` is suitable for use as unique object key.
1593  *
1594  * @private
1595  * @param {*} value The value to check.
1596  * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1597  */
1598 function isKeyable(value) {
1599   var type = typeof value;
1600   return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1601     ? (value !== '__proto__')
1602     : (value === null);
1603 }
1604
1605 /**
1606  * Checks if `func` has its source masked.
1607  *
1608  * @private
1609  * @param {Function} func The function to check.
1610  * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1611  */
1612 function isMasked(func) {
1613   return !!maskSrcKey && (maskSrcKey in func);
1614 }
1615
1616 /**
1617  * Checks if `value` is likely a prototype object.
1618  *
1619  * @private
1620  * @param {*} value The value to check.
1621  * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1622  */
1623 function isPrototype(value) {
1624   var Ctor = value && value.constructor,
1625       proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1626
1627   return value === proto;
1628 }
1629
1630 /**
1631  * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
1632  *
1633  * @private
1634  * @param {*} value The value to check.
1635  * @returns {boolean} Returns `true` if `value` if suitable for strict
1636  *  equality comparisons, else `false`.
1637  */
1638 function isStrictComparable(value) {
1639   return value === value && !isObject(value);
1640 }
1641
1642 /**
1643  * A specialized version of `matchesProperty` for source values suitable
1644  * for strict equality comparisons, i.e. `===`.
1645  *
1646  * @private
1647  * @param {string} key The key of the property to get.
1648  * @param {*} srcValue The value to match.
1649  * @returns {Function} Returns the new spec function.
1650  */
1651 function matchesStrictComparable(key, srcValue) {
1652   return function(object) {
1653     if (object == null) {
1654       return false;
1655     }
1656     return object[key] === srcValue &&
1657       (srcValue !== undefined || (key in Object(object)));
1658   };
1659 }
1660
1661 /**
1662  * Converts `string` to a property path array.
1663  *
1664  * @private
1665  * @param {string} string The string to convert.
1666  * @returns {Array} Returns the property path array.
1667  */
1668 var stringToPath = memoize(function(string) {
1669   string = toString(string);
1670
1671   var result = [];
1672   if (reLeadingDot.test(string)) {
1673     result.push('');
1674   }
1675   string.replace(rePropName, function(match, number, quote, string) {
1676     result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
1677   });
1678   return result;
1679 });
1680
1681 /**
1682  * Converts `value` to a string key if it's not a string or symbol.
1683  *
1684  * @private
1685  * @param {*} value The value to inspect.
1686  * @returns {string|symbol} Returns the key.
1687  */
1688 function toKey(value) {
1689   if (typeof value == 'string' || isSymbol(value)) {
1690     return value;
1691   }
1692   var result = (value + '');
1693   return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1694 }
1695
1696 /**
1697  * Converts `func` to its source code.
1698  *
1699  * @private
1700  * @param {Function} func The function to process.
1701  * @returns {string} Returns the source code.
1702  */
1703 function toSource(func) {
1704   if (func != null) {
1705     try {
1706       return funcToString.call(func);
1707     } catch (e) {}
1708     try {
1709       return (func + '');
1710     } catch (e) {}
1711   }
1712   return '';
1713 }
1714
1715 /**
1716  * Creates a function that memoizes the result of `func`. If `resolver` is
1717  * provided, it determines the cache key for storing the result based on the
1718  * arguments provided to the memoized function. By default, the first argument
1719  * provided to the memoized function is used as the map cache key. The `func`
1720  * is invoked with the `this` binding of the memoized function.
1721  *
1722  * **Note:** The cache is exposed as the `cache` property on the memoized
1723  * function. Its creation may be customized by replacing the `_.memoize.Cache`
1724  * constructor with one whose instances implement the
1725  * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1726  * method interface of `delete`, `get`, `has`, and `set`.
1727  *
1728  * @static
1729  * @memberOf _
1730  * @since 0.1.0
1731  * @category Function
1732  * @param {Function} func The function to have its output memoized.
1733  * @param {Function} [resolver] The function to resolve the cache key.
1734  * @returns {Function} Returns the new memoized function.
1735  * @example
1736  *
1737  * var object = { 'a': 1, 'b': 2 };
1738  * var other = { 'c': 3, 'd': 4 };
1739  *
1740  * var values = _.memoize(_.values);
1741  * values(object);
1742  * // => [1, 2]
1743  *
1744  * values(other);
1745  * // => [3, 4]
1746  *
1747  * object.a = 2;
1748  * values(object);
1749  * // => [1, 2]
1750  *
1751  * // Modify the result cache.
1752  * values.cache.set(object, ['a', 'b']);
1753  * values(object);
1754  * // => ['a', 'b']
1755  *
1756  * // Replace `_.memoize.Cache`.
1757  * _.memoize.Cache = WeakMap;
1758  */
1759 function memoize(func, resolver) {
1760   if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
1761     throw new TypeError(FUNC_ERROR_TEXT);
1762   }
1763   var memoized = function() {
1764     var args = arguments,
1765         key = resolver ? resolver.apply(this, args) : args[0],
1766         cache = memoized.cache;
1767
1768     if (cache.has(key)) {
1769       return cache.get(key);
1770     }
1771     var result = func.apply(this, args);
1772     memoized.cache = cache.set(key, result);
1773     return result;
1774   };
1775   memoized.cache = new (memoize.Cache || MapCache);
1776   return memoized;
1777 }
1778
1779 // Assign cache to `_.memoize`.
1780 memoize.Cache = MapCache;
1781
1782 /**
1783  * Performs a
1784  * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1785  * comparison between two values to determine if they are equivalent.
1786  *
1787  * @static
1788  * @memberOf _
1789  * @since 4.0.0
1790  * @category Lang
1791  * @param {*} value The value to compare.
1792  * @param {*} other The other value to compare.
1793  * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1794  * @example
1795  *
1796  * var object = { 'a': 1 };
1797  * var other = { 'a': 1 };
1798  *
1799  * _.eq(object, object);
1800  * // => true
1801  *
1802  * _.eq(object, other);
1803  * // => false
1804  *
1805  * _.eq('a', 'a');
1806  * // => true
1807  *
1808  * _.eq('a', Object('a'));
1809  * // => false
1810  *
1811  * _.eq(NaN, NaN);
1812  * // => true
1813  */
1814 function eq(value, other) {
1815   return value === other || (value !== value && other !== other);
1816 }
1817
1818 /**
1819  * Checks if `value` is likely an `arguments` object.
1820  *
1821  * @static
1822  * @memberOf _
1823  * @since 0.1.0
1824  * @category Lang
1825  * @param {*} value The value to check.
1826  * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1827  *  else `false`.
1828  * @example
1829  *
1830  * _.isArguments(function() { return arguments; }());
1831  * // => true
1832  *
1833  * _.isArguments([1, 2, 3]);
1834  * // => false
1835  */
1836 function isArguments(value) {
1837   // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1838   return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1839     (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1840 }
1841
1842 /**
1843  * Checks if `value` is classified as an `Array` object.
1844  *
1845  * @static
1846  * @memberOf _
1847  * @since 0.1.0
1848  * @category Lang
1849  * @param {*} value The value to check.
1850  * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1851  * @example
1852  *
1853  * _.isArray([1, 2, 3]);
1854  * // => true
1855  *
1856  * _.isArray(document.body.children);
1857  * // => false
1858  *
1859  * _.isArray('abc');
1860  * // => false
1861  *
1862  * _.isArray(_.noop);
1863  * // => false
1864  */
1865 var isArray = Array.isArray;
1866
1867 /**
1868  * Checks if `value` is array-like. A value is considered array-like if it's
1869  * not a function and has a `value.length` that's an integer greater than or
1870  * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1871  *
1872  * @static
1873  * @memberOf _
1874  * @since 4.0.0
1875  * @category Lang
1876  * @param {*} value The value to check.
1877  * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1878  * @example
1879  *
1880  * _.isArrayLike([1, 2, 3]);
1881  * // => true
1882  *
1883  * _.isArrayLike(document.body.children);
1884  * // => true
1885  *
1886  * _.isArrayLike('abc');
1887  * // => true
1888  *
1889  * _.isArrayLike(_.noop);
1890  * // => false
1891  */
1892 function isArrayLike(value) {
1893   return value != null && isLength(value.length) && !isFunction(value);
1894 }
1895
1896 /**
1897  * This method is like `_.isArrayLike` except that it also checks if `value`
1898  * is an object.
1899  *
1900  * @static
1901  * @memberOf _
1902  * @since 4.0.0
1903  * @category Lang
1904  * @param {*} value The value to check.
1905  * @returns {boolean} Returns `true` if `value` is an array-like object,
1906  *  else `false`.
1907  * @example
1908  *
1909  * _.isArrayLikeObject([1, 2, 3]);
1910  * // => true
1911  *
1912  * _.isArrayLikeObject(document.body.children);
1913  * // => true
1914  *
1915  * _.isArrayLikeObject('abc');
1916  * // => false
1917  *
1918  * _.isArrayLikeObject(_.noop);
1919  * // => false
1920  */
1921 function isArrayLikeObject(value) {
1922   return isObjectLike(value) && isArrayLike(value);
1923 }
1924
1925 /**
1926  * Checks if `value` is classified as a `Function` object.
1927  *
1928  * @static
1929  * @memberOf _
1930  * @since 0.1.0
1931  * @category Lang
1932  * @param {*} value The value to check.
1933  * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1934  * @example
1935  *
1936  * _.isFunction(_);
1937  * // => true
1938  *
1939  * _.isFunction(/abc/);
1940  * // => false
1941  */
1942 function isFunction(value) {
1943   // The use of `Object#toString` avoids issues with the `typeof` operator
1944   // in Safari 8-9 which returns 'object' for typed array and other constructors.
1945   var tag = isObject(value) ? objectToString.call(value) : '';
1946   return tag == funcTag || tag == genTag;
1947 }
1948
1949 /**
1950  * Checks if `value` is a valid array-like length.
1951  *
1952  * **Note:** This method is loosely based on
1953  * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1954  *
1955  * @static
1956  * @memberOf _
1957  * @since 4.0.0
1958  * @category Lang
1959  * @param {*} value The value to check.
1960  * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1961  * @example
1962  *
1963  * _.isLength(3);
1964  * // => true
1965  *
1966  * _.isLength(Number.MIN_VALUE);
1967  * // => false
1968  *
1969  * _.isLength(Infinity);
1970  * // => false
1971  *
1972  * _.isLength('3');
1973  * // => false
1974  */
1975 function isLength(value) {
1976   return typeof value == 'number' &&
1977     value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1978 }
1979
1980 /**
1981  * Checks if `value` is the
1982  * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1983  * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1984  *
1985  * @static
1986  * @memberOf _
1987  * @since 0.1.0
1988  * @category Lang
1989  * @param {*} value The value to check.
1990  * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1991  * @example
1992  *
1993  * _.isObject({});
1994  * // => true
1995  *
1996  * _.isObject([1, 2, 3]);
1997  * // => true
1998  *
1999  * _.isObject(_.noop);
2000  * // => true
2001  *
2002  * _.isObject(null);
2003  * // => false
2004  */
2005 function isObject(value) {
2006   var type = typeof value;
2007   return !!value && (type == 'object' || type == 'function');
2008 }
2009
2010 /**
2011  * Checks if `value` is object-like. A value is object-like if it's not `null`
2012  * and has a `typeof` result of "object".
2013  *
2014  * @static
2015  * @memberOf _
2016  * @since 4.0.0
2017  * @category Lang
2018  * @param {*} value The value to check.
2019  * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2020  * @example
2021  *
2022  * _.isObjectLike({});
2023  * // => true
2024  *
2025  * _.isObjectLike([1, 2, 3]);
2026  * // => true
2027  *
2028  * _.isObjectLike(_.noop);
2029  * // => false
2030  *
2031  * _.isObjectLike(null);
2032  * // => false
2033  */
2034 function isObjectLike(value) {
2035   return !!value && typeof value == 'object';
2036 }
2037
2038 /**
2039  * Checks if `value` is classified as a `Symbol` primitive or object.
2040  *
2041  * @static
2042  * @memberOf _
2043  * @since 4.0.0
2044  * @category Lang
2045  * @param {*} value The value to check.
2046  * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2047  * @example
2048  *
2049  * _.isSymbol(Symbol.iterator);
2050  * // => true
2051  *
2052  * _.isSymbol('abc');
2053  * // => false
2054  */
2055 function isSymbol(value) {
2056   return typeof value == 'symbol' ||
2057     (isObjectLike(value) && objectToString.call(value) == symbolTag);
2058 }
2059
2060 /**
2061  * Checks if `value` is classified as a typed array.
2062  *
2063  * @static
2064  * @memberOf _
2065  * @since 3.0.0
2066  * @category Lang
2067  * @param {*} value The value to check.
2068  * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2069  * @example
2070  *
2071  * _.isTypedArray(new Uint8Array);
2072  * // => true
2073  *
2074  * _.isTypedArray([]);
2075  * // => false
2076  */
2077 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2078
2079 /**
2080  * Converts `value` to a string. An empty string is returned for `null`
2081  * and `undefined` values. The sign of `-0` is preserved.
2082  *
2083  * @static
2084  * @memberOf _
2085  * @since 4.0.0
2086  * @category Lang
2087  * @param {*} value The value to process.
2088  * @returns {string} Returns the string.
2089  * @example
2090  *
2091  * _.toString(null);
2092  * // => ''
2093  *
2094  * _.toString(-0);
2095  * // => '-0'
2096  *
2097  * _.toString([1, 2, 3]);
2098  * // => '1,2,3'
2099  */
2100 function toString(value) {
2101   return value == null ? '' : baseToString(value);
2102 }
2103
2104 /**
2105  * Gets the value at `path` of `object`. If the resolved value is
2106  * `undefined`, the `defaultValue` is returned in its place.
2107  *
2108  * @static
2109  * @memberOf _
2110  * @since 3.7.0
2111  * @category Object
2112  * @param {Object} object The object to query.
2113  * @param {Array|string} path The path of the property to get.
2114  * @param {*} [defaultValue] The value returned for `undefined` resolved values.
2115  * @returns {*} Returns the resolved value.
2116  * @example
2117  *
2118  * var object = { 'a': [{ 'b': { 'c': 3 } }] };
2119  *
2120  * _.get(object, 'a[0].b.c');
2121  * // => 3
2122  *
2123  * _.get(object, ['a', '0', 'b', 'c']);
2124  * // => 3
2125  *
2126  * _.get(object, 'a.b.c', 'default');
2127  * // => 'default'
2128  */
2129 function get(object, path, defaultValue) {
2130   var result = object == null ? undefined : baseGet(object, path);
2131   return result === undefined ? defaultValue : result;
2132 }
2133
2134 /**
2135  * Checks if `path` is a direct or inherited property of `object`.
2136  *
2137  * @static
2138  * @memberOf _
2139  * @since 4.0.0
2140  * @category Object
2141  * @param {Object} object The object to query.
2142  * @param {Array|string} path The path to check.
2143  * @returns {boolean} Returns `true` if `path` exists, else `false`.
2144  * @example
2145  *
2146  * var object = _.create({ 'a': _.create({ 'b': 2 }) });
2147  *
2148  * _.hasIn(object, 'a');
2149  * // => true
2150  *
2151  * _.hasIn(object, 'a.b');
2152  * // => true
2153  *
2154  * _.hasIn(object, ['a', 'b']);
2155  * // => true
2156  *
2157  * _.hasIn(object, 'b');
2158  * // => false
2159  */
2160 function hasIn(object, path) {
2161   return object != null && hasPath(object, path, baseHasIn);
2162 }
2163
2164 /**
2165  * Creates an array of the own enumerable property names of `object`.
2166  *
2167  * **Note:** Non-object values are coerced to objects. See the
2168  * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2169  * for more details.
2170  *
2171  * @static
2172  * @since 0.1.0
2173  * @memberOf _
2174  * @category Object
2175  * @param {Object} object The object to query.
2176  * @returns {Array} Returns the array of property names.
2177  * @example
2178  *
2179  * function Foo() {
2180  *   this.a = 1;
2181  *   this.b = 2;
2182  * }
2183  *
2184  * Foo.prototype.c = 3;
2185  *
2186  * _.keys(new Foo);
2187  * // => ['a', 'b'] (iteration order is not guaranteed)
2188  *
2189  * _.keys('hi');
2190  * // => ['0', '1']
2191  */
2192 function keys(object) {
2193   return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2194 }
2195
2196 /**
2197  * Creates an object with the same keys as `object` and values generated
2198  * by running each own enumerable string keyed property of `object` thru
2199  * `iteratee`. The iteratee is invoked with three arguments:
2200  * (value, key, object).
2201  *
2202  * @static
2203  * @memberOf _
2204  * @since 2.4.0
2205  * @category Object
2206  * @param {Object} object The object to iterate over.
2207  * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2208  * @returns {Object} Returns the new mapped object.
2209  * @see _.mapKeys
2210  * @example
2211  *
2212  * var users = {
2213  *   'fred':    { 'user': 'fred',    'age': 40 },
2214  *   'pebbles': { 'user': 'pebbles', 'age': 1 }
2215  * };
2216  *
2217  * _.mapValues(users, function(o) { return o.age; });
2218  * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
2219  *
2220  * // The `_.property` iteratee shorthand.
2221  * _.mapValues(users, 'age');
2222  * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
2223  */
2224 function mapValues(object, iteratee) {
2225   var result = {};
2226   iteratee = baseIteratee(iteratee, 3);
2227
2228   baseForOwn(object, function(value, key, object) {
2229     result[key] = iteratee(value, key, object);
2230   });
2231   return result;
2232 }
2233
2234 /**
2235  * This method returns the first argument it receives.
2236  *
2237  * @static
2238  * @since 0.1.0
2239  * @memberOf _
2240  * @category Util
2241  * @param {*} value Any value.
2242  * @returns {*} Returns `value`.
2243  * @example
2244  *
2245  * var object = { 'a': 1 };
2246  *
2247  * console.log(_.identity(object) === object);
2248  * // => true
2249  */
2250 function identity(value) {
2251   return value;
2252 }
2253
2254 /**
2255  * Creates a function that returns the value at `path` of a given object.
2256  *
2257  * @static
2258  * @memberOf _
2259  * @since 2.4.0
2260  * @category Util
2261  * @param {Array|string} path The path of the property to get.
2262  * @returns {Function} Returns the new accessor function.
2263  * @example
2264  *
2265  * var objects = [
2266  *   { 'a': { 'b': 2 } },
2267  *   { 'a': { 'b': 1 } }
2268  * ];
2269  *
2270  * _.map(objects, _.property('a.b'));
2271  * // => [2, 1]
2272  *
2273  * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
2274  * // => [1, 2]
2275  */
2276 function property(path) {
2277   return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
2278 }
2279
2280 module.exports = mapValues;