UNPKG

45 kBJavaScriptView Raw
1/**
2 * lodash (Custom Build) <https://lodash.com/>
3 * Build: `lodash modularize exports="npm" -o ./`
4 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
5 * Released under MIT license <https://lodash.com/license>
6 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8 */
9
10/** Used as the size to enable large array optimizations. */
11var LARGE_ARRAY_SIZE = 200;
12
13/** Used to stand-in for `undefined` hash values. */
14var HASH_UNDEFINED = '__lodash_hash_undefined__';
15
16/** Used as references for various `Number` constants. */
17var MAX_SAFE_INTEGER = 9007199254740991;
18
19/** `Object#toString` result references. */
20var 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]';
36
37var 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]';
48
49/**
50 * Used to match `RegExp`
51 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
52 */
53var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
54
55/** Used to match `RegExp` flags from their coerced string values. */
56var reFlags = /\w*$/;
57
58/** Used to detect host constructors (Safari). */
59var reIsHostCtor = /^\[object .+?Constructor\]$/;
60
61/** Used to detect unsigned integer values. */
62var reIsUint = /^(?:0|[1-9]\d*)$/;
63
64/** Used to identify `toStringTag` values supported by `_.clone`. */
65var cloneableTags = {};
66cloneableTags[argsTag] = cloneableTags[arrayTag] =
67cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
68cloneableTags[boolTag] = cloneableTags[dateTag] =
69cloneableTags[float32Tag] = cloneableTags[float64Tag] =
70cloneableTags[int8Tag] = cloneableTags[int16Tag] =
71cloneableTags[int32Tag] = cloneableTags[mapTag] =
72cloneableTags[numberTag] = cloneableTags[objectTag] =
73cloneableTags[regexpTag] = cloneableTags[setTag] =
74cloneableTags[stringTag] = cloneableTags[symbolTag] =
75cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
76cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
77cloneableTags[errorTag] = cloneableTags[funcTag] =
78cloneableTags[weakMapTag] = false;
79
80/** Detect free variable `global` from Node.js. */
81var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
82
83/** Detect free variable `self`. */
84var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
85
86/** Used as a reference to the global object. */
87var root = freeGlobal || freeSelf || Function('return this')();
88
89/** Detect free variable `exports`. */
90var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
91
92/** Detect free variable `module`. */
93var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
94
95/** Detect the popular CommonJS extension `module.exports`. */
96var moduleExports = freeModule && freeModule.exports === freeExports;
97
98/**
99 * Adds the key-value `pair` to `map`.
100 *
101 * @private
102 * @param {Object} map The map to modify.
103 * @param {Array} pair The key-value pair to add.
104 * @returns {Object} Returns `map`.
105 */
106function addMapEntry(map, pair) {
107 // Don't return `map.set` because it's not chainable in IE 11.
108 map.set(pair[0], pair[1]);
109 return map;
110}
111
112/**
113 * Adds `value` to `set`.
114 *
115 * @private
116 * @param {Object} set The set to modify.
117 * @param {*} value The value to add.
118 * @returns {Object} Returns `set`.
119 */
120function addSetEntry(set, value) {
121 // Don't return `set.add` because it's not chainable in IE 11.
122 set.add(value);
123 return set;
124}
125
126/**
127 * A specialized version of `_.forEach` for arrays without support for
128 * iteratee shorthands.
129 *
130 * @private
131 * @param {Array} [array] The array to iterate over.
132 * @param {Function} iteratee The function invoked per iteration.
133 * @returns {Array} Returns `array`.
134 */
135function arrayEach(array, iteratee) {
136 var index = -1,
137 length = array ? array.length : 0;
138
139 while (++index < length) {
140 if (iteratee(array[index], index, array) === false) {
141 break;
142 }
143 }
144 return array;
145}
146
147/**
148 * Appends the elements of `values` to `array`.
149 *
150 * @private
151 * @param {Array} array The array to modify.
152 * @param {Array} values The values to append.
153 * @returns {Array} Returns `array`.
154 */
155function arrayPush(array, values) {
156 var index = -1,
157 length = values.length,
158 offset = array.length;
159
160 while (++index < length) {
161 array[offset + index] = values[index];
162 }
163 return array;
164}
165
166/**
167 * A specialized version of `_.reduce` for arrays without support for
168 * iteratee shorthands.
169 *
170 * @private
171 * @param {Array} [array] The array to iterate over.
172 * @param {Function} iteratee The function invoked per iteration.
173 * @param {*} [accumulator] The initial value.
174 * @param {boolean} [initAccum] Specify using the first element of `array` as
175 * the initial value.
176 * @returns {*} Returns the accumulated value.
177 */
178function arrayReduce(array, iteratee, accumulator, initAccum) {
179 var index = -1,
180 length = array ? array.length : 0;
181
182 if (initAccum && length) {
183 accumulator = array[++index];
184 }
185 while (++index < length) {
186 accumulator = iteratee(accumulator, array[index], index, array);
187 }
188 return accumulator;
189}
190
191/**
192 * The base implementation of `_.times` without support for iteratee shorthands
193 * or max array length checks.
194 *
195 * @private
196 * @param {number} n The number of times to invoke `iteratee`.
197 * @param {Function} iteratee The function invoked per iteration.
198 * @returns {Array} Returns the array of results.
199 */
200function baseTimes(n, iteratee) {
201 var index = -1,
202 result = Array(n);
203
204 while (++index < n) {
205 result[index] = iteratee(index);
206 }
207 return result;
208}
209
210/**
211 * Gets the value at `key` of `object`.
212 *
213 * @private
214 * @param {Object} [object] The object to query.
215 * @param {string} key The key of the property to get.
216 * @returns {*} Returns the property value.
217 */
218function getValue(object, key) {
219 return object == null ? undefined : object[key];
220}
221
222/**
223 * Checks if `value` is a host object in IE < 9.
224 *
225 * @private
226 * @param {*} value The value to check.
227 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
228 */
229function isHostObject(value) {
230 // Many host objects are `Object` objects that can coerce to strings
231 // despite having improperly defined `toString` methods.
232 var result = false;
233 if (value != null && typeof value.toString != 'function') {
234 try {
235 result = !!(value + '');
236 } catch (e) {}
237 }
238 return result;
239}
240
241/**
242 * Converts `map` to its key-value pairs.
243 *
244 * @private
245 * @param {Object} map The map to convert.
246 * @returns {Array} Returns the key-value pairs.
247 */
248function mapToArray(map) {
249 var index = -1,
250 result = Array(map.size);
251
252 map.forEach(function(value, key) {
253 result[++index] = [key, value];
254 });
255 return result;
256}
257
258/**
259 * Creates a unary function that invokes `func` with its argument transformed.
260 *
261 * @private
262 * @param {Function} func The function to wrap.
263 * @param {Function} transform The argument transform.
264 * @returns {Function} Returns the new function.
265 */
266function overArg(func, transform) {
267 return function(arg) {
268 return func(transform(arg));
269 };
270}
271
272/**
273 * Converts `set` to an array of its values.
274 *
275 * @private
276 * @param {Object} set The set to convert.
277 * @returns {Array} Returns the values.
278 */
279function setToArray(set) {
280 var index = -1,
281 result = Array(set.size);
282
283 set.forEach(function(value) {
284 result[++index] = value;
285 });
286 return result;
287}
288
289/** Used for built-in method references. */
290var arrayProto = Array.prototype,
291 funcProto = Function.prototype,
292 objectProto = Object.prototype;
293
294/** Used to detect overreaching core-js shims. */
295var coreJsData = root['__core-js_shared__'];
296
297/** Used to detect methods masquerading as native. */
298var maskSrcKey = (function() {
299 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
300 return uid ? ('Symbol(src)_1.' + uid) : '';
301}());
302
303/** Used to resolve the decompiled source of functions. */
304var funcToString = funcProto.toString;
305
306/** Used to check objects for own properties. */
307var hasOwnProperty = objectProto.hasOwnProperty;
308
309/**
310 * Used to resolve the
311 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
312 * of values.
313 */
314var objectToString = objectProto.toString;
315
316/** Used to detect if a method is native. */
317var reIsNative = RegExp('^' +
318 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
319 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
320);
321
322/** Built-in value references. */
323var Buffer = moduleExports ? root.Buffer : undefined,
324 Symbol = root.Symbol,
325 Uint8Array = root.Uint8Array,
326 getPrototype = overArg(Object.getPrototypeOf, Object),
327 objectCreate = Object.create,
328 propertyIsEnumerable = objectProto.propertyIsEnumerable,
329 splice = arrayProto.splice;
330
331/* Built-in method references for those with the same name as other `lodash` methods. */
332var nativeGetSymbols = Object.getOwnPropertySymbols,
333 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
334 nativeKeys = overArg(Object.keys, Object);
335
336/* Built-in method references that are verified to be native. */
337var DataView = getNative(root, 'DataView'),
338 Map = getNative(root, 'Map'),
339 Promise = getNative(root, 'Promise'),
340 Set = getNative(root, 'Set'),
341 WeakMap = getNative(root, 'WeakMap'),
342 nativeCreate = getNative(Object, 'create');
343
344/** Used to detect maps, sets, and weakmaps. */
345var dataViewCtorString = toSource(DataView),
346 mapCtorString = toSource(Map),
347 promiseCtorString = toSource(Promise),
348 setCtorString = toSource(Set),
349 weakMapCtorString = toSource(WeakMap);
350
351/** Used to convert symbols to primitives and strings. */
352var symbolProto = Symbol ? Symbol.prototype : undefined,
353 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
354
355/**
356 * Creates a hash object.
357 *
358 * @private
359 * @constructor
360 * @param {Array} [entries] The key-value pairs to cache.
361 */
362function Hash(entries) {
363 var index = -1,
364 length = entries ? entries.length : 0;
365
366 this.clear();
367 while (++index < length) {
368 var entry = entries[index];
369 this.set(entry[0], entry[1]);
370 }
371}
372
373/**
374 * Removes all key-value entries from the hash.
375 *
376 * @private
377 * @name clear
378 * @memberOf Hash
379 */
380function hashClear() {
381 this.__data__ = nativeCreate ? nativeCreate(null) : {};
382}
383
384/**
385 * Removes `key` and its value from the hash.
386 *
387 * @private
388 * @name delete
389 * @memberOf Hash
390 * @param {Object} hash The hash to modify.
391 * @param {string} key The key of the value to remove.
392 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
393 */
394function hashDelete(key) {
395 return this.has(key) && delete this.__data__[key];
396}
397
398/**
399 * Gets the hash value for `key`.
400 *
401 * @private
402 * @name get
403 * @memberOf Hash
404 * @param {string} key The key of the value to get.
405 * @returns {*} Returns the entry value.
406 */
407function hashGet(key) {
408 var data = this.__data__;
409 if (nativeCreate) {
410 var result = data[key];
411 return result === HASH_UNDEFINED ? undefined : result;
412 }
413 return hasOwnProperty.call(data, key) ? data[key] : undefined;
414}
415
416/**
417 * Checks if a hash value for `key` exists.
418 *
419 * @private
420 * @name has
421 * @memberOf Hash
422 * @param {string} key The key of the entry to check.
423 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
424 */
425function hashHas(key) {
426 var data = this.__data__;
427 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
428}
429
430/**
431 * Sets the hash `key` to `value`.
432 *
433 * @private
434 * @name set
435 * @memberOf Hash
436 * @param {string} key The key of the value to set.
437 * @param {*} value The value to set.
438 * @returns {Object} Returns the hash instance.
439 */
440function hashSet(key, value) {
441 var data = this.__data__;
442 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
443 return this;
444}
445
446// Add methods to `Hash`.
447Hash.prototype.clear = hashClear;
448Hash.prototype['delete'] = hashDelete;
449Hash.prototype.get = hashGet;
450Hash.prototype.has = hashHas;
451Hash.prototype.set = hashSet;
452
453/**
454 * Creates an list cache object.
455 *
456 * @private
457 * @constructor
458 * @param {Array} [entries] The key-value pairs to cache.
459 */
460function ListCache(entries) {
461 var index = -1,
462 length = entries ? entries.length : 0;
463
464 this.clear();
465 while (++index < length) {
466 var entry = entries[index];
467 this.set(entry[0], entry[1]);
468 }
469}
470
471/**
472 * Removes all key-value entries from the list cache.
473 *
474 * @private
475 * @name clear
476 * @memberOf ListCache
477 */
478function listCacheClear() {
479 this.__data__ = [];
480}
481
482/**
483 * Removes `key` and its value from the list cache.
484 *
485 * @private
486 * @name delete
487 * @memberOf ListCache
488 * @param {string} key The key of the value to remove.
489 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
490 */
491function listCacheDelete(key) {
492 var data = this.__data__,
493 index = assocIndexOf(data, key);
494
495 if (index < 0) {
496 return false;
497 }
498 var lastIndex = data.length - 1;
499 if (index == lastIndex) {
500 data.pop();
501 } else {
502 splice.call(data, index, 1);
503 }
504 return true;
505}
506
507/**
508 * Gets the list cache value for `key`.
509 *
510 * @private
511 * @name get
512 * @memberOf ListCache
513 * @param {string} key The key of the value to get.
514 * @returns {*} Returns the entry value.
515 */
516function listCacheGet(key) {
517 var data = this.__data__,
518 index = assocIndexOf(data, key);
519
520 return index < 0 ? undefined : data[index][1];
521}
522
523/**
524 * Checks if a list cache value for `key` exists.
525 *
526 * @private
527 * @name has
528 * @memberOf ListCache
529 * @param {string} key The key of the entry to check.
530 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
531 */
532function listCacheHas(key) {
533 return assocIndexOf(this.__data__, key) > -1;
534}
535
536/**
537 * Sets the list cache `key` to `value`.
538 *
539 * @private
540 * @name set
541 * @memberOf ListCache
542 * @param {string} key The key of the value to set.
543 * @param {*} value The value to set.
544 * @returns {Object} Returns the list cache instance.
545 */
546function listCacheSet(key, value) {
547 var data = this.__data__,
548 index = assocIndexOf(data, key);
549
550 if (index < 0) {
551 data.push([key, value]);
552 } else {
553 data[index][1] = value;
554 }
555 return this;
556}
557
558// Add methods to `ListCache`.
559ListCache.prototype.clear = listCacheClear;
560ListCache.prototype['delete'] = listCacheDelete;
561ListCache.prototype.get = listCacheGet;
562ListCache.prototype.has = listCacheHas;
563ListCache.prototype.set = listCacheSet;
564
565/**
566 * Creates a map cache object to store key-value pairs.
567 *
568 * @private
569 * @constructor
570 * @param {Array} [entries] The key-value pairs to cache.
571 */
572function MapCache(entries) {
573 var index = -1,
574 length = entries ? entries.length : 0;
575
576 this.clear();
577 while (++index < length) {
578 var entry = entries[index];
579 this.set(entry[0], entry[1]);
580 }
581}
582
583/**
584 * Removes all key-value entries from the map.
585 *
586 * @private
587 * @name clear
588 * @memberOf MapCache
589 */
590function mapCacheClear() {
591 this.__data__ = {
592 'hash': new Hash,
593 'map': new (Map || ListCache),
594 'string': new Hash
595 };
596}
597
598/**
599 * Removes `key` and its value from the map.
600 *
601 * @private
602 * @name delete
603 * @memberOf MapCache
604 * @param {string} key The key of the value to remove.
605 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
606 */
607function mapCacheDelete(key) {
608 return getMapData(this, key)['delete'](key);
609}
610
611/**
612 * Gets the map value for `key`.
613 *
614 * @private
615 * @name get
616 * @memberOf MapCache
617 * @param {string} key The key of the value to get.
618 * @returns {*} Returns the entry value.
619 */
620function mapCacheGet(key) {
621 return getMapData(this, key).get(key);
622}
623
624/**
625 * Checks if a map value for `key` exists.
626 *
627 * @private
628 * @name has
629 * @memberOf MapCache
630 * @param {string} key The key of the entry to check.
631 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
632 */
633function mapCacheHas(key) {
634 return getMapData(this, key).has(key);
635}
636
637/**
638 * Sets the map `key` to `value`.
639 *
640 * @private
641 * @name set
642 * @memberOf MapCache
643 * @param {string} key The key of the value to set.
644 * @param {*} value The value to set.
645 * @returns {Object} Returns the map cache instance.
646 */
647function mapCacheSet(key, value) {
648 getMapData(this, key).set(key, value);
649 return this;
650}
651
652// Add methods to `MapCache`.
653MapCache.prototype.clear = mapCacheClear;
654MapCache.prototype['delete'] = mapCacheDelete;
655MapCache.prototype.get = mapCacheGet;
656MapCache.prototype.has = mapCacheHas;
657MapCache.prototype.set = mapCacheSet;
658
659/**
660 * Creates a stack cache object to store key-value pairs.
661 *
662 * @private
663 * @constructor
664 * @param {Array} [entries] The key-value pairs to cache.
665 */
666function Stack(entries) {
667 this.__data__ = new ListCache(entries);
668}
669
670/**
671 * Removes all key-value entries from the stack.
672 *
673 * @private
674 * @name clear
675 * @memberOf Stack
676 */
677function stackClear() {
678 this.__data__ = new ListCache;
679}
680
681/**
682 * Removes `key` and its value from the stack.
683 *
684 * @private
685 * @name delete
686 * @memberOf Stack
687 * @param {string} key The key of the value to remove.
688 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
689 */
690function stackDelete(key) {
691 return this.__data__['delete'](key);
692}
693
694/**
695 * Gets the stack value for `key`.
696 *
697 * @private
698 * @name get
699 * @memberOf Stack
700 * @param {string} key The key of the value to get.
701 * @returns {*} Returns the entry value.
702 */
703function stackGet(key) {
704 return this.__data__.get(key);
705}
706
707/**
708 * Checks if a stack value for `key` exists.
709 *
710 * @private
711 * @name has
712 * @memberOf Stack
713 * @param {string} key The key of the entry to check.
714 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
715 */
716function stackHas(key) {
717 return this.__data__.has(key);
718}
719
720/**
721 * Sets the stack `key` to `value`.
722 *
723 * @private
724 * @name set
725 * @memberOf Stack
726 * @param {string} key The key of the value to set.
727 * @param {*} value The value to set.
728 * @returns {Object} Returns the stack cache instance.
729 */
730function stackSet(key, value) {
731 var cache = this.__data__;
732 if (cache instanceof ListCache) {
733 var pairs = cache.__data__;
734 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
735 pairs.push([key, value]);
736 return this;
737 }
738 cache = this.__data__ = new MapCache(pairs);
739 }
740 cache.set(key, value);
741 return this;
742}
743
744// Add methods to `Stack`.
745Stack.prototype.clear = stackClear;
746Stack.prototype['delete'] = stackDelete;
747Stack.prototype.get = stackGet;
748Stack.prototype.has = stackHas;
749Stack.prototype.set = stackSet;
750
751/**
752 * Creates an array of the enumerable property names of the array-like `value`.
753 *
754 * @private
755 * @param {*} value The value to query.
756 * @param {boolean} inherited Specify returning inherited property names.
757 * @returns {Array} Returns the array of property names.
758 */
759function arrayLikeKeys(value, inherited) {
760 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
761 // Safari 9 makes `arguments.length` enumerable in strict mode.
762 var result = (isArray(value) || isArguments(value))
763 ? baseTimes(value.length, String)
764 : [];
765
766 var length = result.length,
767 skipIndexes = !!length;
768
769 for (var key in value) {
770 if ((inherited || hasOwnProperty.call(value, key)) &&
771 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
772 result.push(key);
773 }
774 }
775 return result;
776}
777
778/**
779 * Assigns `value` to `key` of `object` if the existing value is not equivalent
780 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
781 * for equality comparisons.
782 *
783 * @private
784 * @param {Object} object The object to modify.
785 * @param {string} key The key of the property to assign.
786 * @param {*} value The value to assign.
787 */
788function assignValue(object, key, value) {
789 var objValue = object[key];
790 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
791 (value === undefined && !(key in object))) {
792 object[key] = value;
793 }
794}
795
796/**
797 * Gets the index at which the `key` is found in `array` of key-value pairs.
798 *
799 * @private
800 * @param {Array} array The array to inspect.
801 * @param {*} key The key to search for.
802 * @returns {number} Returns the index of the matched value, else `-1`.
803 */
804function assocIndexOf(array, key) {
805 var length = array.length;
806 while (length--) {
807 if (eq(array[length][0], key)) {
808 return length;
809 }
810 }
811 return -1;
812}
813
814/**
815 * The base implementation of `_.assign` without support for multiple sources
816 * or `customizer` functions.
817 *
818 * @private
819 * @param {Object} object The destination object.
820 * @param {Object} source The source object.
821 * @returns {Object} Returns `object`.
822 */
823function baseAssign(object, source) {
824 return object && copyObject(source, keys(source), object);
825}
826
827/**
828 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
829 * traversed objects.
830 *
831 * @private
832 * @param {*} value The value to clone.
833 * @param {boolean} [isDeep] Specify a deep clone.
834 * @param {boolean} [isFull] Specify a clone including symbols.
835 * @param {Function} [customizer] The function to customize cloning.
836 * @param {string} [key] The key of `value`.
837 * @param {Object} [object] The parent object of `value`.
838 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
839 * @returns {*} Returns the cloned value.
840 */
841function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
842 var result;
843 if (customizer) {
844 result = object ? customizer(value, key, object, stack) : customizer(value);
845 }
846 if (result !== undefined) {
847 return result;
848 }
849 if (!isObject(value)) {
850 return value;
851 }
852 var isArr = isArray(value);
853 if (isArr) {
854 result = initCloneArray(value);
855 if (!isDeep) {
856 return copyArray(value, result);
857 }
858 } else {
859 var tag = getTag(value),
860 isFunc = tag == funcTag || tag == genTag;
861
862 if (isBuffer(value)) {
863 return cloneBuffer(value, isDeep);
864 }
865 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
866 if (isHostObject(value)) {
867 return object ? value : {};
868 }
869 result = initCloneObject(isFunc ? {} : value);
870 if (!isDeep) {
871 return copySymbols(value, baseAssign(result, value));
872 }
873 } else {
874 if (!cloneableTags[tag]) {
875 return object ? value : {};
876 }
877 result = initCloneByTag(value, tag, baseClone, isDeep);
878 }
879 }
880 // Check for circular references and return its corresponding clone.
881 stack || (stack = new Stack);
882 var stacked = stack.get(value);
883 if (stacked) {
884 return stacked;
885 }
886 stack.set(value, result);
887
888 if (!isArr) {
889 var props = isFull ? getAllKeys(value) : keys(value);
890 }
891 arrayEach(props || value, function(subValue, key) {
892 if (props) {
893 key = subValue;
894 subValue = value[key];
895 }
896 // Recursively populate clone (susceptible to call stack limits).
897 assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
898 });
899 return result;
900}
901
902/**
903 * The base implementation of `_.create` without support for assigning
904 * properties to the created object.
905 *
906 * @private
907 * @param {Object} prototype The object to inherit from.
908 * @returns {Object} Returns the new object.
909 */
910function baseCreate(proto) {
911 return isObject(proto) ? objectCreate(proto) : {};
912}
913
914/**
915 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
916 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
917 * symbols of `object`.
918 *
919 * @private
920 * @param {Object} object The object to query.
921 * @param {Function} keysFunc The function to get the keys of `object`.
922 * @param {Function} symbolsFunc The function to get the symbols of `object`.
923 * @returns {Array} Returns the array of property names and symbols.
924 */
925function baseGetAllKeys(object, keysFunc, symbolsFunc) {
926 var result = keysFunc(object);
927 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
928}
929
930/**
931 * The base implementation of `getTag`.
932 *
933 * @private
934 * @param {*} value The value to query.
935 * @returns {string} Returns the `toStringTag`.
936 */
937function baseGetTag(value) {
938 return objectToString.call(value);
939}
940
941/**
942 * The base implementation of `_.isNative` without bad shim checks.
943 *
944 * @private
945 * @param {*} value The value to check.
946 * @returns {boolean} Returns `true` if `value` is a native function,
947 * else `false`.
948 */
949function baseIsNative(value) {
950 if (!isObject(value) || isMasked(value)) {
951 return false;
952 }
953 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
954 return pattern.test(toSource(value));
955}
956
957/**
958 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
959 *
960 * @private
961 * @param {Object} object The object to query.
962 * @returns {Array} Returns the array of property names.
963 */
964function baseKeys(object) {
965 if (!isPrototype(object)) {
966 return nativeKeys(object);
967 }
968 var result = [];
969 for (var key in Object(object)) {
970 if (hasOwnProperty.call(object, key) && key != 'constructor') {
971 result.push(key);
972 }
973 }
974 return result;
975}
976
977/**
978 * Creates a clone of `buffer`.
979 *
980 * @private
981 * @param {Buffer} buffer The buffer to clone.
982 * @param {boolean} [isDeep] Specify a deep clone.
983 * @returns {Buffer} Returns the cloned buffer.
984 */
985function cloneBuffer(buffer, isDeep) {
986 if (isDeep) {
987 return buffer.slice();
988 }
989 var result = new buffer.constructor(buffer.length);
990 buffer.copy(result);
991 return result;
992}
993
994/**
995 * Creates a clone of `arrayBuffer`.
996 *
997 * @private
998 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
999 * @returns {ArrayBuffer} Returns the cloned array buffer.
1000 */
1001function cloneArrayBuffer(arrayBuffer) {
1002 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1003 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1004 return result;
1005}
1006
1007/**
1008 * Creates a clone of `dataView`.
1009 *
1010 * @private
1011 * @param {Object} dataView The data view to clone.
1012 * @param {boolean} [isDeep] Specify a deep clone.
1013 * @returns {Object} Returns the cloned data view.
1014 */
1015function cloneDataView(dataView, isDeep) {
1016 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1017 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1018}
1019
1020/**
1021 * Creates a clone of `map`.
1022 *
1023 * @private
1024 * @param {Object} map The map to clone.
1025 * @param {Function} cloneFunc The function to clone values.
1026 * @param {boolean} [isDeep] Specify a deep clone.
1027 * @returns {Object} Returns the cloned map.
1028 */
1029function cloneMap(map, isDeep, cloneFunc) {
1030 var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
1031 return arrayReduce(array, addMapEntry, new map.constructor);
1032}
1033
1034/**
1035 * Creates a clone of `regexp`.
1036 *
1037 * @private
1038 * @param {Object} regexp The regexp to clone.
1039 * @returns {Object} Returns the cloned regexp.
1040 */
1041function cloneRegExp(regexp) {
1042 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1043 result.lastIndex = regexp.lastIndex;
1044 return result;
1045}
1046
1047/**
1048 * Creates a clone of `set`.
1049 *
1050 * @private
1051 * @param {Object} set The set to clone.
1052 * @param {Function} cloneFunc The function to clone values.
1053 * @param {boolean} [isDeep] Specify a deep clone.
1054 * @returns {Object} Returns the cloned set.
1055 */
1056function cloneSet(set, isDeep, cloneFunc) {
1057 var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
1058 return arrayReduce(array, addSetEntry, new set.constructor);
1059}
1060
1061/**
1062 * Creates a clone of the `symbol` object.
1063 *
1064 * @private
1065 * @param {Object} symbol The symbol object to clone.
1066 * @returns {Object} Returns the cloned symbol object.
1067 */
1068function cloneSymbol(symbol) {
1069 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1070}
1071
1072/**
1073 * Creates a clone of `typedArray`.
1074 *
1075 * @private
1076 * @param {Object} typedArray The typed array to clone.
1077 * @param {boolean} [isDeep] Specify a deep clone.
1078 * @returns {Object} Returns the cloned typed array.
1079 */
1080function cloneTypedArray(typedArray, isDeep) {
1081 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1082 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1083}
1084
1085/**
1086 * Copies the values of `source` to `array`.
1087 *
1088 * @private
1089 * @param {Array} source The array to copy values from.
1090 * @param {Array} [array=[]] The array to copy values to.
1091 * @returns {Array} Returns `array`.
1092 */
1093function copyArray(source, array) {
1094 var index = -1,
1095 length = source.length;
1096
1097 array || (array = Array(length));
1098 while (++index < length) {
1099 array[index] = source[index];
1100 }
1101 return array;
1102}
1103
1104/**
1105 * Copies properties of `source` to `object`.
1106 *
1107 * @private
1108 * @param {Object} source The object to copy properties from.
1109 * @param {Array} props The property identifiers to copy.
1110 * @param {Object} [object={}] The object to copy properties to.
1111 * @param {Function} [customizer] The function to customize copied values.
1112 * @returns {Object} Returns `object`.
1113 */
1114function copyObject(source, props, object, customizer) {
1115 object || (object = {});
1116
1117 var index = -1,
1118 length = props.length;
1119
1120 while (++index < length) {
1121 var key = props[index];
1122
1123 var newValue = customizer
1124 ? customizer(object[key], source[key], key, object, source)
1125 : undefined;
1126
1127 assignValue(object, key, newValue === undefined ? source[key] : newValue);
1128 }
1129 return object;
1130}
1131
1132/**
1133 * Copies own symbol properties of `source` to `object`.
1134 *
1135 * @private
1136 * @param {Object} source The object to copy symbols from.
1137 * @param {Object} [object={}] The object to copy symbols to.
1138 * @returns {Object} Returns `object`.
1139 */
1140function copySymbols(source, object) {
1141 return copyObject(source, getSymbols(source), object);
1142}
1143
1144/**
1145 * Creates an array of own enumerable property names and symbols of `object`.
1146 *
1147 * @private
1148 * @param {Object} object The object to query.
1149 * @returns {Array} Returns the array of property names and symbols.
1150 */
1151function getAllKeys(object) {
1152 return baseGetAllKeys(object, keys, getSymbols);
1153}
1154
1155/**
1156 * Gets the data for `map`.
1157 *
1158 * @private
1159 * @param {Object} map The map to query.
1160 * @param {string} key The reference key.
1161 * @returns {*} Returns the map data.
1162 */
1163function getMapData(map, key) {
1164 var data = map.__data__;
1165 return isKeyable(key)
1166 ? data[typeof key == 'string' ? 'string' : 'hash']
1167 : data.map;
1168}
1169
1170/**
1171 * Gets the native function at `key` of `object`.
1172 *
1173 * @private
1174 * @param {Object} object The object to query.
1175 * @param {string} key The key of the method to get.
1176 * @returns {*} Returns the function if it's native, else `undefined`.
1177 */
1178function getNative(object, key) {
1179 var value = getValue(object, key);
1180 return baseIsNative(value) ? value : undefined;
1181}
1182
1183/**
1184 * Creates an array of the own enumerable symbol properties of `object`.
1185 *
1186 * @private
1187 * @param {Object} object The object to query.
1188 * @returns {Array} Returns the array of symbols.
1189 */
1190var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
1191
1192/**
1193 * Gets the `toStringTag` of `value`.
1194 *
1195 * @private
1196 * @param {*} value The value to query.
1197 * @returns {string} Returns the `toStringTag`.
1198 */
1199var getTag = baseGetTag;
1200
1201// Fallback for data views, maps, sets, and weak maps in IE 11,
1202// for data views in Edge < 14, and promises in Node.js.
1203if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1204 (Map && getTag(new Map) != mapTag) ||
1205 (Promise && getTag(Promise.resolve()) != promiseTag) ||
1206 (Set && getTag(new Set) != setTag) ||
1207 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1208 getTag = function(value) {
1209 var result = objectToString.call(value),
1210 Ctor = result == objectTag ? value.constructor : undefined,
1211 ctorString = Ctor ? toSource(Ctor) : undefined;
1212
1213 if (ctorString) {
1214 switch (ctorString) {
1215 case dataViewCtorString: return dataViewTag;
1216 case mapCtorString: return mapTag;
1217 case promiseCtorString: return promiseTag;
1218 case setCtorString: return setTag;
1219 case weakMapCtorString: return weakMapTag;
1220 }
1221 }
1222 return result;
1223 };
1224}
1225
1226/**
1227 * Initializes an array clone.
1228 *
1229 * @private
1230 * @param {Array} array The array to clone.
1231 * @returns {Array} Returns the initialized clone.
1232 */
1233function initCloneArray(array) {
1234 var length = array.length,
1235 result = array.constructor(length);
1236
1237 // Add properties assigned by `RegExp#exec`.
1238 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1239 result.index = array.index;
1240 result.input = array.input;
1241 }
1242 return result;
1243}
1244
1245/**
1246 * Initializes an object clone.
1247 *
1248 * @private
1249 * @param {Object} object The object to clone.
1250 * @returns {Object} Returns the initialized clone.
1251 */
1252function initCloneObject(object) {
1253 return (typeof object.constructor == 'function' && !isPrototype(object))
1254 ? baseCreate(getPrototype(object))
1255 : {};
1256}
1257
1258/**
1259 * Initializes an object clone based on its `toStringTag`.
1260 *
1261 * **Note:** This function only supports cloning values with tags of
1262 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1263 *
1264 * @private
1265 * @param {Object} object The object to clone.
1266 * @param {string} tag The `toStringTag` of the object to clone.
1267 * @param {Function} cloneFunc The function to clone values.
1268 * @param {boolean} [isDeep] Specify a deep clone.
1269 * @returns {Object} Returns the initialized clone.
1270 */
1271function initCloneByTag(object, tag, cloneFunc, isDeep) {
1272 var Ctor = object.constructor;
1273 switch (tag) {
1274 case arrayBufferTag:
1275 return cloneArrayBuffer(object);
1276
1277 case boolTag:
1278 case dateTag:
1279 return new Ctor(+object);
1280
1281 case dataViewTag:
1282 return cloneDataView(object, isDeep);
1283
1284 case float32Tag: case float64Tag:
1285 case int8Tag: case int16Tag: case int32Tag:
1286 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
1287 return cloneTypedArray(object, isDeep);
1288
1289 case mapTag:
1290 return cloneMap(object, isDeep, cloneFunc);
1291
1292 case numberTag:
1293 case stringTag:
1294 return new Ctor(object);
1295
1296 case regexpTag:
1297 return cloneRegExp(object);
1298
1299 case setTag:
1300 return cloneSet(object, isDeep, cloneFunc);
1301
1302 case symbolTag:
1303 return cloneSymbol(object);
1304 }
1305}
1306
1307/**
1308 * Checks if `value` is a valid array-like index.
1309 *
1310 * @private
1311 * @param {*} value The value to check.
1312 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1313 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1314 */
1315function isIndex(value, length) {
1316 length = length == null ? MAX_SAFE_INTEGER : length;
1317 return !!length &&
1318 (typeof value == 'number' || reIsUint.test(value)) &&
1319 (value > -1 && value % 1 == 0 && value < length);
1320}
1321
1322/**
1323 * Checks if `value` is suitable for use as unique object key.
1324 *
1325 * @private
1326 * @param {*} value The value to check.
1327 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1328 */
1329function isKeyable(value) {
1330 var type = typeof value;
1331 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1332 ? (value !== '__proto__')
1333 : (value === null);
1334}
1335
1336/**
1337 * Checks if `func` has its source masked.
1338 *
1339 * @private
1340 * @param {Function} func The function to check.
1341 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1342 */
1343function isMasked(func) {
1344 return !!maskSrcKey && (maskSrcKey in func);
1345}
1346
1347/**
1348 * Checks if `value` is likely a prototype object.
1349 *
1350 * @private
1351 * @param {*} value The value to check.
1352 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1353 */
1354function isPrototype(value) {
1355 var Ctor = value && value.constructor,
1356 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1357
1358 return value === proto;
1359}
1360
1361/**
1362 * Converts `func` to its source code.
1363 *
1364 * @private
1365 * @param {Function} func The function to process.
1366 * @returns {string} Returns the source code.
1367 */
1368function toSource(func) {
1369 if (func != null) {
1370 try {
1371 return funcToString.call(func);
1372 } catch (e) {}
1373 try {
1374 return (func + '');
1375 } catch (e) {}
1376 }
1377 return '';
1378}
1379
1380/**
1381 * This method is like `_.clone` except that it recursively clones `value`.
1382 *
1383 * @static
1384 * @memberOf _
1385 * @since 1.0.0
1386 * @category Lang
1387 * @param {*} value The value to recursively clone.
1388 * @returns {*} Returns the deep cloned value.
1389 * @see _.clone
1390 * @example
1391 *
1392 * var objects = [{ 'a': 1 }, { 'b': 2 }];
1393 *
1394 * var deep = _.cloneDeep(objects);
1395 * console.log(deep[0] === objects[0]);
1396 * // => false
1397 */
1398function cloneDeep(value) {
1399 return baseClone(value, true, true);
1400}
1401
1402/**
1403 * Performs a
1404 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1405 * comparison between two values to determine if they are equivalent.
1406 *
1407 * @static
1408 * @memberOf _
1409 * @since 4.0.0
1410 * @category Lang
1411 * @param {*} value The value to compare.
1412 * @param {*} other The other value to compare.
1413 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1414 * @example
1415 *
1416 * var object = { 'a': 1 };
1417 * var other = { 'a': 1 };
1418 *
1419 * _.eq(object, object);
1420 * // => true
1421 *
1422 * _.eq(object, other);
1423 * // => false
1424 *
1425 * _.eq('a', 'a');
1426 * // => true
1427 *
1428 * _.eq('a', Object('a'));
1429 * // => false
1430 *
1431 * _.eq(NaN, NaN);
1432 * // => true
1433 */
1434function eq(value, other) {
1435 return value === other || (value !== value && other !== other);
1436}
1437
1438/**
1439 * Checks if `value` is likely an `arguments` object.
1440 *
1441 * @static
1442 * @memberOf _
1443 * @since 0.1.0
1444 * @category Lang
1445 * @param {*} value The value to check.
1446 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1447 * else `false`.
1448 * @example
1449 *
1450 * _.isArguments(function() { return arguments; }());
1451 * // => true
1452 *
1453 * _.isArguments([1, 2, 3]);
1454 * // => false
1455 */
1456function isArguments(value) {
1457 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1458 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1459 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1460}
1461
1462/**
1463 * Checks if `value` is classified as an `Array` object.
1464 *
1465 * @static
1466 * @memberOf _
1467 * @since 0.1.0
1468 * @category Lang
1469 * @param {*} value The value to check.
1470 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1471 * @example
1472 *
1473 * _.isArray([1, 2, 3]);
1474 * // => true
1475 *
1476 * _.isArray(document.body.children);
1477 * // => false
1478 *
1479 * _.isArray('abc');
1480 * // => false
1481 *
1482 * _.isArray(_.noop);
1483 * // => false
1484 */
1485var isArray = Array.isArray;
1486
1487/**
1488 * Checks if `value` is array-like. A value is considered array-like if it's
1489 * not a function and has a `value.length` that's an integer greater than or
1490 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1491 *
1492 * @static
1493 * @memberOf _
1494 * @since 4.0.0
1495 * @category Lang
1496 * @param {*} value The value to check.
1497 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1498 * @example
1499 *
1500 * _.isArrayLike([1, 2, 3]);
1501 * // => true
1502 *
1503 * _.isArrayLike(document.body.children);
1504 * // => true
1505 *
1506 * _.isArrayLike('abc');
1507 * // => true
1508 *
1509 * _.isArrayLike(_.noop);
1510 * // => false
1511 */
1512function isArrayLike(value) {
1513 return value != null && isLength(value.length) && !isFunction(value);
1514}
1515
1516/**
1517 * This method is like `_.isArrayLike` except that it also checks if `value`
1518 * is an object.
1519 *
1520 * @static
1521 * @memberOf _
1522 * @since 4.0.0
1523 * @category Lang
1524 * @param {*} value The value to check.
1525 * @returns {boolean} Returns `true` if `value` is an array-like object,
1526 * else `false`.
1527 * @example
1528 *
1529 * _.isArrayLikeObject([1, 2, 3]);
1530 * // => true
1531 *
1532 * _.isArrayLikeObject(document.body.children);
1533 * // => true
1534 *
1535 * _.isArrayLikeObject('abc');
1536 * // => false
1537 *
1538 * _.isArrayLikeObject(_.noop);
1539 * // => false
1540 */
1541function isArrayLikeObject(value) {
1542 return isObjectLike(value) && isArrayLike(value);
1543}
1544
1545/**
1546 * Checks if `value` is a buffer.
1547 *
1548 * @static
1549 * @memberOf _
1550 * @since 4.3.0
1551 * @category Lang
1552 * @param {*} value The value to check.
1553 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1554 * @example
1555 *
1556 * _.isBuffer(new Buffer(2));
1557 * // => true
1558 *
1559 * _.isBuffer(new Uint8Array(2));
1560 * // => false
1561 */
1562var isBuffer = nativeIsBuffer || stubFalse;
1563
1564/**
1565 * Checks if `value` is classified as a `Function` object.
1566 *
1567 * @static
1568 * @memberOf _
1569 * @since 0.1.0
1570 * @category Lang
1571 * @param {*} value The value to check.
1572 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1573 * @example
1574 *
1575 * _.isFunction(_);
1576 * // => true
1577 *
1578 * _.isFunction(/abc/);
1579 * // => false
1580 */
1581function isFunction(value) {
1582 // The use of `Object#toString` avoids issues with the `typeof` operator
1583 // in Safari 8-9 which returns 'object' for typed array and other constructors.
1584 var tag = isObject(value) ? objectToString.call(value) : '';
1585 return tag == funcTag || tag == genTag;
1586}
1587
1588/**
1589 * Checks if `value` is a valid array-like length.
1590 *
1591 * **Note:** This method is loosely based on
1592 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1593 *
1594 * @static
1595 * @memberOf _
1596 * @since 4.0.0
1597 * @category Lang
1598 * @param {*} value The value to check.
1599 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1600 * @example
1601 *
1602 * _.isLength(3);
1603 * // => true
1604 *
1605 * _.isLength(Number.MIN_VALUE);
1606 * // => false
1607 *
1608 * _.isLength(Infinity);
1609 * // => false
1610 *
1611 * _.isLength('3');
1612 * // => false
1613 */
1614function isLength(value) {
1615 return typeof value == 'number' &&
1616 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1617}
1618
1619/**
1620 * Checks if `value` is the
1621 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1622 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1623 *
1624 * @static
1625 * @memberOf _
1626 * @since 0.1.0
1627 * @category Lang
1628 * @param {*} value The value to check.
1629 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1630 * @example
1631 *
1632 * _.isObject({});
1633 * // => true
1634 *
1635 * _.isObject([1, 2, 3]);
1636 * // => true
1637 *
1638 * _.isObject(_.noop);
1639 * // => true
1640 *
1641 * _.isObject(null);
1642 * // => false
1643 */
1644function isObject(value) {
1645 var type = typeof value;
1646 return !!value && (type == 'object' || type == 'function');
1647}
1648
1649/**
1650 * Checks if `value` is object-like. A value is object-like if it's not `null`
1651 * and has a `typeof` result of "object".
1652 *
1653 * @static
1654 * @memberOf _
1655 * @since 4.0.0
1656 * @category Lang
1657 * @param {*} value The value to check.
1658 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1659 * @example
1660 *
1661 * _.isObjectLike({});
1662 * // => true
1663 *
1664 * _.isObjectLike([1, 2, 3]);
1665 * // => true
1666 *
1667 * _.isObjectLike(_.noop);
1668 * // => false
1669 *
1670 * _.isObjectLike(null);
1671 * // => false
1672 */
1673function isObjectLike(value) {
1674 return !!value && typeof value == 'object';
1675}
1676
1677/**
1678 * Creates an array of the own enumerable property names of `object`.
1679 *
1680 * **Note:** Non-object values are coerced to objects. See the
1681 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1682 * for more details.
1683 *
1684 * @static
1685 * @since 0.1.0
1686 * @memberOf _
1687 * @category Object
1688 * @param {Object} object The object to query.
1689 * @returns {Array} Returns the array of property names.
1690 * @example
1691 *
1692 * function Foo() {
1693 * this.a = 1;
1694 * this.b = 2;
1695 * }
1696 *
1697 * Foo.prototype.c = 3;
1698 *
1699 * _.keys(new Foo);
1700 * // => ['a', 'b'] (iteration order is not guaranteed)
1701 *
1702 * _.keys('hi');
1703 * // => ['0', '1']
1704 */
1705function keys(object) {
1706 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1707}
1708
1709/**
1710 * This method returns a new empty array.
1711 *
1712 * @static
1713 * @memberOf _
1714 * @since 4.13.0
1715 * @category Util
1716 * @returns {Array} Returns the new empty array.
1717 * @example
1718 *
1719 * var arrays = _.times(2, _.stubArray);
1720 *
1721 * console.log(arrays);
1722 * // => [[], []]
1723 *
1724 * console.log(arrays[0] === arrays[1]);
1725 * // => false
1726 */
1727function stubArray() {
1728 return [];
1729}
1730
1731/**
1732 * This method returns `false`.
1733 *
1734 * @static
1735 * @memberOf _
1736 * @since 4.13.0
1737 * @category Util
1738 * @returns {boolean} Returns `false`.
1739 * @example
1740 *
1741 * _.times(2, _.stubFalse);
1742 * // => [false, false]
1743 */
1744function stubFalse() {
1745 return false;
1746}
1747
1748module.exports = cloneDeep;