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
10 /** Used as the size to enable large array optimizations. */
11 var LARGE_ARRAY_SIZE = 200;
13 /** Used as the `TypeError` message for "Functions" methods. */
14 var FUNC_ERROR_TEXT = 'Expected a function';
16 /** Used to stand-in for `undefined` hash values. */
17 var HASH_UNDEFINED = '__lodash_hash_undefined__';
19 /** Used to compose bitmasks for comparison styles. */
20 var UNORDERED_COMPARE_FLAG = 1,
21 PARTIAL_COMPARE_FLAG = 2;
23 /** Used as references for various `Number` constants. */
25 MAX_SAFE_INTEGER = 9007199254740991;
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]';
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]';
57 /** Used to match property names within property paths. */
58 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
59 reIsPlainProp = /^\w*$/,
61 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
64 * Used to match `RegExp`
65 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
67 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
69 /** Used to match backslashes in property paths. */
70 var reEscapeChar = /\\(\\)?/g;
72 /** Used to detect host constructors (Safari). */
73 var reIsHostCtor = /^\[object .+?Constructor\]$/;
75 /** Used to detect unsigned integer values. */
76 var reIsUint = /^(?:0|[1-9]\d*)$/;
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;
94 /** Detect free variable `global` from Node.js. */
95 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
97 /** Detect free variable `self`. */
98 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
100 /** Used as a reference to the global object. */
101 var root = freeGlobal || freeSelf || Function('return this')();
103 /** Detect free variable `exports`. */
104 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
106 /** Detect free variable `module`. */
107 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
109 /** Detect the popular CommonJS extension `module.exports`. */
110 var moduleExports = freeModule && freeModule.exports === freeExports;
112 /** Detect free variable `process` from Node.js. */
113 var freeProcess = moduleExports && freeGlobal.process;
115 /** Used to access faster Node.js helpers. */
116 var nodeUtil = (function() {
118 return freeProcess && freeProcess.binding('util');
122 /* Node.js helper references. */
123 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
126 * A specialized version of `_.some` for arrays without support for iteratee
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,
135 function arraySome(array, predicate) {
137 length = array ? array.length : 0;
139 while (++index < length) {
140 if (predicate(array[index], index, array)) {
148 * The base implementation of `_.property` without support for deep paths.
151 * @param {string} key The key of the property to get.
152 * @returns {Function} Returns the new accessor function.
154 function baseProperty(key) {
155 return function(object) {
156 return object == null ? undefined : object[key];
161 * The base implementation of `_.times` without support for iteratee shorthands
162 * or max array length checks.
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.
169 function baseTimes(n, iteratee) {
173 while (++index < n) {
174 result[index] = iteratee(index);
180 * The base implementation of `_.unary` without support for storing metadata.
183 * @param {Function} func The function to cap arguments for.
184 * @returns {Function} Returns the new capped function.
186 function baseUnary(func) {
187 return function(value) {
193 * Gets the value at `key` of `object`.
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.
200 function getValue(object, key) {
201 return object == null ? undefined : object[key];
205 * Checks if `value` is a host object in IE < 9.
208 * @param {*} value The value to check.
209 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
211 function isHostObject(value) {
212 // Many host objects are `Object` objects that can coerce to strings
213 // despite having improperly defined `toString` methods.
215 if (value != null && typeof value.toString != 'function') {
217 result = !!(value + '');
224 * Converts `map` to its key-value pairs.
227 * @param {Object} map The map to convert.
228 * @returns {Array} Returns the key-value pairs.
230 function mapToArray(map) {
232 result = Array(map.size);
234 map.forEach(function(value, key) {
235 result[++index] = [key, value];
241 * Creates a unary function that invokes `func` with its argument transformed.
244 * @param {Function} func The function to wrap.
245 * @param {Function} transform The argument transform.
246 * @returns {Function} Returns the new function.
248 function overArg(func, transform) {
249 return function(arg) {
250 return func(transform(arg));
255 * Converts `set` to an array of its values.
258 * @param {Object} set The set to convert.
259 * @returns {Array} Returns the values.
261 function setToArray(set) {
263 result = Array(set.size);
265 set.forEach(function(value) {
266 result[++index] = value;
271 /** Used for built-in method references. */
272 var arrayProto = Array.prototype,
273 funcProto = Function.prototype,
274 objectProto = Object.prototype;
276 /** Used to detect overreaching core-js shims. */
277 var coreJsData = root['__core-js_shared__'];
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) : '';
285 /** Used to resolve the decompiled source of functions. */
286 var funcToString = funcProto.toString;
288 /** Used to check objects for own properties. */
289 var hasOwnProperty = objectProto.hasOwnProperty;
292 * Used to resolve the
293 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
296 var objectToString = objectProto.toString;
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.*?') + '$'
304 /** Built-in value references. */
305 var Symbol = root.Symbol,
306 Uint8Array = root.Uint8Array,
307 propertyIsEnumerable = objectProto.propertyIsEnumerable,
308 splice = arrayProto.splice;
310 /* Built-in method references for those with the same name as other `lodash` methods. */
311 var nativeKeys = overArg(Object.keys, Object);
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');
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);
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;
334 * Creates a hash object.
338 * @param {Array} [entries] The key-value pairs to cache.
340 function Hash(entries) {
342 length = entries ? entries.length : 0;
345 while (++index < length) {
346 var entry = entries[index];
347 this.set(entry[0], entry[1]);
352 * Removes all key-value entries from the hash.
358 function hashClear() {
359 this.__data__ = nativeCreate ? nativeCreate(null) : {};
363 * Removes `key` and its value from the 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`.
372 function hashDelete(key) {
373 return this.has(key) && delete this.__data__[key];
377 * Gets the hash value for `key`.
382 * @param {string} key The key of the value to get.
383 * @returns {*} Returns the entry value.
385 function hashGet(key) {
386 var data = this.__data__;
388 var result = data[key];
389 return result === HASH_UNDEFINED ? undefined : result;
391 return hasOwnProperty.call(data, key) ? data[key] : undefined;
395 * Checks if a hash value for `key` exists.
400 * @param {string} key The key of the entry to check.
401 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
403 function hashHas(key) {
404 var data = this.__data__;
405 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
409 * Sets the hash `key` to `value`.
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.
418 function hashSet(key, value) {
419 var data = this.__data__;
420 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
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;
432 * Creates an list cache object.
436 * @param {Array} [entries] The key-value pairs to cache.
438 function ListCache(entries) {
440 length = entries ? entries.length : 0;
443 while (++index < length) {
444 var entry = entries[index];
445 this.set(entry[0], entry[1]);
450 * Removes all key-value entries from the list cache.
454 * @memberOf ListCache
456 function listCacheClear() {
461 * Removes `key` and its value from the list cache.
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`.
469 function listCacheDelete(key) {
470 var data = this.__data__,
471 index = assocIndexOf(data, key);
476 var lastIndex = data.length - 1;
477 if (index == lastIndex) {
480 splice.call(data, index, 1);
486 * Gets the list cache value for `key`.
490 * @memberOf ListCache
491 * @param {string} key The key of the value to get.
492 * @returns {*} Returns the entry value.
494 function listCacheGet(key) {
495 var data = this.__data__,
496 index = assocIndexOf(data, key);
498 return index < 0 ? undefined : data[index][1];
502 * Checks if a list cache value for `key` exists.
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`.
510 function listCacheHas(key) {
511 return assocIndexOf(this.__data__, key) > -1;
515 * Sets the list cache `key` to `value`.
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.
524 function listCacheSet(key, value) {
525 var data = this.__data__,
526 index = assocIndexOf(data, key);
529 data.push([key, value]);
531 data[index][1] = value;
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;
544 * Creates a map cache object to store key-value pairs.
548 * @param {Array} [entries] The key-value pairs to cache.
550 function MapCache(entries) {
552 length = entries ? entries.length : 0;
555 while (++index < length) {
556 var entry = entries[index];
557 this.set(entry[0], entry[1]);
562 * Removes all key-value entries from the map.
568 function mapCacheClear() {
571 'map': new (Map || ListCache),
577 * Removes `key` and its value from the map.
582 * @param {string} key The key of the value to remove.
583 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
585 function mapCacheDelete(key) {
586 return getMapData(this, key)['delete'](key);
590 * Gets the map value for `key`.
595 * @param {string} key The key of the value to get.
596 * @returns {*} Returns the entry value.
598 function mapCacheGet(key) {
599 return getMapData(this, key).get(key);
603 * Checks if a map value for `key` exists.
608 * @param {string} key The key of the entry to check.
609 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
611 function mapCacheHas(key) {
612 return getMapData(this, key).has(key);
616 * Sets the map `key` to `value`.
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.
625 function mapCacheSet(key, value) {
626 getMapData(this, key).set(key, value);
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;
639 * Creates an array cache object to store unique values.
643 * @param {Array} [values] The values to cache.
645 function SetCache(values) {
647 length = values ? values.length : 0;
649 this.__data__ = new MapCache;
650 while (++index < length) {
651 this.add(values[index]);
656 * Adds `value` to the array cache.
662 * @param {*} value The value to cache.
663 * @returns {Object} Returns the cache instance.
665 function setCacheAdd(value) {
666 this.__data__.set(value, HASH_UNDEFINED);
671 * Checks if `value` is in the array cache.
676 * @param {*} value The value to search for.
677 * @returns {number} Returns `true` if `value` is found, else `false`.
679 function setCacheHas(value) {
680 return this.__data__.has(value);
683 // Add methods to `SetCache`.
684 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
685 SetCache.prototype.has = setCacheHas;
688 * Creates a stack cache object to store key-value pairs.
692 * @param {Array} [entries] The key-value pairs to cache.
694 function Stack(entries) {
695 this.__data__ = new ListCache(entries);
699 * Removes all key-value entries from the stack.
705 function stackClear() {
706 this.__data__ = new ListCache;
710 * Removes `key` and its value from the stack.
715 * @param {string} key The key of the value to remove.
716 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
718 function stackDelete(key) {
719 return this.__data__['delete'](key);
723 * Gets the stack value for `key`.
728 * @param {string} key The key of the value to get.
729 * @returns {*} Returns the entry value.
731 function stackGet(key) {
732 return this.__data__.get(key);
736 * Checks if a stack value for `key` exists.
741 * @param {string} key The key of the entry to check.
742 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
744 function stackHas(key) {
745 return this.__data__.has(key);
749 * Sets the stack `key` to `value`.
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.
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]);
766 cache = this.__data__ = new MapCache(pairs);
768 cache.set(key, value);
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;
780 * Creates an array of the enumerable property names of the array-like `value`.
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.
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)
794 var length = result.length,
795 skipIndexes = !!length;
797 for (var key in value) {
798 if ((inherited || hasOwnProperty.call(value, key)) &&
799 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
807 * Gets the index at which the `key` is found in `array` of key-value pairs.
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`.
814 function assocIndexOf(array, key) {
815 var length = array.length;
817 if (eq(array[length][0], key)) {
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`.
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`.
835 var baseFor = createBaseFor();
838 * The base implementation of `_.forOwn` without support for iteratee shorthands.
841 * @param {Object} object The object to iterate over.
842 * @param {Function} iteratee The function invoked per iteration.
843 * @returns {Object} Returns `object`.
845 function baseForOwn(object, iteratee) {
846 return object && baseFor(object, iteratee, keys);
850 * The base implementation of `_.get` without support for default values.
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.
857 function baseGet(object, path) {
858 path = isKey(path, object) ? [path] : castPath(path);
861 length = path.length;
863 while (object != null && index < length) {
864 object = object[toKey(path[index++])];
866 return (index && index == length) ? object : undefined;
870 * The base implementation of `getTag`.
873 * @param {*} value The value to query.
874 * @returns {string} Returns the `toStringTag`.
876 function baseGetTag(value) {
877 return objectToString.call(value);
881 * The base implementation of `_.hasIn` without support for deep paths.
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`.
888 function baseHasIn(object, key) {
889 return object != null && key in Object(object);
893 * The base implementation of `_.isEqual` which supports partial comparisons
894 * and tracks traversed objects.
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`.
907 function baseIsEqual(value, other, customizer, bitmask, stack) {
908 if (value === other) {
911 if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
912 return value !== value && other !== other;
914 return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
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.
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`
929 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
930 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
932 function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
933 var objIsArr = isArray(object),
934 othIsArr = isArray(other),
939 objTag = getTag(object);
940 objTag = objTag == argsTag ? objectTag : objTag;
943 othTag = getTag(other);
944 othTag = othTag == argsTag ? objectTag : othTag;
946 var objIsObj = objTag == objectTag && !isHostObject(object),
947 othIsObj = othTag == objectTag && !isHostObject(other),
948 isSameTag = objTag == othTag;
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);
956 if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
957 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
958 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
960 if (objIsWrapped || othIsWrapped) {
961 var objUnwrapped = objIsWrapped ? object.value() : object,
962 othUnwrapped = othIsWrapped ? other.value() : other;
964 stack || (stack = new Stack);
965 return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
971 stack || (stack = new Stack);
972 return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
976 * The base implementation of `_.isMatch` without support for iteratee shorthands.
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`.
985 function baseIsMatch(object, source, matchData, customizer) {
986 var index = matchData.length,
988 noCustomizer = !customizer;
990 if (object == null) {
993 object = Object(object);
995 var data = matchData[index];
996 if ((noCustomizer && data[2])
997 ? data[1] !== object[data[0]]
998 : !(data[0] in object)
1003 while (++index < length) {
1004 data = matchData[index];
1006 objValue = object[key],
1009 if (noCustomizer && data[2]) {
1010 if (objValue === undefined && !(key in object)) {
1014 var stack = new Stack;
1016 var result = customizer(objValue, srcValue, key, object, source, stack);
1018 if (!(result === undefined
1019 ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
1030 * The base implementation of `_.isNative` without bad shim checks.
1033 * @param {*} value The value to check.
1034 * @returns {boolean} Returns `true` if `value` is a native function,
1037 function baseIsNative(value) {
1038 if (!isObject(value) || isMasked(value)) {
1041 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1042 return pattern.test(toSource(value));
1046 * The base implementation of `_.isTypedArray` without Node.js optimizations.
1049 * @param {*} value The value to check.
1050 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1052 function baseIsTypedArray(value) {
1053 return isObjectLike(value) &&
1054 isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
1058 * The base implementation of `_.iteratee`.
1061 * @param {*} [value=_.identity] The value to convert to an iteratee.
1062 * @returns {Function} Returns the iteratee.
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') {
1070 if (value == null) {
1073 if (typeof value == 'object') {
1074 return isArray(value)
1075 ? baseMatchesProperty(value[0], value[1])
1076 : baseMatches(value);
1078 return property(value);
1082 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1085 * @param {Object} object The object to query.
1086 * @returns {Array} Returns the array of property names.
1088 function baseKeys(object) {
1089 if (!isPrototype(object)) {
1090 return nativeKeys(object);
1093 for (var key in Object(object)) {
1094 if (hasOwnProperty.call(object, key) && key != 'constructor') {
1102 * The base implementation of `_.matches` which doesn't clone `source`.
1105 * @param {Object} source The object of property values to match.
1106 * @returns {Function} Returns the new spec function.
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]);
1113 return function(object) {
1114 return object === source || baseIsMatch(object, source, matchData);
1119 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
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.
1126 function baseMatchesProperty(path, srcValue) {
1127 if (isKey(path) && isStrictComparable(srcValue)) {
1128 return matchesStrictComparable(toKey(path), srcValue);
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);
1139 * A specialized version of `baseProperty` which supports deep paths.
1142 * @param {Array|string} path The path of the property to get.
1143 * @returns {Function} Returns the new accessor function.
1145 function basePropertyDeep(path) {
1146 return function(object) {
1147 return baseGet(object, path);
1152 * The base implementation of `_.toString` which doesn't convert nullish
1153 * values to empty strings.
1156 * @param {*} value The value to process.
1157 * @returns {string} Returns the string.
1159 function baseToString(value) {
1160 // Exit early for strings to avoid a performance hit in some environments.
1161 if (typeof value == 'string') {
1164 if (isSymbol(value)) {
1165 return symbolToString ? symbolToString.call(value) : '';
1167 var result = (value + '');
1168 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1172 * Casts `value` to a path array if it's not one.
1175 * @param {*} value The value to inspect.
1176 * @returns {Array} Returns the cast property path array.
1178 function castPath(value) {
1179 return isArray(value) ? value : stringToPath(value);
1183 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1186 * @param {boolean} [fromRight] Specify iterating from right to left.
1187 * @returns {Function} Returns the new base function.
1189 function createBaseFor(fromRight) {
1190 return function(object, iteratee, keysFunc) {
1192 iterable = Object(object),
1193 props = keysFunc(object),
1194 length = props.length;
1197 var key = props[fromRight ? length : ++index];
1198 if (iteratee(iterable[key], key, iterable) === false) {
1207 * A specialized version of `baseIsEqualDeep` for arrays with support for
1208 * partial deep comparisons.
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`
1217 * @param {Object} stack Tracks traversed `array` and `other` objects.
1218 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1220 function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
1221 var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1222 arrLength = array.length,
1223 othLength = other.length;
1225 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1228 // Assume cyclic values are equal.
1229 var stacked = stack.get(array);
1230 if (stacked && stack.get(other)) {
1231 return stacked == other;
1235 seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
1237 stack.set(array, other);
1238 stack.set(other, array);
1240 // Ignore non-index properties.
1241 while (++index < arrLength) {
1242 var arrValue = array[index],
1243 othValue = other[index];
1246 var compared = isPartial
1247 ? customizer(othValue, arrValue, index, other, array, stack)
1248 : customizer(arrValue, othValue, index, array, other, stack);
1250 if (compared !== undefined) {
1257 // Recursively compare arrays (susceptible to call stack limits).
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);
1269 arrValue === othValue ||
1270 equalFunc(arrValue, othValue, customizer, bitmask, stack)
1276 stack['delete'](array);
1277 stack['delete'](other);
1282 * A specialized version of `baseIsEqualDeep` for comparing objects of
1283 * the same `toStringTag`.
1285 * **Note:** This function only supports comparing values with tags of
1286 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
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`
1296 * @param {Object} stack Tracks traversed `object` and `other` objects.
1297 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1299 function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
1302 if ((object.byteLength != other.byteLength) ||
1303 (object.byteOffset != other.byteOffset)) {
1306 object = object.buffer;
1307 other = other.buffer;
1309 case arrayBufferTag:
1310 if ((object.byteLength != other.byteLength) ||
1311 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1319 // Coerce booleans to `1` or `0` and dates to milliseconds.
1320 // Invalid dates are coerced to `NaN`.
1321 return eq(+object, +other);
1324 return object.name == other.name && object.message == other.message;
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 + '');
1334 var convert = mapToArray;
1337 var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
1338 convert || (convert = setToArray);
1340 if (object.size != other.size && !isPartial) {
1343 // Assume cyclic values are equal.
1344 var stacked = stack.get(object);
1346 return stacked == other;
1348 bitmask |= UNORDERED_COMPARE_FLAG;
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);
1357 if (symbolValueOf) {
1358 return symbolValueOf.call(object) == symbolValueOf.call(other);
1365 * A specialized version of `baseIsEqualDeep` for objects with support for
1366 * partial deep comparisons.
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`
1375 * @param {Object} stack Tracks traversed `object` and `other` objects.
1376 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
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;
1385 if (objLength != othLength && !isPartial) {
1388 var index = objLength;
1390 var key = objProps[index];
1391 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1395 // Assume cyclic values are equal.
1396 var stacked = stack.get(object);
1397 if (stacked && stack.get(other)) {
1398 return stacked == other;
1401 stack.set(object, other);
1402 stack.set(other, object);
1404 var skipCtor = isPartial;
1405 while (++index < objLength) {
1406 key = objProps[index];
1407 var objValue = object[key],
1408 othValue = other[key];
1411 var compared = isPartial
1412 ? customizer(othValue, objValue, key, other, object, stack)
1413 : customizer(objValue, othValue, key, object, other, stack);
1415 // Recursively compare objects (susceptible to call stack limits).
1416 if (!(compared === undefined
1417 ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
1423 skipCtor || (skipCtor = key == 'constructor');
1425 if (result && !skipCtor) {
1426 var objCtor = object.constructor,
1427 othCtor = other.constructor;
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)) {
1437 stack['delete'](object);
1438 stack['delete'](other);
1443 * Gets the data for `map`.
1446 * @param {Object} map The map to query.
1447 * @param {string} key The reference key.
1448 * @returns {*} Returns the map data.
1450 function getMapData(map, key) {
1451 var data = map.__data__;
1452 return isKeyable(key)
1453 ? data[typeof key == 'string' ? 'string' : 'hash']
1458 * Gets the property names, values, and compare flags of `object`.
1461 * @param {Object} object The object to query.
1462 * @returns {Array} Returns the match data of `object`.
1464 function getMatchData(object) {
1465 var result = keys(object),
1466 length = result.length;
1469 var key = result[length],
1470 value = object[key];
1472 result[length] = [key, value, isStrictComparable(value)];
1478 * Gets the native function at `key` of `object`.
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`.
1485 function getNative(object, key) {
1486 var value = getValue(object, key);
1487 return baseIsNative(value) ? value : undefined;
1491 * Gets the `toStringTag` of `value`.
1494 * @param {*} value The value to query.
1495 * @returns {string} Returns the `toStringTag`.
1497 var getTag = baseGetTag;
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;
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;
1525 * Checks if `path` exists on `object`.
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`.
1533 function hasPath(object, path, hasFunc) {
1534 path = isKey(path, object) ? [path] : castPath(path);
1538 length = path.length;
1540 while (++index < length) {
1541 var key = toKey(path[index]);
1542 if (!(result = object != null && hasFunc(object, key))) {
1545 object = object[key];
1550 var length = object ? object.length : 0;
1551 return !!length && isLength(length) && isIndex(key, length) &&
1552 (isArray(object) || isArguments(object));
1556 * Checks if `value` is a valid array-like index.
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`.
1563 function isIndex(value, length) {
1564 length = length == null ? MAX_SAFE_INTEGER : length;
1566 (typeof value == 'number' || reIsUint.test(value)) &&
1567 (value > -1 && value % 1 == 0 && value < length);
1571 * Checks if `value` is a property name and not a property path.
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`.
1578 function isKey(value, object) {
1579 if (isArray(value)) {
1582 var type = typeof value;
1583 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1584 value == null || isSymbol(value)) {
1587 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1588 (object != null && value in Object(object));
1592 * Checks if `value` is suitable for use as unique object key.
1595 * @param {*} value The value to check.
1596 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1598 function isKeyable(value) {
1599 var type = typeof value;
1600 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1601 ? (value !== '__proto__')
1606 * Checks if `func` has its source masked.
1609 * @param {Function} func The function to check.
1610 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1612 function isMasked(func) {
1613 return !!maskSrcKey && (maskSrcKey in func);
1617 * Checks if `value` is likely a prototype object.
1620 * @param {*} value The value to check.
1621 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1623 function isPrototype(value) {
1624 var Ctor = value && value.constructor,
1625 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1627 return value === proto;
1631 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
1634 * @param {*} value The value to check.
1635 * @returns {boolean} Returns `true` if `value` if suitable for strict
1636 * equality comparisons, else `false`.
1638 function isStrictComparable(value) {
1639 return value === value && !isObject(value);
1643 * A specialized version of `matchesProperty` for source values suitable
1644 * for strict equality comparisons, i.e. `===`.
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.
1651 function matchesStrictComparable(key, srcValue) {
1652 return function(object) {
1653 if (object == null) {
1656 return object[key] === srcValue &&
1657 (srcValue !== undefined || (key in Object(object)));
1662 * Converts `string` to a property path array.
1665 * @param {string} string The string to convert.
1666 * @returns {Array} Returns the property path array.
1668 var stringToPath = memoize(function(string) {
1669 string = toString(string);
1672 if (reLeadingDot.test(string)) {
1675 string.replace(rePropName, function(match, number, quote, string) {
1676 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
1682 * Converts `value` to a string key if it's not a string or symbol.
1685 * @param {*} value The value to inspect.
1686 * @returns {string|symbol} Returns the key.
1688 function toKey(value) {
1689 if (typeof value == 'string' || isSymbol(value)) {
1692 var result = (value + '');
1693 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1697 * Converts `func` to its source code.
1700 * @param {Function} func The function to process.
1701 * @returns {string} Returns the source code.
1703 function toSource(func) {
1706 return funcToString.call(func);
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.
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`.
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.
1737 * var object = { 'a': 1, 'b': 2 };
1738 * var other = { 'c': 3, 'd': 4 };
1740 * var values = _.memoize(_.values);
1751 * // Modify the result cache.
1752 * values.cache.set(object, ['a', 'b']);
1756 * // Replace `_.memoize.Cache`.
1757 * _.memoize.Cache = WeakMap;
1759 function memoize(func, resolver) {
1760 if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
1761 throw new TypeError(FUNC_ERROR_TEXT);
1763 var memoized = function() {
1764 var args = arguments,
1765 key = resolver ? resolver.apply(this, args) : args[0],
1766 cache = memoized.cache;
1768 if (cache.has(key)) {
1769 return cache.get(key);
1771 var result = func.apply(this, args);
1772 memoized.cache = cache.set(key, result);
1775 memoized.cache = new (memoize.Cache || MapCache);
1779 // Assign cache to `_.memoize`.
1780 memoize.Cache = MapCache;
1784 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1785 * comparison between two values to determine if they are equivalent.
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`.
1796 * var object = { 'a': 1 };
1797 * var other = { 'a': 1 };
1799 * _.eq(object, object);
1802 * _.eq(object, other);
1808 * _.eq('a', Object('a'));
1814 function eq(value, other) {
1815 return value === other || (value !== value && other !== other);
1819 * Checks if `value` is likely an `arguments` object.
1825 * @param {*} value The value to check.
1826 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1830 * _.isArguments(function() { return arguments; }());
1833 * _.isArguments([1, 2, 3]);
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);
1843 * Checks if `value` is classified as an `Array` object.
1849 * @param {*} value The value to check.
1850 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1853 * _.isArray([1, 2, 3]);
1856 * _.isArray(document.body.children);
1862 * _.isArray(_.noop);
1865 var isArray = Array.isArray;
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`.
1876 * @param {*} value The value to check.
1877 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1880 * _.isArrayLike([1, 2, 3]);
1883 * _.isArrayLike(document.body.children);
1886 * _.isArrayLike('abc');
1889 * _.isArrayLike(_.noop);
1892 function isArrayLike(value) {
1893 return value != null && isLength(value.length) && !isFunction(value);
1897 * This method is like `_.isArrayLike` except that it also checks if `value`
1904 * @param {*} value The value to check.
1905 * @returns {boolean} Returns `true` if `value` is an array-like object,
1909 * _.isArrayLikeObject([1, 2, 3]);
1912 * _.isArrayLikeObject(document.body.children);
1915 * _.isArrayLikeObject('abc');
1918 * _.isArrayLikeObject(_.noop);
1921 function isArrayLikeObject(value) {
1922 return isObjectLike(value) && isArrayLike(value);
1926 * Checks if `value` is classified as a `Function` object.
1932 * @param {*} value The value to check.
1933 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1939 * _.isFunction(/abc/);
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;
1950 * Checks if `value` is a valid array-like length.
1952 * **Note:** This method is loosely based on
1953 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1959 * @param {*} value The value to check.
1960 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1966 * _.isLength(Number.MIN_VALUE);
1969 * _.isLength(Infinity);
1975 function isLength(value) {
1976 return typeof value == 'number' &&
1977 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
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('')`)
1989 * @param {*} value The value to check.
1990 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1996 * _.isObject([1, 2, 3]);
1999 * _.isObject(_.noop);
2005 function isObject(value) {
2006 var type = typeof value;
2007 return !!value && (type == 'object' || type == 'function');
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".
2018 * @param {*} value The value to check.
2019 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2022 * _.isObjectLike({});
2025 * _.isObjectLike([1, 2, 3]);
2028 * _.isObjectLike(_.noop);
2031 * _.isObjectLike(null);
2034 function isObjectLike(value) {
2035 return !!value && typeof value == 'object';
2039 * Checks if `value` is classified as a `Symbol` primitive or object.
2045 * @param {*} value The value to check.
2046 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2049 * _.isSymbol(Symbol.iterator);
2052 * _.isSymbol('abc');
2055 function isSymbol(value) {
2056 return typeof value == 'symbol' ||
2057 (isObjectLike(value) && objectToString.call(value) == symbolTag);
2061 * Checks if `value` is classified as a typed array.
2067 * @param {*} value The value to check.
2068 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2071 * _.isTypedArray(new Uint8Array);
2074 * _.isTypedArray([]);
2077 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2080 * Converts `value` to a string. An empty string is returned for `null`
2081 * and `undefined` values. The sign of `-0` is preserved.
2087 * @param {*} value The value to process.
2088 * @returns {string} Returns the string.
2097 * _.toString([1, 2, 3]);
2100 function toString(value) {
2101 return value == null ? '' : baseToString(value);
2105 * Gets the value at `path` of `object`. If the resolved value is
2106 * `undefined`, the `defaultValue` is returned in its place.
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.
2118 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
2120 * _.get(object, 'a[0].b.c');
2123 * _.get(object, ['a', '0', 'b', 'c']);
2126 * _.get(object, 'a.b.c', 'default');
2129 function get(object, path, defaultValue) {
2130 var result = object == null ? undefined : baseGet(object, path);
2131 return result === undefined ? defaultValue : result;
2135 * Checks if `path` is a direct or inherited property of `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`.
2146 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
2148 * _.hasIn(object, 'a');
2151 * _.hasIn(object, 'a.b');
2154 * _.hasIn(object, ['a', 'b']);
2157 * _.hasIn(object, 'b');
2160 function hasIn(object, path) {
2161 return object != null && hasPath(object, path, baseHasIn);
2165 * Creates an array of the own enumerable property names of `object`.
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)
2175 * @param {Object} object The object to query.
2176 * @returns {Array} Returns the array of property names.
2184 * Foo.prototype.c = 3;
2187 * // => ['a', 'b'] (iteration order is not guaranteed)
2192 function keys(object) {
2193 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
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).
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.
2213 * 'fred': { 'user': 'fred', 'age': 40 },
2214 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
2217 * _.mapValues(users, function(o) { return o.age; });
2218 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
2220 * // The `_.property` iteratee shorthand.
2221 * _.mapValues(users, 'age');
2222 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
2224 function mapValues(object, iteratee) {
2226 iteratee = baseIteratee(iteratee, 3);
2228 baseForOwn(object, function(value, key, object) {
2229 result[key] = iteratee(value, key, object);
2235 * This method returns the first argument it receives.
2241 * @param {*} value Any value.
2242 * @returns {*} Returns `value`.
2245 * var object = { 'a': 1 };
2247 * console.log(_.identity(object) === object);
2250 function identity(value) {
2255 * Creates a function that returns the value at `path` of a given object.
2261 * @param {Array|string} path The path of the property to get.
2262 * @returns {Function} Returns the new accessor function.
2266 * { 'a': { 'b': 2 } },
2267 * { 'a': { 'b': 1 } }
2270 * _.map(objects, _.property('a.b'));
2273 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
2276 function property(path) {
2277 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
2280 module.exports = mapValues;