source: frontend/node_modules/lodash.sortby/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 70.9 KB
Line 
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 as the `TypeError` message for "Functions" methods. */
14var FUNC_ERROR_TEXT = 'Expected a function';
15
16/** Used to stand-in for `undefined` hash values. */
17var HASH_UNDEFINED = '__lodash_hash_undefined__';
18
19/** Used to compose bitmasks for comparison styles. */
20var UNORDERED_COMPARE_FLAG = 1,
21 PARTIAL_COMPARE_FLAG = 2;
22
23/** Used as references for various `Number` constants. */
24var INFINITY = 1 / 0,
25 MAX_SAFE_INTEGER = 9007199254740991;
26
27/** `Object#toString` result references. */
28var argsTag = '[object Arguments]',
29 arrayTag = '[object Array]',
30 boolTag = '[object Boolean]',
31 dateTag = '[object Date]',
32 errorTag = '[object Error]',
33 funcTag = '[object Function]',
34 genTag = '[object GeneratorFunction]',
35 mapTag = '[object Map]',
36 numberTag = '[object Number]',
37 objectTag = '[object Object]',
38 promiseTag = '[object Promise]',
39 regexpTag = '[object RegExp]',
40 setTag = '[object Set]',
41 stringTag = '[object String]',
42 symbolTag = '[object Symbol]',
43 weakMapTag = '[object WeakMap]';
44
45var arrayBufferTag = '[object ArrayBuffer]',
46 dataViewTag = '[object DataView]',
47 float32Tag = '[object Float32Array]',
48 float64Tag = '[object Float64Array]',
49 int8Tag = '[object Int8Array]',
50 int16Tag = '[object Int16Array]',
51 int32Tag = '[object Int32Array]',
52 uint8Tag = '[object Uint8Array]',
53 uint8ClampedTag = '[object Uint8ClampedArray]',
54 uint16Tag = '[object Uint16Array]',
55 uint32Tag = '[object Uint32Array]';
56
57/** Used to match property names within property paths. */
58var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
59 reIsPlainProp = /^\w*$/,
60 reLeadingDot = /^\./,
61 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
62
63/**
64 * Used to match `RegExp`
65 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
66 */
67var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
68
69/** Used to match backslashes in property paths. */
70var reEscapeChar = /\\(\\)?/g;
71
72/** Used to detect host constructors (Safari). */
73var reIsHostCtor = /^\[object .+?Constructor\]$/;
74
75/** Used to detect unsigned integer values. */
76var reIsUint = /^(?:0|[1-9]\d*)$/;
77
78/** Used to identify `toStringTag` values of typed arrays. */
79var typedArrayTags = {};
80typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
81typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
82typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
83typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
84typedArrayTags[uint32Tag] = true;
85typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
86typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
87typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
88typedArrayTags[errorTag] = typedArrayTags[funcTag] =
89typedArrayTags[mapTag] = typedArrayTags[numberTag] =
90typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
91typedArrayTags[setTag] = typedArrayTags[stringTag] =
92typedArrayTags[weakMapTag] = false;
93
94/** Detect free variable `global` from Node.js. */
95var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
96
97/** Detect free variable `self`. */
98var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
99
100/** Used as a reference to the global object. */
101var root = freeGlobal || freeSelf || Function('return this')();
102
103/** Detect free variable `exports`. */
104var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
105
106/** Detect free variable `module`. */
107var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
108
109/** Detect the popular CommonJS extension `module.exports`. */
110var moduleExports = freeModule && freeModule.exports === freeExports;
111
112/** Detect free variable `process` from Node.js. */
113var freeProcess = moduleExports && freeGlobal.process;
114
115/** Used to access faster Node.js helpers. */
116var nodeUtil = (function() {
117 try {
118 return freeProcess && freeProcess.binding('util');
119 } catch (e) {}
120}());
121
122/* Node.js helper references. */
123var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
124
125/**
126 * A faster alternative to `Function#apply`, this function invokes `func`
127 * with the `this` binding of `thisArg` and the arguments of `args`.
128 *
129 * @private
130 * @param {Function} func The function to invoke.
131 * @param {*} thisArg The `this` binding of `func`.
132 * @param {Array} args The arguments to invoke `func` with.
133 * @returns {*} Returns the result of `func`.
134 */
135function apply(func, thisArg, args) {
136 switch (args.length) {
137 case 0: return func.call(thisArg);
138 case 1: return func.call(thisArg, args[0]);
139 case 2: return func.call(thisArg, args[0], args[1]);
140 case 3: return func.call(thisArg, args[0], args[1], args[2]);
141 }
142 return func.apply(thisArg, args);
143}
144
145/**
146 * A specialized version of `_.map` for arrays without support for iteratee
147 * shorthands.
148 *
149 * @private
150 * @param {Array} [array] The array to iterate over.
151 * @param {Function} iteratee The function invoked per iteration.
152 * @returns {Array} Returns the new mapped array.
153 */
154function arrayMap(array, iteratee) {
155 var index = -1,
156 length = array ? array.length : 0,
157 result = Array(length);
158
159 while (++index < length) {
160 result[index] = iteratee(array[index], index, array);
161 }
162 return result;
163}
164
165/**
166 * Appends the elements of `values` to `array`.
167 *
168 * @private
169 * @param {Array} array The array to modify.
170 * @param {Array} values The values to append.
171 * @returns {Array} Returns `array`.
172 */
173function arrayPush(array, values) {
174 var index = -1,
175 length = values.length,
176 offset = array.length;
177
178 while (++index < length) {
179 array[offset + index] = values[index];
180 }
181 return array;
182}
183
184/**
185 * A specialized version of `_.some` for arrays without support for iteratee
186 * shorthands.
187 *
188 * @private
189 * @param {Array} [array] The array to iterate over.
190 * @param {Function} predicate The function invoked per iteration.
191 * @returns {boolean} Returns `true` if any element passes the predicate check,
192 * else `false`.
193 */
194function arraySome(array, predicate) {
195 var index = -1,
196 length = array ? array.length : 0;
197
198 while (++index < length) {
199 if (predicate(array[index], index, array)) {
200 return true;
201 }
202 }
203 return false;
204}
205
206/**
207 * The base implementation of `_.property` without support for deep paths.
208 *
209 * @private
210 * @param {string} key The key of the property to get.
211 * @returns {Function} Returns the new accessor function.
212 */
213function baseProperty(key) {
214 return function(object) {
215 return object == null ? undefined : object[key];
216 };
217}
218
219/**
220 * The base implementation of `_.sortBy` which uses `comparer` to define the
221 * sort order of `array` and replaces criteria objects with their corresponding
222 * values.
223 *
224 * @private
225 * @param {Array} array The array to sort.
226 * @param {Function} comparer The function to define sort order.
227 * @returns {Array} Returns `array`.
228 */
229function baseSortBy(array, comparer) {
230 var length = array.length;
231
232 array.sort(comparer);
233 while (length--) {
234 array[length] = array[length].value;
235 }
236 return array;
237}
238
239/**
240 * The base implementation of `_.times` without support for iteratee shorthands
241 * or max array length checks.
242 *
243 * @private
244 * @param {number} n The number of times to invoke `iteratee`.
245 * @param {Function} iteratee The function invoked per iteration.
246 * @returns {Array} Returns the array of results.
247 */
248function baseTimes(n, iteratee) {
249 var index = -1,
250 result = Array(n);
251
252 while (++index < n) {
253 result[index] = iteratee(index);
254 }
255 return result;
256}
257
258/**
259 * The base implementation of `_.unary` without support for storing metadata.
260 *
261 * @private
262 * @param {Function} func The function to cap arguments for.
263 * @returns {Function} Returns the new capped function.
264 */
265function baseUnary(func) {
266 return function(value) {
267 return func(value);
268 };
269}
270
271/**
272 * Gets the value at `key` of `object`.
273 *
274 * @private
275 * @param {Object} [object] The object to query.
276 * @param {string} key The key of the property to get.
277 * @returns {*} Returns the property value.
278 */
279function getValue(object, key) {
280 return object == null ? undefined : object[key];
281}
282
283/**
284 * Checks if `value` is a host object in IE < 9.
285 *
286 * @private
287 * @param {*} value The value to check.
288 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
289 */
290function isHostObject(value) {
291 // Many host objects are `Object` objects that can coerce to strings
292 // despite having improperly defined `toString` methods.
293 var result = false;
294 if (value != null && typeof value.toString != 'function') {
295 try {
296 result = !!(value + '');
297 } catch (e) {}
298 }
299 return result;
300}
301
302/**
303 * Converts `map` to its key-value pairs.
304 *
305 * @private
306 * @param {Object} map The map to convert.
307 * @returns {Array} Returns the key-value pairs.
308 */
309function mapToArray(map) {
310 var index = -1,
311 result = Array(map.size);
312
313 map.forEach(function(value, key) {
314 result[++index] = [key, value];
315 });
316 return result;
317}
318
319/**
320 * Creates a unary function that invokes `func` with its argument transformed.
321 *
322 * @private
323 * @param {Function} func The function to wrap.
324 * @param {Function} transform The argument transform.
325 * @returns {Function} Returns the new function.
326 */
327function overArg(func, transform) {
328 return function(arg) {
329 return func(transform(arg));
330 };
331}
332
333/**
334 * Converts `set` to an array of its values.
335 *
336 * @private
337 * @param {Object} set The set to convert.
338 * @returns {Array} Returns the values.
339 */
340function setToArray(set) {
341 var index = -1,
342 result = Array(set.size);
343
344 set.forEach(function(value) {
345 result[++index] = value;
346 });
347 return result;
348}
349
350/** Used for built-in method references. */
351var arrayProto = Array.prototype,
352 funcProto = Function.prototype,
353 objectProto = Object.prototype;
354
355/** Used to detect overreaching core-js shims. */
356var coreJsData = root['__core-js_shared__'];
357
358/** Used to detect methods masquerading as native. */
359var maskSrcKey = (function() {
360 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
361 return uid ? ('Symbol(src)_1.' + uid) : '';
362}());
363
364/** Used to resolve the decompiled source of functions. */
365var funcToString = funcProto.toString;
366
367/** Used to check objects for own properties. */
368var hasOwnProperty = objectProto.hasOwnProperty;
369
370/**
371 * Used to resolve the
372 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
373 * of values.
374 */
375var objectToString = objectProto.toString;
376
377/** Used to detect if a method is native. */
378var reIsNative = RegExp('^' +
379 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
380 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
381);
382
383/** Built-in value references. */
384var Symbol = root.Symbol,
385 Uint8Array = root.Uint8Array,
386 propertyIsEnumerable = objectProto.propertyIsEnumerable,
387 splice = arrayProto.splice,
388 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
389
390/* Built-in method references for those with the same name as other `lodash` methods. */
391var nativeKeys = overArg(Object.keys, Object),
392 nativeMax = Math.max;
393
394/* Built-in method references that are verified to be native. */
395var DataView = getNative(root, 'DataView'),
396 Map = getNative(root, 'Map'),
397 Promise = getNative(root, 'Promise'),
398 Set = getNative(root, 'Set'),
399 WeakMap = getNative(root, 'WeakMap'),
400 nativeCreate = getNative(Object, 'create');
401
402/** Used to detect maps, sets, and weakmaps. */
403var dataViewCtorString = toSource(DataView),
404 mapCtorString = toSource(Map),
405 promiseCtorString = toSource(Promise),
406 setCtorString = toSource(Set),
407 weakMapCtorString = toSource(WeakMap);
408
409/** Used to convert symbols to primitives and strings. */
410var symbolProto = Symbol ? Symbol.prototype : undefined,
411 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
412 symbolToString = symbolProto ? symbolProto.toString : undefined;
413
414/**
415 * Creates a hash object.
416 *
417 * @private
418 * @constructor
419 * @param {Array} [entries] The key-value pairs to cache.
420 */
421function Hash(entries) {
422 var index = -1,
423 length = entries ? entries.length : 0;
424
425 this.clear();
426 while (++index < length) {
427 var entry = entries[index];
428 this.set(entry[0], entry[1]);
429 }
430}
431
432/**
433 * Removes all key-value entries from the hash.
434 *
435 * @private
436 * @name clear
437 * @memberOf Hash
438 */
439function hashClear() {
440 this.__data__ = nativeCreate ? nativeCreate(null) : {};
441}
442
443/**
444 * Removes `key` and its value from the hash.
445 *
446 * @private
447 * @name delete
448 * @memberOf Hash
449 * @param {Object} hash The hash to modify.
450 * @param {string} key The key of the value to remove.
451 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
452 */
453function hashDelete(key) {
454 return this.has(key) && delete this.__data__[key];
455}
456
457/**
458 * Gets the hash value for `key`.
459 *
460 * @private
461 * @name get
462 * @memberOf Hash
463 * @param {string} key The key of the value to get.
464 * @returns {*} Returns the entry value.
465 */
466function hashGet(key) {
467 var data = this.__data__;
468 if (nativeCreate) {
469 var result = data[key];
470 return result === HASH_UNDEFINED ? undefined : result;
471 }
472 return hasOwnProperty.call(data, key) ? data[key] : undefined;
473}
474
475/**
476 * Checks if a hash value for `key` exists.
477 *
478 * @private
479 * @name has
480 * @memberOf Hash
481 * @param {string} key The key of the entry to check.
482 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
483 */
484function hashHas(key) {
485 var data = this.__data__;
486 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
487}
488
489/**
490 * Sets the hash `key` to `value`.
491 *
492 * @private
493 * @name set
494 * @memberOf Hash
495 * @param {string} key The key of the value to set.
496 * @param {*} value The value to set.
497 * @returns {Object} Returns the hash instance.
498 */
499function hashSet(key, value) {
500 var data = this.__data__;
501 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
502 return this;
503}
504
505// Add methods to `Hash`.
506Hash.prototype.clear = hashClear;
507Hash.prototype['delete'] = hashDelete;
508Hash.prototype.get = hashGet;
509Hash.prototype.has = hashHas;
510Hash.prototype.set = hashSet;
511
512/**
513 * Creates an list cache object.
514 *
515 * @private
516 * @constructor
517 * @param {Array} [entries] The key-value pairs to cache.
518 */
519function ListCache(entries) {
520 var index = -1,
521 length = entries ? entries.length : 0;
522
523 this.clear();
524 while (++index < length) {
525 var entry = entries[index];
526 this.set(entry[0], entry[1]);
527 }
528}
529
530/**
531 * Removes all key-value entries from the list cache.
532 *
533 * @private
534 * @name clear
535 * @memberOf ListCache
536 */
537function listCacheClear() {
538 this.__data__ = [];
539}
540
541/**
542 * Removes `key` and its value from the list cache.
543 *
544 * @private
545 * @name delete
546 * @memberOf ListCache
547 * @param {string} key The key of the value to remove.
548 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
549 */
550function listCacheDelete(key) {
551 var data = this.__data__,
552 index = assocIndexOf(data, key);
553
554 if (index < 0) {
555 return false;
556 }
557 var lastIndex = data.length - 1;
558 if (index == lastIndex) {
559 data.pop();
560 } else {
561 splice.call(data, index, 1);
562 }
563 return true;
564}
565
566/**
567 * Gets the list cache value for `key`.
568 *
569 * @private
570 * @name get
571 * @memberOf ListCache
572 * @param {string} key The key of the value to get.
573 * @returns {*} Returns the entry value.
574 */
575function listCacheGet(key) {
576 var data = this.__data__,
577 index = assocIndexOf(data, key);
578
579 return index < 0 ? undefined : data[index][1];
580}
581
582/**
583 * Checks if a list cache value for `key` exists.
584 *
585 * @private
586 * @name has
587 * @memberOf ListCache
588 * @param {string} key The key of the entry to check.
589 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
590 */
591function listCacheHas(key) {
592 return assocIndexOf(this.__data__, key) > -1;
593}
594
595/**
596 * Sets the list cache `key` to `value`.
597 *
598 * @private
599 * @name set
600 * @memberOf ListCache
601 * @param {string} key The key of the value to set.
602 * @param {*} value The value to set.
603 * @returns {Object} Returns the list cache instance.
604 */
605function listCacheSet(key, value) {
606 var data = this.__data__,
607 index = assocIndexOf(data, key);
608
609 if (index < 0) {
610 data.push([key, value]);
611 } else {
612 data[index][1] = value;
613 }
614 return this;
615}
616
617// Add methods to `ListCache`.
618ListCache.prototype.clear = listCacheClear;
619ListCache.prototype['delete'] = listCacheDelete;
620ListCache.prototype.get = listCacheGet;
621ListCache.prototype.has = listCacheHas;
622ListCache.prototype.set = listCacheSet;
623
624/**
625 * Creates a map cache object to store key-value pairs.
626 *
627 * @private
628 * @constructor
629 * @param {Array} [entries] The key-value pairs to cache.
630 */
631function MapCache(entries) {
632 var index = -1,
633 length = entries ? entries.length : 0;
634
635 this.clear();
636 while (++index < length) {
637 var entry = entries[index];
638 this.set(entry[0], entry[1]);
639 }
640}
641
642/**
643 * Removes all key-value entries from the map.
644 *
645 * @private
646 * @name clear
647 * @memberOf MapCache
648 */
649function mapCacheClear() {
650 this.__data__ = {
651 'hash': new Hash,
652 'map': new (Map || ListCache),
653 'string': new Hash
654 };
655}
656
657/**
658 * Removes `key` and its value from the map.
659 *
660 * @private
661 * @name delete
662 * @memberOf MapCache
663 * @param {string} key The key of the value to remove.
664 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
665 */
666function mapCacheDelete(key) {
667 return getMapData(this, key)['delete'](key);
668}
669
670/**
671 * Gets the map value for `key`.
672 *
673 * @private
674 * @name get
675 * @memberOf MapCache
676 * @param {string} key The key of the value to get.
677 * @returns {*} Returns the entry value.
678 */
679function mapCacheGet(key) {
680 return getMapData(this, key).get(key);
681}
682
683/**
684 * Checks if a map value for `key` exists.
685 *
686 * @private
687 * @name has
688 * @memberOf MapCache
689 * @param {string} key The key of the entry to check.
690 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
691 */
692function mapCacheHas(key) {
693 return getMapData(this, key).has(key);
694}
695
696/**
697 * Sets the map `key` to `value`.
698 *
699 * @private
700 * @name set
701 * @memberOf MapCache
702 * @param {string} key The key of the value to set.
703 * @param {*} value The value to set.
704 * @returns {Object} Returns the map cache instance.
705 */
706function mapCacheSet(key, value) {
707 getMapData(this, key).set(key, value);
708 return this;
709}
710
711// Add methods to `MapCache`.
712MapCache.prototype.clear = mapCacheClear;
713MapCache.prototype['delete'] = mapCacheDelete;
714MapCache.prototype.get = mapCacheGet;
715MapCache.prototype.has = mapCacheHas;
716MapCache.prototype.set = mapCacheSet;
717
718/**
719 *
720 * Creates an array cache object to store unique values.
721 *
722 * @private
723 * @constructor
724 * @param {Array} [values] The values to cache.
725 */
726function SetCache(values) {
727 var index = -1,
728 length = values ? values.length : 0;
729
730 this.__data__ = new MapCache;
731 while (++index < length) {
732 this.add(values[index]);
733 }
734}
735
736/**
737 * Adds `value` to the array cache.
738 *
739 * @private
740 * @name add
741 * @memberOf SetCache
742 * @alias push
743 * @param {*} value The value to cache.
744 * @returns {Object} Returns the cache instance.
745 */
746function setCacheAdd(value) {
747 this.__data__.set(value, HASH_UNDEFINED);
748 return this;
749}
750
751/**
752 * Checks if `value` is in the array cache.
753 *
754 * @private
755 * @name has
756 * @memberOf SetCache
757 * @param {*} value The value to search for.
758 * @returns {number} Returns `true` if `value` is found, else `false`.
759 */
760function setCacheHas(value) {
761 return this.__data__.has(value);
762}
763
764// Add methods to `SetCache`.
765SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
766SetCache.prototype.has = setCacheHas;
767
768/**
769 * Creates a stack cache object to store key-value pairs.
770 *
771 * @private
772 * @constructor
773 * @param {Array} [entries] The key-value pairs to cache.
774 */
775function Stack(entries) {
776 this.__data__ = new ListCache(entries);
777}
778
779/**
780 * Removes all key-value entries from the stack.
781 *
782 * @private
783 * @name clear
784 * @memberOf Stack
785 */
786function stackClear() {
787 this.__data__ = new ListCache;
788}
789
790/**
791 * Removes `key` and its value from the stack.
792 *
793 * @private
794 * @name delete
795 * @memberOf Stack
796 * @param {string} key The key of the value to remove.
797 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
798 */
799function stackDelete(key) {
800 return this.__data__['delete'](key);
801}
802
803/**
804 * Gets the stack value for `key`.
805 *
806 * @private
807 * @name get
808 * @memberOf Stack
809 * @param {string} key The key of the value to get.
810 * @returns {*} Returns the entry value.
811 */
812function stackGet(key) {
813 return this.__data__.get(key);
814}
815
816/**
817 * Checks if a stack value for `key` exists.
818 *
819 * @private
820 * @name has
821 * @memberOf Stack
822 * @param {string} key The key of the entry to check.
823 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
824 */
825function stackHas(key) {
826 return this.__data__.has(key);
827}
828
829/**
830 * Sets the stack `key` to `value`.
831 *
832 * @private
833 * @name set
834 * @memberOf Stack
835 * @param {string} key The key of the value to set.
836 * @param {*} value The value to set.
837 * @returns {Object} Returns the stack cache instance.
838 */
839function stackSet(key, value) {
840 var cache = this.__data__;
841 if (cache instanceof ListCache) {
842 var pairs = cache.__data__;
843 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
844 pairs.push([key, value]);
845 return this;
846 }
847 cache = this.__data__ = new MapCache(pairs);
848 }
849 cache.set(key, value);
850 return this;
851}
852
853// Add methods to `Stack`.
854Stack.prototype.clear = stackClear;
855Stack.prototype['delete'] = stackDelete;
856Stack.prototype.get = stackGet;
857Stack.prototype.has = stackHas;
858Stack.prototype.set = stackSet;
859
860/**
861 * Creates an array of the enumerable property names of the array-like `value`.
862 *
863 * @private
864 * @param {*} value The value to query.
865 * @param {boolean} inherited Specify returning inherited property names.
866 * @returns {Array} Returns the array of property names.
867 */
868function arrayLikeKeys(value, inherited) {
869 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
870 // Safari 9 makes `arguments.length` enumerable in strict mode.
871 var result = (isArray(value) || isArguments(value))
872 ? baseTimes(value.length, String)
873 : [];
874
875 var length = result.length,
876 skipIndexes = !!length;
877
878 for (var key in value) {
879 if ((inherited || hasOwnProperty.call(value, key)) &&
880 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
881 result.push(key);
882 }
883 }
884 return result;
885}
886
887/**
888 * Gets the index at which the `key` is found in `array` of key-value pairs.
889 *
890 * @private
891 * @param {Array} array The array to inspect.
892 * @param {*} key The key to search for.
893 * @returns {number} Returns the index of the matched value, else `-1`.
894 */
895function assocIndexOf(array, key) {
896 var length = array.length;
897 while (length--) {
898 if (eq(array[length][0], key)) {
899 return length;
900 }
901 }
902 return -1;
903}
904
905/**
906 * The base implementation of `_.forEach` without support for iteratee shorthands.
907 *
908 * @private
909 * @param {Array|Object} collection The collection to iterate over.
910 * @param {Function} iteratee The function invoked per iteration.
911 * @returns {Array|Object} Returns `collection`.
912 */
913var baseEach = createBaseEach(baseForOwn);
914
915/**
916 * The base implementation of `_.flatten` with support for restricting flattening.
917 *
918 * @private
919 * @param {Array} array The array to flatten.
920 * @param {number} depth The maximum recursion depth.
921 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
922 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
923 * @param {Array} [result=[]] The initial result value.
924 * @returns {Array} Returns the new flattened array.
925 */
926function baseFlatten(array, depth, predicate, isStrict, result) {
927 var index = -1,
928 length = array.length;
929
930 predicate || (predicate = isFlattenable);
931 result || (result = []);
932
933 while (++index < length) {
934 var value = array[index];
935 if (depth > 0 && predicate(value)) {
936 if (depth > 1) {
937 // Recursively flatten arrays (susceptible to call stack limits).
938 baseFlatten(value, depth - 1, predicate, isStrict, result);
939 } else {
940 arrayPush(result, value);
941 }
942 } else if (!isStrict) {
943 result[result.length] = value;
944 }
945 }
946 return result;
947}
948
949/**
950 * The base implementation of `baseForOwn` which iterates over `object`
951 * properties returned by `keysFunc` and invokes `iteratee` for each property.
952 * Iteratee functions may exit iteration early by explicitly returning `false`.
953 *
954 * @private
955 * @param {Object} object The object to iterate over.
956 * @param {Function} iteratee The function invoked per iteration.
957 * @param {Function} keysFunc The function to get the keys of `object`.
958 * @returns {Object} Returns `object`.
959 */
960var baseFor = createBaseFor();
961
962/**
963 * The base implementation of `_.forOwn` without support for iteratee shorthands.
964 *
965 * @private
966 * @param {Object} object The object to iterate over.
967 * @param {Function} iteratee The function invoked per iteration.
968 * @returns {Object} Returns `object`.
969 */
970function baseForOwn(object, iteratee) {
971 return object && baseFor(object, iteratee, keys);
972}
973
974/**
975 * The base implementation of `_.get` without support for default values.
976 *
977 * @private
978 * @param {Object} object The object to query.
979 * @param {Array|string} path The path of the property to get.
980 * @returns {*} Returns the resolved value.
981 */
982function baseGet(object, path) {
983 path = isKey(path, object) ? [path] : castPath(path);
984
985 var index = 0,
986 length = path.length;
987
988 while (object != null && index < length) {
989 object = object[toKey(path[index++])];
990 }
991 return (index && index == length) ? object : undefined;
992}
993
994/**
995 * The base implementation of `getTag`.
996 *
997 * @private
998 * @param {*} value The value to query.
999 * @returns {string} Returns the `toStringTag`.
1000 */
1001function baseGetTag(value) {
1002 return objectToString.call(value);
1003}
1004
1005/**
1006 * The base implementation of `_.hasIn` without support for deep paths.
1007 *
1008 * @private
1009 * @param {Object} [object] The object to query.
1010 * @param {Array|string} key The key to check.
1011 * @returns {boolean} Returns `true` if `key` exists, else `false`.
1012 */
1013function baseHasIn(object, key) {
1014 return object != null && key in Object(object);
1015}
1016
1017/**
1018 * The base implementation of `_.isEqual` which supports partial comparisons
1019 * and tracks traversed objects.
1020 *
1021 * @private
1022 * @param {*} value The value to compare.
1023 * @param {*} other The other value to compare.
1024 * @param {Function} [customizer] The function to customize comparisons.
1025 * @param {boolean} [bitmask] The bitmask of comparison flags.
1026 * The bitmask may be composed of the following flags:
1027 * 1 - Unordered comparison
1028 * 2 - Partial comparison
1029 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
1030 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1031 */
1032function baseIsEqual(value, other, customizer, bitmask, stack) {
1033 if (value === other) {
1034 return true;
1035 }
1036 if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
1037 return value !== value && other !== other;
1038 }
1039 return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
1040}
1041
1042/**
1043 * A specialized version of `baseIsEqual` for arrays and objects which performs
1044 * deep comparisons and tracks traversed objects enabling objects with circular
1045 * references to be compared.
1046 *
1047 * @private
1048 * @param {Object} object The object to compare.
1049 * @param {Object} other The other object to compare.
1050 * @param {Function} equalFunc The function to determine equivalents of values.
1051 * @param {Function} [customizer] The function to customize comparisons.
1052 * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
1053 * for more details.
1054 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
1055 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1056 */
1057function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
1058 var objIsArr = isArray(object),
1059 othIsArr = isArray(other),
1060 objTag = arrayTag,
1061 othTag = arrayTag;
1062
1063 if (!objIsArr) {
1064 objTag = getTag(object);
1065 objTag = objTag == argsTag ? objectTag : objTag;
1066 }
1067 if (!othIsArr) {
1068 othTag = getTag(other);
1069 othTag = othTag == argsTag ? objectTag : othTag;
1070 }
1071 var objIsObj = objTag == objectTag && !isHostObject(object),
1072 othIsObj = othTag == objectTag && !isHostObject(other),
1073 isSameTag = objTag == othTag;
1074
1075 if (isSameTag && !objIsObj) {
1076 stack || (stack = new Stack);
1077 return (objIsArr || isTypedArray(object))
1078 ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
1079 : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
1080 }
1081 if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
1082 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1083 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1084
1085 if (objIsWrapped || othIsWrapped) {
1086 var objUnwrapped = objIsWrapped ? object.value() : object,
1087 othUnwrapped = othIsWrapped ? other.value() : other;
1088
1089 stack || (stack = new Stack);
1090 return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
1091 }
1092 }
1093 if (!isSameTag) {
1094 return false;
1095 }
1096 stack || (stack = new Stack);
1097 return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
1098}
1099
1100/**
1101 * The base implementation of `_.isMatch` without support for iteratee shorthands.
1102 *
1103 * @private
1104 * @param {Object} object The object to inspect.
1105 * @param {Object} source The object of property values to match.
1106 * @param {Array} matchData The property names, values, and compare flags to match.
1107 * @param {Function} [customizer] The function to customize comparisons.
1108 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
1109 */
1110function baseIsMatch(object, source, matchData, customizer) {
1111 var index = matchData.length,
1112 length = index,
1113 noCustomizer = !customizer;
1114
1115 if (object == null) {
1116 return !length;
1117 }
1118 object = Object(object);
1119 while (index--) {
1120 var data = matchData[index];
1121 if ((noCustomizer && data[2])
1122 ? data[1] !== object[data[0]]
1123 : !(data[0] in object)
1124 ) {
1125 return false;
1126 }
1127 }
1128 while (++index < length) {
1129 data = matchData[index];
1130 var key = data[0],
1131 objValue = object[key],
1132 srcValue = data[1];
1133
1134 if (noCustomizer && data[2]) {
1135 if (objValue === undefined && !(key in object)) {
1136 return false;
1137 }
1138 } else {
1139 var stack = new Stack;
1140 if (customizer) {
1141 var result = customizer(objValue, srcValue, key, object, source, stack);
1142 }
1143 if (!(result === undefined
1144 ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
1145 : result
1146 )) {
1147 return false;
1148 }
1149 }
1150 }
1151 return true;
1152}
1153
1154/**
1155 * The base implementation of `_.isNative` without bad shim checks.
1156 *
1157 * @private
1158 * @param {*} value The value to check.
1159 * @returns {boolean} Returns `true` if `value` is a native function,
1160 * else `false`.
1161 */
1162function baseIsNative(value) {
1163 if (!isObject(value) || isMasked(value)) {
1164 return false;
1165 }
1166 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1167 return pattern.test(toSource(value));
1168}
1169
1170/**
1171 * The base implementation of `_.isTypedArray` without Node.js optimizations.
1172 *
1173 * @private
1174 * @param {*} value The value to check.
1175 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1176 */
1177function baseIsTypedArray(value) {
1178 return isObjectLike(value) &&
1179 isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
1180}
1181
1182/**
1183 * The base implementation of `_.iteratee`.
1184 *
1185 * @private
1186 * @param {*} [value=_.identity] The value to convert to an iteratee.
1187 * @returns {Function} Returns the iteratee.
1188 */
1189function baseIteratee(value) {
1190 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
1191 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
1192 if (typeof value == 'function') {
1193 return value;
1194 }
1195 if (value == null) {
1196 return identity;
1197 }
1198 if (typeof value == 'object') {
1199 return isArray(value)
1200 ? baseMatchesProperty(value[0], value[1])
1201 : baseMatches(value);
1202 }
1203 return property(value);
1204}
1205
1206/**
1207 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1208 *
1209 * @private
1210 * @param {Object} object The object to query.
1211 * @returns {Array} Returns the array of property names.
1212 */
1213function baseKeys(object) {
1214 if (!isPrototype(object)) {
1215 return nativeKeys(object);
1216 }
1217 var result = [];
1218 for (var key in Object(object)) {
1219 if (hasOwnProperty.call(object, key) && key != 'constructor') {
1220 result.push(key);
1221 }
1222 }
1223 return result;
1224}
1225
1226/**
1227 * The base implementation of `_.map` without support for iteratee shorthands.
1228 *
1229 * @private
1230 * @param {Array|Object} collection The collection to iterate over.
1231 * @param {Function} iteratee The function invoked per iteration.
1232 * @returns {Array} Returns the new mapped array.
1233 */
1234function baseMap(collection, iteratee) {
1235 var index = -1,
1236 result = isArrayLike(collection) ? Array(collection.length) : [];
1237
1238 baseEach(collection, function(value, key, collection) {
1239 result[++index] = iteratee(value, key, collection);
1240 });
1241 return result;
1242}
1243
1244/**
1245 * The base implementation of `_.matches` which doesn't clone `source`.
1246 *
1247 * @private
1248 * @param {Object} source The object of property values to match.
1249 * @returns {Function} Returns the new spec function.
1250 */
1251function baseMatches(source) {
1252 var matchData = getMatchData(source);
1253 if (matchData.length == 1 && matchData[0][2]) {
1254 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
1255 }
1256 return function(object) {
1257 return object === source || baseIsMatch(object, source, matchData);
1258 };
1259}
1260
1261/**
1262 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
1263 *
1264 * @private
1265 * @param {string} path The path of the property to get.
1266 * @param {*} srcValue The value to match.
1267 * @returns {Function} Returns the new spec function.
1268 */
1269function baseMatchesProperty(path, srcValue) {
1270 if (isKey(path) && isStrictComparable(srcValue)) {
1271 return matchesStrictComparable(toKey(path), srcValue);
1272 }
1273 return function(object) {
1274 var objValue = get(object, path);
1275 return (objValue === undefined && objValue === srcValue)
1276 ? hasIn(object, path)
1277 : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
1278 };
1279}
1280
1281/**
1282 * The base implementation of `_.orderBy` without param guards.
1283 *
1284 * @private
1285 * @param {Array|Object} collection The collection to iterate over.
1286 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
1287 * @param {string[]} orders The sort orders of `iteratees`.
1288 * @returns {Array} Returns the new sorted array.
1289 */
1290function baseOrderBy(collection, iteratees, orders) {
1291 var index = -1;
1292 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
1293
1294 var result = baseMap(collection, function(value, key, collection) {
1295 var criteria = arrayMap(iteratees, function(iteratee) {
1296 return iteratee(value);
1297 });
1298 return { 'criteria': criteria, 'index': ++index, 'value': value };
1299 });
1300
1301 return baseSortBy(result, function(object, other) {
1302 return compareMultiple(object, other, orders);
1303 });
1304}
1305
1306/**
1307 * A specialized version of `baseProperty` which supports deep paths.
1308 *
1309 * @private
1310 * @param {Array|string} path The path of the property to get.
1311 * @returns {Function} Returns the new accessor function.
1312 */
1313function basePropertyDeep(path) {
1314 return function(object) {
1315 return baseGet(object, path);
1316 };
1317}
1318
1319/**
1320 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1321 *
1322 * @private
1323 * @param {Function} func The function to apply a rest parameter to.
1324 * @param {number} [start=func.length-1] The start position of the rest parameter.
1325 * @returns {Function} Returns the new function.
1326 */
1327function baseRest(func, start) {
1328 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1329 return function() {
1330 var args = arguments,
1331 index = -1,
1332 length = nativeMax(args.length - start, 0),
1333 array = Array(length);
1334
1335 while (++index < length) {
1336 array[index] = args[start + index];
1337 }
1338 index = -1;
1339 var otherArgs = Array(start + 1);
1340 while (++index < start) {
1341 otherArgs[index] = args[index];
1342 }
1343 otherArgs[start] = array;
1344 return apply(func, this, otherArgs);
1345 };
1346}
1347
1348/**
1349 * The base implementation of `_.toString` which doesn't convert nullish
1350 * values to empty strings.
1351 *
1352 * @private
1353 * @param {*} value The value to process.
1354 * @returns {string} Returns the string.
1355 */
1356function baseToString(value) {
1357 // Exit early for strings to avoid a performance hit in some environments.
1358 if (typeof value == 'string') {
1359 return value;
1360 }
1361 if (isSymbol(value)) {
1362 return symbolToString ? symbolToString.call(value) : '';
1363 }
1364 var result = (value + '');
1365 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1366}
1367
1368/**
1369 * Casts `value` to a path array if it's not one.
1370 *
1371 * @private
1372 * @param {*} value The value to inspect.
1373 * @returns {Array} Returns the cast property path array.
1374 */
1375function castPath(value) {
1376 return isArray(value) ? value : stringToPath(value);
1377}
1378
1379/**
1380 * Compares values to sort them in ascending order.
1381 *
1382 * @private
1383 * @param {*} value The value to compare.
1384 * @param {*} other The other value to compare.
1385 * @returns {number} Returns the sort order indicator for `value`.
1386 */
1387function compareAscending(value, other) {
1388 if (value !== other) {
1389 var valIsDefined = value !== undefined,
1390 valIsNull = value === null,
1391 valIsReflexive = value === value,
1392 valIsSymbol = isSymbol(value);
1393
1394 var othIsDefined = other !== undefined,
1395 othIsNull = other === null,
1396 othIsReflexive = other === other,
1397 othIsSymbol = isSymbol(other);
1398
1399 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
1400 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
1401 (valIsNull && othIsDefined && othIsReflexive) ||
1402 (!valIsDefined && othIsReflexive) ||
1403 !valIsReflexive) {
1404 return 1;
1405 }
1406 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
1407 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
1408 (othIsNull && valIsDefined && valIsReflexive) ||
1409 (!othIsDefined && valIsReflexive) ||
1410 !othIsReflexive) {
1411 return -1;
1412 }
1413 }
1414 return 0;
1415}
1416
1417/**
1418 * Used by `_.orderBy` to compare multiple properties of a value to another
1419 * and stable sort them.
1420 *
1421 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
1422 * specify an order of "desc" for descending or "asc" for ascending sort order
1423 * of corresponding values.
1424 *
1425 * @private
1426 * @param {Object} object The object to compare.
1427 * @param {Object} other The other object to compare.
1428 * @param {boolean[]|string[]} orders The order to sort by for each property.
1429 * @returns {number} Returns the sort order indicator for `object`.
1430 */
1431function compareMultiple(object, other, orders) {
1432 var index = -1,
1433 objCriteria = object.criteria,
1434 othCriteria = other.criteria,
1435 length = objCriteria.length,
1436 ordersLength = orders.length;
1437
1438 while (++index < length) {
1439 var result = compareAscending(objCriteria[index], othCriteria[index]);
1440 if (result) {
1441 if (index >= ordersLength) {
1442 return result;
1443 }
1444 var order = orders[index];
1445 return result * (order == 'desc' ? -1 : 1);
1446 }
1447 }
1448 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
1449 // that causes it, under certain circumstances, to provide the same value for
1450 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
1451 // for more details.
1452 //
1453 // This also ensures a stable sort in V8 and other engines.
1454 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
1455 return object.index - other.index;
1456}
1457
1458/**
1459 * Creates a `baseEach` or `baseEachRight` function.
1460 *
1461 * @private
1462 * @param {Function} eachFunc The function to iterate over a collection.
1463 * @param {boolean} [fromRight] Specify iterating from right to left.
1464 * @returns {Function} Returns the new base function.
1465 */
1466function createBaseEach(eachFunc, fromRight) {
1467 return function(collection, iteratee) {
1468 if (collection == null) {
1469 return collection;
1470 }
1471 if (!isArrayLike(collection)) {
1472 return eachFunc(collection, iteratee);
1473 }
1474 var length = collection.length,
1475 index = fromRight ? length : -1,
1476 iterable = Object(collection);
1477
1478 while ((fromRight ? index-- : ++index < length)) {
1479 if (iteratee(iterable[index], index, iterable) === false) {
1480 break;
1481 }
1482 }
1483 return collection;
1484 };
1485}
1486
1487/**
1488 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1489 *
1490 * @private
1491 * @param {boolean} [fromRight] Specify iterating from right to left.
1492 * @returns {Function} Returns the new base function.
1493 */
1494function createBaseFor(fromRight) {
1495 return function(object, iteratee, keysFunc) {
1496 var index = -1,
1497 iterable = Object(object),
1498 props = keysFunc(object),
1499 length = props.length;
1500
1501 while (length--) {
1502 var key = props[fromRight ? length : ++index];
1503 if (iteratee(iterable[key], key, iterable) === false) {
1504 break;
1505 }
1506 }
1507 return object;
1508 };
1509}
1510
1511/**
1512 * A specialized version of `baseIsEqualDeep` for arrays with support for
1513 * partial deep comparisons.
1514 *
1515 * @private
1516 * @param {Array} array The array to compare.
1517 * @param {Array} other The other array to compare.
1518 * @param {Function} equalFunc The function to determine equivalents of values.
1519 * @param {Function} customizer The function to customize comparisons.
1520 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1521 * for more details.
1522 * @param {Object} stack Tracks traversed `array` and `other` objects.
1523 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1524 */
1525function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
1526 var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1527 arrLength = array.length,
1528 othLength = other.length;
1529
1530 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1531 return false;
1532 }
1533 // Assume cyclic values are equal.
1534 var stacked = stack.get(array);
1535 if (stacked && stack.get(other)) {
1536 return stacked == other;
1537 }
1538 var index = -1,
1539 result = true,
1540 seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
1541
1542 stack.set(array, other);
1543 stack.set(other, array);
1544
1545 // Ignore non-index properties.
1546 while (++index < arrLength) {
1547 var arrValue = array[index],
1548 othValue = other[index];
1549
1550 if (customizer) {
1551 var compared = isPartial
1552 ? customizer(othValue, arrValue, index, other, array, stack)
1553 : customizer(arrValue, othValue, index, array, other, stack);
1554 }
1555 if (compared !== undefined) {
1556 if (compared) {
1557 continue;
1558 }
1559 result = false;
1560 break;
1561 }
1562 // Recursively compare arrays (susceptible to call stack limits).
1563 if (seen) {
1564 if (!arraySome(other, function(othValue, othIndex) {
1565 if (!seen.has(othIndex) &&
1566 (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
1567 return seen.add(othIndex);
1568 }
1569 })) {
1570 result = false;
1571 break;
1572 }
1573 } else if (!(
1574 arrValue === othValue ||
1575 equalFunc(arrValue, othValue, customizer, bitmask, stack)
1576 )) {
1577 result = false;
1578 break;
1579 }
1580 }
1581 stack['delete'](array);
1582 stack['delete'](other);
1583 return result;
1584}
1585
1586/**
1587 * A specialized version of `baseIsEqualDeep` for comparing objects of
1588 * the same `toStringTag`.
1589 *
1590 * **Note:** This function only supports comparing values with tags of
1591 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1592 *
1593 * @private
1594 * @param {Object} object The object to compare.
1595 * @param {Object} other The other object to compare.
1596 * @param {string} tag The `toStringTag` of the objects to compare.
1597 * @param {Function} equalFunc The function to determine equivalents of values.
1598 * @param {Function} customizer The function to customize comparisons.
1599 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1600 * for more details.
1601 * @param {Object} stack Tracks traversed `object` and `other` objects.
1602 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1603 */
1604function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
1605 switch (tag) {
1606 case dataViewTag:
1607 if ((object.byteLength != other.byteLength) ||
1608 (object.byteOffset != other.byteOffset)) {
1609 return false;
1610 }
1611 object = object.buffer;
1612 other = other.buffer;
1613
1614 case arrayBufferTag:
1615 if ((object.byteLength != other.byteLength) ||
1616 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1617 return false;
1618 }
1619 return true;
1620
1621 case boolTag:
1622 case dateTag:
1623 case numberTag:
1624 // Coerce booleans to `1` or `0` and dates to milliseconds.
1625 // Invalid dates are coerced to `NaN`.
1626 return eq(+object, +other);
1627
1628 case errorTag:
1629 return object.name == other.name && object.message == other.message;
1630
1631 case regexpTag:
1632 case stringTag:
1633 // Coerce regexes to strings and treat strings, primitives and objects,
1634 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1635 // for more details.
1636 return object == (other + '');
1637
1638 case mapTag:
1639 var convert = mapToArray;
1640
1641 case setTag:
1642 var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
1643 convert || (convert = setToArray);
1644
1645 if (object.size != other.size && !isPartial) {
1646 return false;
1647 }
1648 // Assume cyclic values are equal.
1649 var stacked = stack.get(object);
1650 if (stacked) {
1651 return stacked == other;
1652 }
1653 bitmask |= UNORDERED_COMPARE_FLAG;
1654
1655 // Recursively compare objects (susceptible to call stack limits).
1656 stack.set(object, other);
1657 var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
1658 stack['delete'](object);
1659 return result;
1660
1661 case symbolTag:
1662 if (symbolValueOf) {
1663 return symbolValueOf.call(object) == symbolValueOf.call(other);
1664 }
1665 }
1666 return false;
1667}
1668
1669/**
1670 * A specialized version of `baseIsEqualDeep` for objects with support for
1671 * partial deep comparisons.
1672 *
1673 * @private
1674 * @param {Object} object The object to compare.
1675 * @param {Object} other The other object to compare.
1676 * @param {Function} equalFunc The function to determine equivalents of values.
1677 * @param {Function} customizer The function to customize comparisons.
1678 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1679 * for more details.
1680 * @param {Object} stack Tracks traversed `object` and `other` objects.
1681 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1682 */
1683function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
1684 var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1685 objProps = keys(object),
1686 objLength = objProps.length,
1687 othProps = keys(other),
1688 othLength = othProps.length;
1689
1690 if (objLength != othLength && !isPartial) {
1691 return false;
1692 }
1693 var index = objLength;
1694 while (index--) {
1695 var key = objProps[index];
1696 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1697 return false;
1698 }
1699 }
1700 // Assume cyclic values are equal.
1701 var stacked = stack.get(object);
1702 if (stacked && stack.get(other)) {
1703 return stacked == other;
1704 }
1705 var result = true;
1706 stack.set(object, other);
1707 stack.set(other, object);
1708
1709 var skipCtor = isPartial;
1710 while (++index < objLength) {
1711 key = objProps[index];
1712 var objValue = object[key],
1713 othValue = other[key];
1714
1715 if (customizer) {
1716 var compared = isPartial
1717 ? customizer(othValue, objValue, key, other, object, stack)
1718 : customizer(objValue, othValue, key, object, other, stack);
1719 }
1720 // Recursively compare objects (susceptible to call stack limits).
1721 if (!(compared === undefined
1722 ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
1723 : compared
1724 )) {
1725 result = false;
1726 break;
1727 }
1728 skipCtor || (skipCtor = key == 'constructor');
1729 }
1730 if (result && !skipCtor) {
1731 var objCtor = object.constructor,
1732 othCtor = other.constructor;
1733
1734 // Non `Object` object instances with different constructors are not equal.
1735 if (objCtor != othCtor &&
1736 ('constructor' in object && 'constructor' in other) &&
1737 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1738 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1739 result = false;
1740 }
1741 }
1742 stack['delete'](object);
1743 stack['delete'](other);
1744 return result;
1745}
1746
1747/**
1748 * Gets the data for `map`.
1749 *
1750 * @private
1751 * @param {Object} map The map to query.
1752 * @param {string} key The reference key.
1753 * @returns {*} Returns the map data.
1754 */
1755function getMapData(map, key) {
1756 var data = map.__data__;
1757 return isKeyable(key)
1758 ? data[typeof key == 'string' ? 'string' : 'hash']
1759 : data.map;
1760}
1761
1762/**
1763 * Gets the property names, values, and compare flags of `object`.
1764 *
1765 * @private
1766 * @param {Object} object The object to query.
1767 * @returns {Array} Returns the match data of `object`.
1768 */
1769function getMatchData(object) {
1770 var result = keys(object),
1771 length = result.length;
1772
1773 while (length--) {
1774 var key = result[length],
1775 value = object[key];
1776
1777 result[length] = [key, value, isStrictComparable(value)];
1778 }
1779 return result;
1780}
1781
1782/**
1783 * Gets the native function at `key` of `object`.
1784 *
1785 * @private
1786 * @param {Object} object The object to query.
1787 * @param {string} key The key of the method to get.
1788 * @returns {*} Returns the function if it's native, else `undefined`.
1789 */
1790function getNative(object, key) {
1791 var value = getValue(object, key);
1792 return baseIsNative(value) ? value : undefined;
1793}
1794
1795/**
1796 * Gets the `toStringTag` of `value`.
1797 *
1798 * @private
1799 * @param {*} value The value to query.
1800 * @returns {string} Returns the `toStringTag`.
1801 */
1802var getTag = baseGetTag;
1803
1804// Fallback for data views, maps, sets, and weak maps in IE 11,
1805// for data views in Edge < 14, and promises in Node.js.
1806if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1807 (Map && getTag(new Map) != mapTag) ||
1808 (Promise && getTag(Promise.resolve()) != promiseTag) ||
1809 (Set && getTag(new Set) != setTag) ||
1810 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1811 getTag = function(value) {
1812 var result = objectToString.call(value),
1813 Ctor = result == objectTag ? value.constructor : undefined,
1814 ctorString = Ctor ? toSource(Ctor) : undefined;
1815
1816 if (ctorString) {
1817 switch (ctorString) {
1818 case dataViewCtorString: return dataViewTag;
1819 case mapCtorString: return mapTag;
1820 case promiseCtorString: return promiseTag;
1821 case setCtorString: return setTag;
1822 case weakMapCtorString: return weakMapTag;
1823 }
1824 }
1825 return result;
1826 };
1827}
1828
1829/**
1830 * Checks if `path` exists on `object`.
1831 *
1832 * @private
1833 * @param {Object} object The object to query.
1834 * @param {Array|string} path The path to check.
1835 * @param {Function} hasFunc The function to check properties.
1836 * @returns {boolean} Returns `true` if `path` exists, else `false`.
1837 */
1838function hasPath(object, path, hasFunc) {
1839 path = isKey(path, object) ? [path] : castPath(path);
1840
1841 var result,
1842 index = -1,
1843 length = path.length;
1844
1845 while (++index < length) {
1846 var key = toKey(path[index]);
1847 if (!(result = object != null && hasFunc(object, key))) {
1848 break;
1849 }
1850 object = object[key];
1851 }
1852 if (result) {
1853 return result;
1854 }
1855 var length = object ? object.length : 0;
1856 return !!length && isLength(length) && isIndex(key, length) &&
1857 (isArray(object) || isArguments(object));
1858}
1859
1860/**
1861 * Checks if `value` is a flattenable `arguments` object or array.
1862 *
1863 * @private
1864 * @param {*} value The value to check.
1865 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1866 */
1867function isFlattenable(value) {
1868 return isArray(value) || isArguments(value) ||
1869 !!(spreadableSymbol && value && value[spreadableSymbol]);
1870}
1871
1872/**
1873 * Checks if `value` is a valid array-like index.
1874 *
1875 * @private
1876 * @param {*} value The value to check.
1877 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1878 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1879 */
1880function isIndex(value, length) {
1881 length = length == null ? MAX_SAFE_INTEGER : length;
1882 return !!length &&
1883 (typeof value == 'number' || reIsUint.test(value)) &&
1884 (value > -1 && value % 1 == 0 && value < length);
1885}
1886
1887/**
1888 * Checks if the given arguments are from an iteratee call.
1889 *
1890 * @private
1891 * @param {*} value The potential iteratee value argument.
1892 * @param {*} index The potential iteratee index or key argument.
1893 * @param {*} object The potential iteratee object argument.
1894 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1895 * else `false`.
1896 */
1897function isIterateeCall(value, index, object) {
1898 if (!isObject(object)) {
1899 return false;
1900 }
1901 var type = typeof index;
1902 if (type == 'number'
1903 ? (isArrayLike(object) && isIndex(index, object.length))
1904 : (type == 'string' && index in object)
1905 ) {
1906 return eq(object[index], value);
1907 }
1908 return false;
1909}
1910
1911/**
1912 * Checks if `value` is a property name and not a property path.
1913 *
1914 * @private
1915 * @param {*} value The value to check.
1916 * @param {Object} [object] The object to query keys on.
1917 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1918 */
1919function isKey(value, object) {
1920 if (isArray(value)) {
1921 return false;
1922 }
1923 var type = typeof value;
1924 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1925 value == null || isSymbol(value)) {
1926 return true;
1927 }
1928 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1929 (object != null && value in Object(object));
1930}
1931
1932/**
1933 * Checks if `value` is suitable for use as unique object key.
1934 *
1935 * @private
1936 * @param {*} value The value to check.
1937 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1938 */
1939function isKeyable(value) {
1940 var type = typeof value;
1941 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1942 ? (value !== '__proto__')
1943 : (value === null);
1944}
1945
1946/**
1947 * Checks if `func` has its source masked.
1948 *
1949 * @private
1950 * @param {Function} func The function to check.
1951 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1952 */
1953function isMasked(func) {
1954 return !!maskSrcKey && (maskSrcKey in func);
1955}
1956
1957/**
1958 * Checks if `value` is likely a prototype object.
1959 *
1960 * @private
1961 * @param {*} value The value to check.
1962 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1963 */
1964function isPrototype(value) {
1965 var Ctor = value && value.constructor,
1966 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1967
1968 return value === proto;
1969}
1970
1971/**
1972 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
1973 *
1974 * @private
1975 * @param {*} value The value to check.
1976 * @returns {boolean} Returns `true` if `value` if suitable for strict
1977 * equality comparisons, else `false`.
1978 */
1979function isStrictComparable(value) {
1980 return value === value && !isObject(value);
1981}
1982
1983/**
1984 * A specialized version of `matchesProperty` for source values suitable
1985 * for strict equality comparisons, i.e. `===`.
1986 *
1987 * @private
1988 * @param {string} key The key of the property to get.
1989 * @param {*} srcValue The value to match.
1990 * @returns {Function} Returns the new spec function.
1991 */
1992function matchesStrictComparable(key, srcValue) {
1993 return function(object) {
1994 if (object == null) {
1995 return false;
1996 }
1997 return object[key] === srcValue &&
1998 (srcValue !== undefined || (key in Object(object)));
1999 };
2000}
2001
2002/**
2003 * Converts `string` to a property path array.
2004 *
2005 * @private
2006 * @param {string} string The string to convert.
2007 * @returns {Array} Returns the property path array.
2008 */
2009var stringToPath = memoize(function(string) {
2010 string = toString(string);
2011
2012 var result = [];
2013 if (reLeadingDot.test(string)) {
2014 result.push('');
2015 }
2016 string.replace(rePropName, function(match, number, quote, string) {
2017 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
2018 });
2019 return result;
2020});
2021
2022/**
2023 * Converts `value` to a string key if it's not a string or symbol.
2024 *
2025 * @private
2026 * @param {*} value The value to inspect.
2027 * @returns {string|symbol} Returns the key.
2028 */
2029function toKey(value) {
2030 if (typeof value == 'string' || isSymbol(value)) {
2031 return value;
2032 }
2033 var result = (value + '');
2034 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
2035}
2036
2037/**
2038 * Converts `func` to its source code.
2039 *
2040 * @private
2041 * @param {Function} func The function to process.
2042 * @returns {string} Returns the source code.
2043 */
2044function toSource(func) {
2045 if (func != null) {
2046 try {
2047 return funcToString.call(func);
2048 } catch (e) {}
2049 try {
2050 return (func + '');
2051 } catch (e) {}
2052 }
2053 return '';
2054}
2055
2056/**
2057 * Creates an array of elements, sorted in ascending order by the results of
2058 * running each element in a collection thru each iteratee. This method
2059 * performs a stable sort, that is, it preserves the original sort order of
2060 * equal elements. The iteratees are invoked with one argument: (value).
2061 *
2062 * @static
2063 * @memberOf _
2064 * @since 0.1.0
2065 * @category Collection
2066 * @param {Array|Object} collection The collection to iterate over.
2067 * @param {...(Function|Function[])} [iteratees=[_.identity]]
2068 * The iteratees to sort by.
2069 * @returns {Array} Returns the new sorted array.
2070 * @example
2071 *
2072 * var users = [
2073 * { 'user': 'fred', 'age': 48 },
2074 * { 'user': 'barney', 'age': 36 },
2075 * { 'user': 'fred', 'age': 40 },
2076 * { 'user': 'barney', 'age': 34 }
2077 * ];
2078 *
2079 * _.sortBy(users, function(o) { return o.user; });
2080 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2081 *
2082 * _.sortBy(users, ['user', 'age']);
2083 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
2084 *
2085 * _.sortBy(users, 'user', function(o) {
2086 * return Math.floor(o.age / 10);
2087 * });
2088 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2089 */
2090var sortBy = baseRest(function(collection, iteratees) {
2091 if (collection == null) {
2092 return [];
2093 }
2094 var length = iteratees.length;
2095 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
2096 iteratees = [];
2097 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
2098 iteratees = [iteratees[0]];
2099 }
2100 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
2101});
2102
2103/**
2104 * Creates a function that memoizes the result of `func`. If `resolver` is
2105 * provided, it determines the cache key for storing the result based on the
2106 * arguments provided to the memoized function. By default, the first argument
2107 * provided to the memoized function is used as the map cache key. The `func`
2108 * is invoked with the `this` binding of the memoized function.
2109 *
2110 * **Note:** The cache is exposed as the `cache` property on the memoized
2111 * function. Its creation may be customized by replacing the `_.memoize.Cache`
2112 * constructor with one whose instances implement the
2113 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
2114 * method interface of `delete`, `get`, `has`, and `set`.
2115 *
2116 * @static
2117 * @memberOf _
2118 * @since 0.1.0
2119 * @category Function
2120 * @param {Function} func The function to have its output memoized.
2121 * @param {Function} [resolver] The function to resolve the cache key.
2122 * @returns {Function} Returns the new memoized function.
2123 * @example
2124 *
2125 * var object = { 'a': 1, 'b': 2 };
2126 * var other = { 'c': 3, 'd': 4 };
2127 *
2128 * var values = _.memoize(_.values);
2129 * values(object);
2130 * // => [1, 2]
2131 *
2132 * values(other);
2133 * // => [3, 4]
2134 *
2135 * object.a = 2;
2136 * values(object);
2137 * // => [1, 2]
2138 *
2139 * // Modify the result cache.
2140 * values.cache.set(object, ['a', 'b']);
2141 * values(object);
2142 * // => ['a', 'b']
2143 *
2144 * // Replace `_.memoize.Cache`.
2145 * _.memoize.Cache = WeakMap;
2146 */
2147function memoize(func, resolver) {
2148 if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
2149 throw new TypeError(FUNC_ERROR_TEXT);
2150 }
2151 var memoized = function() {
2152 var args = arguments,
2153 key = resolver ? resolver.apply(this, args) : args[0],
2154 cache = memoized.cache;
2155
2156 if (cache.has(key)) {
2157 return cache.get(key);
2158 }
2159 var result = func.apply(this, args);
2160 memoized.cache = cache.set(key, result);
2161 return result;
2162 };
2163 memoized.cache = new (memoize.Cache || MapCache);
2164 return memoized;
2165}
2166
2167// Assign cache to `_.memoize`.
2168memoize.Cache = MapCache;
2169
2170/**
2171 * Performs a
2172 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2173 * comparison between two values to determine if they are equivalent.
2174 *
2175 * @static
2176 * @memberOf _
2177 * @since 4.0.0
2178 * @category Lang
2179 * @param {*} value The value to compare.
2180 * @param {*} other The other value to compare.
2181 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2182 * @example
2183 *
2184 * var object = { 'a': 1 };
2185 * var other = { 'a': 1 };
2186 *
2187 * _.eq(object, object);
2188 * // => true
2189 *
2190 * _.eq(object, other);
2191 * // => false
2192 *
2193 * _.eq('a', 'a');
2194 * // => true
2195 *
2196 * _.eq('a', Object('a'));
2197 * // => false
2198 *
2199 * _.eq(NaN, NaN);
2200 * // => true
2201 */
2202function eq(value, other) {
2203 return value === other || (value !== value && other !== other);
2204}
2205
2206/**
2207 * Checks if `value` is likely an `arguments` object.
2208 *
2209 * @static
2210 * @memberOf _
2211 * @since 0.1.0
2212 * @category Lang
2213 * @param {*} value The value to check.
2214 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2215 * else `false`.
2216 * @example
2217 *
2218 * _.isArguments(function() { return arguments; }());
2219 * // => true
2220 *
2221 * _.isArguments([1, 2, 3]);
2222 * // => false
2223 */
2224function isArguments(value) {
2225 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
2226 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
2227 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
2228}
2229
2230/**
2231 * Checks if `value` is classified as an `Array` object.
2232 *
2233 * @static
2234 * @memberOf _
2235 * @since 0.1.0
2236 * @category Lang
2237 * @param {*} value The value to check.
2238 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2239 * @example
2240 *
2241 * _.isArray([1, 2, 3]);
2242 * // => true
2243 *
2244 * _.isArray(document.body.children);
2245 * // => false
2246 *
2247 * _.isArray('abc');
2248 * // => false
2249 *
2250 * _.isArray(_.noop);
2251 * // => false
2252 */
2253var isArray = Array.isArray;
2254
2255/**
2256 * Checks if `value` is array-like. A value is considered array-like if it's
2257 * not a function and has a `value.length` that's an integer greater than or
2258 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2259 *
2260 * @static
2261 * @memberOf _
2262 * @since 4.0.0
2263 * @category Lang
2264 * @param {*} value The value to check.
2265 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2266 * @example
2267 *
2268 * _.isArrayLike([1, 2, 3]);
2269 * // => true
2270 *
2271 * _.isArrayLike(document.body.children);
2272 * // => true
2273 *
2274 * _.isArrayLike('abc');
2275 * // => true
2276 *
2277 * _.isArrayLike(_.noop);
2278 * // => false
2279 */
2280function isArrayLike(value) {
2281 return value != null && isLength(value.length) && !isFunction(value);
2282}
2283
2284/**
2285 * This method is like `_.isArrayLike` except that it also checks if `value`
2286 * is an object.
2287 *
2288 * @static
2289 * @memberOf _
2290 * @since 4.0.0
2291 * @category Lang
2292 * @param {*} value The value to check.
2293 * @returns {boolean} Returns `true` if `value` is an array-like object,
2294 * else `false`.
2295 * @example
2296 *
2297 * _.isArrayLikeObject([1, 2, 3]);
2298 * // => true
2299 *
2300 * _.isArrayLikeObject(document.body.children);
2301 * // => true
2302 *
2303 * _.isArrayLikeObject('abc');
2304 * // => false
2305 *
2306 * _.isArrayLikeObject(_.noop);
2307 * // => false
2308 */
2309function isArrayLikeObject(value) {
2310 return isObjectLike(value) && isArrayLike(value);
2311}
2312
2313/**
2314 * Checks if `value` is classified as a `Function` object.
2315 *
2316 * @static
2317 * @memberOf _
2318 * @since 0.1.0
2319 * @category Lang
2320 * @param {*} value The value to check.
2321 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2322 * @example
2323 *
2324 * _.isFunction(_);
2325 * // => true
2326 *
2327 * _.isFunction(/abc/);
2328 * // => false
2329 */
2330function isFunction(value) {
2331 // The use of `Object#toString` avoids issues with the `typeof` operator
2332 // in Safari 8-9 which returns 'object' for typed array and other constructors.
2333 var tag = isObject(value) ? objectToString.call(value) : '';
2334 return tag == funcTag || tag == genTag;
2335}
2336
2337/**
2338 * Checks if `value` is a valid array-like length.
2339 *
2340 * **Note:** This method is loosely based on
2341 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2342 *
2343 * @static
2344 * @memberOf _
2345 * @since 4.0.0
2346 * @category Lang
2347 * @param {*} value The value to check.
2348 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2349 * @example
2350 *
2351 * _.isLength(3);
2352 * // => true
2353 *
2354 * _.isLength(Number.MIN_VALUE);
2355 * // => false
2356 *
2357 * _.isLength(Infinity);
2358 * // => false
2359 *
2360 * _.isLength('3');
2361 * // => false
2362 */
2363function isLength(value) {
2364 return typeof value == 'number' &&
2365 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2366}
2367
2368/**
2369 * Checks if `value` is the
2370 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2371 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2372 *
2373 * @static
2374 * @memberOf _
2375 * @since 0.1.0
2376 * @category Lang
2377 * @param {*} value The value to check.
2378 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2379 * @example
2380 *
2381 * _.isObject({});
2382 * // => true
2383 *
2384 * _.isObject([1, 2, 3]);
2385 * // => true
2386 *
2387 * _.isObject(_.noop);
2388 * // => true
2389 *
2390 * _.isObject(null);
2391 * // => false
2392 */
2393function isObject(value) {
2394 var type = typeof value;
2395 return !!value && (type == 'object' || type == 'function');
2396}
2397
2398/**
2399 * Checks if `value` is object-like. A value is object-like if it's not `null`
2400 * and has a `typeof` result of "object".
2401 *
2402 * @static
2403 * @memberOf _
2404 * @since 4.0.0
2405 * @category Lang
2406 * @param {*} value The value to check.
2407 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2408 * @example
2409 *
2410 * _.isObjectLike({});
2411 * // => true
2412 *
2413 * _.isObjectLike([1, 2, 3]);
2414 * // => true
2415 *
2416 * _.isObjectLike(_.noop);
2417 * // => false
2418 *
2419 * _.isObjectLike(null);
2420 * // => false
2421 */
2422function isObjectLike(value) {
2423 return !!value && typeof value == 'object';
2424}
2425
2426/**
2427 * Checks if `value` is classified as a `Symbol` primitive or object.
2428 *
2429 * @static
2430 * @memberOf _
2431 * @since 4.0.0
2432 * @category Lang
2433 * @param {*} value The value to check.
2434 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2435 * @example
2436 *
2437 * _.isSymbol(Symbol.iterator);
2438 * // => true
2439 *
2440 * _.isSymbol('abc');
2441 * // => false
2442 */
2443function isSymbol(value) {
2444 return typeof value == 'symbol' ||
2445 (isObjectLike(value) && objectToString.call(value) == symbolTag);
2446}
2447
2448/**
2449 * Checks if `value` is classified as a typed array.
2450 *
2451 * @static
2452 * @memberOf _
2453 * @since 3.0.0
2454 * @category Lang
2455 * @param {*} value The value to check.
2456 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2457 * @example
2458 *
2459 * _.isTypedArray(new Uint8Array);
2460 * // => true
2461 *
2462 * _.isTypedArray([]);
2463 * // => false
2464 */
2465var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2466
2467/**
2468 * Converts `value` to a string. An empty string is returned for `null`
2469 * and `undefined` values. The sign of `-0` is preserved.
2470 *
2471 * @static
2472 * @memberOf _
2473 * @since 4.0.0
2474 * @category Lang
2475 * @param {*} value The value to process.
2476 * @returns {string} Returns the string.
2477 * @example
2478 *
2479 * _.toString(null);
2480 * // => ''
2481 *
2482 * _.toString(-0);
2483 * // => '-0'
2484 *
2485 * _.toString([1, 2, 3]);
2486 * // => '1,2,3'
2487 */
2488function toString(value) {
2489 return value == null ? '' : baseToString(value);
2490}
2491
2492/**
2493 * Gets the value at `path` of `object`. If the resolved value is
2494 * `undefined`, the `defaultValue` is returned in its place.
2495 *
2496 * @static
2497 * @memberOf _
2498 * @since 3.7.0
2499 * @category Object
2500 * @param {Object} object The object to query.
2501 * @param {Array|string} path The path of the property to get.
2502 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
2503 * @returns {*} Returns the resolved value.
2504 * @example
2505 *
2506 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
2507 *
2508 * _.get(object, 'a[0].b.c');
2509 * // => 3
2510 *
2511 * _.get(object, ['a', '0', 'b', 'c']);
2512 * // => 3
2513 *
2514 * _.get(object, 'a.b.c', 'default');
2515 * // => 'default'
2516 */
2517function get(object, path, defaultValue) {
2518 var result = object == null ? undefined : baseGet(object, path);
2519 return result === undefined ? defaultValue : result;
2520}
2521
2522/**
2523 * Checks if `path` is a direct or inherited property of `object`.
2524 *
2525 * @static
2526 * @memberOf _
2527 * @since 4.0.0
2528 * @category Object
2529 * @param {Object} object The object to query.
2530 * @param {Array|string} path The path to check.
2531 * @returns {boolean} Returns `true` if `path` exists, else `false`.
2532 * @example
2533 *
2534 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
2535 *
2536 * _.hasIn(object, 'a');
2537 * // => true
2538 *
2539 * _.hasIn(object, 'a.b');
2540 * // => true
2541 *
2542 * _.hasIn(object, ['a', 'b']);
2543 * // => true
2544 *
2545 * _.hasIn(object, 'b');
2546 * // => false
2547 */
2548function hasIn(object, path) {
2549 return object != null && hasPath(object, path, baseHasIn);
2550}
2551
2552/**
2553 * Creates an array of the own enumerable property names of `object`.
2554 *
2555 * **Note:** Non-object values are coerced to objects. See the
2556 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2557 * for more details.
2558 *
2559 * @static
2560 * @since 0.1.0
2561 * @memberOf _
2562 * @category Object
2563 * @param {Object} object The object to query.
2564 * @returns {Array} Returns the array of property names.
2565 * @example
2566 *
2567 * function Foo() {
2568 * this.a = 1;
2569 * this.b = 2;
2570 * }
2571 *
2572 * Foo.prototype.c = 3;
2573 *
2574 * _.keys(new Foo);
2575 * // => ['a', 'b'] (iteration order is not guaranteed)
2576 *
2577 * _.keys('hi');
2578 * // => ['0', '1']
2579 */
2580function keys(object) {
2581 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2582}
2583
2584/**
2585 * This method returns the first argument it receives.
2586 *
2587 * @static
2588 * @since 0.1.0
2589 * @memberOf _
2590 * @category Util
2591 * @param {*} value Any value.
2592 * @returns {*} Returns `value`.
2593 * @example
2594 *
2595 * var object = { 'a': 1 };
2596 *
2597 * console.log(_.identity(object) === object);
2598 * // => true
2599 */
2600function identity(value) {
2601 return value;
2602}
2603
2604/**
2605 * Creates a function that returns the value at `path` of a given object.
2606 *
2607 * @static
2608 * @memberOf _
2609 * @since 2.4.0
2610 * @category Util
2611 * @param {Array|string} path The path of the property to get.
2612 * @returns {Function} Returns the new accessor function.
2613 * @example
2614 *
2615 * var objects = [
2616 * { 'a': { 'b': 2 } },
2617 * { 'a': { 'b': 1 } }
2618 * ];
2619 *
2620 * _.map(objects, _.property('a.b'));
2621 * // => [2, 1]
2622 *
2623 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
2624 * // => [1, 2]
2625 */
2626function property(path) {
2627 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
2628}
2629
2630module.exports = sortBy;
Note: See TracBrowser for help on using the repository browser.