• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 INFINITY = 1 / 0,
18    MAX_SAFE_INTEGER = 9007199254740991;
19
20/** `Object#toString` result references. */
21var argsTag = '[object Arguments]',
22    funcTag = '[object Function]',
23    genTag = '[object GeneratorFunction]';
24
25/**
26 * Used to match `RegExp`
27 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
28 */
29var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
30
31/** Used to detect host constructors (Safari). */
32var reIsHostCtor = /^\[object .+?Constructor\]$/;
33
34/** Detect free variable `global` from Node.js. */
35var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
36
37/** Detect free variable `self`. */
38var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
39
40/** Used as a reference to the global object. */
41var root = freeGlobal || freeSelf || Function('return this')();
42
43/**
44 * A faster alternative to `Function#apply`, this function invokes `func`
45 * with the `this` binding of `thisArg` and the arguments of `args`.
46 *
47 * @private
48 * @param {Function} func The function to invoke.
49 * @param {*} thisArg The `this` binding of `func`.
50 * @param {Array} args The arguments to invoke `func` with.
51 * @returns {*} Returns the result of `func`.
52 */
53function apply(func, thisArg, args) {
54  switch (args.length) {
55    case 0: return func.call(thisArg);
56    case 1: return func.call(thisArg, args[0]);
57    case 2: return func.call(thisArg, args[0], args[1]);
58    case 3: return func.call(thisArg, args[0], args[1], args[2]);
59  }
60  return func.apply(thisArg, args);
61}
62
63/**
64 * A specialized version of `_.includes` for arrays without support for
65 * specifying an index to search from.
66 *
67 * @private
68 * @param {Array} [array] The array to inspect.
69 * @param {*} target The value to search for.
70 * @returns {boolean} Returns `true` if `target` is found, else `false`.
71 */
72function arrayIncludes(array, value) {
73  var length = array ? array.length : 0;
74  return !!length && baseIndexOf(array, value, 0) > -1;
75}
76
77/**
78 * This function is like `arrayIncludes` except that it accepts a comparator.
79 *
80 * @private
81 * @param {Array} [array] The array to inspect.
82 * @param {*} target The value to search for.
83 * @param {Function} comparator The comparator invoked per element.
84 * @returns {boolean} Returns `true` if `target` is found, else `false`.
85 */
86function arrayIncludesWith(array, value, comparator) {
87  var index = -1,
88      length = array ? array.length : 0;
89
90  while (++index < length) {
91    if (comparator(value, array[index])) {
92      return true;
93    }
94  }
95  return false;
96}
97
98/**
99 * Appends the elements of `values` to `array`.
100 *
101 * @private
102 * @param {Array} array The array to modify.
103 * @param {Array} values The values to append.
104 * @returns {Array} Returns `array`.
105 */
106function arrayPush(array, values) {
107  var index = -1,
108      length = values.length,
109      offset = array.length;
110
111  while (++index < length) {
112    array[offset + index] = values[index];
113  }
114  return array;
115}
116
117/**
118 * The base implementation of `_.findIndex` and `_.findLastIndex` without
119 * support for iteratee shorthands.
120 *
121 * @private
122 * @param {Array} array The array to inspect.
123 * @param {Function} predicate The function invoked per iteration.
124 * @param {number} fromIndex The index to search from.
125 * @param {boolean} [fromRight] Specify iterating from right to left.
126 * @returns {number} Returns the index of the matched value, else `-1`.
127 */
128function baseFindIndex(array, predicate, fromIndex, fromRight) {
129  var length = array.length,
130      index = fromIndex + (fromRight ? 1 : -1);
131
132  while ((fromRight ? index-- : ++index < length)) {
133    if (predicate(array[index], index, array)) {
134      return index;
135    }
136  }
137  return -1;
138}
139
140/**
141 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
142 *
143 * @private
144 * @param {Array} array The array to inspect.
145 * @param {*} value The value to search for.
146 * @param {number} fromIndex The index to search from.
147 * @returns {number} Returns the index of the matched value, else `-1`.
148 */
149function baseIndexOf(array, value, fromIndex) {
150  if (value !== value) {
151    return baseFindIndex(array, baseIsNaN, fromIndex);
152  }
153  var index = fromIndex - 1,
154      length = array.length;
155
156  while (++index < length) {
157    if (array[index] === value) {
158      return index;
159    }
160  }
161  return -1;
162}
163
164/**
165 * The base implementation of `_.isNaN` without support for number objects.
166 *
167 * @private
168 * @param {*} value The value to check.
169 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
170 */
171function baseIsNaN(value) {
172  return value !== value;
173}
174
175/**
176 * Checks if a cache value for `key` exists.
177 *
178 * @private
179 * @param {Object} cache The cache to query.
180 * @param {string} key The key of the entry to check.
181 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
182 */
183function cacheHas(cache, key) {
184  return cache.has(key);
185}
186
187/**
188 * Gets the value at `key` of `object`.
189 *
190 * @private
191 * @param {Object} [object] The object to query.
192 * @param {string} key The key of the property to get.
193 * @returns {*} Returns the property value.
194 */
195function getValue(object, key) {
196  return object == null ? undefined : object[key];
197}
198
199/**
200 * Checks if `value` is a host object in IE < 9.
201 *
202 * @private
203 * @param {*} value The value to check.
204 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
205 */
206function isHostObject(value) {
207  // Many host objects are `Object` objects that can coerce to strings
208  // despite having improperly defined `toString` methods.
209  var result = false;
210  if (value != null && typeof value.toString != 'function') {
211    try {
212      result = !!(value + '');
213    } catch (e) {}
214  }
215  return result;
216}
217
218/**
219 * Converts `set` to an array of its values.
220 *
221 * @private
222 * @param {Object} set The set to convert.
223 * @returns {Array} Returns the values.
224 */
225function setToArray(set) {
226  var index = -1,
227      result = Array(set.size);
228
229  set.forEach(function(value) {
230    result[++index] = value;
231  });
232  return result;
233}
234
235/** Used for built-in method references. */
236var arrayProto = Array.prototype,
237    funcProto = Function.prototype,
238    objectProto = Object.prototype;
239
240/** Used to detect overreaching core-js shims. */
241var coreJsData = root['__core-js_shared__'];
242
243/** Used to detect methods masquerading as native. */
244var maskSrcKey = (function() {
245  var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
246  return uid ? ('Symbol(src)_1.' + uid) : '';
247}());
248
249/** Used to resolve the decompiled source of functions. */
250var funcToString = funcProto.toString;
251
252/** Used to check objects for own properties. */
253var hasOwnProperty = objectProto.hasOwnProperty;
254
255/**
256 * Used to resolve the
257 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
258 * of values.
259 */
260var objectToString = objectProto.toString;
261
262/** Used to detect if a method is native. */
263var reIsNative = RegExp('^' +
264  funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
265  .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
266);
267
268/** Built-in value references. */
269var Symbol = root.Symbol,
270    propertyIsEnumerable = objectProto.propertyIsEnumerable,
271    splice = arrayProto.splice,
272    spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
273
274/* Built-in method references for those with the same name as other `lodash` methods. */
275var nativeMax = Math.max;
276
277/* Built-in method references that are verified to be native. */
278var Map = getNative(root, 'Map'),
279    Set = getNative(root, 'Set'),
280    nativeCreate = getNative(Object, 'create');
281
282/**
283 * Creates a hash object.
284 *
285 * @private
286 * @constructor
287 * @param {Array} [entries] The key-value pairs to cache.
288 */
289function Hash(entries) {
290  var index = -1,
291      length = entries ? entries.length : 0;
292
293  this.clear();
294  while (++index < length) {
295    var entry = entries[index];
296    this.set(entry[0], entry[1]);
297  }
298}
299
300/**
301 * Removes all key-value entries from the hash.
302 *
303 * @private
304 * @name clear
305 * @memberOf Hash
306 */
307function hashClear() {
308  this.__data__ = nativeCreate ? nativeCreate(null) : {};
309}
310
311/**
312 * Removes `key` and its value from the hash.
313 *
314 * @private
315 * @name delete
316 * @memberOf Hash
317 * @param {Object} hash The hash to modify.
318 * @param {string} key The key of the value to remove.
319 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
320 */
321function hashDelete(key) {
322  return this.has(key) && delete this.__data__[key];
323}
324
325/**
326 * Gets the hash value for `key`.
327 *
328 * @private
329 * @name get
330 * @memberOf Hash
331 * @param {string} key The key of the value to get.
332 * @returns {*} Returns the entry value.
333 */
334function hashGet(key) {
335  var data = this.__data__;
336  if (nativeCreate) {
337    var result = data[key];
338    return result === HASH_UNDEFINED ? undefined : result;
339  }
340  return hasOwnProperty.call(data, key) ? data[key] : undefined;
341}
342
343/**
344 * Checks if a hash value for `key` exists.
345 *
346 * @private
347 * @name has
348 * @memberOf Hash
349 * @param {string} key The key of the entry to check.
350 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
351 */
352function hashHas(key) {
353  var data = this.__data__;
354  return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
355}
356
357/**
358 * Sets the hash `key` to `value`.
359 *
360 * @private
361 * @name set
362 * @memberOf Hash
363 * @param {string} key The key of the value to set.
364 * @param {*} value The value to set.
365 * @returns {Object} Returns the hash instance.
366 */
367function hashSet(key, value) {
368  var data = this.__data__;
369  data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
370  return this;
371}
372
373// Add methods to `Hash`.
374Hash.prototype.clear = hashClear;
375Hash.prototype['delete'] = hashDelete;
376Hash.prototype.get = hashGet;
377Hash.prototype.has = hashHas;
378Hash.prototype.set = hashSet;
379
380/**
381 * Creates an list cache object.
382 *
383 * @private
384 * @constructor
385 * @param {Array} [entries] The key-value pairs to cache.
386 */
387function ListCache(entries) {
388  var index = -1,
389      length = entries ? entries.length : 0;
390
391  this.clear();
392  while (++index < length) {
393    var entry = entries[index];
394    this.set(entry[0], entry[1]);
395  }
396}
397
398/**
399 * Removes all key-value entries from the list cache.
400 *
401 * @private
402 * @name clear
403 * @memberOf ListCache
404 */
405function listCacheClear() {
406  this.__data__ = [];
407}
408
409/**
410 * Removes `key` and its value from the list cache.
411 *
412 * @private
413 * @name delete
414 * @memberOf ListCache
415 * @param {string} key The key of the value to remove.
416 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
417 */
418function listCacheDelete(key) {
419  var data = this.__data__,
420      index = assocIndexOf(data, key);
421
422  if (index < 0) {
423    return false;
424  }
425  var lastIndex = data.length - 1;
426  if (index == lastIndex) {
427    data.pop();
428  } else {
429    splice.call(data, index, 1);
430  }
431  return true;
432}
433
434/**
435 * Gets the list cache value for `key`.
436 *
437 * @private
438 * @name get
439 * @memberOf ListCache
440 * @param {string} key The key of the value to get.
441 * @returns {*} Returns the entry value.
442 */
443function listCacheGet(key) {
444  var data = this.__data__,
445      index = assocIndexOf(data, key);
446
447  return index < 0 ? undefined : data[index][1];
448}
449
450/**
451 * Checks if a list cache value for `key` exists.
452 *
453 * @private
454 * @name has
455 * @memberOf ListCache
456 * @param {string} key The key of the entry to check.
457 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
458 */
459function listCacheHas(key) {
460  return assocIndexOf(this.__data__, key) > -1;
461}
462
463/**
464 * Sets the list cache `key` to `value`.
465 *
466 * @private
467 * @name set
468 * @memberOf ListCache
469 * @param {string} key The key of the value to set.
470 * @param {*} value The value to set.
471 * @returns {Object} Returns the list cache instance.
472 */
473function listCacheSet(key, value) {
474  var data = this.__data__,
475      index = assocIndexOf(data, key);
476
477  if (index < 0) {
478    data.push([key, value]);
479  } else {
480    data[index][1] = value;
481  }
482  return this;
483}
484
485// Add methods to `ListCache`.
486ListCache.prototype.clear = listCacheClear;
487ListCache.prototype['delete'] = listCacheDelete;
488ListCache.prototype.get = listCacheGet;
489ListCache.prototype.has = listCacheHas;
490ListCache.prototype.set = listCacheSet;
491
492/**
493 * Creates a map cache object to store key-value pairs.
494 *
495 * @private
496 * @constructor
497 * @param {Array} [entries] The key-value pairs to cache.
498 */
499function MapCache(entries) {
500  var index = -1,
501      length = entries ? entries.length : 0;
502
503  this.clear();
504  while (++index < length) {
505    var entry = entries[index];
506    this.set(entry[0], entry[1]);
507  }
508}
509
510/**
511 * Removes all key-value entries from the map.
512 *
513 * @private
514 * @name clear
515 * @memberOf MapCache
516 */
517function mapCacheClear() {
518  this.__data__ = {
519    'hash': new Hash,
520    'map': new (Map || ListCache),
521    'string': new Hash
522  };
523}
524
525/**
526 * Removes `key` and its value from the map.
527 *
528 * @private
529 * @name delete
530 * @memberOf MapCache
531 * @param {string} key The key of the value to remove.
532 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
533 */
534function mapCacheDelete(key) {
535  return getMapData(this, key)['delete'](key);
536}
537
538/**
539 * Gets the map value for `key`.
540 *
541 * @private
542 * @name get
543 * @memberOf MapCache
544 * @param {string} key The key of the value to get.
545 * @returns {*} Returns the entry value.
546 */
547function mapCacheGet(key) {
548  return getMapData(this, key).get(key);
549}
550
551/**
552 * Checks if a map value for `key` exists.
553 *
554 * @private
555 * @name has
556 * @memberOf MapCache
557 * @param {string} key The key of the entry to check.
558 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
559 */
560function mapCacheHas(key) {
561  return getMapData(this, key).has(key);
562}
563
564/**
565 * Sets the map `key` to `value`.
566 *
567 * @private
568 * @name set
569 * @memberOf MapCache
570 * @param {string} key The key of the value to set.
571 * @param {*} value The value to set.
572 * @returns {Object} Returns the map cache instance.
573 */
574function mapCacheSet(key, value) {
575  getMapData(this, key).set(key, value);
576  return this;
577}
578
579// Add methods to `MapCache`.
580MapCache.prototype.clear = mapCacheClear;
581MapCache.prototype['delete'] = mapCacheDelete;
582MapCache.prototype.get = mapCacheGet;
583MapCache.prototype.has = mapCacheHas;
584MapCache.prototype.set = mapCacheSet;
585
586/**
587 *
588 * Creates an array cache object to store unique values.
589 *
590 * @private
591 * @constructor
592 * @param {Array} [values] The values to cache.
593 */
594function SetCache(values) {
595  var index = -1,
596      length = values ? values.length : 0;
597
598  this.__data__ = new MapCache;
599  while (++index < length) {
600    this.add(values[index]);
601  }
602}
603
604/**
605 * Adds `value` to the array cache.
606 *
607 * @private
608 * @name add
609 * @memberOf SetCache
610 * @alias push
611 * @param {*} value The value to cache.
612 * @returns {Object} Returns the cache instance.
613 */
614function setCacheAdd(value) {
615  this.__data__.set(value, HASH_UNDEFINED);
616  return this;
617}
618
619/**
620 * Checks if `value` is in the array cache.
621 *
622 * @private
623 * @name has
624 * @memberOf SetCache
625 * @param {*} value The value to search for.
626 * @returns {number} Returns `true` if `value` is found, else `false`.
627 */
628function setCacheHas(value) {
629  return this.__data__.has(value);
630}
631
632// Add methods to `SetCache`.
633SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
634SetCache.prototype.has = setCacheHas;
635
636/**
637 * Gets the index at which the `key` is found in `array` of key-value pairs.
638 *
639 * @private
640 * @param {Array} array The array to inspect.
641 * @param {*} key The key to search for.
642 * @returns {number} Returns the index of the matched value, else `-1`.
643 */
644function assocIndexOf(array, key) {
645  var length = array.length;
646  while (length--) {
647    if (eq(array[length][0], key)) {
648      return length;
649    }
650  }
651  return -1;
652}
653
654/**
655 * The base implementation of `_.flatten` with support for restricting flattening.
656 *
657 * @private
658 * @param {Array} array The array to flatten.
659 * @param {number} depth The maximum recursion depth.
660 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
661 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
662 * @param {Array} [result=[]] The initial result value.
663 * @returns {Array} Returns the new flattened array.
664 */
665function baseFlatten(array, depth, predicate, isStrict, result) {
666  var index = -1,
667      length = array.length;
668
669  predicate || (predicate = isFlattenable);
670  result || (result = []);
671
672  while (++index < length) {
673    var value = array[index];
674    if (depth > 0 && predicate(value)) {
675      if (depth > 1) {
676        // Recursively flatten arrays (susceptible to call stack limits).
677        baseFlatten(value, depth - 1, predicate, isStrict, result);
678      } else {
679        arrayPush(result, value);
680      }
681    } else if (!isStrict) {
682      result[result.length] = value;
683    }
684  }
685  return result;
686}
687
688/**
689 * The base implementation of `_.isNative` without bad shim checks.
690 *
691 * @private
692 * @param {*} value The value to check.
693 * @returns {boolean} Returns `true` if `value` is a native function,
694 *  else `false`.
695 */
696function baseIsNative(value) {
697  if (!isObject(value) || isMasked(value)) {
698    return false;
699  }
700  var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
701  return pattern.test(toSource(value));
702}
703
704/**
705 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
706 *
707 * @private
708 * @param {Function} func The function to apply a rest parameter to.
709 * @param {number} [start=func.length-1] The start position of the rest parameter.
710 * @returns {Function} Returns the new function.
711 */
712function baseRest(func, start) {
713  start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
714  return function() {
715    var args = arguments,
716        index = -1,
717        length = nativeMax(args.length - start, 0),
718        array = Array(length);
719
720    while (++index < length) {
721      array[index] = args[start + index];
722    }
723    index = -1;
724    var otherArgs = Array(start + 1);
725    while (++index < start) {
726      otherArgs[index] = args[index];
727    }
728    otherArgs[start] = array;
729    return apply(func, this, otherArgs);
730  };
731}
732
733/**
734 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
735 *
736 * @private
737 * @param {Array} array The array to inspect.
738 * @param {Function} [iteratee] The iteratee invoked per element.
739 * @param {Function} [comparator] The comparator invoked per element.
740 * @returns {Array} Returns the new duplicate free array.
741 */
742function baseUniq(array, iteratee, comparator) {
743  var index = -1,
744      includes = arrayIncludes,
745      length = array.length,
746      isCommon = true,
747      result = [],
748      seen = result;
749
750  if (comparator) {
751    isCommon = false;
752    includes = arrayIncludesWith;
753  }
754  else if (length >= LARGE_ARRAY_SIZE) {
755    var set = iteratee ? null : createSet(array);
756    if (set) {
757      return setToArray(set);
758    }
759    isCommon = false;
760    includes = cacheHas;
761    seen = new SetCache;
762  }
763  else {
764    seen = iteratee ? [] : result;
765  }
766  outer:
767  while (++index < length) {
768    var value = array[index],
769        computed = iteratee ? iteratee(value) : value;
770
771    value = (comparator || value !== 0) ? value : 0;
772    if (isCommon && computed === computed) {
773      var seenIndex = seen.length;
774      while (seenIndex--) {
775        if (seen[seenIndex] === computed) {
776          continue outer;
777        }
778      }
779      if (iteratee) {
780        seen.push(computed);
781      }
782      result.push(value);
783    }
784    else if (!includes(seen, computed, comparator)) {
785      if (seen !== result) {
786        seen.push(computed);
787      }
788      result.push(value);
789    }
790  }
791  return result;
792}
793
794/**
795 * Creates a set object of `values`.
796 *
797 * @private
798 * @param {Array} values The values to add to the set.
799 * @returns {Object} Returns the new set.
800 */
801var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
802  return new Set(values);
803};
804
805/**
806 * Gets the data for `map`.
807 *
808 * @private
809 * @param {Object} map The map to query.
810 * @param {string} key The reference key.
811 * @returns {*} Returns the map data.
812 */
813function getMapData(map, key) {
814  var data = map.__data__;
815  return isKeyable(key)
816    ? data[typeof key == 'string' ? 'string' : 'hash']
817    : data.map;
818}
819
820/**
821 * Gets the native function at `key` of `object`.
822 *
823 * @private
824 * @param {Object} object The object to query.
825 * @param {string} key The key of the method to get.
826 * @returns {*} Returns the function if it's native, else `undefined`.
827 */
828function getNative(object, key) {
829  var value = getValue(object, key);
830  return baseIsNative(value) ? value : undefined;
831}
832
833/**
834 * Checks if `value` is a flattenable `arguments` object or array.
835 *
836 * @private
837 * @param {*} value The value to check.
838 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
839 */
840function isFlattenable(value) {
841  return isArray(value) || isArguments(value) ||
842    !!(spreadableSymbol && value && value[spreadableSymbol]);
843}
844
845/**
846 * Checks if `value` is suitable for use as unique object key.
847 *
848 * @private
849 * @param {*} value The value to check.
850 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
851 */
852function isKeyable(value) {
853  var type = typeof value;
854  return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
855    ? (value !== '__proto__')
856    : (value === null);
857}
858
859/**
860 * Checks if `func` has its source masked.
861 *
862 * @private
863 * @param {Function} func The function to check.
864 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
865 */
866function isMasked(func) {
867  return !!maskSrcKey && (maskSrcKey in func);
868}
869
870/**
871 * Converts `func` to its source code.
872 *
873 * @private
874 * @param {Function} func The function to process.
875 * @returns {string} Returns the source code.
876 */
877function toSource(func) {
878  if (func != null) {
879    try {
880      return funcToString.call(func);
881    } catch (e) {}
882    try {
883      return (func + '');
884    } catch (e) {}
885  }
886  return '';
887}
888
889/**
890 * Creates an array of unique values, in order, from all given arrays using
891 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
892 * for equality comparisons.
893 *
894 * @static
895 * @memberOf _
896 * @since 0.1.0
897 * @category Array
898 * @param {...Array} [arrays] The arrays to inspect.
899 * @returns {Array} Returns the new array of combined values.
900 * @example
901 *
902 * _.union([2], [1, 2]);
903 * // => [2, 1]
904 */
905var union = baseRest(function(arrays) {
906  return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
907});
908
909/**
910 * Performs a
911 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
912 * comparison between two values to determine if they are equivalent.
913 *
914 * @static
915 * @memberOf _
916 * @since 4.0.0
917 * @category Lang
918 * @param {*} value The value to compare.
919 * @param {*} other The other value to compare.
920 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
921 * @example
922 *
923 * var object = { 'a': 1 };
924 * var other = { 'a': 1 };
925 *
926 * _.eq(object, object);
927 * // => true
928 *
929 * _.eq(object, other);
930 * // => false
931 *
932 * _.eq('a', 'a');
933 * // => true
934 *
935 * _.eq('a', Object('a'));
936 * // => false
937 *
938 * _.eq(NaN, NaN);
939 * // => true
940 */
941function eq(value, other) {
942  return value === other || (value !== value && other !== other);
943}
944
945/**
946 * Checks if `value` is likely an `arguments` object.
947 *
948 * @static
949 * @memberOf _
950 * @since 0.1.0
951 * @category Lang
952 * @param {*} value The value to check.
953 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
954 *  else `false`.
955 * @example
956 *
957 * _.isArguments(function() { return arguments; }());
958 * // => true
959 *
960 * _.isArguments([1, 2, 3]);
961 * // => false
962 */
963function isArguments(value) {
964  // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
965  return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
966    (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
967}
968
969/**
970 * Checks if `value` is classified as an `Array` object.
971 *
972 * @static
973 * @memberOf _
974 * @since 0.1.0
975 * @category Lang
976 * @param {*} value The value to check.
977 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
978 * @example
979 *
980 * _.isArray([1, 2, 3]);
981 * // => true
982 *
983 * _.isArray(document.body.children);
984 * // => false
985 *
986 * _.isArray('abc');
987 * // => false
988 *
989 * _.isArray(_.noop);
990 * // => false
991 */
992var isArray = Array.isArray;
993
994/**
995 * Checks if `value` is array-like. A value is considered array-like if it's
996 * not a function and has a `value.length` that's an integer greater than or
997 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
998 *
999 * @static
1000 * @memberOf _
1001 * @since 4.0.0
1002 * @category Lang
1003 * @param {*} value The value to check.
1004 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1005 * @example
1006 *
1007 * _.isArrayLike([1, 2, 3]);
1008 * // => true
1009 *
1010 * _.isArrayLike(document.body.children);
1011 * // => true
1012 *
1013 * _.isArrayLike('abc');
1014 * // => true
1015 *
1016 * _.isArrayLike(_.noop);
1017 * // => false
1018 */
1019function isArrayLike(value) {
1020  return value != null && isLength(value.length) && !isFunction(value);
1021}
1022
1023/**
1024 * This method is like `_.isArrayLike` except that it also checks if `value`
1025 * is an object.
1026 *
1027 * @static
1028 * @memberOf _
1029 * @since 4.0.0
1030 * @category Lang
1031 * @param {*} value The value to check.
1032 * @returns {boolean} Returns `true` if `value` is an array-like object,
1033 *  else `false`.
1034 * @example
1035 *
1036 * _.isArrayLikeObject([1, 2, 3]);
1037 * // => true
1038 *
1039 * _.isArrayLikeObject(document.body.children);
1040 * // => true
1041 *
1042 * _.isArrayLikeObject('abc');
1043 * // => false
1044 *
1045 * _.isArrayLikeObject(_.noop);
1046 * // => false
1047 */
1048function isArrayLikeObject(value) {
1049  return isObjectLike(value) && isArrayLike(value);
1050}
1051
1052/**
1053 * Checks if `value` is classified as a `Function` object.
1054 *
1055 * @static
1056 * @memberOf _
1057 * @since 0.1.0
1058 * @category Lang
1059 * @param {*} value The value to check.
1060 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1061 * @example
1062 *
1063 * _.isFunction(_);
1064 * // => true
1065 *
1066 * _.isFunction(/abc/);
1067 * // => false
1068 */
1069function isFunction(value) {
1070  // The use of `Object#toString` avoids issues with the `typeof` operator
1071  // in Safari 8-9 which returns 'object' for typed array and other constructors.
1072  var tag = isObject(value) ? objectToString.call(value) : '';
1073  return tag == funcTag || tag == genTag;
1074}
1075
1076/**
1077 * Checks if `value` is a valid array-like length.
1078 *
1079 * **Note:** This method is loosely based on
1080 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1081 *
1082 * @static
1083 * @memberOf _
1084 * @since 4.0.0
1085 * @category Lang
1086 * @param {*} value The value to check.
1087 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1088 * @example
1089 *
1090 * _.isLength(3);
1091 * // => true
1092 *
1093 * _.isLength(Number.MIN_VALUE);
1094 * // => false
1095 *
1096 * _.isLength(Infinity);
1097 * // => false
1098 *
1099 * _.isLength('3');
1100 * // => false
1101 */
1102function isLength(value) {
1103  return typeof value == 'number' &&
1104    value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1105}
1106
1107/**
1108 * Checks if `value` is the
1109 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1110 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1111 *
1112 * @static
1113 * @memberOf _
1114 * @since 0.1.0
1115 * @category Lang
1116 * @param {*} value The value to check.
1117 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1118 * @example
1119 *
1120 * _.isObject({});
1121 * // => true
1122 *
1123 * _.isObject([1, 2, 3]);
1124 * // => true
1125 *
1126 * _.isObject(_.noop);
1127 * // => true
1128 *
1129 * _.isObject(null);
1130 * // => false
1131 */
1132function isObject(value) {
1133  var type = typeof value;
1134  return !!value && (type == 'object' || type == 'function');
1135}
1136
1137/**
1138 * Checks if `value` is object-like. A value is object-like if it's not `null`
1139 * and has a `typeof` result of "object".
1140 *
1141 * @static
1142 * @memberOf _
1143 * @since 4.0.0
1144 * @category Lang
1145 * @param {*} value The value to check.
1146 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1147 * @example
1148 *
1149 * _.isObjectLike({});
1150 * // => true
1151 *
1152 * _.isObjectLike([1, 2, 3]);
1153 * // => true
1154 *
1155 * _.isObjectLike(_.noop);
1156 * // => false
1157 *
1158 * _.isObjectLike(null);
1159 * // => false
1160 */
1161function isObjectLike(value) {
1162  return !!value && typeof value == 'object';
1163}
1164
1165/**
1166 * This method returns `undefined`.
1167 *
1168 * @static
1169 * @memberOf _
1170 * @since 2.3.0
1171 * @category Util
1172 * @example
1173 *
1174 * _.times(2, _.noop);
1175 * // => [undefined, undefined]
1176 */
1177function noop() {
1178  // No operation performed.
1179}
1180
1181module.exports = union;
1182