UNPKG

23.4 kBJavaScriptView Raw
1/**
2 * lodash 4.2.0 (Custom Build) <https://lodash.com/>
3 * Build: `lodash modularize exports="npm" -o ./`
4 * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
5 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
6 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
7 * Available under MIT license <https://lodash.com/license>
8 */
9var Stack = require('lodash._stack'),
10 baseFor = require('lodash._basefor'),
11 isBuffer = require('lodash.isbuffer'),
12 keys = require('lodash.keys'),
13 root = require('lodash._root');
14
15/** `Object#toString` result references. */
16var argsTag = '[object Arguments]',
17 arrayTag = '[object Array]',
18 boolTag = '[object Boolean]',
19 dateTag = '[object Date]',
20 errorTag = '[object Error]',
21 funcTag = '[object Function]',
22 genTag = '[object GeneratorFunction]',
23 mapTag = '[object Map]',
24 numberTag = '[object Number]',
25 objectTag = '[object Object]',
26 regexpTag = '[object RegExp]',
27 setTag = '[object Set]',
28 stringTag = '[object String]',
29 symbolTag = '[object Symbol]',
30 weakMapTag = '[object WeakMap]';
31
32var arrayBufferTag = '[object ArrayBuffer]',
33 float32Tag = '[object Float32Array]',
34 float64Tag = '[object Float64Array]',
35 int8Tag = '[object Int8Array]',
36 int16Tag = '[object Int16Array]',
37 int32Tag = '[object Int32Array]',
38 uint8Tag = '[object Uint8Array]',
39 uint8ClampedTag = '[object Uint8ClampedArray]',
40 uint16Tag = '[object Uint16Array]',
41 uint32Tag = '[object Uint32Array]';
42
43/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
44var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
45
46/** Used to match `RegExp` flags from their coerced string values. */
47var reFlags = /\w*$/;
48
49/** Used to detect host constructors (Safari > 5). */
50var reIsHostCtor = /^\[object .+?Constructor\]$/;
51
52/** Used to identify `toStringTag` values supported by `_.clone`. */
53var cloneableTags = {};
54cloneableTags[argsTag] = cloneableTags[arrayTag] =
55cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
56cloneableTags[dateTag] = cloneableTags[float32Tag] =
57cloneableTags[float64Tag] = cloneableTags[int8Tag] =
58cloneableTags[int16Tag] = cloneableTags[int32Tag] =
59cloneableTags[mapTag] = cloneableTags[numberTag] =
60cloneableTags[objectTag] = cloneableTags[regexpTag] =
61cloneableTags[setTag] = cloneableTags[stringTag] =
62cloneableTags[symbolTag] = cloneableTags[uint8Tag] =
63cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] =
64cloneableTags[uint32Tag] = true;
65cloneableTags[errorTag] = cloneableTags[funcTag] =
66cloneableTags[weakMapTag] = false;
67
68/**
69 * Adds the key-value `pair` to `map`.
70 *
71 * @private
72 * @param {Object} map The map to modify.
73 * @param {Array} pair The key-value pair to add.
74 * @returns {Object} Returns `map`.
75 */
76function addMapEntry(map, pair) {
77 map.set(pair[0], pair[1]);
78 return map;
79}
80
81/**
82 * Adds `value` to `set`.
83 *
84 * @private
85 * @param {Object} set The set to modify.
86 * @param {*} value The value to add.
87 * @returns {Object} Returns `set`.
88 */
89function addSetEntry(set, value) {
90 set.add(value);
91 return set;
92}
93
94/**
95 * A specialized version of `_.forEach` for arrays without support for
96 * iteratee shorthands.
97 *
98 * @private
99 * @param {Array} array The array to iterate over.
100 * @param {Function} iteratee The function invoked per iteration.
101 * @returns {Array} Returns `array`.
102 */
103function arrayEach(array, iteratee) {
104 var index = -1,
105 length = array.length;
106
107 while (++index < length) {
108 if (iteratee(array[index], index, array) === false) {
109 break;
110 }
111 }
112 return array;
113}
114
115/**
116 * A specialized version of `_.reduce` for arrays without support for
117 * iteratee shorthands.
118 *
119 * @private
120 * @param {Array} array The array to iterate over.
121 * @param {Function} iteratee The function invoked per iteration.
122 * @param {*} [accumulator] The initial value.
123 * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
124 * @returns {*} Returns the accumulated value.
125 */
126function arrayReduce(array, iteratee, accumulator, initAccum) {
127 var index = -1,
128 length = array.length;
129
130 if (initAccum && length) {
131 accumulator = array[++index];
132 }
133 while (++index < length) {
134 accumulator = iteratee(accumulator, array[index], index, array);
135 }
136 return accumulator;
137}
138
139/**
140 * Checks if `value` is a host object in IE < 9.
141 *
142 * @private
143 * @param {*} value The value to check.
144 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
145 */
146function isHostObject(value) {
147 // Many host objects are `Object` objects that can coerce to strings
148 // despite having improperly defined `toString` methods.
149 var result = false;
150 if (value != null && typeof value.toString != 'function') {
151 try {
152 result = !!(value + '');
153 } catch (e) {}
154 }
155 return result;
156}
157
158/**
159 * Converts `map` to an array.
160 *
161 * @private
162 * @param {Object} map The map to convert.
163 * @returns {Array} Returns the converted array.
164 */
165function mapToArray(map) {
166 var index = -1,
167 result = Array(map.size);
168
169 map.forEach(function(value, key) {
170 result[++index] = [key, value];
171 });
172 return result;
173}
174
175/**
176 * Converts `set` to an array.
177 *
178 * @private
179 * @param {Object} set The set to convert.
180 * @returns {Array} Returns the converted array.
181 */
182function setToArray(set) {
183 var index = -1,
184 result = Array(set.size);
185
186 set.forEach(function(value) {
187 result[++index] = value;
188 });
189 return result;
190}
191
192/** Used for built-in method references. */
193var objectProto = Object.prototype;
194
195/** Used to resolve the decompiled source of functions. */
196var funcToString = Function.prototype.toString;
197
198/** Used to check objects for own properties. */
199var hasOwnProperty = objectProto.hasOwnProperty;
200
201/**
202 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
203 * of values.
204 */
205var objectToString = objectProto.toString;
206
207/** Used to detect if a method is native. */
208var reIsNative = RegExp('^' +
209 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
210 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
211);
212
213/** Built-in value references. */
214var Symbol = root.Symbol,
215 Uint8Array = root.Uint8Array,
216 getOwnPropertySymbols = Object.getOwnPropertySymbols,
217 objectCreate = Object.create;
218
219/* Built-in method references that are verified to be native. */
220var Map = getNative(root, 'Map'),
221 Set = getNative(root, 'Set'),
222 WeakMap = getNative(root, 'WeakMap');
223
224/** Used to detect maps, sets, and weakmaps. */
225var mapCtorString = Map ? funcToString.call(Map) : '',
226 setCtorString = Set ? funcToString.call(Set) : '',
227 weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
228
229/** Used to convert symbols to primitives and strings. */
230var symbolProto = Symbol ? Symbol.prototype : undefined,
231 symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
232
233/**
234 * Assigns `value` to `key` of `object` if the existing value is not equivalent
235 * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
236 * for equality comparisons.
237 *
238 * @private
239 * @param {Object} object The object to modify.
240 * @param {string} key The key of the property to assign.
241 * @param {*} value The value to assign.
242 */
243function assignValue(object, key, value) {
244 var objValue = object[key];
245 if ((!eq(objValue, value) ||
246 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
247 (value === undefined && !(key in object))) {
248 object[key] = value;
249 }
250}
251
252/**
253 * The base implementation of `_.assign` without support for multiple sources
254 * or `customizer` functions.
255 *
256 * @private
257 * @param {Object} object The destination object.
258 * @param {Object} source The source object.
259 * @returns {Object} Returns `object`.
260 */
261function baseAssign(object, source) {
262 return object && copyObject(source, keys(source), object);
263}
264
265/**
266 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
267 * traversed objects.
268 *
269 * @private
270 * @param {*} value The value to clone.
271 * @param {boolean} [isDeep] Specify a deep clone.
272 * @param {Function} [customizer] The function to customize cloning.
273 * @param {string} [key] The key of `value`.
274 * @param {Object} [object] The parent object of `value`.
275 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
276 * @returns {*} Returns the cloned value.
277 */
278function baseClone(value, isDeep, customizer, key, object, stack) {
279 var result;
280 if (customizer) {
281 result = object ? customizer(value, key, object, stack) : customizer(value);
282 }
283 if (result !== undefined) {
284 return result;
285 }
286 if (!isObject(value)) {
287 return value;
288 }
289 var isArr = isArray(value);
290 if (isArr) {
291 result = initCloneArray(value);
292 if (!isDeep) {
293 return copyArray(value, result);
294 }
295 } else {
296 var tag = getTag(value),
297 isFunc = tag == funcTag || tag == genTag;
298
299 if (isBuffer(value)) {
300 return cloneBuffer(value, isDeep);
301 }
302 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
303 if (isHostObject(value)) {
304 return object ? value : {};
305 }
306 result = initCloneObject(isFunc ? {} : value);
307 if (!isDeep) {
308 return copySymbols(value, baseAssign(result, value));
309 }
310 } else {
311 return cloneableTags[tag]
312 ? initCloneByTag(value, tag, isDeep)
313 : (object ? value : {});
314 }
315 }
316 // Check for circular references and return its corresponding clone.
317 stack || (stack = new Stack);
318 var stacked = stack.get(value);
319 if (stacked) {
320 return stacked;
321 }
322 stack.set(value, result);
323
324 // Recursively populate clone (susceptible to call stack limits).
325 (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
326 assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
327 });
328 return isArr ? result : copySymbols(value, result);
329}
330
331/**
332 * The base implementation of `_.create` without support for assigning
333 * properties to the created object.
334 *
335 * @private
336 * @param {Object} prototype The object to inherit from.
337 * @returns {Object} Returns the new object.
338 */
339function baseCreate(proto) {
340 return isObject(proto) ? objectCreate(proto) : {};
341}
342
343/**
344 * The base implementation of `_.forOwn` without support for iteratee shorthands.
345 *
346 * @private
347 * @param {Object} object The object to iterate over.
348 * @param {Function} iteratee The function invoked per iteration.
349 * @returns {Object} Returns `object`.
350 */
351function baseForOwn(object, iteratee) {
352 return object && baseFor(object, iteratee, keys);
353}
354
355/**
356 * Creates a clone of `buffer`.
357 *
358 * @private
359 * @param {Buffer} buffer The buffer to clone.
360 * @param {boolean} [isDeep] Specify a deep clone.
361 * @returns {Buffer} Returns the cloned buffer.
362 */
363function cloneBuffer(buffer, isDeep) {
364 if (isDeep) {
365 return buffer.slice();
366 }
367 var Ctor = buffer.constructor,
368 result = new Ctor(buffer.length);
369
370 buffer.copy(result);
371 return result;
372}
373
374/**
375 * Creates a clone of `arrayBuffer`.
376 *
377 * @private
378 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
379 * @returns {ArrayBuffer} Returns the cloned array buffer.
380 */
381function cloneArrayBuffer(arrayBuffer) {
382 var Ctor = arrayBuffer.constructor,
383 result = new Ctor(arrayBuffer.byteLength),
384 view = new Uint8Array(result);
385
386 view.set(new Uint8Array(arrayBuffer));
387 return result;
388}
389
390/**
391 * Creates a clone of `map`.
392 *
393 * @private
394 * @param {Object} map The map to clone.
395 * @returns {Object} Returns the cloned map.
396 */
397function cloneMap(map) {
398 var Ctor = map.constructor;
399 return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
400}
401
402/**
403 * Creates a clone of `regexp`.
404 *
405 * @private
406 * @param {Object} regexp The regexp to clone.
407 * @returns {Object} Returns the cloned regexp.
408 */
409function cloneRegExp(regexp) {
410 var Ctor = regexp.constructor,
411 result = new Ctor(regexp.source, reFlags.exec(regexp));
412
413 result.lastIndex = regexp.lastIndex;
414 return result;
415}
416
417/**
418 * Creates a clone of `set`.
419 *
420 * @private
421 * @param {Object} set The set to clone.
422 * @returns {Object} Returns the cloned set.
423 */
424function cloneSet(set) {
425 var Ctor = set.constructor;
426 return arrayReduce(setToArray(set), addSetEntry, new Ctor);
427}
428
429/**
430 * Creates a clone of the `symbol` object.
431 *
432 * @private
433 * @param {Object} symbol The symbol object to clone.
434 * @returns {Object} Returns the cloned symbol object.
435 */
436function cloneSymbol(symbol) {
437 return Symbol ? Object(symbolValueOf.call(symbol)) : {};
438}
439
440/**
441 * Creates a clone of `typedArray`.
442 *
443 * @private
444 * @param {Object} typedArray The typed array to clone.
445 * @param {boolean} [isDeep] Specify a deep clone.
446 * @returns {Object} Returns the cloned typed array.
447 */
448function cloneTypedArray(typedArray, isDeep) {
449 var arrayBuffer = typedArray.buffer,
450 buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
451 Ctor = typedArray.constructor;
452
453 return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
454}
455
456/**
457 * Copies the values of `source` to `array`.
458 *
459 * @private
460 * @param {Array} source The array to copy values from.
461 * @param {Array} [array=[]] The array to copy values to.
462 * @returns {Array} Returns `array`.
463 */
464function copyArray(source, array) {
465 var index = -1,
466 length = source.length;
467
468 array || (array = Array(length));
469 while (++index < length) {
470 array[index] = source[index];
471 }
472 return array;
473}
474
475/**
476 * Copies properties of `source` to `object`.
477 *
478 * @private
479 * @param {Object} source The object to copy properties from.
480 * @param {Array} props The property names to copy.
481 * @param {Object} [object={}] The object to copy properties to.
482 * @returns {Object} Returns `object`.
483 */
484function copyObject(source, props, object) {
485 return copyObjectWith(source, props, object);
486}
487
488/**
489 * This function is like `copyObject` except that it accepts a function to
490 * customize copied values.
491 *
492 * @private
493 * @param {Object} source The object to copy properties from.
494 * @param {Array} props The property names to copy.
495 * @param {Object} [object={}] The object to copy properties to.
496 * @param {Function} [customizer] The function to customize copied values.
497 * @returns {Object} Returns `object`.
498 */
499function copyObjectWith(source, props, object, customizer) {
500 object || (object = {});
501
502 var index = -1,
503 length = props.length;
504
505 while (++index < length) {
506 var key = props[index];
507
508 var newValue = customizer
509 ? customizer(object[key], source[key], key, object, source)
510 : source[key];
511
512 assignValue(object, key, newValue);
513 }
514 return object;
515}
516
517/**
518 * Copies own symbol properties of `source` to `object`.
519 *
520 * @private
521 * @param {Object} source The object to copy symbols from.
522 * @param {Object} [object={}] The object to copy symbols to.
523 * @returns {Object} Returns `object`.
524 */
525function copySymbols(source, object) {
526 return copyObject(source, getSymbols(source), object);
527}
528
529/**
530 * Gets the native function at `key` of `object`.
531 *
532 * @private
533 * @param {Object} object The object to query.
534 * @param {string} key The key of the method to get.
535 * @returns {*} Returns the function if it's native, else `undefined`.
536 */
537function getNative(object, key) {
538 var value = object == null ? undefined : object[key];
539 return isNative(value) ? value : undefined;
540}
541
542/**
543 * Creates an array of the own symbol properties of `object`.
544 *
545 * @private
546 * @param {Object} object The object to query.
547 * @returns {Array} Returns the array of symbols.
548 */
549var getSymbols = getOwnPropertySymbols || function() {
550 return [];
551};
552
553/**
554 * Gets the `toStringTag` of `value`.
555 *
556 * @private
557 * @param {*} value The value to query.
558 * @returns {string} Returns the `toStringTag`.
559 */
560function getTag(value) {
561 return objectToString.call(value);
562}
563
564// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
565if ((Map && getTag(new Map) != mapTag) ||
566 (Set && getTag(new Set) != setTag) ||
567 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
568 getTag = function(value) {
569 var result = objectToString.call(value),
570 Ctor = result == objectTag ? value.constructor : null,
571 ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
572
573 if (ctorString) {
574 switch (ctorString) {
575 case mapCtorString: return mapTag;
576 case setCtorString: return setTag;
577 case weakMapCtorString: return weakMapTag;
578 }
579 }
580 return result;
581 };
582}
583
584/**
585 * Initializes an array clone.
586 *
587 * @private
588 * @param {Array} array The array to clone.
589 * @returns {Array} Returns the initialized clone.
590 */
591function initCloneArray(array) {
592 var length = array.length,
593 result = array.constructor(length);
594
595 // Add properties assigned by `RegExp#exec`.
596 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
597 result.index = array.index;
598 result.input = array.input;
599 }
600 return result;
601}
602
603/**
604 * Initializes an object clone.
605 *
606 * @private
607 * @param {Object} object The object to clone.
608 * @returns {Object} Returns the initialized clone.
609 */
610function initCloneObject(object) {
611 if (isPrototype(object)) {
612 return {};
613 }
614 var Ctor = object.constructor;
615 return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
616}
617
618/**
619 * Initializes an object clone based on its `toStringTag`.
620 *
621 * **Note:** This function only supports cloning values with tags of
622 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
623 *
624 * @private
625 * @param {Object} object The object to clone.
626 * @param {string} tag The `toStringTag` of the object to clone.
627 * @param {boolean} [isDeep] Specify a deep clone.
628 * @returns {Object} Returns the initialized clone.
629 */
630function initCloneByTag(object, tag, isDeep) {
631 var Ctor = object.constructor;
632 switch (tag) {
633 case arrayBufferTag:
634 return cloneArrayBuffer(object);
635
636 case boolTag:
637 case dateTag:
638 return new Ctor(+object);
639
640 case float32Tag: case float64Tag:
641 case int8Tag: case int16Tag: case int32Tag:
642 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
643 return cloneTypedArray(object, isDeep);
644
645 case mapTag:
646 return cloneMap(object);
647
648 case numberTag:
649 case stringTag:
650 return new Ctor(object);
651
652 case regexpTag:
653 return cloneRegExp(object);
654
655 case setTag:
656 return cloneSet(object);
657
658 case symbolTag:
659 return cloneSymbol(object);
660 }
661}
662
663/**
664 * Checks if `value` is likely a prototype object.
665 *
666 * @private
667 * @param {*} value The value to check.
668 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
669 */
670function isPrototype(value) {
671 var Ctor = value && value.constructor,
672 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
673
674 return value === proto;
675}
676
677/**
678 * This method is like `_.cloneWith` except that it recursively clones `value`.
679 *
680 * @static
681 * @memberOf _
682 * @category Lang
683 * @param {*} value The value to recursively clone.
684 * @param {Function} [customizer] The function to customize cloning.
685 * @returns {*} Returns the deep cloned value.
686 * @example
687 *
688 * function customizer(value) {
689 * if (_.isElement(value)) {
690 * return value.cloneNode(true);
691 * }
692 * }
693 *
694 * var el = _.cloneDeepWith(document.body, customizer);
695 *
696 * console.log(el === document.body);
697 * // => false
698 * console.log(el.nodeName);
699 * // => 'BODY'
700 * console.log(el.childNodes.length);
701 * // => 20
702 */
703function cloneDeepWith(value, customizer) {
704 return baseClone(value, true, customizer);
705}
706
707/**
708 * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
709 * comparison between two values to determine if they are equivalent.
710 *
711 * @static
712 * @memberOf _
713 * @category Lang
714 * @param {*} value The value to compare.
715 * @param {*} other The other value to compare.
716 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
717 * @example
718 *
719 * var object = { 'user': 'fred' };
720 * var other = { 'user': 'fred' };
721 *
722 * _.eq(object, object);
723 * // => true
724 *
725 * _.eq(object, other);
726 * // => false
727 *
728 * _.eq('a', 'a');
729 * // => true
730 *
731 * _.eq('a', Object('a'));
732 * // => false
733 *
734 * _.eq(NaN, NaN);
735 * // => true
736 */
737function eq(value, other) {
738 return value === other || (value !== value && other !== other);
739}
740
741/**
742 * Checks if `value` is classified as an `Array` object.
743 *
744 * @static
745 * @memberOf _
746 * @type {Function}
747 * @category Lang
748 * @param {*} value The value to check.
749 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
750 * @example
751 *
752 * _.isArray([1, 2, 3]);
753 * // => true
754 *
755 * _.isArray(document.body.children);
756 * // => false
757 *
758 * _.isArray('abc');
759 * // => false
760 *
761 * _.isArray(_.noop);
762 * // => false
763 */
764var isArray = Array.isArray;
765
766/**
767 * Checks if `value` is classified as a `Function` object.
768 *
769 * @static
770 * @memberOf _
771 * @category Lang
772 * @param {*} value The value to check.
773 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
774 * @example
775 *
776 * _.isFunction(_);
777 * // => true
778 *
779 * _.isFunction(/abc/);
780 * // => false
781 */
782function isFunction(value) {
783 // The use of `Object#toString` avoids issues with the `typeof` operator
784 // in Safari 8 which returns 'object' for typed array constructors, and
785 // PhantomJS 1.9 which returns 'function' for `NodeList` instances.
786 var tag = isObject(value) ? objectToString.call(value) : '';
787 return tag == funcTag || tag == genTag;
788}
789
790/**
791 * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
792 * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
793 *
794 * @static
795 * @memberOf _
796 * @category Lang
797 * @param {*} value The value to check.
798 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
799 * @example
800 *
801 * _.isObject({});
802 * // => true
803 *
804 * _.isObject([1, 2, 3]);
805 * // => true
806 *
807 * _.isObject(_.noop);
808 * // => true
809 *
810 * _.isObject(null);
811 * // => false
812 */
813function isObject(value) {
814 var type = typeof value;
815 return !!value && (type == 'object' || type == 'function');
816}
817
818/**
819 * Checks if `value` is object-like. A value is object-like if it's not `null`
820 * and has a `typeof` result of "object".
821 *
822 * @static
823 * @memberOf _
824 * @category Lang
825 * @param {*} value The value to check.
826 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
827 * @example
828 *
829 * _.isObjectLike({});
830 * // => true
831 *
832 * _.isObjectLike([1, 2, 3]);
833 * // => true
834 *
835 * _.isObjectLike(_.noop);
836 * // => false
837 *
838 * _.isObjectLike(null);
839 * // => false
840 */
841function isObjectLike(value) {
842 return !!value && typeof value == 'object';
843}
844
845/**
846 * Checks if `value` is a native function.
847 *
848 * @static
849 * @memberOf _
850 * @category Lang
851 * @param {*} value The value to check.
852 * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
853 * @example
854 *
855 * _.isNative(Array.prototype.push);
856 * // => true
857 *
858 * _.isNative(_);
859 * // => false
860 */
861function isNative(value) {
862 if (value == null) {
863 return false;
864 }
865 if (isFunction(value)) {
866 return reIsNative.test(funcToString.call(value));
867 }
868 return isObjectLike(value) &&
869 (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
870}
871
872module.exports = cloneDeepWith;