UNPKG

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