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 to stand-in for `undefined` hash values. */
14 var HASH_UNDEFINED = '__lodash_hash_undefined__';
16 /** Used as references for various `Number` constants. */
17 var MAX_SAFE_INTEGER = 9007199254740991;
19 /** `Object#toString` result references. */
20 var argsTag = '[object Arguments]',
21 arrayTag = '[object Array]',
22 boolTag = '[object Boolean]',
23 dateTag = '[object Date]',
24 errorTag = '[object Error]',
25 funcTag = '[object Function]',
26 genTag = '[object GeneratorFunction]',
27 mapTag = '[object Map]',
28 numberTag = '[object Number]',
29 objectTag = '[object Object]',
30 promiseTag = '[object Promise]',
31 regexpTag = '[object RegExp]',
32 setTag = '[object Set]',
33 stringTag = '[object String]',
34 symbolTag = '[object Symbol]',
35 weakMapTag = '[object WeakMap]';
37 var arrayBufferTag = '[object ArrayBuffer]',
38 dataViewTag = '[object DataView]',
39 float32Tag = '[object Float32Array]',
40 float64Tag = '[object Float64Array]',
41 int8Tag = '[object Int8Array]',
42 int16Tag = '[object Int16Array]',
43 int32Tag = '[object Int32Array]',
44 uint8Tag = '[object Uint8Array]',
45 uint8ClampedTag = '[object Uint8ClampedArray]',
46 uint16Tag = '[object Uint16Array]',
47 uint32Tag = '[object Uint32Array]';
50 * Used to match `RegExp`
51 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
53 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
55 /** Used to match `RegExp` flags from their coerced string values. */
58 /** Used to detect host constructors (Safari). */
59 var reIsHostCtor = /^\[object .+?Constructor\]$/;
61 /** Used to detect unsigned integer values. */
62 var reIsUint = /^(?:0|[1-9]\d*)$/;
64 /** Used to identify `toStringTag` values of typed arrays. */
65 var typedArrayTags = {};
66 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
67 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
68 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
69 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
70 typedArrayTags[uint32Tag] = true;
71 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
72 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
73 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
74 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
75 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
76 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
77 typedArrayTags[setTag] = typedArrayTags[stringTag] =
78 typedArrayTags[weakMapTag] = false;
80 /** Used to identify `toStringTag` values supported by `_.clone`. */
81 var cloneableTags = {};
82 cloneableTags[argsTag] = cloneableTags[arrayTag] =
83 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
84 cloneableTags[boolTag] = cloneableTags[dateTag] =
85 cloneableTags[float32Tag] = cloneableTags[float64Tag] =
86 cloneableTags[int8Tag] = cloneableTags[int16Tag] =
87 cloneableTags[int32Tag] = cloneableTags[mapTag] =
88 cloneableTags[numberTag] = cloneableTags[objectTag] =
89 cloneableTags[regexpTag] = cloneableTags[setTag] =
90 cloneableTags[stringTag] = cloneableTags[symbolTag] =
91 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
92 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
93 cloneableTags[errorTag] = cloneableTags[funcTag] =
94 cloneableTags[weakMapTag] = false;
96 /** Detect free variable `global` from Node.js. */
97 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
99 /** Detect free variable `self`. */
100 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
102 /** Used as a reference to the global object. */
103 var root = freeGlobal || freeSelf || Function('return this')();
105 /** Detect free variable `exports`. */
106 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
108 /** Detect free variable `module`. */
109 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
111 /** Detect the popular CommonJS extension `module.exports`. */
112 var moduleExports = freeModule && freeModule.exports === freeExports;
114 /** Detect free variable `process` from Node.js. */
115 var freeProcess = moduleExports && freeGlobal.process;
117 /** Used to access faster Node.js helpers. */
118 var nodeUtil = (function() {
120 return freeProcess && freeProcess.binding('util');
124 /* Node.js helper references. */
125 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
128 * Adds the key-value `pair` to `map`.
131 * @param {Object} map The map to modify.
132 * @param {Array} pair The key-value pair to add.
133 * @returns {Object} Returns `map`.
135 function addMapEntry(map, pair) {
136 // Don't return `map.set` because it's not chainable in IE 11.
137 map.set(pair[0], pair[1]);
142 * Adds `value` to `set`.
145 * @param {Object} set The set to modify.
146 * @param {*} value The value to add.
147 * @returns {Object} Returns `set`.
149 function addSetEntry(set, value) {
150 // Don't return `set.add` because it's not chainable in IE 11.
156 * A faster alternative to `Function#apply`, this function invokes `func`
157 * with the `this` binding of `thisArg` and the arguments of `args`.
160 * @param {Function} func The function to invoke.
161 * @param {*} thisArg The `this` binding of `func`.
162 * @param {Array} args The arguments to invoke `func` with.
163 * @returns {*} Returns the result of `func`.
165 function apply(func, thisArg, args) {
166 switch (args.length) {
167 case 0: return func.call(thisArg);
168 case 1: return func.call(thisArg, args[0]);
169 case 2: return func.call(thisArg, args[0], args[1]);
170 case 3: return func.call(thisArg, args[0], args[1], args[2]);
172 return func.apply(thisArg, args);
176 * A specialized version of `_.forEach` for arrays without support for
177 * iteratee shorthands.
180 * @param {Array} [array] The array to iterate over.
181 * @param {Function} iteratee The function invoked per iteration.
182 * @returns {Array} Returns `array`.
184 function arrayEach(array, iteratee) {
186 length = array ? array.length : 0;
188 while (++index < length) {
189 if (iteratee(array[index], index, array) === false) {
197 * Appends the elements of `values` to `array`.
200 * @param {Array} array The array to modify.
201 * @param {Array} values The values to append.
202 * @returns {Array} Returns `array`.
204 function arrayPush(array, values) {
206 length = values.length,
207 offset = array.length;
209 while (++index < length) {
210 array[offset + index] = values[index];
216 * A specialized version of `_.reduce` for arrays without support for
217 * iteratee shorthands.
220 * @param {Array} [array] The array to iterate over.
221 * @param {Function} iteratee The function invoked per iteration.
222 * @param {*} [accumulator] The initial value.
223 * @param {boolean} [initAccum] Specify using the first element of `array` as
225 * @returns {*} Returns the accumulated value.
227 function arrayReduce(array, iteratee, accumulator, initAccum) {
229 length = array ? array.length : 0;
231 if (initAccum && length) {
232 accumulator = array[++index];
234 while (++index < length) {
235 accumulator = iteratee(accumulator, array[index], index, array);
241 * The base implementation of `_.times` without support for iteratee shorthands
242 * or max array length checks.
245 * @param {number} n The number of times to invoke `iteratee`.
246 * @param {Function} iteratee The function invoked per iteration.
247 * @returns {Array} Returns the array of results.
249 function baseTimes(n, iteratee) {
253 while (++index < n) {
254 result[index] = iteratee(index);
260 * The base implementation of `_.unary` without support for storing metadata.
263 * @param {Function} func The function to cap arguments for.
264 * @returns {Function} Returns the new capped function.
266 function baseUnary(func) {
267 return function(value) {
273 * Gets the value at `key` of `object`.
276 * @param {Object} [object] The object to query.
277 * @param {string} key The key of the property to get.
278 * @returns {*} Returns the property value.
280 function getValue(object, key) {
281 return object == null ? undefined : object[key];
285 * Checks if `value` is a host object in IE < 9.
288 * @param {*} value The value to check.
289 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
291 function isHostObject(value) {
292 // Many host objects are `Object` objects that can coerce to strings
293 // despite having improperly defined `toString` methods.
295 if (value != null && typeof value.toString != 'function') {
297 result = !!(value + '');
304 * Converts `map` to its key-value pairs.
307 * @param {Object} map The map to convert.
308 * @returns {Array} Returns the key-value pairs.
310 function mapToArray(map) {
312 result = Array(map.size);
314 map.forEach(function(value, key) {
315 result[++index] = [key, value];
321 * Creates a unary function that invokes `func` with its argument transformed.
324 * @param {Function} func The function to wrap.
325 * @param {Function} transform The argument transform.
326 * @returns {Function} Returns the new function.
328 function overArg(func, transform) {
329 return function(arg) {
330 return func(transform(arg));
335 * Converts `set` to an array of its values.
338 * @param {Object} set The set to convert.
339 * @returns {Array} Returns the values.
341 function setToArray(set) {
343 result = Array(set.size);
345 set.forEach(function(value) {
346 result[++index] = value;
351 /** Used for built-in method references. */
352 var arrayProto = Array.prototype,
353 funcProto = Function.prototype,
354 objectProto = Object.prototype;
356 /** Used to detect overreaching core-js shims. */
357 var coreJsData = root['__core-js_shared__'];
359 /** Used to detect methods masquerading as native. */
360 var maskSrcKey = (function() {
361 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
362 return uid ? ('Symbol(src)_1.' + uid) : '';
365 /** Used to resolve the decompiled source of functions. */
366 var funcToString = funcProto.toString;
368 /** Used to check objects for own properties. */
369 var hasOwnProperty = objectProto.hasOwnProperty;
371 /** Used to infer the `Object` constructor. */
372 var objectCtorString = funcToString.call(Object);
375 * Used to resolve the
376 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
379 var objectToString = objectProto.toString;
381 /** Used to detect if a method is native. */
382 var reIsNative = RegExp('^' +
383 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
384 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
387 /** Built-in value references. */
388 var Buffer = moduleExports ? root.Buffer : undefined,
389 Symbol = root.Symbol,
390 Uint8Array = root.Uint8Array,
391 getPrototype = overArg(Object.getPrototypeOf, Object),
392 objectCreate = Object.create,
393 propertyIsEnumerable = objectProto.propertyIsEnumerable,
394 splice = arrayProto.splice;
396 /* Built-in method references for those with the same name as other `lodash` methods. */
397 var nativeGetSymbols = Object.getOwnPropertySymbols,
398 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
399 nativeKeys = overArg(Object.keys, Object),
400 nativeMax = Math.max;
402 /* Built-in method references that are verified to be native. */
403 var DataView = getNative(root, 'DataView'),
404 Map = getNative(root, 'Map'),
405 Promise = getNative(root, 'Promise'),
406 Set = getNative(root, 'Set'),
407 WeakMap = getNative(root, 'WeakMap'),
408 nativeCreate = getNative(Object, 'create');
410 /** Used to detect maps, sets, and weakmaps. */
411 var dataViewCtorString = toSource(DataView),
412 mapCtorString = toSource(Map),
413 promiseCtorString = toSource(Promise),
414 setCtorString = toSource(Set),
415 weakMapCtorString = toSource(WeakMap);
417 /** Used to convert symbols to primitives and strings. */
418 var symbolProto = Symbol ? Symbol.prototype : undefined,
419 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
422 * Creates a hash object.
426 * @param {Array} [entries] The key-value pairs to cache.
428 function Hash(entries) {
430 length = entries ? entries.length : 0;
433 while (++index < length) {
434 var entry = entries[index];
435 this.set(entry[0], entry[1]);
440 * Removes all key-value entries from the hash.
446 function hashClear() {
447 this.__data__ = nativeCreate ? nativeCreate(null) : {};
451 * Removes `key` and its value from the hash.
456 * @param {Object} hash The hash to modify.
457 * @param {string} key The key of the value to remove.
458 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
460 function hashDelete(key) {
461 return this.has(key) && delete this.__data__[key];
465 * Gets the hash value for `key`.
470 * @param {string} key The key of the value to get.
471 * @returns {*} Returns the entry value.
473 function hashGet(key) {
474 var data = this.__data__;
476 var result = data[key];
477 return result === HASH_UNDEFINED ? undefined : result;
479 return hasOwnProperty.call(data, key) ? data[key] : undefined;
483 * Checks if a hash value for `key` exists.
488 * @param {string} key The key of the entry to check.
489 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
491 function hashHas(key) {
492 var data = this.__data__;
493 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
497 * Sets the hash `key` to `value`.
502 * @param {string} key The key of the value to set.
503 * @param {*} value The value to set.
504 * @returns {Object} Returns the hash instance.
506 function hashSet(key, value) {
507 var data = this.__data__;
508 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
512 // Add methods to `Hash`.
513 Hash.prototype.clear = hashClear;
514 Hash.prototype['delete'] = hashDelete;
515 Hash.prototype.get = hashGet;
516 Hash.prototype.has = hashHas;
517 Hash.prototype.set = hashSet;
520 * Creates an list cache object.
524 * @param {Array} [entries] The key-value pairs to cache.
526 function ListCache(entries) {
528 length = entries ? entries.length : 0;
531 while (++index < length) {
532 var entry = entries[index];
533 this.set(entry[0], entry[1]);
538 * Removes all key-value entries from the list cache.
542 * @memberOf ListCache
544 function listCacheClear() {
549 * Removes `key` and its value from the list cache.
553 * @memberOf ListCache
554 * @param {string} key The key of the value to remove.
555 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
557 function listCacheDelete(key) {
558 var data = this.__data__,
559 index = assocIndexOf(data, key);
564 var lastIndex = data.length - 1;
565 if (index == lastIndex) {
568 splice.call(data, index, 1);
574 * Gets the list cache value for `key`.
578 * @memberOf ListCache
579 * @param {string} key The key of the value to get.
580 * @returns {*} Returns the entry value.
582 function listCacheGet(key) {
583 var data = this.__data__,
584 index = assocIndexOf(data, key);
586 return index < 0 ? undefined : data[index][1];
590 * Checks if a list cache value for `key` exists.
594 * @memberOf ListCache
595 * @param {string} key The key of the entry to check.
596 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
598 function listCacheHas(key) {
599 return assocIndexOf(this.__data__, key) > -1;
603 * Sets the list cache `key` to `value`.
607 * @memberOf ListCache
608 * @param {string} key The key of the value to set.
609 * @param {*} value The value to set.
610 * @returns {Object} Returns the list cache instance.
612 function listCacheSet(key, value) {
613 var data = this.__data__,
614 index = assocIndexOf(data, key);
617 data.push([key, value]);
619 data[index][1] = value;
624 // Add methods to `ListCache`.
625 ListCache.prototype.clear = listCacheClear;
626 ListCache.prototype['delete'] = listCacheDelete;
627 ListCache.prototype.get = listCacheGet;
628 ListCache.prototype.has = listCacheHas;
629 ListCache.prototype.set = listCacheSet;
632 * Creates a map cache object to store key-value pairs.
636 * @param {Array} [entries] The key-value pairs to cache.
638 function MapCache(entries) {
640 length = entries ? entries.length : 0;
643 while (++index < length) {
644 var entry = entries[index];
645 this.set(entry[0], entry[1]);
650 * Removes all key-value entries from the map.
656 function mapCacheClear() {
659 'map': new (Map || ListCache),
665 * Removes `key` and its value from the map.
670 * @param {string} key The key of the value to remove.
671 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
673 function mapCacheDelete(key) {
674 return getMapData(this, key)['delete'](key);
678 * Gets the map value for `key`.
683 * @param {string} key The key of the value to get.
684 * @returns {*} Returns the entry value.
686 function mapCacheGet(key) {
687 return getMapData(this, key).get(key);
691 * Checks if a map value for `key` exists.
696 * @param {string} key The key of the entry to check.
697 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
699 function mapCacheHas(key) {
700 return getMapData(this, key).has(key);
704 * Sets the map `key` to `value`.
709 * @param {string} key The key of the value to set.
710 * @param {*} value The value to set.
711 * @returns {Object} Returns the map cache instance.
713 function mapCacheSet(key, value) {
714 getMapData(this, key).set(key, value);
718 // Add methods to `MapCache`.
719 MapCache.prototype.clear = mapCacheClear;
720 MapCache.prototype['delete'] = mapCacheDelete;
721 MapCache.prototype.get = mapCacheGet;
722 MapCache.prototype.has = mapCacheHas;
723 MapCache.prototype.set = mapCacheSet;
726 * Creates a stack cache object to store key-value pairs.
730 * @param {Array} [entries] The key-value pairs to cache.
732 function Stack(entries) {
733 this.__data__ = new ListCache(entries);
737 * Removes all key-value entries from the stack.
743 function stackClear() {
744 this.__data__ = new ListCache;
748 * Removes `key` and its value from the stack.
753 * @param {string} key The key of the value to remove.
754 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
756 function stackDelete(key) {
757 return this.__data__['delete'](key);
761 * Gets the stack value for `key`.
766 * @param {string} key The key of the value to get.
767 * @returns {*} Returns the entry value.
769 function stackGet(key) {
770 return this.__data__.get(key);
774 * Checks if a stack value for `key` exists.
779 * @param {string} key The key of the entry to check.
780 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
782 function stackHas(key) {
783 return this.__data__.has(key);
787 * Sets the stack `key` to `value`.
792 * @param {string} key The key of the value to set.
793 * @param {*} value The value to set.
794 * @returns {Object} Returns the stack cache instance.
796 function stackSet(key, value) {
797 var cache = this.__data__;
798 if (cache instanceof ListCache) {
799 var pairs = cache.__data__;
800 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
801 pairs.push([key, value]);
804 cache = this.__data__ = new MapCache(pairs);
806 cache.set(key, value);
810 // Add methods to `Stack`.
811 Stack.prototype.clear = stackClear;
812 Stack.prototype['delete'] = stackDelete;
813 Stack.prototype.get = stackGet;
814 Stack.prototype.has = stackHas;
815 Stack.prototype.set = stackSet;
818 * Creates an array of the enumerable property names of the array-like `value`.
821 * @param {*} value The value to query.
822 * @param {boolean} inherited Specify returning inherited property names.
823 * @returns {Array} Returns the array of property names.
825 function arrayLikeKeys(value, inherited) {
826 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
827 // Safari 9 makes `arguments.length` enumerable in strict mode.
828 var result = (isArray(value) || isArguments(value))
829 ? baseTimes(value.length, String)
832 var length = result.length,
833 skipIndexes = !!length;
835 for (var key in value) {
836 if ((inherited || hasOwnProperty.call(value, key)) &&
837 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
845 * This function is like `assignValue` except that it doesn't assign
846 * `undefined` values.
849 * @param {Object} object The object to modify.
850 * @param {string} key The key of the property to assign.
851 * @param {*} value The value to assign.
853 function assignMergeValue(object, key, value) {
854 if ((value !== undefined && !eq(object[key], value)) ||
855 (typeof key == 'number' && value === undefined && !(key in object))) {
861 * Assigns `value` to `key` of `object` if the existing value is not equivalent
862 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
863 * for equality comparisons.
866 * @param {Object} object The object to modify.
867 * @param {string} key The key of the property to assign.
868 * @param {*} value The value to assign.
870 function assignValue(object, key, value) {
871 var objValue = object[key];
872 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
873 (value === undefined && !(key in object))) {
879 * Gets the index at which the `key` is found in `array` of key-value pairs.
882 * @param {Array} array The array to inspect.
883 * @param {*} key The key to search for.
884 * @returns {number} Returns the index of the matched value, else `-1`.
886 function assocIndexOf(array, key) {
887 var length = array.length;
889 if (eq(array[length][0], key)) {
897 * The base implementation of `_.assign` without support for multiple sources
898 * or `customizer` functions.
901 * @param {Object} object The destination object.
902 * @param {Object} source The source object.
903 * @returns {Object} Returns `object`.
905 function baseAssign(object, source) {
906 return object && copyObject(source, keys(source), object);
910 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
914 * @param {*} value The value to clone.
915 * @param {boolean} [isDeep] Specify a deep clone.
916 * @param {boolean} [isFull] Specify a clone including symbols.
917 * @param {Function} [customizer] The function to customize cloning.
918 * @param {string} [key] The key of `value`.
919 * @param {Object} [object] The parent object of `value`.
920 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
921 * @returns {*} Returns the cloned value.
923 function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
926 result = object ? customizer(value, key, object, stack) : customizer(value);
928 if (result !== undefined) {
931 if (!isObject(value)) {
934 var isArr = isArray(value);
936 result = initCloneArray(value);
938 return copyArray(value, result);
941 var tag = getTag(value),
942 isFunc = tag == funcTag || tag == genTag;
944 if (isBuffer(value)) {
945 return cloneBuffer(value, isDeep);
947 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
948 if (isHostObject(value)) {
949 return object ? value : {};
951 result = initCloneObject(isFunc ? {} : value);
953 return copySymbols(value, baseAssign(result, value));
956 if (!cloneableTags[tag]) {
957 return object ? value : {};
959 result = initCloneByTag(value, tag, baseClone, isDeep);
962 // Check for circular references and return its corresponding clone.
963 stack || (stack = new Stack);
964 var stacked = stack.get(value);
968 stack.set(value, result);
971 var props = isFull ? getAllKeys(value) : keys(value);
973 arrayEach(props || value, function(subValue, key) {
976 subValue = value[key];
978 // Recursively populate clone (susceptible to call stack limits).
979 assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
985 * The base implementation of `_.create` without support for assigning
986 * properties to the created object.
989 * @param {Object} prototype The object to inherit from.
990 * @returns {Object} Returns the new object.
992 function baseCreate(proto) {
993 return isObject(proto) ? objectCreate(proto) : {};
997 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
998 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
999 * symbols of `object`.
1002 * @param {Object} object The object to query.
1003 * @param {Function} keysFunc The function to get the keys of `object`.
1004 * @param {Function} symbolsFunc The function to get the symbols of `object`.
1005 * @returns {Array} Returns the array of property names and symbols.
1007 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1008 var result = keysFunc(object);
1009 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1013 * The base implementation of `getTag`.
1016 * @param {*} value The value to query.
1017 * @returns {string} Returns the `toStringTag`.
1019 function baseGetTag(value) {
1020 return objectToString.call(value);
1024 * The base implementation of `_.isNative` without bad shim checks.
1027 * @param {*} value The value to check.
1028 * @returns {boolean} Returns `true` if `value` is a native function,
1031 function baseIsNative(value) {
1032 if (!isObject(value) || isMasked(value)) {
1035 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1036 return pattern.test(toSource(value));
1040 * The base implementation of `_.isTypedArray` without Node.js optimizations.
1043 * @param {*} value The value to check.
1044 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1046 function baseIsTypedArray(value) {
1047 return isObjectLike(value) &&
1048 isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
1052 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1055 * @param {Object} object The object to query.
1056 * @returns {Array} Returns the array of property names.
1058 function baseKeys(object) {
1059 if (!isPrototype(object)) {
1060 return nativeKeys(object);
1063 for (var key in Object(object)) {
1064 if (hasOwnProperty.call(object, key) && key != 'constructor') {
1072 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1075 * @param {Object} object The object to query.
1076 * @returns {Array} Returns the array of property names.
1078 function baseKeysIn(object) {
1079 if (!isObject(object)) {
1080 return nativeKeysIn(object);
1082 var isProto = isPrototype(object),
1085 for (var key in object) {
1086 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
1094 * The base implementation of `_.merge` without support for multiple sources.
1097 * @param {Object} object The destination object.
1098 * @param {Object} source The source object.
1099 * @param {number} srcIndex The index of `source`.
1100 * @param {Function} [customizer] The function to customize merged values.
1101 * @param {Object} [stack] Tracks traversed source values and their merged
1104 function baseMerge(object, source, srcIndex, customizer, stack) {
1105 if (object === source) {
1108 if (!(isArray(source) || isTypedArray(source))) {
1109 var props = baseKeysIn(source);
1111 arrayEach(props || source, function(srcValue, key) {
1114 srcValue = source[key];
1116 if (isObject(srcValue)) {
1117 stack || (stack = new Stack);
1118 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
1121 var newValue = customizer
1122 ? customizer(object[key], srcValue, (key + ''), object, source, stack)
1125 if (newValue === undefined) {
1126 newValue = srcValue;
1128 assignMergeValue(object, key, newValue);
1134 * A specialized version of `baseMerge` for arrays and objects which performs
1135 * deep merges and tracks traversed objects enabling objects with circular
1136 * references to be merged.
1139 * @param {Object} object The destination object.
1140 * @param {Object} source The source object.
1141 * @param {string} key The key of the value to merge.
1142 * @param {number} srcIndex The index of `source`.
1143 * @param {Function} mergeFunc The function to merge values.
1144 * @param {Function} [customizer] The function to customize assigned values.
1145 * @param {Object} [stack] Tracks traversed source values and their merged
1148 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1149 var objValue = object[key],
1150 srcValue = source[key],
1151 stacked = stack.get(srcValue);
1154 assignMergeValue(object, key, stacked);
1157 var newValue = customizer
1158 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
1161 var isCommon = newValue === undefined;
1164 newValue = srcValue;
1165 if (isArray(srcValue) || isTypedArray(srcValue)) {
1166 if (isArray(objValue)) {
1167 newValue = objValue;
1169 else if (isArrayLikeObject(objValue)) {
1170 newValue = copyArray(objValue);
1174 newValue = baseClone(srcValue, true);
1177 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
1178 if (isArguments(objValue)) {
1179 newValue = toPlainObject(objValue);
1181 else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
1183 newValue = baseClone(srcValue, true);
1186 newValue = objValue;
1194 // Recursively merge objects and arrays (susceptible to call stack limits).
1195 stack.set(srcValue, newValue);
1196 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
1197 stack['delete'](srcValue);
1199 assignMergeValue(object, key, newValue);
1203 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1206 * @param {Function} func The function to apply a rest parameter to.
1207 * @param {number} [start=func.length-1] The start position of the rest parameter.
1208 * @returns {Function} Returns the new function.
1210 function baseRest(func, start) {
1211 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1213 var args = arguments,
1215 length = nativeMax(args.length - start, 0),
1216 array = Array(length);
1218 while (++index < length) {
1219 array[index] = args[start + index];
1222 var otherArgs = Array(start + 1);
1223 while (++index < start) {
1224 otherArgs[index] = args[index];
1226 otherArgs[start] = array;
1227 return apply(func, this, otherArgs);
1232 * Creates a clone of `buffer`.
1235 * @param {Buffer} buffer The buffer to clone.
1236 * @param {boolean} [isDeep] Specify a deep clone.
1237 * @returns {Buffer} Returns the cloned buffer.
1239 function cloneBuffer(buffer, isDeep) {
1241 return buffer.slice();
1243 var result = new buffer.constructor(buffer.length);
1244 buffer.copy(result);
1249 * Creates a clone of `arrayBuffer`.
1252 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1253 * @returns {ArrayBuffer} Returns the cloned array buffer.
1255 function cloneArrayBuffer(arrayBuffer) {
1256 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1257 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1262 * Creates a clone of `dataView`.
1265 * @param {Object} dataView The data view to clone.
1266 * @param {boolean} [isDeep] Specify a deep clone.
1267 * @returns {Object} Returns the cloned data view.
1269 function cloneDataView(dataView, isDeep) {
1270 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1271 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1275 * Creates a clone of `map`.
1278 * @param {Object} map The map to clone.
1279 * @param {Function} cloneFunc The function to clone values.
1280 * @param {boolean} [isDeep] Specify a deep clone.
1281 * @returns {Object} Returns the cloned map.
1283 function cloneMap(map, isDeep, cloneFunc) {
1284 var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
1285 return arrayReduce(array, addMapEntry, new map.constructor);
1289 * Creates a clone of `regexp`.
1292 * @param {Object} regexp The regexp to clone.
1293 * @returns {Object} Returns the cloned regexp.
1295 function cloneRegExp(regexp) {
1296 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1297 result.lastIndex = regexp.lastIndex;
1302 * Creates a clone of `set`.
1305 * @param {Object} set The set to clone.
1306 * @param {Function} cloneFunc The function to clone values.
1307 * @param {boolean} [isDeep] Specify a deep clone.
1308 * @returns {Object} Returns the cloned set.
1310 function cloneSet(set, isDeep, cloneFunc) {
1311 var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
1312 return arrayReduce(array, addSetEntry, new set.constructor);
1316 * Creates a clone of the `symbol` object.
1319 * @param {Object} symbol The symbol object to clone.
1320 * @returns {Object} Returns the cloned symbol object.
1322 function cloneSymbol(symbol) {
1323 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1327 * Creates a clone of `typedArray`.
1330 * @param {Object} typedArray The typed array to clone.
1331 * @param {boolean} [isDeep] Specify a deep clone.
1332 * @returns {Object} Returns the cloned typed array.
1334 function cloneTypedArray(typedArray, isDeep) {
1335 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1336 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1340 * Copies the values of `source` to `array`.
1343 * @param {Array} source The array to copy values from.
1344 * @param {Array} [array=[]] The array to copy values to.
1345 * @returns {Array} Returns `array`.
1347 function copyArray(source, array) {
1349 length = source.length;
1351 array || (array = Array(length));
1352 while (++index < length) {
1353 array[index] = source[index];
1359 * Copies properties of `source` to `object`.
1362 * @param {Object} source The object to copy properties from.
1363 * @param {Array} props The property identifiers to copy.
1364 * @param {Object} [object={}] The object to copy properties to.
1365 * @param {Function} [customizer] The function to customize copied values.
1366 * @returns {Object} Returns `object`.
1368 function copyObject(source, props, object, customizer) {
1369 object || (object = {});
1372 length = props.length;
1374 while (++index < length) {
1375 var key = props[index];
1377 var newValue = customizer
1378 ? customizer(object[key], source[key], key, object, source)
1381 assignValue(object, key, newValue === undefined ? source[key] : newValue);
1387 * Copies own symbol properties of `source` to `object`.
1390 * @param {Object} source The object to copy symbols from.
1391 * @param {Object} [object={}] The object to copy symbols to.
1392 * @returns {Object} Returns `object`.
1394 function copySymbols(source, object) {
1395 return copyObject(source, getSymbols(source), object);
1399 * Creates a function like `_.assign`.
1402 * @param {Function} assigner The function to assign values.
1403 * @returns {Function} Returns the new assigner function.
1405 function createAssigner(assigner) {
1406 return baseRest(function(object, sources) {
1408 length = sources.length,
1409 customizer = length > 1 ? sources[length - 1] : undefined,
1410 guard = length > 2 ? sources[2] : undefined;
1412 customizer = (assigner.length > 3 && typeof customizer == 'function')
1413 ? (length--, customizer)
1416 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1417 customizer = length < 3 ? undefined : customizer;
1420 object = Object(object);
1421 while (++index < length) {
1422 var source = sources[index];
1424 assigner(object, source, index, customizer);
1432 * Creates an array of own enumerable property names and symbols of `object`.
1435 * @param {Object} object The object to query.
1436 * @returns {Array} Returns the array of property names and symbols.
1438 function getAllKeys(object) {
1439 return baseGetAllKeys(object, keys, getSymbols);
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 native function at `key` of `object`.
1461 * @param {Object} object The object to query.
1462 * @param {string} key The key of the method to get.
1463 * @returns {*} Returns the function if it's native, else `undefined`.
1465 function getNative(object, key) {
1466 var value = getValue(object, key);
1467 return baseIsNative(value) ? value : undefined;
1471 * Creates an array of the own enumerable symbol properties of `object`.
1474 * @param {Object} object The object to query.
1475 * @returns {Array} Returns the array of symbols.
1477 var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
1480 * Gets the `toStringTag` of `value`.
1483 * @param {*} value The value to query.
1484 * @returns {string} Returns the `toStringTag`.
1486 var getTag = baseGetTag;
1488 // Fallback for data views, maps, sets, and weak maps in IE 11,
1489 // for data views in Edge < 14, and promises in Node.js.
1490 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1491 (Map && getTag(new Map) != mapTag) ||
1492 (Promise && getTag(Promise.resolve()) != promiseTag) ||
1493 (Set && getTag(new Set) != setTag) ||
1494 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1495 getTag = function(value) {
1496 var result = objectToString.call(value),
1497 Ctor = result == objectTag ? value.constructor : undefined,
1498 ctorString = Ctor ? toSource(Ctor) : undefined;
1501 switch (ctorString) {
1502 case dataViewCtorString: return dataViewTag;
1503 case mapCtorString: return mapTag;
1504 case promiseCtorString: return promiseTag;
1505 case setCtorString: return setTag;
1506 case weakMapCtorString: return weakMapTag;
1514 * Initializes an array clone.
1517 * @param {Array} array The array to clone.
1518 * @returns {Array} Returns the initialized clone.
1520 function initCloneArray(array) {
1521 var length = array.length,
1522 result = array.constructor(length);
1524 // Add properties assigned by `RegExp#exec`.
1525 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1526 result.index = array.index;
1527 result.input = array.input;
1533 * Initializes an object clone.
1536 * @param {Object} object The object to clone.
1537 * @returns {Object} Returns the initialized clone.
1539 function initCloneObject(object) {
1540 return (typeof object.constructor == 'function' && !isPrototype(object))
1541 ? baseCreate(getPrototype(object))
1546 * Initializes an object clone based on its `toStringTag`.
1548 * **Note:** This function only supports cloning values with tags of
1549 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1552 * @param {Object} object The object to clone.
1553 * @param {string} tag The `toStringTag` of the object to clone.
1554 * @param {Function} cloneFunc The function to clone values.
1555 * @param {boolean} [isDeep] Specify a deep clone.
1556 * @returns {Object} Returns the initialized clone.
1558 function initCloneByTag(object, tag, cloneFunc, isDeep) {
1559 var Ctor = object.constructor;
1561 case arrayBufferTag:
1562 return cloneArrayBuffer(object);
1566 return new Ctor(+object);
1569 return cloneDataView(object, isDeep);
1571 case float32Tag: case float64Tag:
1572 case int8Tag: case int16Tag: case int32Tag:
1573 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
1574 return cloneTypedArray(object, isDeep);
1577 return cloneMap(object, isDeep, cloneFunc);
1581 return new Ctor(object);
1584 return cloneRegExp(object);
1587 return cloneSet(object, isDeep, cloneFunc);
1590 return cloneSymbol(object);
1595 * Checks if `value` is a valid array-like index.
1598 * @param {*} value The value to check.
1599 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1600 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1602 function isIndex(value, length) {
1603 length = length == null ? MAX_SAFE_INTEGER : length;
1605 (typeof value == 'number' || reIsUint.test(value)) &&
1606 (value > -1 && value % 1 == 0 && value < length);
1610 * Checks if the given arguments are from an iteratee call.
1613 * @param {*} value The potential iteratee value argument.
1614 * @param {*} index The potential iteratee index or key argument.
1615 * @param {*} object The potential iteratee object argument.
1616 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1619 function isIterateeCall(value, index, object) {
1620 if (!isObject(object)) {
1623 var type = typeof index;
1624 if (type == 'number'
1625 ? (isArrayLike(object) && isIndex(index, object.length))
1626 : (type == 'string' && index in object)
1628 return eq(object[index], value);
1634 * Checks if `value` is suitable for use as unique object key.
1637 * @param {*} value The value to check.
1638 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1640 function isKeyable(value) {
1641 var type = typeof value;
1642 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1643 ? (value !== '__proto__')
1648 * Checks if `func` has its source masked.
1651 * @param {Function} func The function to check.
1652 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1654 function isMasked(func) {
1655 return !!maskSrcKey && (maskSrcKey in func);
1659 * Checks if `value` is likely a prototype object.
1662 * @param {*} value The value to check.
1663 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1665 function isPrototype(value) {
1666 var Ctor = value && value.constructor,
1667 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1669 return value === proto;
1673 * This function is like
1674 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1675 * except that it includes inherited enumerable properties.
1678 * @param {Object} object The object to query.
1679 * @returns {Array} Returns the array of property names.
1681 function nativeKeysIn(object) {
1683 if (object != null) {
1684 for (var key in Object(object)) {
1692 * Converts `func` to its source code.
1695 * @param {Function} func The function to process.
1696 * @returns {string} Returns the source code.
1698 function toSource(func) {
1701 return funcToString.call(func);
1712 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1713 * comparison between two values to determine if they are equivalent.
1719 * @param {*} value The value to compare.
1720 * @param {*} other The other value to compare.
1721 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1724 * var object = { 'a': 1 };
1725 * var other = { 'a': 1 };
1727 * _.eq(object, object);
1730 * _.eq(object, other);
1736 * _.eq('a', Object('a'));
1742 function eq(value, other) {
1743 return value === other || (value !== value && other !== other);
1747 * Checks if `value` is likely an `arguments` object.
1753 * @param {*} value The value to check.
1754 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1758 * _.isArguments(function() { return arguments; }());
1761 * _.isArguments([1, 2, 3]);
1764 function isArguments(value) {
1765 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1766 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1767 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1771 * Checks if `value` is classified as an `Array` object.
1777 * @param {*} value The value to check.
1778 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1781 * _.isArray([1, 2, 3]);
1784 * _.isArray(document.body.children);
1790 * _.isArray(_.noop);
1793 var isArray = Array.isArray;
1796 * Checks if `value` is array-like. A value is considered array-like if it's
1797 * not a function and has a `value.length` that's an integer greater than or
1798 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1804 * @param {*} value The value to check.
1805 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1808 * _.isArrayLike([1, 2, 3]);
1811 * _.isArrayLike(document.body.children);
1814 * _.isArrayLike('abc');
1817 * _.isArrayLike(_.noop);
1820 function isArrayLike(value) {
1821 return value != null && isLength(value.length) && !isFunction(value);
1825 * This method is like `_.isArrayLike` except that it also checks if `value`
1832 * @param {*} value The value to check.
1833 * @returns {boolean} Returns `true` if `value` is an array-like object,
1837 * _.isArrayLikeObject([1, 2, 3]);
1840 * _.isArrayLikeObject(document.body.children);
1843 * _.isArrayLikeObject('abc');
1846 * _.isArrayLikeObject(_.noop);
1849 function isArrayLikeObject(value) {
1850 return isObjectLike(value) && isArrayLike(value);
1854 * Checks if `value` is a buffer.
1860 * @param {*} value The value to check.
1861 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1864 * _.isBuffer(new Buffer(2));
1867 * _.isBuffer(new Uint8Array(2));
1870 var isBuffer = nativeIsBuffer || stubFalse;
1873 * Checks if `value` is classified as a `Function` object.
1879 * @param {*} value The value to check.
1880 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1886 * _.isFunction(/abc/);
1889 function isFunction(value) {
1890 // The use of `Object#toString` avoids issues with the `typeof` operator
1891 // in Safari 8-9 which returns 'object' for typed array and other constructors.
1892 var tag = isObject(value) ? objectToString.call(value) : '';
1893 return tag == funcTag || tag == genTag;
1897 * Checks if `value` is a valid array-like length.
1899 * **Note:** This method is loosely based on
1900 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1906 * @param {*} value The value to check.
1907 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1913 * _.isLength(Number.MIN_VALUE);
1916 * _.isLength(Infinity);
1922 function isLength(value) {
1923 return typeof value == 'number' &&
1924 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1928 * Checks if `value` is the
1929 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1930 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1936 * @param {*} value The value to check.
1937 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1943 * _.isObject([1, 2, 3]);
1946 * _.isObject(_.noop);
1952 function isObject(value) {
1953 var type = typeof value;
1954 return !!value && (type == 'object' || type == 'function');
1958 * Checks if `value` is object-like. A value is object-like if it's not `null`
1959 * and has a `typeof` result of "object".
1965 * @param {*} value The value to check.
1966 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1969 * _.isObjectLike({});
1972 * _.isObjectLike([1, 2, 3]);
1975 * _.isObjectLike(_.noop);
1978 * _.isObjectLike(null);
1981 function isObjectLike(value) {
1982 return !!value && typeof value == 'object';
1986 * Checks if `value` is a plain object, that is, an object created by the
1987 * `Object` constructor or one with a `[[Prototype]]` of `null`.
1993 * @param {*} value The value to check.
1994 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2001 * _.isPlainObject(new Foo);
2004 * _.isPlainObject([1, 2, 3]);
2007 * _.isPlainObject({ 'x': 0, 'y': 0 });
2010 * _.isPlainObject(Object.create(null));
2013 function isPlainObject(value) {
2014 if (!isObjectLike(value) ||
2015 objectToString.call(value) != objectTag || isHostObject(value)) {
2018 var proto = getPrototype(value);
2019 if (proto === null) {
2022 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
2023 return (typeof Ctor == 'function' &&
2024 Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
2028 * Checks if `value` is classified as a typed array.
2034 * @param {*} value The value to check.
2035 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2038 * _.isTypedArray(new Uint8Array);
2041 * _.isTypedArray([]);
2044 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2047 * Converts `value` to a plain object flattening inherited enumerable string
2048 * keyed properties of `value` to own properties of the plain object.
2054 * @param {*} value The value to convert.
2055 * @returns {Object} Returns the converted plain object.
2062 * Foo.prototype.c = 3;
2064 * _.assign({ 'a': 1 }, new Foo);
2065 * // => { 'a': 1, 'b': 2 }
2067 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
2068 * // => { 'a': 1, 'b': 2, 'c': 3 }
2070 function toPlainObject(value) {
2071 return copyObject(value, keysIn(value));
2075 * Creates an array of the own enumerable property names of `object`.
2077 * **Note:** Non-object values are coerced to objects. See the
2078 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2085 * @param {Object} object The object to query.
2086 * @returns {Array} Returns the array of property names.
2094 * Foo.prototype.c = 3;
2097 * // => ['a', 'b'] (iteration order is not guaranteed)
2102 function keys(object) {
2103 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2107 * Creates an array of the own and inherited enumerable property names of `object`.
2109 * **Note:** Non-object values are coerced to objects.
2115 * @param {Object} object The object to query.
2116 * @returns {Array} Returns the array of property names.
2124 * Foo.prototype.c = 3;
2126 * _.keysIn(new Foo);
2127 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2129 function keysIn(object) {
2130 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2134 * This method is like `_.merge` except that it accepts `customizer` which
2135 * is invoked to produce the merged values of the destination and source
2136 * properties. If `customizer` returns `undefined`, merging is handled by the
2137 * method instead. The `customizer` is invoked with seven arguments:
2138 * (objValue, srcValue, key, object, source, stack).
2140 * **Note:** This method mutates `object`.
2146 * @param {Object} object The destination object.
2147 * @param {...Object} sources The source objects.
2148 * @param {Function} customizer The function to customize assigned values.
2149 * @returns {Object} Returns `object`.
2152 * function customizer(objValue, srcValue) {
2153 * if (_.isArray(objValue)) {
2154 * return objValue.concat(srcValue);
2158 * var object = { 'a': [1], 'b': [2] };
2159 * var other = { 'a': [3], 'b': [4] };
2161 * _.mergeWith(object, other, customizer);
2162 * // => { 'a': [1, 3], 'b': [2, 4] }
2164 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
2165 baseMerge(object, source, srcIndex, customizer);
2169 * This method returns a new empty array.
2175 * @returns {Array} Returns the new empty array.
2178 * var arrays = _.times(2, _.stubArray);
2180 * console.log(arrays);
2183 * console.log(arrays[0] === arrays[1]);
2186 function stubArray() {
2191 * This method returns `false`.
2197 * @returns {boolean} Returns `false`.
2200 * _.times(2, _.stubFalse);
2201 * // => [false, false]
2203 function stubFalse() {
2207 module.exports = mergeWith;