react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / index.js
80736 views/**1* @license2* lodash 3.9.3 (Custom Build) <https://lodash.com/>3* Build: `lodash modern -d -o ./index.js`4* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>5* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>6* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors7* Available under MIT license <https://lodash.com/license>8*/9;(function() {1011/** Used as a safe reference for `undefined` in pre-ES5 environments. */12var undefined;1314/** Used as the semantic version number. */15var VERSION = '3.9.3';1617/** Used to compose bitmasks for wrapper metadata. */18var BIND_FLAG = 1,19BIND_KEY_FLAG = 2,20CURRY_BOUND_FLAG = 4,21CURRY_FLAG = 8,22CURRY_RIGHT_FLAG = 16,23PARTIAL_FLAG = 32,24PARTIAL_RIGHT_FLAG = 64,25ARY_FLAG = 128,26REARG_FLAG = 256;2728/** Used as default options for `_.trunc`. */29var DEFAULT_TRUNC_LENGTH = 30,30DEFAULT_TRUNC_OMISSION = '...';3132/** Used to detect when a function becomes hot. */33var HOT_COUNT = 150,34HOT_SPAN = 16;3536/** Used to indicate the type of lazy iteratees. */37var LAZY_DROP_WHILE_FLAG = 0,38LAZY_FILTER_FLAG = 1,39LAZY_MAP_FLAG = 2;4041/** Used as the `TypeError` message for "Functions" methods. */42var FUNC_ERROR_TEXT = 'Expected a function';4344/** Used as the internal argument placeholder. */45var PLACEHOLDER = '__lodash_placeholder__';4647/** `Object#toString` result references. */48var argsTag = '[object Arguments]',49arrayTag = '[object Array]',50boolTag = '[object Boolean]',51dateTag = '[object Date]',52errorTag = '[object Error]',53funcTag = '[object Function]',54mapTag = '[object Map]',55numberTag = '[object Number]',56objectTag = '[object Object]',57regexpTag = '[object RegExp]',58setTag = '[object Set]',59stringTag = '[object String]',60weakMapTag = '[object WeakMap]';6162var arrayBufferTag = '[object ArrayBuffer]',63float32Tag = '[object Float32Array]',64float64Tag = '[object Float64Array]',65int8Tag = '[object Int8Array]',66int16Tag = '[object Int16Array]',67int32Tag = '[object Int32Array]',68uint8Tag = '[object Uint8Array]',69uint8ClampedTag = '[object Uint8ClampedArray]',70uint16Tag = '[object Uint16Array]',71uint32Tag = '[object Uint32Array]';7273/** Used to match empty string literals in compiled template source. */74var reEmptyStringLeading = /\b__p \+= '';/g,75reEmptyStringMiddle = /\b(__p \+=) '' \+/g,76reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;7778/** Used to match HTML entities and HTML characters. */79var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,80reUnescapedHtml = /[&<>"'`]/g,81reHasEscapedHtml = RegExp(reEscapedHtml.source),82reHasUnescapedHtml = RegExp(reUnescapedHtml.source);8384/** Used to match template delimiters. */85var reEscape = /<%-([\s\S]+?)%>/g,86reEvaluate = /<%([\s\S]+?)%>/g,87reInterpolate = /<%=([\s\S]+?)%>/g;8889/** Used to match property names within property paths. */90var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,91reIsPlainProp = /^\w*$/,92rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;9394/**95* Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).96* In addition to special characters the forward slash is escaped to allow for97* easier `eval` use and `Function` compilation.98*/99var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,100reHasRegExpChars = RegExp(reRegExpChars.source);101102/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */103var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g;104105/** Used to match backslashes in property paths. */106var reEscapeChar = /\\(\\)?/g;107108/** Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */109var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;110111/** Used to match `RegExp` flags from their coerced string values. */112var reFlags = /\w*$/;113114/** Used to detect hexadecimal string values. */115var reHasHexPrefix = /^0[xX]/;116117/** Used to detect host constructors (Safari > 5). */118var reIsHostCtor = /^\[object .+?Constructor\]$/;119120/** Used to detect unsigned integer values. */121var reIsUint = /^\d+$/;122123/** Used to match latin-1 supplementary letters (excluding mathematical operators). */124var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;125126/** Used to ensure capturing order of template delimiters. */127var reNoMatch = /($^)/;128129/** Used to match unescaped characters in compiled string literals. */130var reUnescapedString = /['\n\r\u2028\u2029\\]/g;131132/** Used to match words to create compound words. */133var reWords = (function() {134var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]',135lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';136137return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');138}());139140/** Used to detect and test for whitespace. */141var whitespace = (142// Basic whitespace characters.143' \t\x0b\f\xa0\ufeff' +144145// Line terminators.146'\n\r\u2028\u2029' +147148// Unicode category "Zs" space separators.149'\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'150);151152/** Used to assign default `context` object properties. */153var contextProps = [154'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',155'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',156'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document',157'isFinite', 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',158'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 'window'159];160161/** Used to make template sourceURLs easier to identify. */162var templateCounter = -1;163164/** Used to identify `toStringTag` values of typed arrays. */165var typedArrayTags = {};166typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =167typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =168typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =169typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =170typedArrayTags[uint32Tag] = true;171typedArrayTags[argsTag] = typedArrayTags[arrayTag] =172typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =173typedArrayTags[dateTag] = typedArrayTags[errorTag] =174typedArrayTags[funcTag] = typedArrayTags[mapTag] =175typedArrayTags[numberTag] = typedArrayTags[objectTag] =176typedArrayTags[regexpTag] = typedArrayTags[setTag] =177typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;178179/** Used to identify `toStringTag` values supported by `_.clone`. */180var cloneableTags = {};181cloneableTags[argsTag] = cloneableTags[arrayTag] =182cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =183cloneableTags[dateTag] = cloneableTags[float32Tag] =184cloneableTags[float64Tag] = cloneableTags[int8Tag] =185cloneableTags[int16Tag] = cloneableTags[int32Tag] =186cloneableTags[numberTag] = cloneableTags[objectTag] =187cloneableTags[regexpTag] = cloneableTags[stringTag] =188cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =189cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;190cloneableTags[errorTag] = cloneableTags[funcTag] =191cloneableTags[mapTag] = cloneableTags[setTag] =192cloneableTags[weakMapTag] = false;193194/** Used as an internal `_.debounce` options object by `_.throttle`. */195var debounceOptions = {196'leading': false,197'maxWait': 0,198'trailing': false199};200201/** Used to map latin-1 supplementary letters to basic latin letters. */202var deburredLetters = {203'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',204'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',205'\xc7': 'C', '\xe7': 'c',206'\xd0': 'D', '\xf0': 'd',207'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',208'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',209'\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',210'\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',211'\xd1': 'N', '\xf1': 'n',212'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',213'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',214'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',215'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',216'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',217'\xc6': 'Ae', '\xe6': 'ae',218'\xde': 'Th', '\xfe': 'th',219'\xdf': 'ss'220};221222/** Used to map characters to HTML entities. */223var htmlEscapes = {224'&': '&',225'<': '<',226'>': '>',227'"': '"',228"'": ''',229'`': '`'230};231232/** Used to map HTML entities to characters. */233var htmlUnescapes = {234'&': '&',235'<': '<',236'>': '>',237'"': '"',238''': "'",239'`': '`'240};241242/** Used to determine if values are of the language type `Object`. */243var objectTypes = {244'function': true,245'object': true246};247248/** Used to escape characters for inclusion in compiled string literals. */249var stringEscapes = {250'\\': '\\',251"'": "'",252'\n': 'n',253'\r': 'r',254'\u2028': 'u2028',255'\u2029': 'u2029'256};257258/** Detect free variable `exports`. */259var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;260261/** Detect free variable `module`. */262var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;263264/** Detect free variable `global` from Node.js. */265var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;266267/** Detect free variable `self`. */268var freeSelf = objectTypes[typeof self] && self && self.Object && self;269270/** Detect free variable `window`. */271var freeWindow = objectTypes[typeof window] && window && window.Object && window;272273/** Detect the popular CommonJS extension `module.exports`. */274var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;275276/**277* Used as a reference to the global object.278*279* The `this` value is used if it's the global object to avoid Greasemonkey's280* restricted `window` object, otherwise the `window` object is used.281*/282var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;283284/*--------------------------------------------------------------------------*/285286/**287* The base implementation of `compareAscending` which compares values and288* sorts them in ascending order without guaranteeing a stable sort.289*290* @private291* @param {*} value The value to compare.292* @param {*} other The other value to compare.293* @returns {number} Returns the sort order indicator for `value`.294*/295function baseCompareAscending(value, other) {296if (value !== other) {297var valIsNull = value === null,298valIsUndef = value === undefined,299valIsReflexive = value === value;300301var othIsNull = other === null,302othIsUndef = other === undefined,303othIsReflexive = other === other;304305if ((value > other && !othIsNull) || !valIsReflexive ||306(valIsNull && !othIsUndef && othIsReflexive) ||307(valIsUndef && othIsReflexive)) {308return 1;309}310if ((value < other && !valIsNull) || !othIsReflexive ||311(othIsNull && !valIsUndef && valIsReflexive) ||312(othIsUndef && valIsReflexive)) {313return -1;314}315}316return 0;317}318319/**320* The base implementation of `_.findIndex` and `_.findLastIndex` without321* support for callback shorthands and `this` binding.322*323* @private324* @param {Array} array The array to search.325* @param {Function} predicate The function invoked per iteration.326* @param {boolean} [fromRight] Specify iterating from right to left.327* @returns {number} Returns the index of the matched value, else `-1`.328*/329function baseFindIndex(array, predicate, fromRight) {330var length = array.length,331index = fromRight ? length : -1;332333while ((fromRight ? index-- : ++index < length)) {334if (predicate(array[index], index, array)) {335return index;336}337}338return -1;339}340341/**342* The base implementation of `_.indexOf` without support for binary searches.343*344* @private345* @param {Array} array The array to search.346* @param {*} value The value to search for.347* @param {number} fromIndex The index to search from.348* @returns {number} Returns the index of the matched value, else `-1`.349*/350function baseIndexOf(array, value, fromIndex) {351if (value !== value) {352return indexOfNaN(array, fromIndex);353}354var index = fromIndex - 1,355length = array.length;356357while (++index < length) {358if (array[index] === value) {359return index;360}361}362return -1;363}364365/**366* The base implementation of `_.isFunction` without support for environments367* with incorrect `typeof` results.368*369* @private370* @param {*} value The value to check.371* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.372*/373function baseIsFunction(value) {374// Avoid a Chakra JIT bug in compatibility modes of IE 11.375// See https://github.com/jashkenas/underscore/issues/1621 for more details.376return typeof value == 'function' || false;377}378379/**380* Converts `value` to a string if it's not one. An empty string is returned381* for `null` or `undefined` values.382*383* @private384* @param {*} value The value to process.385* @returns {string} Returns the string.386*/387function baseToString(value) {388if (typeof value == 'string') {389return value;390}391return value == null ? '' : (value + '');392}393394/**395* Used by `_.trim` and `_.trimLeft` to get the index of the first character396* of `string` that is not found in `chars`.397*398* @private399* @param {string} string The string to inspect.400* @param {string} chars The characters to find.401* @returns {number} Returns the index of the first character not found in `chars`.402*/403function charsLeftIndex(string, chars) {404var index = -1,405length = string.length;406407while (++index < length && chars.indexOf(string.charAt(index)) > -1) {}408return index;409}410411/**412* Used by `_.trim` and `_.trimRight` to get the index of the last character413* of `string` that is not found in `chars`.414*415* @private416* @param {string} string The string to inspect.417* @param {string} chars The characters to find.418* @returns {number} Returns the index of the last character not found in `chars`.419*/420function charsRightIndex(string, chars) {421var index = string.length;422423while (index-- && chars.indexOf(string.charAt(index)) > -1) {}424return index;425}426427/**428* Used by `_.sortBy` to compare transformed elements of a collection and stable429* sort them in ascending order.430*431* @private432* @param {Object} object The object to compare to `other`.433* @param {Object} other The object to compare to `object`.434* @returns {number} Returns the sort order indicator for `object`.435*/436function compareAscending(object, other) {437return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);438}439440/**441* Used by `_.sortByOrder` to compare multiple properties of each element442* in a collection and stable sort them in the following order:443*444* If `orders` is unspecified, sort in ascending order for all properties.445* Otherwise, for each property, sort in ascending order if its corresponding value in446* orders is true, and descending order if false.447*448* @private449* @param {Object} object The object to compare to `other`.450* @param {Object} other The object to compare to `object`.451* @param {boolean[]} orders The order to sort by for each property.452* @returns {number} Returns the sort order indicator for `object`.453*/454function compareMultiple(object, other, orders) {455var index = -1,456objCriteria = object.criteria,457othCriteria = other.criteria,458length = objCriteria.length,459ordersLength = orders.length;460461while (++index < length) {462var result = baseCompareAscending(objCriteria[index], othCriteria[index]);463if (result) {464if (index >= ordersLength) {465return result;466}467return result * (orders[index] ? 1 : -1);468}469}470// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications471// that causes it, under certain circumstances, to provide the same value for472// `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247473// for more details.474//475// This also ensures a stable sort in V8 and other engines.476// See https://code.google.com/p/v8/issues/detail?id=90 for more details.477return object.index - other.index;478}479480/**481* Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.482*483* @private484* @param {string} letter The matched letter to deburr.485* @returns {string} Returns the deburred letter.486*/487function deburrLetter(letter) {488return deburredLetters[letter];489}490491/**492* Used by `_.escape` to convert characters to HTML entities.493*494* @private495* @param {string} chr The matched character to escape.496* @returns {string} Returns the escaped character.497*/498function escapeHtmlChar(chr) {499return htmlEscapes[chr];500}501502/**503* Used by `_.template` to escape characters for inclusion in compiled504* string literals.505*506* @private507* @param {string} chr The matched character to escape.508* @returns {string} Returns the escaped character.509*/510function escapeStringChar(chr) {511return '\\' + stringEscapes[chr];512}513514/**515* Gets the index at which the first occurrence of `NaN` is found in `array`.516*517* @private518* @param {Array} array The array to search.519* @param {number} fromIndex The index to search from.520* @param {boolean} [fromRight] Specify iterating from right to left.521* @returns {number} Returns the index of the matched `NaN`, else `-1`.522*/523function indexOfNaN(array, fromIndex, fromRight) {524var length = array.length,525index = fromIndex + (fromRight ? 0 : -1);526527while ((fromRight ? index-- : ++index < length)) {528var other = array[index];529if (other !== other) {530return index;531}532}533return -1;534}535536/**537* Checks if `value` is object-like.538*539* @private540* @param {*} value The value to check.541* @returns {boolean} Returns `true` if `value` is object-like, else `false`.542*/543function isObjectLike(value) {544return !!value && typeof value == 'object';545}546547/**548* Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a549* character code is whitespace.550*551* @private552* @param {number} charCode The character code to inspect.553* @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.554*/555function isSpace(charCode) {556return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||557(charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));558}559560/**561* Replaces all `placeholder` elements in `array` with an internal placeholder562* and returns an array of their indexes.563*564* @private565* @param {Array} array The array to modify.566* @param {*} placeholder The placeholder to replace.567* @returns {Array} Returns the new array of placeholder indexes.568*/569function replaceHolders(array, placeholder) {570var index = -1,571length = array.length,572resIndex = -1,573result = [];574575while (++index < length) {576if (array[index] === placeholder) {577array[index] = PLACEHOLDER;578result[++resIndex] = index;579}580}581return result;582}583584/**585* An implementation of `_.uniq` optimized for sorted arrays without support586* for callback shorthands and `this` binding.587*588* @private589* @param {Array} array The array to inspect.590* @param {Function} [iteratee] The function invoked per iteration.591* @returns {Array} Returns the new duplicate-value-free array.592*/593function sortedUniq(array, iteratee) {594var seen,595index = -1,596length = array.length,597resIndex = -1,598result = [];599600while (++index < length) {601var value = array[index],602computed = iteratee ? iteratee(value, index, array) : value;603604if (!index || seen !== computed) {605seen = computed;606result[++resIndex] = value;607}608}609return result;610}611612/**613* Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace614* character of `string`.615*616* @private617* @param {string} string The string to inspect.618* @returns {number} Returns the index of the first non-whitespace character.619*/620function trimmedLeftIndex(string) {621var index = -1,622length = string.length;623624while (++index < length && isSpace(string.charCodeAt(index))) {}625return index;626}627628/**629* Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace630* character of `string`.631*632* @private633* @param {string} string The string to inspect.634* @returns {number} Returns the index of the last non-whitespace character.635*/636function trimmedRightIndex(string) {637var index = string.length;638639while (index-- && isSpace(string.charCodeAt(index))) {}640return index;641}642643/**644* Used by `_.unescape` to convert HTML entities to characters.645*646* @private647* @param {string} chr The matched character to unescape.648* @returns {string} Returns the unescaped character.649*/650function unescapeHtmlChar(chr) {651return htmlUnescapes[chr];652}653654/*--------------------------------------------------------------------------*/655656/**657* Create a new pristine `lodash` function using the given `context` object.658*659* @static660* @memberOf _661* @category Utility662* @param {Object} [context=root] The context object.663* @returns {Function} Returns a new `lodash` function.664* @example665*666* _.mixin({ 'foo': _.constant('foo') });667*668* var lodash = _.runInContext();669* lodash.mixin({ 'bar': lodash.constant('bar') });670*671* _.isFunction(_.foo);672* // => true673* _.isFunction(_.bar);674* // => false675*676* lodash.isFunction(lodash.foo);677* // => false678* lodash.isFunction(lodash.bar);679* // => true680*681* // using `context` to mock `Date#getTime` use in `_.now`682* var mock = _.runInContext({683* 'Date': function() {684* return { 'getTime': getTimeMock };685* }686* });687*688* // or creating a suped-up `defer` in Node.js689* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;690*/691function runInContext(context) {692// Avoid issues with some ES3 environments that attempt to use values, named693// after built-in constructors like `Object`, for the creation of literals.694// ES5 clears this up by stating that literals must use built-in constructors.695// See https://es5.github.io/#x11.1.5 for more details.696context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;697698/** Native constructor references. */699var Array = context.Array,700Date = context.Date,701Error = context.Error,702Function = context.Function,703Math = context.Math,704Number = context.Number,705Object = context.Object,706RegExp = context.RegExp,707String = context.String,708TypeError = context.TypeError;709710/** Used for native method references. */711var arrayProto = Array.prototype,712objectProto = Object.prototype,713stringProto = String.prototype;714715/** Used to detect DOM support. */716var document = (document = context.window) ? document.document : null;717718/** Used to resolve the decompiled source of functions. */719var fnToString = Function.prototype.toString;720721/** Used to check objects for own properties. */722var hasOwnProperty = objectProto.hasOwnProperty;723724/** Used to generate unique IDs. */725var idCounter = 0;726727/**728* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)729* of values.730*/731var objToString = objectProto.toString;732733/** Used to restore the original `_` reference in `_.noConflict`. */734var oldDash = context._;735736/** Used to detect if a method is native. */737var reIsNative = RegExp('^' +738escapeRegExp(fnToString.call(hasOwnProperty))739.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'740);741742/** Native method references. */743var ArrayBuffer = getNative(context, 'ArrayBuffer'),744bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'),745ceil = Math.ceil,746clearTimeout = context.clearTimeout,747floor = Math.floor,748getPrototypeOf = getNative(Object, 'getPrototypeOf'),749parseFloat = context.parseFloat,750push = arrayProto.push,751Set = getNative(context, 'Set'),752setTimeout = context.setTimeout,753splice = arrayProto.splice,754Uint8Array = getNative(context, 'Uint8Array'),755WeakMap = getNative(context, 'WeakMap');756757/** Used to clone array buffers. */758var Float64Array = (function() {759// Safari 5 errors when using an array buffer to initialize a typed array760// where the array buffer's `byteLength` is not a multiple of the typed761// array's `BYTES_PER_ELEMENT`.762try {763var func = getNative(context, 'Float64Array'),764result = new func(new ArrayBuffer(10), 0, 1) && func;765} catch(e) {}766return result || null;767}());768769/* Native method references for those with the same name as other `lodash` methods. */770var nativeCreate = getNative(Object, 'create'),771nativeIsArray = getNative(Array, 'isArray'),772nativeIsFinite = context.isFinite,773nativeKeys = getNative(Object, 'keys'),774nativeMax = Math.max,775nativeMin = Math.min,776nativeNow = getNative(Date, 'now'),777nativeNumIsFinite = getNative(Number, 'isFinite'),778nativeParseInt = context.parseInt,779nativeRandom = Math.random;780781/** Used as references for `-Infinity` and `Infinity`. */782var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,783POSITIVE_INFINITY = Number.POSITIVE_INFINITY;784785/** Used as references for the maximum length and index of an array. */786var MAX_ARRAY_LENGTH = 4294967295,787MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,788HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;789790/** Used as the size, in bytes, of each `Float64Array` element. */791var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;792793/**794* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)795* of an array-like value.796*/797var MAX_SAFE_INTEGER = 9007199254740991;798799/** Used to store function metadata. */800var metaMap = WeakMap && new WeakMap;801802/** Used to lookup unminified function names. */803var realNames = {};804805/*------------------------------------------------------------------------*/806807/**808* Creates a `lodash` object which wraps `value` to enable implicit chaining.809* Methods that operate on and return arrays, collections, and functions can810* be chained together. Methods that return a boolean or single value will811* automatically end the chain returning the unwrapped value. Explicit chaining812* may be enabled using `_.chain`. The execution of chained methods is lazy,813* that is, execution is deferred until `_#value` is implicitly or explicitly814* called.815*816* Lazy evaluation allows several methods to support shortcut fusion. Shortcut817* fusion is an optimization that merges iteratees to avoid creating intermediate818* arrays and reduce the number of iteratee executions.819*820* Chaining is supported in custom builds as long as the `_#value` method is821* directly or indirectly included in the build.822*823* In addition to lodash methods, wrappers have `Array` and `String` methods.824*825* The wrapper `Array` methods are:826* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,827* `splice`, and `unshift`828*829* The wrapper `String` methods are:830* `replace` and `split`831*832* The wrapper methods that support shortcut fusion are:833* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,834* `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,835* `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,836* and `where`837*838* The chainable wrapper methods are:839* `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,840* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,841* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,842* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,843* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,844* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,845* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,846* `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,847* `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`,848* `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`,849* `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`,850* `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`,851* `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`,852* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,853* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,854* `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`,855* `wrap`, `xor`, `zip`, `zipObject`, `zipWith`856*857* The wrapper methods that are **not** chainable by default are:858* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,859* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,860* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`,861* `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,862* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,863* `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,864* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,865* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`,866* `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`,867* `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`,868* `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,869* `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`,870* `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`871*872* The wrapper method `sample` will return a wrapped value when `n` is provided,873* otherwise an unwrapped value is returned.874*875* @name _876* @constructor877* @category Chain878* @param {*} value The value to wrap in a `lodash` instance.879* @returns {Object} Returns the new `lodash` wrapper instance.880* @example881*882* var wrapped = _([1, 2, 3]);883*884* // returns an unwrapped value885* wrapped.reduce(function(total, n) {886* return total + n;887* });888* // => 6889*890* // returns a wrapped value891* var squares = wrapped.map(function(n) {892* return n * n;893* });894*895* _.isArray(squares);896* // => false897*898* _.isArray(squares.value());899* // => true900*/901function lodash(value) {902if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {903if (value instanceof LodashWrapper) {904return value;905}906if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {907return wrapperClone(value);908}909}910return new LodashWrapper(value);911}912913/**914* The function whose prototype all chaining wrappers inherit from.915*916* @private917*/918function baseLodash() {919// No operation performed.920}921922/**923* The base constructor for creating `lodash` wrapper objects.924*925* @private926* @param {*} value The value to wrap.927* @param {boolean} [chainAll] Enable chaining for all wrapper methods.928* @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.929*/930function LodashWrapper(value, chainAll, actions) {931this.__wrapped__ = value;932this.__actions__ = actions || [];933this.__chain__ = !!chainAll;934}935936/**937* An object environment feature flags.938*939* @static940* @memberOf _941* @type Object942*/943var support = lodash.support = {};944945(function(x) {946var Ctor = function() { this.x = x; },947object = { '0': x, 'length': x },948props = [];949950Ctor.prototype = { 'valueOf': x, 'y': x };951for (var key in new Ctor) { props.push(key); }952953/**954* Detect if the DOM is supported.955*956* @memberOf _.support957* @type boolean958*/959try {960support.dom = document.createDocumentFragment().nodeType === 11;961} catch(e) {962support.dom = false;963}964}(1, 0));965966/**967* By default, the template delimiters used by lodash are like those in968* embedded Ruby (ERB). Change the following template settings to use969* alternative delimiters.970*971* @static972* @memberOf _973* @type Object974*/975lodash.templateSettings = {976977/**978* Used to detect `data` property values to be HTML-escaped.979*980* @memberOf _.templateSettings981* @type RegExp982*/983'escape': reEscape,984985/**986* Used to detect code to be evaluated.987*988* @memberOf _.templateSettings989* @type RegExp990*/991'evaluate': reEvaluate,992993/**994* Used to detect `data` property values to inject.995*996* @memberOf _.templateSettings997* @type RegExp998*/999'interpolate': reInterpolate,10001001/**1002* Used to reference the data object in the template text.1003*1004* @memberOf _.templateSettings1005* @type string1006*/1007'variable': '',10081009/**1010* Used to import variables into the compiled template.1011*1012* @memberOf _.templateSettings1013* @type Object1014*/1015'imports': {10161017/**1018* A reference to the `lodash` function.1019*1020* @memberOf _.templateSettings.imports1021* @type Function1022*/1023'_': lodash1024}1025};10261027/*------------------------------------------------------------------------*/10281029/**1030* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.1031*1032* @private1033* @param {*} value The value to wrap.1034*/1035function LazyWrapper(value) {1036this.__wrapped__ = value;1037this.__actions__ = null;1038this.__dir__ = 1;1039this.__dropCount__ = 0;1040this.__filtered__ = false;1041this.__iteratees__ = null;1042this.__takeCount__ = POSITIVE_INFINITY;1043this.__views__ = null;1044}10451046/**1047* Creates a clone of the lazy wrapper object.1048*1049* @private1050* @name clone1051* @memberOf LazyWrapper1052* @returns {Object} Returns the cloned `LazyWrapper` object.1053*/1054function lazyClone() {1055var actions = this.__actions__,1056iteratees = this.__iteratees__,1057views = this.__views__,1058result = new LazyWrapper(this.__wrapped__);10591060result.__actions__ = actions ? arrayCopy(actions) : null;1061result.__dir__ = this.__dir__;1062result.__filtered__ = this.__filtered__;1063result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;1064result.__takeCount__ = this.__takeCount__;1065result.__views__ = views ? arrayCopy(views) : null;1066return result;1067}10681069/**1070* Reverses the direction of lazy iteration.1071*1072* @private1073* @name reverse1074* @memberOf LazyWrapper1075* @returns {Object} Returns the new reversed `LazyWrapper` object.1076*/1077function lazyReverse() {1078if (this.__filtered__) {1079var result = new LazyWrapper(this);1080result.__dir__ = -1;1081result.__filtered__ = true;1082} else {1083result = this.clone();1084result.__dir__ *= -1;1085}1086return result;1087}10881089/**1090* Extracts the unwrapped value from its lazy wrapper.1091*1092* @private1093* @name value1094* @memberOf LazyWrapper1095* @returns {*} Returns the unwrapped value.1096*/1097function lazyValue() {1098var array = this.__wrapped__.value();1099if (!isArray(array)) {1100return baseWrapperValue(array, this.__actions__);1101}1102var dir = this.__dir__,1103isRight = dir < 0,1104view = getView(0, array.length, this.__views__),1105start = view.start,1106end = view.end,1107length = end - start,1108index = isRight ? end : (start - 1),1109takeCount = nativeMin(length, this.__takeCount__),1110iteratees = this.__iteratees__,1111iterLength = iteratees ? iteratees.length : 0,1112resIndex = 0,1113result = [];11141115outer:1116while (length-- && resIndex < takeCount) {1117index += dir;11181119var iterIndex = -1,1120value = array[index];11211122while (++iterIndex < iterLength) {1123var data = iteratees[iterIndex],1124iteratee = data.iteratee,1125type = data.type;11261127if (type == LAZY_DROP_WHILE_FLAG) {1128if (data.done && (isRight ? (index > data.index) : (index < data.index))) {1129data.count = 0;1130data.done = false;1131}1132data.index = index;1133if (!data.done) {1134var limit = data.limit;1135if (!(data.done = limit > -1 ? (data.count++ >= limit) : !iteratee(value))) {1136continue outer;1137}1138}1139} else {1140var computed = iteratee(value);1141if (type == LAZY_MAP_FLAG) {1142value = computed;1143} else if (!computed) {1144if (type == LAZY_FILTER_FLAG) {1145continue outer;1146} else {1147break outer;1148}1149}1150}1151}1152result[resIndex++] = value;1153}1154return result;1155}11561157/*------------------------------------------------------------------------*/11581159/**1160* Creates a cache object to store key/value pairs.1161*1162* @private1163* @static1164* @name Cache1165* @memberOf _.memoize1166*/1167function MapCache() {1168this.__data__ = {};1169}11701171/**1172* Removes `key` and its value from the cache.1173*1174* @private1175* @name delete1176* @memberOf _.memoize.Cache1177* @param {string} key The key of the value to remove.1178* @returns {boolean} Returns `true` if the entry was removed successfully, else `false`.1179*/1180function mapDelete(key) {1181return this.has(key) && delete this.__data__[key];1182}11831184/**1185* Gets the cached value for `key`.1186*1187* @private1188* @name get1189* @memberOf _.memoize.Cache1190* @param {string} key The key of the value to get.1191* @returns {*} Returns the cached value.1192*/1193function mapGet(key) {1194return key == '__proto__' ? undefined : this.__data__[key];1195}11961197/**1198* Checks if a cached value for `key` exists.1199*1200* @private1201* @name has1202* @memberOf _.memoize.Cache1203* @param {string} key The key of the entry to check.1204* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.1205*/1206function mapHas(key) {1207return key != '__proto__' && hasOwnProperty.call(this.__data__, key);1208}12091210/**1211* Sets `value` to `key` of the cache.1212*1213* @private1214* @name set1215* @memberOf _.memoize.Cache1216* @param {string} key The key of the value to cache.1217* @param {*} value The value to cache.1218* @returns {Object} Returns the cache object.1219*/1220function mapSet(key, value) {1221if (key != '__proto__') {1222this.__data__[key] = value;1223}1224return this;1225}12261227/*------------------------------------------------------------------------*/12281229/**1230*1231* Creates a cache object to store unique values.1232*1233* @private1234* @param {Array} [values] The values to cache.1235*/1236function SetCache(values) {1237var length = values ? values.length : 0;12381239this.data = { 'hash': nativeCreate(null), 'set': new Set };1240while (length--) {1241this.push(values[length]);1242}1243}12441245/**1246* Checks if `value` is in `cache` mimicking the return signature of1247* `_.indexOf` by returning `0` if the value is found, else `-1`.1248*1249* @private1250* @param {Object} cache The cache to search.1251* @param {*} value The value to search for.1252* @returns {number} Returns `0` if `value` is found, else `-1`.1253*/1254function cacheIndexOf(cache, value) {1255var data = cache.data,1256result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];12571258return result ? 0 : -1;1259}12601261/**1262* Adds `value` to the cache.1263*1264* @private1265* @name push1266* @memberOf SetCache1267* @param {*} value The value to cache.1268*/1269function cachePush(value) {1270var data = this.data;1271if (typeof value == 'string' || isObject(value)) {1272data.set.add(value);1273} else {1274data.hash[value] = true;1275}1276}12771278/*------------------------------------------------------------------------*/12791280/**1281* Copies the values of `source` to `array`.1282*1283* @private1284* @param {Array} source The array to copy values from.1285* @param {Array} [array=[]] The array to copy values to.1286* @returns {Array} Returns `array`.1287*/1288function arrayCopy(source, array) {1289var index = -1,1290length = source.length;12911292array || (array = Array(length));1293while (++index < length) {1294array[index] = source[index];1295}1296return array;1297}12981299/**1300* A specialized version of `_.forEach` for arrays without support for callback1301* shorthands and `this` binding.1302*1303* @private1304* @param {Array} array The array to iterate over.1305* @param {Function} iteratee The function invoked per iteration.1306* @returns {Array} Returns `array`.1307*/1308function arrayEach(array, iteratee) {1309var index = -1,1310length = array.length;13111312while (++index < length) {1313if (iteratee(array[index], index, array) === false) {1314break;1315}1316}1317return array;1318}13191320/**1321* A specialized version of `_.forEachRight` for arrays without support for1322* callback shorthands and `this` binding.1323*1324* @private1325* @param {Array} array The array to iterate over.1326* @param {Function} iteratee The function invoked per iteration.1327* @returns {Array} Returns `array`.1328*/1329function arrayEachRight(array, iteratee) {1330var length = array.length;13311332while (length--) {1333if (iteratee(array[length], length, array) === false) {1334break;1335}1336}1337return array;1338}13391340/**1341* A specialized version of `_.every` for arrays without support for callback1342* shorthands and `this` binding.1343*1344* @private1345* @param {Array} array The array to iterate over.1346* @param {Function} predicate The function invoked per iteration.1347* @returns {boolean} Returns `true` if all elements pass the predicate check,1348* else `false`.1349*/1350function arrayEvery(array, predicate) {1351var index = -1,1352length = array.length;13531354while (++index < length) {1355if (!predicate(array[index], index, array)) {1356return false;1357}1358}1359return true;1360}13611362/**1363* A specialized version of `baseExtremum` for arrays which invokes `iteratee`1364* with one argument: (value).1365*1366* @private1367* @param {Array} array The array to iterate over.1368* @param {Function} iteratee The function invoked per iteration.1369* @param {Function} comparator The function used to compare values.1370* @param {*} exValue The initial extremum value.1371* @returns {*} Returns the extremum value.1372*/1373function arrayExtremum(array, iteratee, comparator, exValue) {1374var index = -1,1375length = array.length,1376computed = exValue,1377result = computed;13781379while (++index < length) {1380var value = array[index],1381current = +iteratee(value);13821383if (comparator(current, computed)) {1384computed = current;1385result = value;1386}1387}1388return result;1389}13901391/**1392* A specialized version of `_.filter` for arrays without support for callback1393* shorthands and `this` binding.1394*1395* @private1396* @param {Array} array The array to iterate over.1397* @param {Function} predicate The function invoked per iteration.1398* @returns {Array} Returns the new filtered array.1399*/1400function arrayFilter(array, predicate) {1401var index = -1,1402length = array.length,1403resIndex = -1,1404result = [];14051406while (++index < length) {1407var value = array[index];1408if (predicate(value, index, array)) {1409result[++resIndex] = value;1410}1411}1412return result;1413}14141415/**1416* A specialized version of `_.map` for arrays without support for callback1417* shorthands and `this` binding.1418*1419* @private1420* @param {Array} array The array to iterate over.1421* @param {Function} iteratee The function invoked per iteration.1422* @returns {Array} Returns the new mapped array.1423*/1424function arrayMap(array, iteratee) {1425var index = -1,1426length = array.length,1427result = Array(length);14281429while (++index < length) {1430result[index] = iteratee(array[index], index, array);1431}1432return result;1433}14341435/**1436* A specialized version of `_.reduce` for arrays without support for callback1437* shorthands and `this` binding.1438*1439* @private1440* @param {Array} array The array to iterate over.1441* @param {Function} iteratee The function invoked per iteration.1442* @param {*} [accumulator] The initial value.1443* @param {boolean} [initFromArray] Specify using the first element of `array`1444* as the initial value.1445* @returns {*} Returns the accumulated value.1446*/1447function arrayReduce(array, iteratee, accumulator, initFromArray) {1448var index = -1,1449length = array.length;14501451if (initFromArray && length) {1452accumulator = array[++index];1453}1454while (++index < length) {1455accumulator = iteratee(accumulator, array[index], index, array);1456}1457return accumulator;1458}14591460/**1461* A specialized version of `_.reduceRight` for arrays without support for1462* callback shorthands and `this` binding.1463*1464* @private1465* @param {Array} array The array to iterate over.1466* @param {Function} iteratee The function invoked per iteration.1467* @param {*} [accumulator] The initial value.1468* @param {boolean} [initFromArray] Specify using the last element of `array`1469* as the initial value.1470* @returns {*} Returns the accumulated value.1471*/1472function arrayReduceRight(array, iteratee, accumulator, initFromArray) {1473var length = array.length;1474if (initFromArray && length) {1475accumulator = array[--length];1476}1477while (length--) {1478accumulator = iteratee(accumulator, array[length], length, array);1479}1480return accumulator;1481}14821483/**1484* A specialized version of `_.some` for arrays without support for callback1485* shorthands and `this` binding.1486*1487* @private1488* @param {Array} array The array to iterate over.1489* @param {Function} predicate The function invoked per iteration.1490* @returns {boolean} Returns `true` if any element passes the predicate check,1491* else `false`.1492*/1493function arraySome(array, predicate) {1494var index = -1,1495length = array.length;14961497while (++index < length) {1498if (predicate(array[index], index, array)) {1499return true;1500}1501}1502return false;1503}15041505/**1506* A specialized version of `_.sum` for arrays without support for iteratees.1507*1508* @private1509* @param {Array} array The array to iterate over.1510* @returns {number} Returns the sum.1511*/1512function arraySum(array) {1513var length = array.length,1514result = 0;15151516while (length--) {1517result += +array[length] || 0;1518}1519return result;1520}15211522/**1523* Used by `_.defaults` to customize its `_.assign` use.1524*1525* @private1526* @param {*} objectValue The destination object property value.1527* @param {*} sourceValue The source object property value.1528* @returns {*} Returns the value to assign to the destination object.1529*/1530function assignDefaults(objectValue, sourceValue) {1531return objectValue === undefined ? sourceValue : objectValue;1532}15331534/**1535* Used by `_.template` to customize its `_.assign` use.1536*1537* **Note:** This function is like `assignDefaults` except that it ignores1538* inherited property values when checking if a property is `undefined`.1539*1540* @private1541* @param {*} objectValue The destination object property value.1542* @param {*} sourceValue The source object property value.1543* @param {string} key The key associated with the object and source values.1544* @param {Object} object The destination object.1545* @returns {*} Returns the value to assign to the destination object.1546*/1547function assignOwnDefaults(objectValue, sourceValue, key, object) {1548return (objectValue === undefined || !hasOwnProperty.call(object, key))1549? sourceValue1550: objectValue;1551}15521553/**1554* A specialized version of `_.assign` for customizing assigned values without1555* support for argument juggling, multiple sources, and `this` binding `customizer`1556* functions.1557*1558* @private1559* @param {Object} object The destination object.1560* @param {Object} source The source object.1561* @param {Function} customizer The function to customize assigned values.1562* @returns {Object} Returns `object`.1563*/1564function assignWith(object, source, customizer) {1565var index = -1,1566props = keys(source),1567length = props.length;15681569while (++index < length) {1570var key = props[index],1571value = object[key],1572result = customizer(value, source[key], key, object, source);15731574if ((result === result ? (result !== value) : (value === value)) ||1575(value === undefined && !(key in object))) {1576object[key] = result;1577}1578}1579return object;1580}15811582/**1583* The base implementation of `_.assign` without support for argument juggling,1584* multiple sources, and `customizer` functions.1585*1586* @private1587* @param {Object} object The destination object.1588* @param {Object} source The source object.1589* @returns {Object} Returns `object`.1590*/1591function baseAssign(object, source) {1592return source == null1593? object1594: baseCopy(source, keys(source), object);1595}15961597/**1598* The base implementation of `_.at` without support for string collections1599* and individual key arguments.1600*1601* @private1602* @param {Array|Object} collection The collection to iterate over.1603* @param {number[]|string[]} props The property names or indexes of elements to pick.1604* @returns {Array} Returns the new array of picked elements.1605*/1606function baseAt(collection, props) {1607var index = -1,1608isNil = collection == null,1609isArr = !isNil && isArrayLike(collection),1610length = isArr ? collection.length : 0,1611propsLength = props.length,1612result = Array(propsLength);16131614while(++index < propsLength) {1615var key = props[index];1616if (isArr) {1617result[index] = isIndex(key, length) ? collection[key] : undefined;1618} else {1619result[index] = isNil ? undefined : collection[key];1620}1621}1622return result;1623}16241625/**1626* Copies properties of `source` to `object`.1627*1628* @private1629* @param {Object} source The object to copy properties from.1630* @param {Array} props The property names to copy.1631* @param {Object} [object={}] The object to copy properties to.1632* @returns {Object} Returns `object`.1633*/1634function baseCopy(source, props, object) {1635object || (object = {});16361637var index = -1,1638length = props.length;16391640while (++index < length) {1641var key = props[index];1642object[key] = source[key];1643}1644return object;1645}16461647/**1648* The base implementation of `_.callback` which supports specifying the1649* number of arguments to provide to `func`.1650*1651* @private1652* @param {*} [func=_.identity] The value to convert to a callback.1653* @param {*} [thisArg] The `this` binding of `func`.1654* @param {number} [argCount] The number of arguments to provide to `func`.1655* @returns {Function} Returns the callback.1656*/1657function baseCallback(func, thisArg, argCount) {1658var type = typeof func;1659if (type == 'function') {1660return thisArg === undefined1661? func1662: bindCallback(func, thisArg, argCount);1663}1664if (func == null) {1665return identity;1666}1667if (type == 'object') {1668return baseMatches(func);1669}1670return thisArg === undefined1671? property(func)1672: baseMatchesProperty(func, thisArg);1673}16741675/**1676* The base implementation of `_.clone` without support for argument juggling1677* and `this` binding `customizer` functions.1678*1679* @private1680* @param {*} value The value to clone.1681* @param {boolean} [isDeep] Specify a deep clone.1682* @param {Function} [customizer] The function to customize cloning values.1683* @param {string} [key] The key of `value`.1684* @param {Object} [object] The object `value` belongs to.1685* @param {Array} [stackA=[]] Tracks traversed source objects.1686* @param {Array} [stackB=[]] Associates clones with source counterparts.1687* @returns {*} Returns the cloned value.1688*/1689function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {1690var result;1691if (customizer) {1692result = object ? customizer(value, key, object) : customizer(value);1693}1694if (result !== undefined) {1695return result;1696}1697if (!isObject(value)) {1698return value;1699}1700var isArr = isArray(value);1701if (isArr) {1702result = initCloneArray(value);1703if (!isDeep) {1704return arrayCopy(value, result);1705}1706} else {1707var tag = objToString.call(value),1708isFunc = tag == funcTag;17091710if (tag == objectTag || tag == argsTag || (isFunc && !object)) {1711result = initCloneObject(isFunc ? {} : value);1712if (!isDeep) {1713return baseAssign(result, value);1714}1715} else {1716return cloneableTags[tag]1717? initCloneByTag(value, tag, isDeep)1718: (object ? value : {});1719}1720}1721// Check for circular references and return corresponding clone.1722stackA || (stackA = []);1723stackB || (stackB = []);17241725var length = stackA.length;1726while (length--) {1727if (stackA[length] == value) {1728return stackB[length];1729}1730}1731// Add the source value to the stack of traversed objects and associate it with its clone.1732stackA.push(value);1733stackB.push(result);17341735// Recursively populate clone (susceptible to call stack limits).1736(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {1737result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);1738});1739return result;1740}17411742/**1743* The base implementation of `_.create` without support for assigning1744* properties to the created object.1745*1746* @private1747* @param {Object} prototype The object to inherit from.1748* @returns {Object} Returns the new object.1749*/1750var baseCreate = (function() {1751function object() {}1752return function(prototype) {1753if (isObject(prototype)) {1754object.prototype = prototype;1755var result = new object;1756object.prototype = null;1757}1758return result || {};1759};1760}());17611762/**1763* The base implementation of `_.delay` and `_.defer` which accepts an index1764* of where to slice the arguments to provide to `func`.1765*1766* @private1767* @param {Function} func The function to delay.1768* @param {number} wait The number of milliseconds to delay invocation.1769* @param {Object} args The arguments provide to `func`.1770* @returns {number} Returns the timer id.1771*/1772function baseDelay(func, wait, args) {1773if (typeof func != 'function') {1774throw new TypeError(FUNC_ERROR_TEXT);1775}1776return setTimeout(function() { func.apply(undefined, args); }, wait);1777}17781779/**1780* The base implementation of `_.difference` which accepts a single array1781* of values to exclude.1782*1783* @private1784* @param {Array} array The array to inspect.1785* @param {Array} values The values to exclude.1786* @returns {Array} Returns the new array of filtered values.1787*/1788function baseDifference(array, values) {1789var length = array ? array.length : 0,1790result = [];17911792if (!length) {1793return result;1794}1795var index = -1,1796indexOf = getIndexOf(),1797isCommon = indexOf == baseIndexOf,1798cache = (isCommon && values.length >= 200) ? createCache(values) : null,1799valuesLength = values.length;18001801if (cache) {1802indexOf = cacheIndexOf;1803isCommon = false;1804values = cache;1805}1806outer:1807while (++index < length) {1808var value = array[index];18091810if (isCommon && value === value) {1811var valuesIndex = valuesLength;1812while (valuesIndex--) {1813if (values[valuesIndex] === value) {1814continue outer;1815}1816}1817result.push(value);1818}1819else if (indexOf(values, value, 0) < 0) {1820result.push(value);1821}1822}1823return result;1824}18251826/**1827* The base implementation of `_.forEach` without support for callback1828* shorthands and `this` binding.1829*1830* @private1831* @param {Array|Object|string} collection The collection to iterate over.1832* @param {Function} iteratee The function invoked per iteration.1833* @returns {Array|Object|string} Returns `collection`.1834*/1835var baseEach = createBaseEach(baseForOwn);18361837/**1838* The base implementation of `_.forEachRight` without support for callback1839* shorthands and `this` binding.1840*1841* @private1842* @param {Array|Object|string} collection The collection to iterate over.1843* @param {Function} iteratee The function invoked per iteration.1844* @returns {Array|Object|string} Returns `collection`.1845*/1846var baseEachRight = createBaseEach(baseForOwnRight, true);18471848/**1849* The base implementation of `_.every` without support for callback1850* shorthands and `this` binding.1851*1852* @private1853* @param {Array|Object|string} collection The collection to iterate over.1854* @param {Function} predicate The function invoked per iteration.1855* @returns {boolean} Returns `true` if all elements pass the predicate check,1856* else `false`1857*/1858function baseEvery(collection, predicate) {1859var result = true;1860baseEach(collection, function(value, index, collection) {1861result = !!predicate(value, index, collection);1862return result;1863});1864return result;1865}18661867/**1868* Gets the extremum value of `collection` invoking `iteratee` for each value1869* in `collection` to generate the criterion by which the value is ranked.1870* The `iteratee` is invoked with three arguments: (value, index|key, collection).1871*1872* @private1873* @param {Array|Object|string} collection The collection to iterate over.1874* @param {Function} iteratee The function invoked per iteration.1875* @param {Function} comparator The function used to compare values.1876* @param {*} exValue The initial extremum value.1877* @returns {*} Returns the extremum value.1878*/1879function baseExtremum(collection, iteratee, comparator, exValue) {1880var computed = exValue,1881result = computed;18821883baseEach(collection, function(value, index, collection) {1884var current = +iteratee(value, index, collection);1885if (comparator(current, computed) || (current === exValue && current === result)) {1886computed = current;1887result = value;1888}1889});1890return result;1891}18921893/**1894* The base implementation of `_.fill` without an iteratee call guard.1895*1896* @private1897* @param {Array} array The array to fill.1898* @param {*} value The value to fill `array` with.1899* @param {number} [start=0] The start position.1900* @param {number} [end=array.length] The end position.1901* @returns {Array} Returns `array`.1902*/1903function baseFill(array, value, start, end) {1904var length = array.length;19051906start = start == null ? 0 : (+start || 0);1907if (start < 0) {1908start = -start > length ? 0 : (length + start);1909}1910end = (end === undefined || end > length) ? length : (+end || 0);1911if (end < 0) {1912end += length;1913}1914length = start > end ? 0 : (end >>> 0);1915start >>>= 0;19161917while (start < length) {1918array[start++] = value;1919}1920return array;1921}19221923/**1924* The base implementation of `_.filter` without support for callback1925* shorthands and `this` binding.1926*1927* @private1928* @param {Array|Object|string} collection The collection to iterate over.1929* @param {Function} predicate The function invoked per iteration.1930* @returns {Array} Returns the new filtered array.1931*/1932function baseFilter(collection, predicate) {1933var result = [];1934baseEach(collection, function(value, index, collection) {1935if (predicate(value, index, collection)) {1936result.push(value);1937}1938});1939return result;1940}19411942/**1943* The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,1944* without support for callback shorthands and `this` binding, which iterates1945* over `collection` using the provided `eachFunc`.1946*1947* @private1948* @param {Array|Object|string} collection The collection to search.1949* @param {Function} predicate The function invoked per iteration.1950* @param {Function} eachFunc The function to iterate over `collection`.1951* @param {boolean} [retKey] Specify returning the key of the found element1952* instead of the element itself.1953* @returns {*} Returns the found element or its key, else `undefined`.1954*/1955function baseFind(collection, predicate, eachFunc, retKey) {1956var result;1957eachFunc(collection, function(value, key, collection) {1958if (predicate(value, key, collection)) {1959result = retKey ? key : value;1960return false;1961}1962});1963return result;1964}19651966/**1967* The base implementation of `_.flatten` with added support for restricting1968* flattening and specifying the start index.1969*1970* @private1971* @param {Array} array The array to flatten.1972* @param {boolean} [isDeep] Specify a deep flatten.1973* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.1974* @returns {Array} Returns the new flattened array.1975*/1976function baseFlatten(array, isDeep, isStrict) {1977var index = -1,1978length = array.length,1979resIndex = -1,1980result = [];19811982while (++index < length) {1983var value = array[index];1984if (isObjectLike(value) && isArrayLike(value) &&1985(isStrict || isArray(value) || isArguments(value))) {1986if (isDeep) {1987// Recursively flatten arrays (susceptible to call stack limits).1988value = baseFlatten(value, isDeep, isStrict);1989}1990var valIndex = -1,1991valLength = value.length;19921993while (++valIndex < valLength) {1994result[++resIndex] = value[valIndex];1995}1996} else if (!isStrict) {1997result[++resIndex] = value;1998}1999}2000return result;2001}20022003/**2004* The base implementation of `baseForIn` and `baseForOwn` which iterates2005* over `object` properties returned by `keysFunc` invoking `iteratee` for2006* each property. Iteratee functions may exit iteration early by explicitly2007* returning `false`.2008*2009* @private2010* @param {Object} object The object to iterate over.2011* @param {Function} iteratee The function invoked per iteration.2012* @param {Function} keysFunc The function to get the keys of `object`.2013* @returns {Object} Returns `object`.2014*/2015var baseFor = createBaseFor();20162017/**2018* This function is like `baseFor` except that it iterates over properties2019* in the opposite order.2020*2021* @private2022* @param {Object} object The object to iterate over.2023* @param {Function} iteratee The function invoked per iteration.2024* @param {Function} keysFunc The function to get the keys of `object`.2025* @returns {Object} Returns `object`.2026*/2027var baseForRight = createBaseFor(true);20282029/**2030* The base implementation of `_.forIn` without support for callback2031* shorthands and `this` binding.2032*2033* @private2034* @param {Object} object The object to iterate over.2035* @param {Function} iteratee The function invoked per iteration.2036* @returns {Object} Returns `object`.2037*/2038function baseForIn(object, iteratee) {2039return baseFor(object, iteratee, keysIn);2040}20412042/**2043* The base implementation of `_.forOwn` without support for callback2044* shorthands and `this` binding.2045*2046* @private2047* @param {Object} object The object to iterate over.2048* @param {Function} iteratee The function invoked per iteration.2049* @returns {Object} Returns `object`.2050*/2051function baseForOwn(object, iteratee) {2052return baseFor(object, iteratee, keys);2053}20542055/**2056* The base implementation of `_.forOwnRight` without support for callback2057* shorthands and `this` binding.2058*2059* @private2060* @param {Object} object The object to iterate over.2061* @param {Function} iteratee The function invoked per iteration.2062* @returns {Object} Returns `object`.2063*/2064function baseForOwnRight(object, iteratee) {2065return baseForRight(object, iteratee, keys);2066}20672068/**2069* The base implementation of `_.functions` which creates an array of2070* `object` function property names filtered from those provided.2071*2072* @private2073* @param {Object} object The object to inspect.2074* @param {Array} props The property names to filter.2075* @returns {Array} Returns the new array of filtered property names.2076*/2077function baseFunctions(object, props) {2078var index = -1,2079length = props.length,2080resIndex = -1,2081result = [];20822083while (++index < length) {2084var key = props[index];2085if (isFunction(object[key])) {2086result[++resIndex] = key;2087}2088}2089return result;2090}20912092/**2093* The base implementation of `get` without support for string paths2094* and default values.2095*2096* @private2097* @param {Object} object The object to query.2098* @param {Array} path The path of the property to get.2099* @param {string} [pathKey] The key representation of path.2100* @returns {*} Returns the resolved value.2101*/2102function baseGet(object, path, pathKey) {2103if (object == null) {2104return;2105}2106if (pathKey !== undefined && pathKey in toObject(object)) {2107path = [pathKey];2108}2109var index = 0,2110length = path.length;21112112while (object != null && index < length) {2113object = object[path[index++]];2114}2115return (index && index == length) ? object : undefined;2116}21172118/**2119* The base implementation of `_.isEqual` without support for `this` binding2120* `customizer` functions.2121*2122* @private2123* @param {*} value The value to compare.2124* @param {*} other The other value to compare.2125* @param {Function} [customizer] The function to customize comparing values.2126* @param {boolean} [isLoose] Specify performing partial comparisons.2127* @param {Array} [stackA] Tracks traversed `value` objects.2128* @param {Array} [stackB] Tracks traversed `other` objects.2129* @returns {boolean} Returns `true` if the values are equivalent, else `false`.2130*/2131function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {2132if (value === other) {2133return true;2134}2135if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {2136return value !== value && other !== other;2137}2138return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);2139}21402141/**2142* A specialized version of `baseIsEqual` for arrays and objects which performs2143* deep comparisons and tracks traversed objects enabling objects with circular2144* references to be compared.2145*2146* @private2147* @param {Object} object The object to compare.2148* @param {Object} other The other object to compare.2149* @param {Function} equalFunc The function to determine equivalents of values.2150* @param {Function} [customizer] The function to customize comparing objects.2151* @param {boolean} [isLoose] Specify performing partial comparisons.2152* @param {Array} [stackA=[]] Tracks traversed `value` objects.2153* @param {Array} [stackB=[]] Tracks traversed `other` objects.2154* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.2155*/2156function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {2157var objIsArr = isArray(object),2158othIsArr = isArray(other),2159objTag = arrayTag,2160othTag = arrayTag;21612162if (!objIsArr) {2163objTag = objToString.call(object);2164if (objTag == argsTag) {2165objTag = objectTag;2166} else if (objTag != objectTag) {2167objIsArr = isTypedArray(object);2168}2169}2170if (!othIsArr) {2171othTag = objToString.call(other);2172if (othTag == argsTag) {2173othTag = objectTag;2174} else if (othTag != objectTag) {2175othIsArr = isTypedArray(other);2176}2177}2178var objIsObj = objTag == objectTag,2179othIsObj = othTag == objectTag,2180isSameTag = objTag == othTag;21812182if (isSameTag && !(objIsArr || objIsObj)) {2183return equalByTag(object, other, objTag);2184}2185if (!isLoose) {2186var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),2187othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');21882189if (objIsWrapped || othIsWrapped) {2190return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);2191}2192}2193if (!isSameTag) {2194return false;2195}2196// Assume cyclic values are equal.2197// For more information on detecting circular references see https://es5.github.io/#JO.2198stackA || (stackA = []);2199stackB || (stackB = []);22002201var length = stackA.length;2202while (length--) {2203if (stackA[length] == object) {2204return stackB[length] == other;2205}2206}2207// Add `object` and `other` to the stack of traversed objects.2208stackA.push(object);2209stackB.push(other);22102211var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);22122213stackA.pop();2214stackB.pop();22152216return result;2217}22182219/**2220* The base implementation of `_.isMatch` without support for callback2221* shorthands and `this` binding.2222*2223* @private2224* @param {Object} object The object to inspect.2225* @param {Array} matchData The propery names, values, and compare flags to match.2226* @param {Function} [customizer] The function to customize comparing objects.2227* @returns {boolean} Returns `true` if `object` is a match, else `false`.2228*/2229function baseIsMatch(object, matchData, customizer) {2230var index = matchData.length,2231length = index,2232noCustomizer = !customizer;22332234if (object == null) {2235return !length;2236}2237object = toObject(object);2238while (index--) {2239var data = matchData[index];2240if ((noCustomizer && data[2])2241? data[1] !== object[data[0]]2242: !(data[0] in object)2243) {2244return false;2245}2246}2247while (++index < length) {2248data = matchData[index];2249var key = data[0],2250objValue = object[key],2251srcValue = data[1];22522253if (noCustomizer && data[2]) {2254if (objValue === undefined && !(key in object)) {2255return false;2256}2257} else {2258var result = customizer ? customizer(objValue, srcValue, key) : undefined;2259if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {2260return false;2261}2262}2263}2264return true;2265}22662267/**2268* The base implementation of `_.map` without support for callback shorthands2269* and `this` binding.2270*2271* @private2272* @param {Array|Object|string} collection The collection to iterate over.2273* @param {Function} iteratee The function invoked per iteration.2274* @returns {Array} Returns the new mapped array.2275*/2276function baseMap(collection, iteratee) {2277var index = -1,2278result = isArrayLike(collection) ? Array(collection.length) : [];22792280baseEach(collection, function(value, key, collection) {2281result[++index] = iteratee(value, key, collection);2282});2283return result;2284}22852286/**2287* The base implementation of `_.matches` which does not clone `source`.2288*2289* @private2290* @param {Object} source The object of property values to match.2291* @returns {Function} Returns the new function.2292*/2293function baseMatches(source) {2294var matchData = getMatchData(source);2295if (matchData.length == 1 && matchData[0][2]) {2296var key = matchData[0][0],2297value = matchData[0][1];22982299return function(object) {2300if (object == null) {2301return false;2302}2303return object[key] === value && (value !== undefined || (key in toObject(object)));2304};2305}2306return function(object) {2307return baseIsMatch(object, matchData);2308};2309}23102311/**2312* The base implementation of `_.matchesProperty` which does not clone `srcValue`.2313*2314* @private2315* @param {string} path The path of the property to get.2316* @param {*} srcValue The value to compare.2317* @returns {Function} Returns the new function.2318*/2319function baseMatchesProperty(path, srcValue) {2320var isArr = isArray(path),2321isCommon = isKey(path) && isStrictComparable(srcValue),2322pathKey = (path + '');23232324path = toPath(path);2325return function(object) {2326if (object == null) {2327return false;2328}2329var key = pathKey;2330object = toObject(object);2331if ((isArr || !isCommon) && !(key in object)) {2332object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));2333if (object == null) {2334return false;2335}2336key = last(path);2337object = toObject(object);2338}2339return object[key] === srcValue2340? (srcValue !== undefined || (key in object))2341: baseIsEqual(srcValue, object[key], undefined, true);2342};2343}23442345/**2346* The base implementation of `_.merge` without support for argument juggling,2347* multiple sources, and `this` binding `customizer` functions.2348*2349* @private2350* @param {Object} object The destination object.2351* @param {Object} source The source object.2352* @param {Function} [customizer] The function to customize merging properties.2353* @param {Array} [stackA=[]] Tracks traversed source objects.2354* @param {Array} [stackB=[]] Associates values with source counterparts.2355* @returns {Object} Returns `object`.2356*/2357function baseMerge(object, source, customizer, stackA, stackB) {2358if (!isObject(object)) {2359return object;2360}2361var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),2362props = isSrcArr ? null : keys(source);23632364arrayEach(props || source, function(srcValue, key) {2365if (props) {2366key = srcValue;2367srcValue = source[key];2368}2369if (isObjectLike(srcValue)) {2370stackA || (stackA = []);2371stackB || (stackB = []);2372baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);2373}2374else {2375var value = object[key],2376result = customizer ? customizer(value, srcValue, key, object, source) : undefined,2377isCommon = result === undefined;23782379if (isCommon) {2380result = srcValue;2381}2382if ((result !== undefined || (isSrcArr && !(key in object))) &&2383(isCommon || (result === result ? (result !== value) : (value === value)))) {2384object[key] = result;2385}2386}2387});2388return object;2389}23902391/**2392* A specialized version of `baseMerge` for arrays and objects which performs2393* deep merges and tracks traversed objects enabling objects with circular2394* references to be merged.2395*2396* @private2397* @param {Object} object The destination object.2398* @param {Object} source The source object.2399* @param {string} key The key of the value to merge.2400* @param {Function} mergeFunc The function to merge values.2401* @param {Function} [customizer] The function to customize merging properties.2402* @param {Array} [stackA=[]] Tracks traversed source objects.2403* @param {Array} [stackB=[]] Associates values with source counterparts.2404* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.2405*/2406function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {2407var length = stackA.length,2408srcValue = source[key];24092410while (length--) {2411if (stackA[length] == srcValue) {2412object[key] = stackB[length];2413return;2414}2415}2416var value = object[key],2417result = customizer ? customizer(value, srcValue, key, object, source) : undefined,2418isCommon = result === undefined;24192420if (isCommon) {2421result = srcValue;2422if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {2423result = isArray(value)2424? value2425: (isArrayLike(value) ? arrayCopy(value) : []);2426}2427else if (isPlainObject(srcValue) || isArguments(srcValue)) {2428result = isArguments(value)2429? toPlainObject(value)2430: (isPlainObject(value) ? value : {});2431}2432else {2433isCommon = false;2434}2435}2436// Add the source value to the stack of traversed objects and associate2437// it with its merged value.2438stackA.push(srcValue);2439stackB.push(result);24402441if (isCommon) {2442// Recursively merge objects and arrays (susceptible to call stack limits).2443object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);2444} else if (result === result ? (result !== value) : (value === value)) {2445object[key] = result;2446}2447}24482449/**2450* The base implementation of `_.property` without support for deep paths.2451*2452* @private2453* @param {string} key The key of the property to get.2454* @returns {Function} Returns the new function.2455*/2456function baseProperty(key) {2457return function(object) {2458return object == null ? undefined : object[key];2459};2460}24612462/**2463* A specialized version of `baseProperty` which supports deep paths.2464*2465* @private2466* @param {Array|string} path The path of the property to get.2467* @returns {Function} Returns the new function.2468*/2469function basePropertyDeep(path) {2470var pathKey = (path + '');2471path = toPath(path);2472return function(object) {2473return baseGet(object, path, pathKey);2474};2475}24762477/**2478* The base implementation of `_.pullAt` without support for individual2479* index arguments and capturing the removed elements.2480*2481* @private2482* @param {Array} array The array to modify.2483* @param {number[]} indexes The indexes of elements to remove.2484* @returns {Array} Returns `array`.2485*/2486function basePullAt(array, indexes) {2487var length = array ? indexes.length : 0;2488while (length--) {2489var index = indexes[length];2490if (index != previous && isIndex(index)) {2491var previous = index;2492splice.call(array, index, 1);2493}2494}2495return array;2496}24972498/**2499* The base implementation of `_.random` without support for argument juggling2500* and returning floating-point numbers.2501*2502* @private2503* @param {number} min The minimum possible value.2504* @param {number} max The maximum possible value.2505* @returns {number} Returns the random number.2506*/2507function baseRandom(min, max) {2508return min + floor(nativeRandom() * (max - min + 1));2509}25102511/**2512* The base implementation of `_.reduce` and `_.reduceRight` without support2513* for callback shorthands and `this` binding, which iterates over `collection`2514* using the provided `eachFunc`.2515*2516* @private2517* @param {Array|Object|string} collection The collection to iterate over.2518* @param {Function} iteratee The function invoked per iteration.2519* @param {*} accumulator The initial value.2520* @param {boolean} initFromCollection Specify using the first or last element2521* of `collection` as the initial value.2522* @param {Function} eachFunc The function to iterate over `collection`.2523* @returns {*} Returns the accumulated value.2524*/2525function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {2526eachFunc(collection, function(value, index, collection) {2527accumulator = initFromCollection2528? (initFromCollection = false, value)2529: iteratee(accumulator, value, index, collection);2530});2531return accumulator;2532}25332534/**2535* The base implementation of `setData` without support for hot loop detection.2536*2537* @private2538* @param {Function} func The function to associate metadata with.2539* @param {*} data The metadata.2540* @returns {Function} Returns `func`.2541*/2542var baseSetData = !metaMap ? identity : function(func, data) {2543metaMap.set(func, data);2544return func;2545};25462547/**2548* The base implementation of `_.slice` without an iteratee call guard.2549*2550* @private2551* @param {Array} array The array to slice.2552* @param {number} [start=0] The start position.2553* @param {number} [end=array.length] The end position.2554* @returns {Array} Returns the slice of `array`.2555*/2556function baseSlice(array, start, end) {2557var index = -1,2558length = array.length;25592560start = start == null ? 0 : (+start || 0);2561if (start < 0) {2562start = -start > length ? 0 : (length + start);2563}2564end = (end === undefined || end > length) ? length : (+end || 0);2565if (end < 0) {2566end += length;2567}2568length = start > end ? 0 : ((end - start) >>> 0);2569start >>>= 0;25702571var result = Array(length);2572while (++index < length) {2573result[index] = array[index + start];2574}2575return result;2576}25772578/**2579* The base implementation of `_.some` without support for callback shorthands2580* and `this` binding.2581*2582* @private2583* @param {Array|Object|string} collection The collection to iterate over.2584* @param {Function} predicate The function invoked per iteration.2585* @returns {boolean} Returns `true` if any element passes the predicate check,2586* else `false`.2587*/2588function baseSome(collection, predicate) {2589var result;25902591baseEach(collection, function(value, index, collection) {2592result = predicate(value, index, collection);2593return !result;2594});2595return !!result;2596}25972598/**2599* The base implementation of `_.sortBy` which uses `comparer` to define2600* the sort order of `array` and replaces criteria objects with their2601* corresponding values.2602*2603* @private2604* @param {Array} array The array to sort.2605* @param {Function} comparer The function to define sort order.2606* @returns {Array} Returns `array`.2607*/2608function baseSortBy(array, comparer) {2609var length = array.length;26102611array.sort(comparer);2612while (length--) {2613array[length] = array[length].value;2614}2615return array;2616}26172618/**2619* The base implementation of `_.sortByOrder` without param guards.2620*2621* @private2622* @param {Array|Object|string} collection The collection to iterate over.2623* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.2624* @param {boolean[]} orders The sort orders of `iteratees`.2625* @returns {Array} Returns the new sorted array.2626*/2627function baseSortByOrder(collection, iteratees, orders) {2628var callback = getCallback(),2629index = -1;26302631iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); });26322633var result = baseMap(collection, function(value) {2634var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); });2635return { 'criteria': criteria, 'index': ++index, 'value': value };2636});26372638return baseSortBy(result, function(object, other) {2639return compareMultiple(object, other, orders);2640});2641}26422643/**2644* The base implementation of `_.sum` without support for callback shorthands2645* and `this` binding.2646*2647* @private2648* @param {Array|Object|string} collection The collection to iterate over.2649* @param {Function} iteratee The function invoked per iteration.2650* @returns {number} Returns the sum.2651*/2652function baseSum(collection, iteratee) {2653var result = 0;2654baseEach(collection, function(value, index, collection) {2655result += +iteratee(value, index, collection) || 0;2656});2657return result;2658}26592660/**2661* The base implementation of `_.uniq` without support for callback shorthands2662* and `this` binding.2663*2664* @private2665* @param {Array} array The array to inspect.2666* @param {Function} [iteratee] The function invoked per iteration.2667* @returns {Array} Returns the new duplicate-value-free array.2668*/2669function baseUniq(array, iteratee) {2670var index = -1,2671indexOf = getIndexOf(),2672length = array.length,2673isCommon = indexOf == baseIndexOf,2674isLarge = isCommon && length >= 200,2675seen = isLarge ? createCache() : null,2676result = [];26772678if (seen) {2679indexOf = cacheIndexOf;2680isCommon = false;2681} else {2682isLarge = false;2683seen = iteratee ? [] : result;2684}2685outer:2686while (++index < length) {2687var value = array[index],2688computed = iteratee ? iteratee(value, index, array) : value;26892690if (isCommon && value === value) {2691var seenIndex = seen.length;2692while (seenIndex--) {2693if (seen[seenIndex] === computed) {2694continue outer;2695}2696}2697if (iteratee) {2698seen.push(computed);2699}2700result.push(value);2701}2702else if (indexOf(seen, computed, 0) < 0) {2703if (iteratee || isLarge) {2704seen.push(computed);2705}2706result.push(value);2707}2708}2709return result;2710}27112712/**2713* The base implementation of `_.values` and `_.valuesIn` which creates an2714* array of `object` property values corresponding to the property names2715* of `props`.2716*2717* @private2718* @param {Object} object The object to query.2719* @param {Array} props The property names to get values for.2720* @returns {Object} Returns the array of property values.2721*/2722function baseValues(object, props) {2723var index = -1,2724length = props.length,2725result = Array(length);27262727while (++index < length) {2728result[index] = object[props[index]];2729}2730return result;2731}27322733/**2734* The base implementation of `_.dropRightWhile`, `_.dropWhile`, `_.takeRightWhile`,2735* and `_.takeWhile` without support for callback shorthands and `this` binding.2736*2737* @private2738* @param {Array} array The array to query.2739* @param {Function} predicate The function invoked per iteration.2740* @param {boolean} [isDrop] Specify dropping elements instead of taking them.2741* @param {boolean} [fromRight] Specify iterating from right to left.2742* @returns {Array} Returns the slice of `array`.2743*/2744function baseWhile(array, predicate, isDrop, fromRight) {2745var length = array.length,2746index = fromRight ? length : -1;27472748while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {}2749return isDrop2750? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))2751: baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));2752}27532754/**2755* The base implementation of `wrapperValue` which returns the result of2756* performing a sequence of actions on the unwrapped `value`, where each2757* successive action is supplied the return value of the previous.2758*2759* @private2760* @param {*} value The unwrapped value.2761* @param {Array} actions Actions to peform to resolve the unwrapped value.2762* @returns {*} Returns the resolved value.2763*/2764function baseWrapperValue(value, actions) {2765var result = value;2766if (result instanceof LazyWrapper) {2767result = result.value();2768}2769var index = -1,2770length = actions.length;27712772while (++index < length) {2773var args = [result],2774action = actions[index];27752776push.apply(args, action.args);2777result = action.func.apply(action.thisArg, args);2778}2779return result;2780}27812782/**2783* Performs a binary search of `array` to determine the index at which `value`2784* should be inserted into `array` in order to maintain its sort order.2785*2786* @private2787* @param {Array} array The sorted array to inspect.2788* @param {*} value The value to evaluate.2789* @param {boolean} [retHighest] Specify returning the highest qualified index.2790* @returns {number} Returns the index at which `value` should be inserted2791* into `array`.2792*/2793function binaryIndex(array, value, retHighest) {2794var low = 0,2795high = array ? array.length : low;27962797if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {2798while (low < high) {2799var mid = (low + high) >>> 1,2800computed = array[mid];28012802if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {2803low = mid + 1;2804} else {2805high = mid;2806}2807}2808return high;2809}2810return binaryIndexBy(array, value, identity, retHighest);2811}28122813/**2814* This function is like `binaryIndex` except that it invokes `iteratee` for2815* `value` and each element of `array` to compute their sort ranking. The2816* iteratee is invoked with one argument; (value).2817*2818* @private2819* @param {Array} array The sorted array to inspect.2820* @param {*} value The value to evaluate.2821* @param {Function} iteratee The function invoked per iteration.2822* @param {boolean} [retHighest] Specify returning the highest qualified index.2823* @returns {number} Returns the index at which `value` should be inserted2824* into `array`.2825*/2826function binaryIndexBy(array, value, iteratee, retHighest) {2827value = iteratee(value);28282829var low = 0,2830high = array ? array.length : 0,2831valIsNaN = value !== value,2832valIsNull = value === null,2833valIsUndef = value === undefined;28342835while (low < high) {2836var mid = floor((low + high) / 2),2837computed = iteratee(array[mid]),2838isDef = computed !== undefined,2839isReflexive = computed === computed;28402841if (valIsNaN) {2842var setLow = isReflexive || retHighest;2843} else if (valIsNull) {2844setLow = isReflexive && isDef && (retHighest || computed != null);2845} else if (valIsUndef) {2846setLow = isReflexive && (retHighest || isDef);2847} else if (computed == null) {2848setLow = false;2849} else {2850setLow = retHighest ? (computed <= value) : (computed < value);2851}2852if (setLow) {2853low = mid + 1;2854} else {2855high = mid;2856}2857}2858return nativeMin(high, MAX_ARRAY_INDEX);2859}28602861/**2862* A specialized version of `baseCallback` which only supports `this` binding2863* and specifying the number of arguments to provide to `func`.2864*2865* @private2866* @param {Function} func The function to bind.2867* @param {*} thisArg The `this` binding of `func`.2868* @param {number} [argCount] The number of arguments to provide to `func`.2869* @returns {Function} Returns the callback.2870*/2871function bindCallback(func, thisArg, argCount) {2872if (typeof func != 'function') {2873return identity;2874}2875if (thisArg === undefined) {2876return func;2877}2878switch (argCount) {2879case 1: return function(value) {2880return func.call(thisArg, value);2881};2882case 3: return function(value, index, collection) {2883return func.call(thisArg, value, index, collection);2884};2885case 4: return function(accumulator, value, index, collection) {2886return func.call(thisArg, accumulator, value, index, collection);2887};2888case 5: return function(value, other, key, object, source) {2889return func.call(thisArg, value, other, key, object, source);2890};2891}2892return function() {2893return func.apply(thisArg, arguments);2894};2895}28962897/**2898* Creates a clone of the given array buffer.2899*2900* @private2901* @param {ArrayBuffer} buffer The array buffer to clone.2902* @returns {ArrayBuffer} Returns the cloned array buffer.2903*/2904function bufferClone(buffer) {2905return bufferSlice.call(buffer, 0);2906}2907if (!bufferSlice) {2908// PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`.2909bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {2910var byteLength = buffer.byteLength,2911floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,2912offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,2913result = new ArrayBuffer(byteLength);29142915if (floatLength) {2916var view = new Float64Array(result, 0, floatLength);2917view.set(new Float64Array(buffer, 0, floatLength));2918}2919if (byteLength != offset) {2920view = new Uint8Array(result, offset);2921view.set(new Uint8Array(buffer, offset));2922}2923return result;2924};2925}29262927/**2928* Creates an array that is the composition of partially applied arguments,2929* placeholders, and provided arguments into a single array of arguments.2930*2931* @private2932* @param {Array|Object} args The provided arguments.2933* @param {Array} partials The arguments to prepend to those provided.2934* @param {Array} holders The `partials` placeholder indexes.2935* @returns {Array} Returns the new array of composed arguments.2936*/2937function composeArgs(args, partials, holders) {2938var holdersLength = holders.length,2939argsIndex = -1,2940argsLength = nativeMax(args.length - holdersLength, 0),2941leftIndex = -1,2942leftLength = partials.length,2943result = Array(argsLength + leftLength);29442945while (++leftIndex < leftLength) {2946result[leftIndex] = partials[leftIndex];2947}2948while (++argsIndex < holdersLength) {2949result[holders[argsIndex]] = args[argsIndex];2950}2951while (argsLength--) {2952result[leftIndex++] = args[argsIndex++];2953}2954return result;2955}29562957/**2958* This function is like `composeArgs` except that the arguments composition2959* is tailored for `_.partialRight`.2960*2961* @private2962* @param {Array|Object} args The provided arguments.2963* @param {Array} partials The arguments to append to those provided.2964* @param {Array} holders The `partials` placeholder indexes.2965* @returns {Array} Returns the new array of composed arguments.2966*/2967function composeArgsRight(args, partials, holders) {2968var holdersIndex = -1,2969holdersLength = holders.length,2970argsIndex = -1,2971argsLength = nativeMax(args.length - holdersLength, 0),2972rightIndex = -1,2973rightLength = partials.length,2974result = Array(argsLength + rightLength);29752976while (++argsIndex < argsLength) {2977result[argsIndex] = args[argsIndex];2978}2979var offset = argsIndex;2980while (++rightIndex < rightLength) {2981result[offset + rightIndex] = partials[rightIndex];2982}2983while (++holdersIndex < holdersLength) {2984result[offset + holders[holdersIndex]] = args[argsIndex++];2985}2986return result;2987}29882989/**2990* Creates a function that aggregates a collection, creating an accumulator2991* object composed from the results of running each element in the collection2992* through an iteratee.2993*2994* **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`,2995* and `_.partition`.2996*2997* @private2998* @param {Function} setter The function to set keys and values of the accumulator object.2999* @param {Function} [initializer] The function to initialize the accumulator object.3000* @returns {Function} Returns the new aggregator function.3001*/3002function createAggregator(setter, initializer) {3003return function(collection, iteratee, thisArg) {3004var result = initializer ? initializer() : {};3005iteratee = getCallback(iteratee, thisArg, 3);30063007if (isArray(collection)) {3008var index = -1,3009length = collection.length;30103011while (++index < length) {3012var value = collection[index];3013setter(result, value, iteratee(value, index, collection), collection);3014}3015} else {3016baseEach(collection, function(value, key, collection) {3017setter(result, value, iteratee(value, key, collection), collection);3018});3019}3020return result;3021};3022}30233024/**3025* Creates a function that assigns properties of source object(s) to a given3026* destination object.3027*3028* **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.3029*3030* @private3031* @param {Function} assigner The function to assign values.3032* @returns {Function} Returns the new assigner function.3033*/3034function createAssigner(assigner) {3035return restParam(function(object, sources) {3036var index = -1,3037length = object == null ? 0 : sources.length,3038customizer = length > 2 ? sources[length - 2] : undefined,3039guard = length > 2 ? sources[2] : undefined,3040thisArg = length > 1 ? sources[length - 1] : undefined;30413042if (typeof customizer == 'function') {3043customizer = bindCallback(customizer, thisArg, 5);3044length -= 2;3045} else {3046customizer = typeof thisArg == 'function' ? thisArg : undefined;3047length -= (customizer ? 1 : 0);3048}3049if (guard && isIterateeCall(sources[0], sources[1], guard)) {3050customizer = length < 3 ? undefined : customizer;3051length = 1;3052}3053while (++index < length) {3054var source = sources[index];3055if (source) {3056assigner(object, source, customizer);3057}3058}3059return object;3060});3061}30623063/**3064* Creates a `baseEach` or `baseEachRight` function.3065*3066* @private3067* @param {Function} eachFunc The function to iterate over a collection.3068* @param {boolean} [fromRight] Specify iterating from right to left.3069* @returns {Function} Returns the new base function.3070*/3071function createBaseEach(eachFunc, fromRight) {3072return function(collection, iteratee) {3073var length = collection ? getLength(collection) : 0;3074if (!isLength(length)) {3075return eachFunc(collection, iteratee);3076}3077var index = fromRight ? length : -1,3078iterable = toObject(collection);30793080while ((fromRight ? index-- : ++index < length)) {3081if (iteratee(iterable[index], index, iterable) === false) {3082break;3083}3084}3085return collection;3086};3087}30883089/**3090* Creates a base function for `_.forIn` or `_.forInRight`.3091*3092* @private3093* @param {boolean} [fromRight] Specify iterating from right to left.3094* @returns {Function} Returns the new base function.3095*/3096function createBaseFor(fromRight) {3097return function(object, iteratee, keysFunc) {3098var iterable = toObject(object),3099props = keysFunc(object),3100length = props.length,3101index = fromRight ? length : -1;31023103while ((fromRight ? index-- : ++index < length)) {3104var key = props[index];3105if (iteratee(iterable[key], key, iterable) === false) {3106break;3107}3108}3109return object;3110};3111}31123113/**3114* Creates a function that wraps `func` and invokes it with the `this`3115* binding of `thisArg`.3116*3117* @private3118* @param {Function} func The function to bind.3119* @param {*} [thisArg] The `this` binding of `func`.3120* @returns {Function} Returns the new bound function.3121*/3122function createBindWrapper(func, thisArg) {3123var Ctor = createCtorWrapper(func);31243125function wrapper() {3126var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;3127return fn.apply(thisArg, arguments);3128}3129return wrapper;3130}31313132/**3133* Creates a `Set` cache object to optimize linear searches of large arrays.3134*3135* @private3136* @param {Array} [values] The values to cache.3137* @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.3138*/3139var createCache = !(nativeCreate && Set) ? constant(null) : function(values) {3140return new SetCache(values);3141};31423143/**3144* Creates a function that produces compound words out of the words in a3145* given string.3146*3147* @private3148* @param {Function} callback The function to combine each word.3149* @returns {Function} Returns the new compounder function.3150*/3151function createCompounder(callback) {3152return function(string) {3153var index = -1,3154array = words(deburr(string)),3155length = array.length,3156result = '';31573158while (++index < length) {3159result = callback(result, array[index], index);3160}3161return result;3162};3163}31643165/**3166* Creates a function that produces an instance of `Ctor` regardless of3167* whether it was invoked as part of a `new` expression or by `call` or `apply`.3168*3169* @private3170* @param {Function} Ctor The constructor to wrap.3171* @returns {Function} Returns the new wrapped function.3172*/3173function createCtorWrapper(Ctor) {3174return function() {3175// Use a `switch` statement to work with class constructors.3176// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist3177// for more details.3178var args = arguments;3179switch (args.length) {3180case 0: return new Ctor;3181case 1: return new Ctor(args[0]);3182case 2: return new Ctor(args[0], args[1]);3183case 3: return new Ctor(args[0], args[1], args[2]);3184case 4: return new Ctor(args[0], args[1], args[2], args[3]);3185case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);3186}3187var thisBinding = baseCreate(Ctor.prototype),3188result = Ctor.apply(thisBinding, args);31893190// Mimic the constructor's `return` behavior.3191// See https://es5.github.io/#x13.2.2 for more details.3192return isObject(result) ? result : thisBinding;3193};3194}31953196/**3197* Creates a `_.curry` or `_.curryRight` function.3198*3199* @private3200* @param {boolean} flag The curry bit flag.3201* @returns {Function} Returns the new curry function.3202*/3203function createCurry(flag) {3204function curryFunc(func, arity, guard) {3205if (guard && isIterateeCall(func, arity, guard)) {3206arity = null;3207}3208var result = createWrapper(func, flag, null, null, null, null, null, arity);3209result.placeholder = curryFunc.placeholder;3210return result;3211}3212return curryFunc;3213}32143215/**3216* Creates a `_.max` or `_.min` function.3217*3218* @private3219* @param {Function} comparator The function used to compare values.3220* @param {*} exValue The initial extremum value.3221* @returns {Function} Returns the new extremum function.3222*/3223function createExtremum(comparator, exValue) {3224return function(collection, iteratee, thisArg) {3225if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {3226iteratee = null;3227}3228iteratee = getCallback(iteratee, thisArg, 3);3229if (iteratee.length == 1) {3230collection = toIterable(collection);3231var result = arrayExtremum(collection, iteratee, comparator, exValue);3232if (!(collection.length && result === exValue)) {3233return result;3234}3235}3236return baseExtremum(collection, iteratee, comparator, exValue);3237};3238}32393240/**3241* Creates a `_.find` or `_.findLast` function.3242*3243* @private3244* @param {Function} eachFunc The function to iterate over a collection.3245* @param {boolean} [fromRight] Specify iterating from right to left.3246* @returns {Function} Returns the new find function.3247*/3248function createFind(eachFunc, fromRight) {3249return function(collection, predicate, thisArg) {3250predicate = getCallback(predicate, thisArg, 3);3251if (isArray(collection)) {3252var index = baseFindIndex(collection, predicate, fromRight);3253return index > -1 ? collection[index] : undefined;3254}3255return baseFind(collection, predicate, eachFunc);3256};3257}32583259/**3260* Creates a `_.findIndex` or `_.findLastIndex` function.3261*3262* @private3263* @param {boolean} [fromRight] Specify iterating from right to left.3264* @returns {Function} Returns the new find function.3265*/3266function createFindIndex(fromRight) {3267return function(array, predicate, thisArg) {3268if (!(array && array.length)) {3269return -1;3270}3271predicate = getCallback(predicate, thisArg, 3);3272return baseFindIndex(array, predicate, fromRight);3273};3274}32753276/**3277* Creates a `_.findKey` or `_.findLastKey` function.3278*3279* @private3280* @param {Function} objectFunc The function to iterate over an object.3281* @returns {Function} Returns the new find function.3282*/3283function createFindKey(objectFunc) {3284return function(object, predicate, thisArg) {3285predicate = getCallback(predicate, thisArg, 3);3286return baseFind(object, predicate, objectFunc, true);3287};3288}32893290/**3291* Creates a `_.flow` or `_.flowRight` function.3292*3293* @private3294* @param {boolean} [fromRight] Specify iterating from right to left.3295* @returns {Function} Returns the new flow function.3296*/3297function createFlow(fromRight) {3298return function() {3299var wrapper,3300length = arguments.length,3301index = fromRight ? length : -1,3302leftIndex = 0,3303funcs = Array(length);33043305while ((fromRight ? index-- : ++index < length)) {3306var func = funcs[leftIndex++] = arguments[index];3307if (typeof func != 'function') {3308throw new TypeError(FUNC_ERROR_TEXT);3309}3310if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {3311wrapper = new LodashWrapper([]);3312}3313}3314index = wrapper ? -1 : length;3315while (++index < length) {3316func = funcs[index];33173318var funcName = getFuncName(func),3319data = funcName == 'wrapper' ? getData(func) : null;33203321if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {3322wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);3323} else {3324wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);3325}3326}3327return function() {3328var args = arguments;3329if (wrapper && args.length == 1 && isArray(args[0])) {3330return wrapper.plant(args[0]).value();3331}3332var index = 0,3333result = length ? funcs[index].apply(this, args) : args[0];33343335while (++index < length) {3336result = funcs[index].call(this, result);3337}3338return result;3339};3340};3341}33423343/**3344* Creates a function for `_.forEach` or `_.forEachRight`.3345*3346* @private3347* @param {Function} arrayFunc The function to iterate over an array.3348* @param {Function} eachFunc The function to iterate over a collection.3349* @returns {Function} Returns the new each function.3350*/3351function createForEach(arrayFunc, eachFunc) {3352return function(collection, iteratee, thisArg) {3353return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))3354? arrayFunc(collection, iteratee)3355: eachFunc(collection, bindCallback(iteratee, thisArg, 3));3356};3357}33583359/**3360* Creates a function for `_.forIn` or `_.forInRight`.3361*3362* @private3363* @param {Function} objectFunc The function to iterate over an object.3364* @returns {Function} Returns the new each function.3365*/3366function createForIn(objectFunc) {3367return function(object, iteratee, thisArg) {3368if (typeof iteratee != 'function' || thisArg !== undefined) {3369iteratee = bindCallback(iteratee, thisArg, 3);3370}3371return objectFunc(object, iteratee, keysIn);3372};3373}33743375/**3376* Creates a function for `_.forOwn` or `_.forOwnRight`.3377*3378* @private3379* @param {Function} objectFunc The function to iterate over an object.3380* @returns {Function} Returns the new each function.3381*/3382function createForOwn(objectFunc) {3383return function(object, iteratee, thisArg) {3384if (typeof iteratee != 'function' || thisArg !== undefined) {3385iteratee = bindCallback(iteratee, thisArg, 3);3386}3387return objectFunc(object, iteratee);3388};3389}33903391/**3392* Creates a function for `_.mapKeys` or `_.mapValues`.3393*3394* @private3395* @param {boolean} [isMapKeys] Specify mapping keys instead of values.3396* @returns {Function} Returns the new map function.3397*/3398function createObjectMapper(isMapKeys) {3399return function(object, iteratee, thisArg) {3400var result = {};3401iteratee = getCallback(iteratee, thisArg, 3);34023403baseForOwn(object, function(value, key, object) {3404var mapped = iteratee(value, key, object);3405key = isMapKeys ? mapped : key;3406value = isMapKeys ? value : mapped;3407result[key] = value;3408});3409return result;3410};3411}34123413/**3414* Creates a function for `_.padLeft` or `_.padRight`.3415*3416* @private3417* @param {boolean} [fromRight] Specify padding from the right.3418* @returns {Function} Returns the new pad function.3419*/3420function createPadDir(fromRight) {3421return function(string, length, chars) {3422string = baseToString(string);3423return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);3424};3425}34263427/**3428* Creates a `_.partial` or `_.partialRight` function.3429*3430* @private3431* @param {boolean} flag The partial bit flag.3432* @returns {Function} Returns the new partial function.3433*/3434function createPartial(flag) {3435var partialFunc = restParam(function(func, partials) {3436var holders = replaceHolders(partials, partialFunc.placeholder);3437return createWrapper(func, flag, null, partials, holders);3438});3439return partialFunc;3440}34413442/**3443* Creates a function for `_.reduce` or `_.reduceRight`.3444*3445* @private3446* @param {Function} arrayFunc The function to iterate over an array.3447* @param {Function} eachFunc The function to iterate over a collection.3448* @returns {Function} Returns the new each function.3449*/3450function createReduce(arrayFunc, eachFunc) {3451return function(collection, iteratee, accumulator, thisArg) {3452var initFromArray = arguments.length < 3;3453return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))3454? arrayFunc(collection, iteratee, accumulator, initFromArray)3455: baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);3456};3457}34583459/**3460* Creates a function that wraps `func` and invokes it with optional `this`3461* binding of, partial application, and currying.3462*3463* @private3464* @param {Function|string} func The function or method name to reference.3465* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.3466* @param {*} [thisArg] The `this` binding of `func`.3467* @param {Array} [partials] The arguments to prepend to those provided to the new function.3468* @param {Array} [holders] The `partials` placeholder indexes.3469* @param {Array} [partialsRight] The arguments to append to those provided to the new function.3470* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.3471* @param {Array} [argPos] The argument positions of the new function.3472* @param {number} [ary] The arity cap of `func`.3473* @param {number} [arity] The arity of `func`.3474* @returns {Function} Returns the new wrapped function.3475*/3476function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {3477var isAry = bitmask & ARY_FLAG,3478isBind = bitmask & BIND_FLAG,3479isBindKey = bitmask & BIND_KEY_FLAG,3480isCurry = bitmask & CURRY_FLAG,3481isCurryBound = bitmask & CURRY_BOUND_FLAG,3482isCurryRight = bitmask & CURRY_RIGHT_FLAG,3483Ctor = isBindKey ? null : createCtorWrapper(func);34843485function wrapper() {3486// Avoid `arguments` object use disqualifying optimizations by3487// converting it to an array before providing it to other functions.3488var length = arguments.length,3489index = length,3490args = Array(length);34913492while (index--) {3493args[index] = arguments[index];3494}3495if (partials) {3496args = composeArgs(args, partials, holders);3497}3498if (partialsRight) {3499args = composeArgsRight(args, partialsRight, holdersRight);3500}3501if (isCurry || isCurryRight) {3502var placeholder = wrapper.placeholder,3503argsHolders = replaceHolders(args, placeholder);35043505length -= argsHolders.length;3506if (length < arity) {3507var newArgPos = argPos ? arrayCopy(argPos) : null,3508newArity = nativeMax(arity - length, 0),3509newsHolders = isCurry ? argsHolders : null,3510newHoldersRight = isCurry ? null : argsHolders,3511newPartials = isCurry ? args : null,3512newPartialsRight = isCurry ? null : args;35133514bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);3515bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);35163517if (!isCurryBound) {3518bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);3519}3520var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],3521result = createHybridWrapper.apply(undefined, newData);35223523if (isLaziable(func)) {3524setData(result, newData);3525}3526result.placeholder = placeholder;3527return result;3528}3529}3530var thisBinding = isBind ? thisArg : this,3531fn = isBindKey ? thisBinding[func] : func;35323533if (argPos) {3534args = reorder(args, argPos);3535}3536if (isAry && ary < args.length) {3537args.length = ary;3538}3539if (this && this !== root && this instanceof wrapper) {3540fn = Ctor || createCtorWrapper(func);3541}3542return fn.apply(thisBinding, args);3543}3544return wrapper;3545}35463547/**3548* Creates the padding required for `string` based on the given `length`.3549* The `chars` string is truncated if the number of characters exceeds `length`.3550*3551* @private3552* @param {string} string The string to create padding for.3553* @param {number} [length=0] The padding length.3554* @param {string} [chars=' '] The string used as padding.3555* @returns {string} Returns the pad for `string`.3556*/3557function createPadding(string, length, chars) {3558var strLength = string.length;3559length = +length;35603561if (strLength >= length || !nativeIsFinite(length)) {3562return '';3563}3564var padLength = length - strLength;3565chars = chars == null ? ' ' : (chars + '');3566return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);3567}35683569/**3570* Creates a function that wraps `func` and invokes it with the optional `this`3571* binding of `thisArg` and the `partials` prepended to those provided to3572* the wrapper.3573*3574* @private3575* @param {Function} func The function to partially apply arguments to.3576* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.3577* @param {*} thisArg The `this` binding of `func`.3578* @param {Array} partials The arguments to prepend to those provided to the new function.3579* @returns {Function} Returns the new bound function.3580*/3581function createPartialWrapper(func, bitmask, thisArg, partials) {3582var isBind = bitmask & BIND_FLAG,3583Ctor = createCtorWrapper(func);35843585function wrapper() {3586// Avoid `arguments` object use disqualifying optimizations by3587// converting it to an array before providing it `func`.3588var argsIndex = -1,3589argsLength = arguments.length,3590leftIndex = -1,3591leftLength = partials.length,3592args = Array(argsLength + leftLength);35933594while (++leftIndex < leftLength) {3595args[leftIndex] = partials[leftIndex];3596}3597while (argsLength--) {3598args[leftIndex++] = arguments[++argsIndex];3599}3600var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;3601return fn.apply(isBind ? thisArg : this, args);3602}3603return wrapper;3604}36053606/**3607* Creates a `_.sortedIndex` or `_.sortedLastIndex` function.3608*3609* @private3610* @param {boolean} [retHighest] Specify returning the highest qualified index.3611* @returns {Function} Returns the new index function.3612*/3613function createSortedIndex(retHighest) {3614return function(array, value, iteratee, thisArg) {3615var callback = getCallback(iteratee);3616return (iteratee == null && callback === baseCallback)3617? binaryIndex(array, value, retHighest)3618: binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest);3619};3620}36213622/**3623* Creates a function that either curries or invokes `func` with optional3624* `this` binding and partially applied arguments.3625*3626* @private3627* @param {Function|string} func The function or method name to reference.3628* @param {number} bitmask The bitmask of flags.3629* The bitmask may be composed of the following flags:3630* 1 - `_.bind`3631* 2 - `_.bindKey`3632* 4 - `_.curry` or `_.curryRight` of a bound function3633* 8 - `_.curry`3634* 16 - `_.curryRight`3635* 32 - `_.partial`3636* 64 - `_.partialRight`3637* 128 - `_.rearg`3638* 256 - `_.ary`3639* @param {*} [thisArg] The `this` binding of `func`.3640* @param {Array} [partials] The arguments to be partially applied.3641* @param {Array} [holders] The `partials` placeholder indexes.3642* @param {Array} [argPos] The argument positions of the new function.3643* @param {number} [ary] The arity cap of `func`.3644* @param {number} [arity] The arity of `func`.3645* @returns {Function} Returns the new wrapped function.3646*/3647function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {3648var isBindKey = bitmask & BIND_KEY_FLAG;3649if (!isBindKey && typeof func != 'function') {3650throw new TypeError(FUNC_ERROR_TEXT);3651}3652var length = partials ? partials.length : 0;3653if (!length) {3654bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);3655partials = holders = null;3656}3657length -= (holders ? holders.length : 0);3658if (bitmask & PARTIAL_RIGHT_FLAG) {3659var partialsRight = partials,3660holdersRight = holders;36613662partials = holders = null;3663}3664var data = isBindKey ? null : getData(func),3665newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];36663667if (data) {3668mergeData(newData, data);3669bitmask = newData[1];3670arity = newData[9];3671}3672newData[9] = arity == null3673? (isBindKey ? 0 : func.length)3674: (nativeMax(arity - length, 0) || 0);36753676if (bitmask == BIND_FLAG) {3677var result = createBindWrapper(newData[0], newData[2]);3678} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {3679result = createPartialWrapper.apply(undefined, newData);3680} else {3681result = createHybridWrapper.apply(undefined, newData);3682}3683var setter = data ? baseSetData : setData;3684return setter(result, newData);3685}36863687/**3688* A specialized version of `baseIsEqualDeep` for arrays with support for3689* partial deep comparisons.3690*3691* @private3692* @param {Array} array The array to compare.3693* @param {Array} other The other array to compare.3694* @param {Function} equalFunc The function to determine equivalents of values.3695* @param {Function} [customizer] The function to customize comparing arrays.3696* @param {boolean} [isLoose] Specify performing partial comparisons.3697* @param {Array} [stackA] Tracks traversed `value` objects.3698* @param {Array} [stackB] Tracks traversed `other` objects.3699* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.3700*/3701function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {3702var index = -1,3703arrLength = array.length,3704othLength = other.length;37053706if (arrLength != othLength && !(isLoose && othLength > arrLength)) {3707return false;3708}3709// Ignore non-index properties.3710while (++index < arrLength) {3711var arrValue = array[index],3712othValue = other[index],3713result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;37143715if (result !== undefined) {3716if (result) {3717continue;3718}3719return false;3720}3721// Recursively compare arrays (susceptible to call stack limits).3722if (isLoose) {3723if (!arraySome(other, function(othValue) {3724return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);3725})) {3726return false;3727}3728} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {3729return false;3730}3731}3732return true;3733}37343735/**3736* A specialized version of `baseIsEqualDeep` for comparing objects of3737* the same `toStringTag`.3738*3739* **Note:** This function only supports comparing values with tags of3740* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.3741*3742* @private3743* @param {Object} value The object to compare.3744* @param {Object} other The other object to compare.3745* @param {string} tag The `toStringTag` of the objects to compare.3746* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.3747*/3748function equalByTag(object, other, tag) {3749switch (tag) {3750case boolTag:3751case dateTag:3752// Coerce dates and booleans to numbers, dates to milliseconds and booleans3753// to `1` or `0` treating invalid dates coerced to `NaN` as not equal.3754return +object == +other;37553756case errorTag:3757return object.name == other.name && object.message == other.message;37583759case numberTag:3760// Treat `NaN` vs. `NaN` as equal.3761return (object != +object)3762? other != +other3763: object == +other;37643765case regexpTag:3766case stringTag:3767// Coerce regexes to strings and treat strings primitives and string3768// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.3769return object == (other + '');3770}3771return false;3772}37733774/**3775* A specialized version of `baseIsEqualDeep` for objects with support for3776* partial deep comparisons.3777*3778* @private3779* @param {Object} object The object to compare.3780* @param {Object} other The other object to compare.3781* @param {Function} equalFunc The function to determine equivalents of values.3782* @param {Function} [customizer] The function to customize comparing values.3783* @param {boolean} [isLoose] Specify performing partial comparisons.3784* @param {Array} [stackA] Tracks traversed `value` objects.3785* @param {Array} [stackB] Tracks traversed `other` objects.3786* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.3787*/3788function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {3789var objProps = keys(object),3790objLength = objProps.length,3791othProps = keys(other),3792othLength = othProps.length;37933794if (objLength != othLength && !isLoose) {3795return false;3796}3797var index = objLength;3798while (index--) {3799var key = objProps[index];3800if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {3801return false;3802}3803}3804var skipCtor = isLoose;3805while (++index < objLength) {3806key = objProps[index];3807var objValue = object[key],3808othValue = other[key],3809result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;38103811// Recursively compare objects (susceptible to call stack limits).3812if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {3813return false;3814}3815skipCtor || (skipCtor = key == 'constructor');3816}3817if (!skipCtor) {3818var objCtor = object.constructor,3819othCtor = other.constructor;38203821// Non `Object` object instances with different constructors are not equal.3822if (objCtor != othCtor &&3823('constructor' in object && 'constructor' in other) &&3824!(typeof objCtor == 'function' && objCtor instanceof objCtor &&3825typeof othCtor == 'function' && othCtor instanceof othCtor)) {3826return false;3827}3828}3829return true;3830}38313832/**3833* Gets the appropriate "callback" function. If the `_.callback` method is3834* customized this function returns the custom method, otherwise it returns3835* the `baseCallback` function. If arguments are provided the chosen function3836* is invoked with them and its result is returned.3837*3838* @private3839* @returns {Function} Returns the chosen function or its result.3840*/3841function getCallback(func, thisArg, argCount) {3842var result = lodash.callback || callback;3843result = result === callback ? baseCallback : result;3844return argCount ? result(func, thisArg, argCount) : result;3845}38463847/**3848* Gets metadata for `func`.3849*3850* @private3851* @param {Function} func The function to query.3852* @returns {*} Returns the metadata for `func`.3853*/3854var getData = !metaMap ? noop : function(func) {3855return metaMap.get(func);3856};38573858/**3859* Gets the name of `func`.3860*3861* @private3862* @param {Function} func The function to query.3863* @returns {string} Returns the function name.3864*/3865function getFuncName(func) {3866var result = func.name,3867array = realNames[result],3868length = array ? array.length : 0;38693870while (length--) {3871var data = array[length],3872otherFunc = data.func;3873if (otherFunc == null || otherFunc == func) {3874return data.name;3875}3876}3877return result;3878}38793880/**3881* Gets the appropriate "indexOf" function. If the `_.indexOf` method is3882* customized this function returns the custom method, otherwise it returns3883* the `baseIndexOf` function. If arguments are provided the chosen function3884* is invoked with them and its result is returned.3885*3886* @private3887* @returns {Function|number} Returns the chosen function or its result.3888*/3889function getIndexOf(collection, target, fromIndex) {3890var result = lodash.indexOf || indexOf;3891result = result === indexOf ? baseIndexOf : result;3892return collection ? result(collection, target, fromIndex) : result;3893}38943895/**3896* Gets the "length" property value of `object`.3897*3898* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)3899* that affects Safari on at least iOS 8.1-8.3 ARM64.3900*3901* @private3902* @param {Object} object The object to query.3903* @returns {*} Returns the "length" value.3904*/3905var getLength = baseProperty('length');39063907/**3908* Gets the propery names, values, and compare flags of `object`.3909*3910* @private3911* @param {Object} object The object to query.3912* @returns {Array} Returns the match data of `object`.3913*/3914function getMatchData(object) {3915var result = pairs(object),3916length = result.length;39173918while (length--) {3919result[length][2] = isStrictComparable(result[length][1]);3920}3921return result;3922}39233924/**3925* Gets the native function at `key` of `object`.3926*3927* @private3928* @param {Object} object The object to query.3929* @param {string} key The key of the method to get.3930* @returns {*} Returns the function if it's native, else `undefined`.3931*/3932function getNative(object, key) {3933var value = object == null ? undefined : object[key];3934return isNative(value) ? value : undefined;3935}39363937/**3938* Gets the view, applying any `transforms` to the `start` and `end` positions.3939*3940* @private3941* @param {number} start The start of the view.3942* @param {number} end The end of the view.3943* @param {Array} [transforms] The transformations to apply to the view.3944* @returns {Object} Returns an object containing the `start` and `end`3945* positions of the view.3946*/3947function getView(start, end, transforms) {3948var index = -1,3949length = transforms ? transforms.length : 0;39503951while (++index < length) {3952var data = transforms[index],3953size = data.size;39543955switch (data.type) {3956case 'drop': start += size; break;3957case 'dropRight': end -= size; break;3958case 'take': end = nativeMin(end, start + size); break;3959case 'takeRight': start = nativeMax(start, end - size); break;3960}3961}3962return { 'start': start, 'end': end };3963}39643965/**3966* Initializes an array clone.3967*3968* @private3969* @param {Array} array The array to clone.3970* @returns {Array} Returns the initialized clone.3971*/3972function initCloneArray(array) {3973var length = array.length,3974result = new array.constructor(length);39753976// Add array properties assigned by `RegExp#exec`.3977if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {3978result.index = array.index;3979result.input = array.input;3980}3981return result;3982}39833984/**3985* Initializes an object clone.3986*3987* @private3988* @param {Object} object The object to clone.3989* @returns {Object} Returns the initialized clone.3990*/3991function initCloneObject(object) {3992var Ctor = object.constructor;3993if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {3994Ctor = Object;3995}3996return new Ctor;3997}39983999/**4000* Initializes an object clone based on its `toStringTag`.4001*4002* **Note:** This function only supports cloning values with tags of4003* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.4004*4005* @private4006* @param {Object} object The object to clone.4007* @param {string} tag The `toStringTag` of the object to clone.4008* @param {boolean} [isDeep] Specify a deep clone.4009* @returns {Object} Returns the initialized clone.4010*/4011function initCloneByTag(object, tag, isDeep) {4012var Ctor = object.constructor;4013switch (tag) {4014case arrayBufferTag:4015return bufferClone(object);40164017case boolTag:4018case dateTag:4019return new Ctor(+object);40204021case float32Tag: case float64Tag:4022case int8Tag: case int16Tag: case int32Tag:4023case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:4024var buffer = object.buffer;4025return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);40264027case numberTag:4028case stringTag:4029return new Ctor(object);40304031case regexpTag:4032var result = new Ctor(object.source, reFlags.exec(object));4033result.lastIndex = object.lastIndex;4034}4035return result;4036}40374038/**4039* Invokes the method at `path` on `object`.4040*4041* @private4042* @param {Object} object The object to query.4043* @param {Array|string} path The path of the method to invoke.4044* @param {Array} args The arguments to invoke the method with.4045* @returns {*} Returns the result of the invoked method.4046*/4047function invokePath(object, path, args) {4048if (object != null && !isKey(path, object)) {4049path = toPath(path);4050object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));4051path = last(path);4052}4053var func = object == null ? object : object[path];4054return func == null ? undefined : func.apply(object, args);4055}40564057/**4058* Checks if `value` is array-like.4059*4060* @private4061* @param {*} value The value to check.4062* @returns {boolean} Returns `true` if `value` is array-like, else `false`.4063*/4064function isArrayLike(value) {4065return value != null && isLength(getLength(value));4066}40674068/**4069* Checks if `value` is a valid array-like index.4070*4071* @private4072* @param {*} value The value to check.4073* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.4074* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.4075*/4076function isIndex(value, length) {4077value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;4078length = length == null ? MAX_SAFE_INTEGER : length;4079return value > -1 && value % 1 == 0 && value < length;4080}40814082/**4083* Checks if the provided arguments are from an iteratee call.4084*4085* @private4086* @param {*} value The potential iteratee value argument.4087* @param {*} index The potential iteratee index or key argument.4088* @param {*} object The potential iteratee object argument.4089* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.4090*/4091function isIterateeCall(value, index, object) {4092if (!isObject(object)) {4093return false;4094}4095var type = typeof index;4096if (type == 'number'4097? (isArrayLike(object) && isIndex(index, object.length))4098: (type == 'string' && index in object)) {4099var other = object[index];4100return value === value ? (value === other) : (other !== other);4101}4102return false;4103}41044105/**4106* Checks if `value` is a property name and not a property path.4107*4108* @private4109* @param {*} value The value to check.4110* @param {Object} [object] The object to query keys on.4111* @returns {boolean} Returns `true` if `value` is a property name, else `false`.4112*/4113function isKey(value, object) {4114var type = typeof value;4115if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {4116return true;4117}4118if (isArray(value)) {4119return false;4120}4121var result = !reIsDeepProp.test(value);4122return result || (object != null && value in toObject(object));4123}41244125/**4126* Checks if `func` has a lazy counterpart.4127*4128* @private4129* @param {Function} func The function to check.4130* @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.4131*/4132function isLaziable(func) {4133var funcName = getFuncName(func);4134if (!(funcName in LazyWrapper.prototype)) {4135return false;4136}4137var other = lodash[funcName];4138if (func === other) {4139return true;4140}4141var data = getData(other);4142return !!data && func === data[0];4143}41444145/**4146* Checks if `value` is a valid array-like length.4147*4148* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).4149*4150* @private4151* @param {*} value The value to check.4152* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.4153*/4154function isLength(value) {4155return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;4156}41574158/**4159* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.4160*4161* @private4162* @param {*} value The value to check.4163* @returns {boolean} Returns `true` if `value` if suitable for strict4164* equality comparisons, else `false`.4165*/4166function isStrictComparable(value) {4167return value === value && !isObject(value);4168}41694170/**4171* Merges the function metadata of `source` into `data`.4172*4173* Merging metadata reduces the number of wrappers required to invoke a function.4174* This is possible because methods like `_.bind`, `_.curry`, and `_.partial`4175* may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`4176* augment function arguments, making the order in which they are executed important,4177* preventing the merging of metadata. However, we make an exception for a safe4178* common case where curried functions have `_.ary` and or `_.rearg` applied.4179*4180* @private4181* @param {Array} data The destination metadata.4182* @param {Array} source The source metadata.4183* @returns {Array} Returns `data`.4184*/4185function mergeData(data, source) {4186var bitmask = data[1],4187srcBitmask = source[1],4188newBitmask = bitmask | srcBitmask,4189isCommon = newBitmask < ARY_FLAG;41904191var isCombo =4192(srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||4193(srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||4194(srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);41954196// Exit early if metadata can't be merged.4197if (!(isCommon || isCombo)) {4198return data;4199}4200// Use source `thisArg` if available.4201if (srcBitmask & BIND_FLAG) {4202data[2] = source[2];4203// Set when currying a bound function.4204newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;4205}4206// Compose partial arguments.4207var value = source[3];4208if (value) {4209var partials = data[3];4210data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);4211data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);4212}4213// Compose partial right arguments.4214value = source[5];4215if (value) {4216partials = data[5];4217data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);4218data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);4219}4220// Use source `argPos` if available.4221value = source[7];4222if (value) {4223data[7] = arrayCopy(value);4224}4225// Use source `ary` if it's smaller.4226if (srcBitmask & ARY_FLAG) {4227data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);4228}4229// Use source `arity` if one is not provided.4230if (data[9] == null) {4231data[9] = source[9];4232}4233// Use source `func` and merge bitmasks.4234data[0] = source[0];4235data[1] = newBitmask;42364237return data;4238}42394240/**4241* A specialized version of `_.pick` which picks `object` properties specified4242* by `props`.4243*4244* @private4245* @param {Object} object The source object.4246* @param {string[]} props The property names to pick.4247* @returns {Object} Returns the new object.4248*/4249function pickByArray(object, props) {4250object = toObject(object);42514252var index = -1,4253length = props.length,4254result = {};42554256while (++index < length) {4257var key = props[index];4258if (key in object) {4259result[key] = object[key];4260}4261}4262return result;4263}42644265/**4266* A specialized version of `_.pick` which picks `object` properties `predicate`4267* returns truthy for.4268*4269* @private4270* @param {Object} object The source object.4271* @param {Function} predicate The function invoked per iteration.4272* @returns {Object} Returns the new object.4273*/4274function pickByCallback(object, predicate) {4275var result = {};4276baseForIn(object, function(value, key, object) {4277if (predicate(value, key, object)) {4278result[key] = value;4279}4280});4281return result;4282}42834284/**4285* Reorder `array` according to the specified indexes where the element at4286* the first index is assigned as the first element, the element at4287* the second index is assigned as the second element, and so on.4288*4289* @private4290* @param {Array} array The array to reorder.4291* @param {Array} indexes The arranged array indexes.4292* @returns {Array} Returns `array`.4293*/4294function reorder(array, indexes) {4295var arrLength = array.length,4296length = nativeMin(indexes.length, arrLength),4297oldArray = arrayCopy(array);42984299while (length--) {4300var index = indexes[length];4301array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;4302}4303return array;4304}43054306/**4307* Sets metadata for `func`.4308*4309* **Note:** If this function becomes hot, i.e. is invoked a lot in a short4310* period of time, it will trip its breaker and transition to an identity function4311* to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)4312* for more details.4313*4314* @private4315* @param {Function} func The function to associate metadata with.4316* @param {*} data The metadata.4317* @returns {Function} Returns `func`.4318*/4319var setData = (function() {4320var count = 0,4321lastCalled = 0;43224323return function(key, value) {4324var stamp = now(),4325remaining = HOT_SPAN - (stamp - lastCalled);43264327lastCalled = stamp;4328if (remaining > 0) {4329if (++count >= HOT_COUNT) {4330return key;4331}4332} else {4333count = 0;4334}4335return baseSetData(key, value);4336};4337}());43384339/**4340* A fallback implementation of `_.isPlainObject` which checks if `value`4341* is an object created by the `Object` constructor or has a `[[Prototype]]`4342* of `null`.4343*4344* @private4345* @param {*} value The value to check.4346* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.4347*/4348function shimIsPlainObject(value) {4349var Ctor,4350support = lodash.support;43514352// Exit early for non `Object` objects.4353if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||4354(!hasOwnProperty.call(value, 'constructor') &&4355(Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {4356return false;4357}4358// IE < 9 iterates inherited properties before own properties. If the first4359// iterated property is an object's own property then there are no inherited4360// enumerable properties.4361var result;4362// In most environments an object's own properties are iterated before4363// its inherited properties. If the last iterated property is an object's4364// own property then there are no inherited enumerable properties.4365baseForIn(value, function(subValue, key) {4366result = key;4367});4368return result === undefined || hasOwnProperty.call(value, result);4369}43704371/**4372* A fallback implementation of `Object.keys` which creates an array of the4373* own enumerable property names of `object`.4374*4375* @private4376* @param {Object} object The object to query.4377* @returns {Array} Returns the array of property names.4378*/4379function shimKeys(object) {4380var props = keysIn(object),4381propsLength = props.length,4382length = propsLength && object.length;43834384var allowIndexes = !!length && isLength(length) &&4385(isArray(object) || isArguments(object));43864387var index = -1,4388result = [];43894390while (++index < propsLength) {4391var key = props[index];4392if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {4393result.push(key);4394}4395}4396return result;4397}43984399/**4400* Converts `value` to an array-like object if it's not one.4401*4402* @private4403* @param {*} value The value to process.4404* @returns {Array|Object} Returns the array-like object.4405*/4406function toIterable(value) {4407if (value == null) {4408return [];4409}4410if (!isArrayLike(value)) {4411return values(value);4412}4413return isObject(value) ? value : Object(value);4414}44154416/**4417* Converts `value` to an object if it's not one.4418*4419* @private4420* @param {*} value The value to process.4421* @returns {Object} Returns the object.4422*/4423function toObject(value) {4424return isObject(value) ? value : Object(value);4425}44264427/**4428* Converts `value` to property path array if it's not one.4429*4430* @private4431* @param {*} value The value to process.4432* @returns {Array} Returns the property path array.4433*/4434function toPath(value) {4435if (isArray(value)) {4436return value;4437}4438var result = [];4439baseToString(value).replace(rePropName, function(match, number, quote, string) {4440result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));4441});4442return result;4443}44444445/**4446* Creates a clone of `wrapper`.4447*4448* @private4449* @param {Object} wrapper The wrapper to clone.4450* @returns {Object} Returns the cloned wrapper.4451*/4452function wrapperClone(wrapper) {4453return wrapper instanceof LazyWrapper4454? wrapper.clone()4455: new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));4456}44574458/*------------------------------------------------------------------------*/44594460/**4461* Creates an array of elements split into groups the length of `size`.4462* If `collection` can't be split evenly, the final chunk will be the remaining4463* elements.4464*4465* @static4466* @memberOf _4467* @category Array4468* @param {Array} array The array to process.4469* @param {number} [size=1] The length of each chunk.4470* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.4471* @returns {Array} Returns the new array containing chunks.4472* @example4473*4474* _.chunk(['a', 'b', 'c', 'd'], 2);4475* // => [['a', 'b'], ['c', 'd']]4476*4477* _.chunk(['a', 'b', 'c', 'd'], 3);4478* // => [['a', 'b', 'c'], ['d']]4479*/4480function chunk(array, size, guard) {4481if (guard ? isIterateeCall(array, size, guard) : size == null) {4482size = 1;4483} else {4484size = nativeMax(+size || 1, 1);4485}4486var index = 0,4487length = array ? array.length : 0,4488resIndex = -1,4489result = Array(ceil(length / size));44904491while (index < length) {4492result[++resIndex] = baseSlice(array, index, (index += size));4493}4494return result;4495}44964497/**4498* Creates an array with all falsey values removed. The values `false`, `null`,4499* `0`, `""`, `undefined`, and `NaN` are falsey.4500*4501* @static4502* @memberOf _4503* @category Array4504* @param {Array} array The array to compact.4505* @returns {Array} Returns the new array of filtered values.4506* @example4507*4508* _.compact([0, 1, false, 2, '', 3]);4509* // => [1, 2, 3]4510*/4511function compact(array) {4512var index = -1,4513length = array ? array.length : 0,4514resIndex = -1,4515result = [];45164517while (++index < length) {4518var value = array[index];4519if (value) {4520result[++resIndex] = value;4521}4522}4523return result;4524}45254526/**4527* Creates an array of unique `array` values not included in the other4528* provided arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)4529* for equality comparisons.4530*4531* @static4532* @memberOf _4533* @category Array4534* @param {Array} array The array to inspect.4535* @param {...Array} [values] The arrays of values to exclude.4536* @returns {Array} Returns the new array of filtered values.4537* @example4538*4539* _.difference([1, 2, 3], [4, 2]);4540* // => [1, 3]4541*/4542var difference = restParam(function(array, values) {4543return isArrayLike(array)4544? baseDifference(array, baseFlatten(values, false, true))4545: [];4546});45474548/**4549* Creates a slice of `array` with `n` elements dropped from the beginning.4550*4551* @static4552* @memberOf _4553* @category Array4554* @param {Array} array The array to query.4555* @param {number} [n=1] The number of elements to drop.4556* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.4557* @returns {Array} Returns the slice of `array`.4558* @example4559*4560* _.drop([1, 2, 3]);4561* // => [2, 3]4562*4563* _.drop([1, 2, 3], 2);4564* // => [3]4565*4566* _.drop([1, 2, 3], 5);4567* // => []4568*4569* _.drop([1, 2, 3], 0);4570* // => [1, 2, 3]4571*/4572function drop(array, n, guard) {4573var length = array ? array.length : 0;4574if (!length) {4575return [];4576}4577if (guard ? isIterateeCall(array, n, guard) : n == null) {4578n = 1;4579}4580return baseSlice(array, n < 0 ? 0 : n);4581}45824583/**4584* Creates a slice of `array` with `n` elements dropped from the end.4585*4586* @static4587* @memberOf _4588* @category Array4589* @param {Array} array The array to query.4590* @param {number} [n=1] The number of elements to drop.4591* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.4592* @returns {Array} Returns the slice of `array`.4593* @example4594*4595* _.dropRight([1, 2, 3]);4596* // => [1, 2]4597*4598* _.dropRight([1, 2, 3], 2);4599* // => [1]4600*4601* _.dropRight([1, 2, 3], 5);4602* // => []4603*4604* _.dropRight([1, 2, 3], 0);4605* // => [1, 2, 3]4606*/4607function dropRight(array, n, guard) {4608var length = array ? array.length : 0;4609if (!length) {4610return [];4611}4612if (guard ? isIterateeCall(array, n, guard) : n == null) {4613n = 1;4614}4615n = length - (+n || 0);4616return baseSlice(array, 0, n < 0 ? 0 : n);4617}46184619/**4620* Creates a slice of `array` excluding elements dropped from the end.4621* Elements are dropped until `predicate` returns falsey. The predicate is4622* bound to `thisArg` and invoked with three arguments: (value, index, array).4623*4624* If a property name is provided for `predicate` the created `_.property`4625* style callback returns the property value of the given element.4626*4627* If a value is also provided for `thisArg` the created `_.matchesProperty`4628* style callback returns `true` for elements that have a matching property4629* value, else `false`.4630*4631* If an object is provided for `predicate` the created `_.matches` style4632* callback returns `true` for elements that match the properties of the given4633* object, else `false`.4634*4635* @static4636* @memberOf _4637* @category Array4638* @param {Array} array The array to query.4639* @param {Function|Object|string} [predicate=_.identity] The function invoked4640* per iteration.4641* @param {*} [thisArg] The `this` binding of `predicate`.4642* @returns {Array} Returns the slice of `array`.4643* @example4644*4645* _.dropRightWhile([1, 2, 3], function(n) {4646* return n > 1;4647* });4648* // => [1]4649*4650* var users = [4651* { 'user': 'barney', 'active': true },4652* { 'user': 'fred', 'active': false },4653* { 'user': 'pebbles', 'active': false }4654* ];4655*4656* // using the `_.matches` callback shorthand4657* _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');4658* // => ['barney', 'fred']4659*4660* // using the `_.matchesProperty` callback shorthand4661* _.pluck(_.dropRightWhile(users, 'active', false), 'user');4662* // => ['barney']4663*4664* // using the `_.property` callback shorthand4665* _.pluck(_.dropRightWhile(users, 'active'), 'user');4666* // => ['barney', 'fred', 'pebbles']4667*/4668function dropRightWhile(array, predicate, thisArg) {4669return (array && array.length)4670? baseWhile(array, getCallback(predicate, thisArg, 3), true, true)4671: [];4672}46734674/**4675* Creates a slice of `array` excluding elements dropped from the beginning.4676* Elements are dropped until `predicate` returns falsey. The predicate is4677* bound to `thisArg` and invoked with three arguments: (value, index, array).4678*4679* If a property name is provided for `predicate` the created `_.property`4680* style callback returns the property value of the given element.4681*4682* If a value is also provided for `thisArg` the created `_.matchesProperty`4683* style callback returns `true` for elements that have a matching property4684* value, else `false`.4685*4686* If an object is provided for `predicate` the created `_.matches` style4687* callback returns `true` for elements that have the properties of the given4688* object, else `false`.4689*4690* @static4691* @memberOf _4692* @category Array4693* @param {Array} array The array to query.4694* @param {Function|Object|string} [predicate=_.identity] The function invoked4695* per iteration.4696* @param {*} [thisArg] The `this` binding of `predicate`.4697* @returns {Array} Returns the slice of `array`.4698* @example4699*4700* _.dropWhile([1, 2, 3], function(n) {4701* return n < 3;4702* });4703* // => [3]4704*4705* var users = [4706* { 'user': 'barney', 'active': false },4707* { 'user': 'fred', 'active': false },4708* { 'user': 'pebbles', 'active': true }4709* ];4710*4711* // using the `_.matches` callback shorthand4712* _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');4713* // => ['fred', 'pebbles']4714*4715* // using the `_.matchesProperty` callback shorthand4716* _.pluck(_.dropWhile(users, 'active', false), 'user');4717* // => ['pebbles']4718*4719* // using the `_.property` callback shorthand4720* _.pluck(_.dropWhile(users, 'active'), 'user');4721* // => ['barney', 'fred', 'pebbles']4722*/4723function dropWhile(array, predicate, thisArg) {4724return (array && array.length)4725? baseWhile(array, getCallback(predicate, thisArg, 3), true)4726: [];4727}47284729/**4730* Fills elements of `array` with `value` from `start` up to, but not4731* including, `end`.4732*4733* **Note:** This method mutates `array`.4734*4735* @static4736* @memberOf _4737* @category Array4738* @param {Array} array The array to fill.4739* @param {*} value The value to fill `array` with.4740* @param {number} [start=0] The start position.4741* @param {number} [end=array.length] The end position.4742* @returns {Array} Returns `array`.4743* @example4744*4745* var array = [1, 2, 3];4746*4747* _.fill(array, 'a');4748* console.log(array);4749* // => ['a', 'a', 'a']4750*4751* _.fill(Array(3), 2);4752* // => [2, 2, 2]4753*4754* _.fill([4, 6, 8], '*', 1, 2);4755* // => [4, '*', 8]4756*/4757function fill(array, value, start, end) {4758var length = array ? array.length : 0;4759if (!length) {4760return [];4761}4762if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {4763start = 0;4764end = length;4765}4766return baseFill(array, value, start, end);4767}47684769/**4770* This method is like `_.find` except that it returns the index of the first4771* element `predicate` returns truthy for instead of the element itself.4772*4773* If a property name is provided for `predicate` the created `_.property`4774* style callback returns the property value of the given element.4775*4776* If a value is also provided for `thisArg` the created `_.matchesProperty`4777* style callback returns `true` for elements that have a matching property4778* value, else `false`.4779*4780* If an object is provided for `predicate` the created `_.matches` style4781* callback returns `true` for elements that have the properties of the given4782* object, else `false`.4783*4784* @static4785* @memberOf _4786* @category Array4787* @param {Array} array The array to search.4788* @param {Function|Object|string} [predicate=_.identity] The function invoked4789* per iteration.4790* @param {*} [thisArg] The `this` binding of `predicate`.4791* @returns {number} Returns the index of the found element, else `-1`.4792* @example4793*4794* var users = [4795* { 'user': 'barney', 'active': false },4796* { 'user': 'fred', 'active': false },4797* { 'user': 'pebbles', 'active': true }4798* ];4799*4800* _.findIndex(users, function(chr) {4801* return chr.user == 'barney';4802* });4803* // => 04804*4805* // using the `_.matches` callback shorthand4806* _.findIndex(users, { 'user': 'fred', 'active': false });4807* // => 14808*4809* // using the `_.matchesProperty` callback shorthand4810* _.findIndex(users, 'active', false);4811* // => 04812*4813* // using the `_.property` callback shorthand4814* _.findIndex(users, 'active');4815* // => 24816*/4817var findIndex = createFindIndex();48184819/**4820* This method is like `_.findIndex` except that it iterates over elements4821* of `collection` from right to left.4822*4823* If a property name is provided for `predicate` the created `_.property`4824* style callback returns the property value of the given element.4825*4826* If a value is also provided for `thisArg` the created `_.matchesProperty`4827* style callback returns `true` for elements that have a matching property4828* value, else `false`.4829*4830* If an object is provided for `predicate` the created `_.matches` style4831* callback returns `true` for elements that have the properties of the given4832* object, else `false`.4833*4834* @static4835* @memberOf _4836* @category Array4837* @param {Array} array The array to search.4838* @param {Function|Object|string} [predicate=_.identity] The function invoked4839* per iteration.4840* @param {*} [thisArg] The `this` binding of `predicate`.4841* @returns {number} Returns the index of the found element, else `-1`.4842* @example4843*4844* var users = [4845* { 'user': 'barney', 'active': true },4846* { 'user': 'fred', 'active': false },4847* { 'user': 'pebbles', 'active': false }4848* ];4849*4850* _.findLastIndex(users, function(chr) {4851* return chr.user == 'pebbles';4852* });4853* // => 24854*4855* // using the `_.matches` callback shorthand4856* _.findLastIndex(users, { 'user': 'barney', 'active': true });4857* // => 04858*4859* // using the `_.matchesProperty` callback shorthand4860* _.findLastIndex(users, 'active', false);4861* // => 24862*4863* // using the `_.property` callback shorthand4864* _.findLastIndex(users, 'active');4865* // => 04866*/4867var findLastIndex = createFindIndex(true);48684869/**4870* Gets the first element of `array`.4871*4872* @static4873* @memberOf _4874* @alias head4875* @category Array4876* @param {Array} array The array to query.4877* @returns {*} Returns the first element of `array`.4878* @example4879*4880* _.first([1, 2, 3]);4881* // => 14882*4883* _.first([]);4884* // => undefined4885*/4886function first(array) {4887return array ? array[0] : undefined;4888}48894890/**4891* Flattens a nested array. If `isDeep` is `true` the array is recursively4892* flattened, otherwise it is only flattened a single level.4893*4894* @static4895* @memberOf _4896* @category Array4897* @param {Array} array The array to flatten.4898* @param {boolean} [isDeep] Specify a deep flatten.4899* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.4900* @returns {Array} Returns the new flattened array.4901* @example4902*4903* _.flatten([1, [2, 3, [4]]]);4904* // => [1, 2, 3, [4]]4905*4906* // using `isDeep`4907* _.flatten([1, [2, 3, [4]]], true);4908* // => [1, 2, 3, 4]4909*/4910function flatten(array, isDeep, guard) {4911var length = array ? array.length : 0;4912if (guard && isIterateeCall(array, isDeep, guard)) {4913isDeep = false;4914}4915return length ? baseFlatten(array, isDeep) : [];4916}49174918/**4919* Recursively flattens a nested array.4920*4921* @static4922* @memberOf _4923* @category Array4924* @param {Array} array The array to recursively flatten.4925* @returns {Array} Returns the new flattened array.4926* @example4927*4928* _.flattenDeep([1, [2, 3, [4]]]);4929* // => [1, 2, 3, 4]4930*/4931function flattenDeep(array) {4932var length = array ? array.length : 0;4933return length ? baseFlatten(array, true) : [];4934}49354936/**4937* Gets the index at which the first occurrence of `value` is found in `array`4938* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)4939* for equality comparisons. If `fromIndex` is negative, it is used as the offset4940* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`4941* performs a faster binary search.4942*4943* @static4944* @memberOf _4945* @category Array4946* @param {Array} array The array to search.4947* @param {*} value The value to search for.4948* @param {boolean|number} [fromIndex=0] The index to search from or `true`4949* to perform a binary search on a sorted array.4950* @returns {number} Returns the index of the matched value, else `-1`.4951* @example4952*4953* _.indexOf([1, 2, 1, 2], 2);4954* // => 14955*4956* // using `fromIndex`4957* _.indexOf([1, 2, 1, 2], 2, 2);4958* // => 34959*4960* // performing a binary search4961* _.indexOf([1, 1, 2, 2], 2, true);4962* // => 24963*/4964function indexOf(array, value, fromIndex) {4965var length = array ? array.length : 0;4966if (!length) {4967return -1;4968}4969if (typeof fromIndex == 'number') {4970fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;4971} else if (fromIndex) {4972var index = binaryIndex(array, value),4973other = array[index];49744975if (value === value ? (value === other) : (other !== other)) {4976return index;4977}4978return -1;4979}4980return baseIndexOf(array, value, fromIndex || 0);4981}49824983/**4984* Gets all but the last element of `array`.4985*4986* @static4987* @memberOf _4988* @category Array4989* @param {Array} array The array to query.4990* @returns {Array} Returns the slice of `array`.4991* @example4992*4993* _.initial([1, 2, 3]);4994* // => [1, 2]4995*/4996function initial(array) {4997return dropRight(array, 1);4998}49995000/**5001* Creates an array of unique values that are included in all of the provided5002* arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)5003* for equality comparisons.5004*5005* @static5006* @memberOf _5007* @category Array5008* @param {...Array} [arrays] The arrays to inspect.5009* @returns {Array} Returns the new array of shared values.5010* @example5011* _.intersection([1, 2], [4, 2], [2, 1]);5012* // => [2]5013*/5014var intersection = restParam(function(arrays) {5015var othLength = arrays.length,5016othIndex = othLength,5017caches = Array(length),5018indexOf = getIndexOf(),5019isCommon = indexOf == baseIndexOf,5020result = [];50215022while (othIndex--) {5023var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];5024caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;5025}5026var array = arrays[0],5027index = -1,5028length = array ? array.length : 0,5029seen = caches[0];50305031outer:5032while (++index < length) {5033value = array[index];5034if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {5035var othIndex = othLength;5036while (--othIndex) {5037var cache = caches[othIndex];5038if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {5039continue outer;5040}5041}5042if (seen) {5043seen.push(value);5044}5045result.push(value);5046}5047}5048return result;5049});50505051/**5052* Gets the last element of `array`.5053*5054* @static5055* @memberOf _5056* @category Array5057* @param {Array} array The array to query.5058* @returns {*} Returns the last element of `array`.5059* @example5060*5061* _.last([1, 2, 3]);5062* // => 35063*/5064function last(array) {5065var length = array ? array.length : 0;5066return length ? array[length - 1] : undefined;5067}50685069/**5070* This method is like `_.indexOf` except that it iterates over elements of5071* `array` from right to left.5072*5073* @static5074* @memberOf _5075* @category Array5076* @param {Array} array The array to search.5077* @param {*} value The value to search for.5078* @param {boolean|number} [fromIndex=array.length-1] The index to search from5079* or `true` to perform a binary search on a sorted array.5080* @returns {number} Returns the index of the matched value, else `-1`.5081* @example5082*5083* _.lastIndexOf([1, 2, 1, 2], 2);5084* // => 35085*5086* // using `fromIndex`5087* _.lastIndexOf([1, 2, 1, 2], 2, 2);5088* // => 15089*5090* // performing a binary search5091* _.lastIndexOf([1, 1, 2, 2], 2, true);5092* // => 35093*/5094function lastIndexOf(array, value, fromIndex) {5095var length = array ? array.length : 0;5096if (!length) {5097return -1;5098}5099var index = length;5100if (typeof fromIndex == 'number') {5101index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;5102} else if (fromIndex) {5103index = binaryIndex(array, value, true) - 1;5104var other = array[index];5105if (value === value ? (value === other) : (other !== other)) {5106return index;5107}5108return -1;5109}5110if (value !== value) {5111return indexOfNaN(array, index, true);5112}5113while (index--) {5114if (array[index] === value) {5115return index;5116}5117}5118return -1;5119}51205121/**5122* Removes all provided values from `array` using5123* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)5124* for equality comparisons.5125*5126* **Note:** Unlike `_.without`, this method mutates `array`.5127*5128* @static5129* @memberOf _5130* @category Array5131* @param {Array} array The array to modify.5132* @param {...*} [values] The values to remove.5133* @returns {Array} Returns `array`.5134* @example5135*5136* var array = [1, 2, 3, 1, 2, 3];5137*5138* _.pull(array, 2, 3);5139* console.log(array);5140* // => [1, 1]5141*/5142function pull() {5143var args = arguments,5144array = args[0];51455146if (!(array && array.length)) {5147return array;5148}5149var index = 0,5150indexOf = getIndexOf(),5151length = args.length;51525153while (++index < length) {5154var fromIndex = 0,5155value = args[index];51565157while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {5158splice.call(array, fromIndex, 1);5159}5160}5161return array;5162}51635164/**5165* Removes elements from `array` corresponding to the given indexes and returns5166* an array of the removed elements. Indexes may be specified as an array of5167* indexes or as individual arguments.5168*5169* **Note:** Unlike `_.at`, this method mutates `array`.5170*5171* @static5172* @memberOf _5173* @category Array5174* @param {Array} array The array to modify.5175* @param {...(number|number[])} [indexes] The indexes of elements to remove,5176* specified as individual indexes or arrays of indexes.5177* @returns {Array} Returns the new array of removed elements.5178* @example5179*5180* var array = [5, 10, 15, 20];5181* var evens = _.pullAt(array, 1, 3);5182*5183* console.log(array);5184* // => [5, 15]5185*5186* console.log(evens);5187* // => [10, 20]5188*/5189var pullAt = restParam(function(array, indexes) {5190indexes = baseFlatten(indexes);51915192var result = baseAt(array, indexes);5193basePullAt(array, indexes.sort(baseCompareAscending));5194return result;5195});51965197/**5198* Removes all elements from `array` that `predicate` returns truthy for5199* and returns an array of the removed elements. The predicate is bound to5200* `thisArg` and invoked with three arguments: (value, index, array).5201*5202* If a property name is provided for `predicate` the created `_.property`5203* style callback returns the property value of the given element.5204*5205* If a value is also provided for `thisArg` the created `_.matchesProperty`5206* style callback returns `true` for elements that have a matching property5207* value, else `false`.5208*5209* If an object is provided for `predicate` the created `_.matches` style5210* callback returns `true` for elements that have the properties of the given5211* object, else `false`.5212*5213* **Note:** Unlike `_.filter`, this method mutates `array`.5214*5215* @static5216* @memberOf _5217* @category Array5218* @param {Array} array The array to modify.5219* @param {Function|Object|string} [predicate=_.identity] The function invoked5220* per iteration.5221* @param {*} [thisArg] The `this` binding of `predicate`.5222* @returns {Array} Returns the new array of removed elements.5223* @example5224*5225* var array = [1, 2, 3, 4];5226* var evens = _.remove(array, function(n) {5227* return n % 2 == 0;5228* });5229*5230* console.log(array);5231* // => [1, 3]5232*5233* console.log(evens);5234* // => [2, 4]5235*/5236function remove(array, predicate, thisArg) {5237var result = [];5238if (!(array && array.length)) {5239return result;5240}5241var index = -1,5242indexes = [],5243length = array.length;52445245predicate = getCallback(predicate, thisArg, 3);5246while (++index < length) {5247var value = array[index];5248if (predicate(value, index, array)) {5249result.push(value);5250indexes.push(index);5251}5252}5253basePullAt(array, indexes);5254return result;5255}52565257/**5258* Gets all but the first element of `array`.5259*5260* @static5261* @memberOf _5262* @alias tail5263* @category Array5264* @param {Array} array The array to query.5265* @returns {Array} Returns the slice of `array`.5266* @example5267*5268* _.rest([1, 2, 3]);5269* // => [2, 3]5270*/5271function rest(array) {5272return drop(array, 1);5273}52745275/**5276* Creates a slice of `array` from `start` up to, but not including, `end`.5277*5278* **Note:** This method is used instead of `Array#slice` to support node5279* lists in IE < 9 and to ensure dense arrays are returned.5280*5281* @static5282* @memberOf _5283* @category Array5284* @param {Array} array The array to slice.5285* @param {number} [start=0] The start position.5286* @param {number} [end=array.length] The end position.5287* @returns {Array} Returns the slice of `array`.5288*/5289function slice(array, start, end) {5290var length = array ? array.length : 0;5291if (!length) {5292return [];5293}5294if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {5295start = 0;5296end = length;5297}5298return baseSlice(array, start, end);5299}53005301/**5302* Uses a binary search to determine the lowest index at which `value` should5303* be inserted into `array` in order to maintain its sort order. If an iteratee5304* function is provided it is invoked for `value` and each element of `array`5305* to compute their sort ranking. The iteratee is bound to `thisArg` and5306* invoked with one argument; (value).5307*5308* If a property name is provided for `iteratee` the created `_.property`5309* style callback returns the property value of the given element.5310*5311* If a value is also provided for `thisArg` the created `_.matchesProperty`5312* style callback returns `true` for elements that have a matching property5313* value, else `false`.5314*5315* If an object is provided for `iteratee` the created `_.matches` style5316* callback returns `true` for elements that have the properties of the given5317* object, else `false`.5318*5319* @static5320* @memberOf _5321* @category Array5322* @param {Array} array The sorted array to inspect.5323* @param {*} value The value to evaluate.5324* @param {Function|Object|string} [iteratee=_.identity] The function invoked5325* per iteration.5326* @param {*} [thisArg] The `this` binding of `iteratee`.5327* @returns {number} Returns the index at which `value` should be inserted5328* into `array`.5329* @example5330*5331* _.sortedIndex([30, 50], 40);5332* // => 15333*5334* _.sortedIndex([4, 4, 5, 5], 5);5335* // => 25336*5337* var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };5338*5339* // using an iteratee function5340* _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {5341* return this.data[word];5342* }, dict);5343* // => 15344*5345* // using the `_.property` callback shorthand5346* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');5347* // => 15348*/5349var sortedIndex = createSortedIndex();53505351/**5352* This method is like `_.sortedIndex` except that it returns the highest5353* index at which `value` should be inserted into `array` in order to5354* maintain its sort order.5355*5356* @static5357* @memberOf _5358* @category Array5359* @param {Array} array The sorted array to inspect.5360* @param {*} value The value to evaluate.5361* @param {Function|Object|string} [iteratee=_.identity] The function invoked5362* per iteration.5363* @param {*} [thisArg] The `this` binding of `iteratee`.5364* @returns {number} Returns the index at which `value` should be inserted5365* into `array`.5366* @example5367*5368* _.sortedLastIndex([4, 4, 5, 5], 5);5369* // => 45370*/5371var sortedLastIndex = createSortedIndex(true);53725373/**5374* Creates a slice of `array` with `n` elements taken from the beginning.5375*5376* @static5377* @memberOf _5378* @category Array5379* @param {Array} array The array to query.5380* @param {number} [n=1] The number of elements to take.5381* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.5382* @returns {Array} Returns the slice of `array`.5383* @example5384*5385* _.take([1, 2, 3]);5386* // => [1]5387*5388* _.take([1, 2, 3], 2);5389* // => [1, 2]5390*5391* _.take([1, 2, 3], 5);5392* // => [1, 2, 3]5393*5394* _.take([1, 2, 3], 0);5395* // => []5396*/5397function take(array, n, guard) {5398var length = array ? array.length : 0;5399if (!length) {5400return [];5401}5402if (guard ? isIterateeCall(array, n, guard) : n == null) {5403n = 1;5404}5405return baseSlice(array, 0, n < 0 ? 0 : n);5406}54075408/**5409* Creates a slice of `array` with `n` elements taken from the end.5410*5411* @static5412* @memberOf _5413* @category Array5414* @param {Array} array The array to query.5415* @param {number} [n=1] The number of elements to take.5416* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.5417* @returns {Array} Returns the slice of `array`.5418* @example5419*5420* _.takeRight([1, 2, 3]);5421* // => [3]5422*5423* _.takeRight([1, 2, 3], 2);5424* // => [2, 3]5425*5426* _.takeRight([1, 2, 3], 5);5427* // => [1, 2, 3]5428*5429* _.takeRight([1, 2, 3], 0);5430* // => []5431*/5432function takeRight(array, n, guard) {5433var length = array ? array.length : 0;5434if (!length) {5435return [];5436}5437if (guard ? isIterateeCall(array, n, guard) : n == null) {5438n = 1;5439}5440n = length - (+n || 0);5441return baseSlice(array, n < 0 ? 0 : n);5442}54435444/**5445* Creates a slice of `array` with elements taken from the end. Elements are5446* taken until `predicate` returns falsey. The predicate is bound to `thisArg`5447* and invoked with three arguments: (value, index, array).5448*5449* If a property name is provided for `predicate` the created `_.property`5450* style callback returns the property value of the given element.5451*5452* If a value is also provided for `thisArg` the created `_.matchesProperty`5453* style callback returns `true` for elements that have a matching property5454* value, else `false`.5455*5456* If an object is provided for `predicate` the created `_.matches` style5457* callback returns `true` for elements that have the properties of the given5458* object, else `false`.5459*5460* @static5461* @memberOf _5462* @category Array5463* @param {Array} array The array to query.5464* @param {Function|Object|string} [predicate=_.identity] The function invoked5465* per iteration.5466* @param {*} [thisArg] The `this` binding of `predicate`.5467* @returns {Array} Returns the slice of `array`.5468* @example5469*5470* _.takeRightWhile([1, 2, 3], function(n) {5471* return n > 1;5472* });5473* // => [2, 3]5474*5475* var users = [5476* { 'user': 'barney', 'active': true },5477* { 'user': 'fred', 'active': false },5478* { 'user': 'pebbles', 'active': false }5479* ];5480*5481* // using the `_.matches` callback shorthand5482* _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');5483* // => ['pebbles']5484*5485* // using the `_.matchesProperty` callback shorthand5486* _.pluck(_.takeRightWhile(users, 'active', false), 'user');5487* // => ['fred', 'pebbles']5488*5489* // using the `_.property` callback shorthand5490* _.pluck(_.takeRightWhile(users, 'active'), 'user');5491* // => []5492*/5493function takeRightWhile(array, predicate, thisArg) {5494return (array && array.length)5495? baseWhile(array, getCallback(predicate, thisArg, 3), false, true)5496: [];5497}54985499/**5500* Creates a slice of `array` with elements taken from the beginning. Elements5501* are taken until `predicate` returns falsey. The predicate is bound to5502* `thisArg` and invoked with three arguments: (value, index, array).5503*5504* If a property name is provided for `predicate` the created `_.property`5505* style callback returns the property value of the given element.5506*5507* If a value is also provided for `thisArg` the created `_.matchesProperty`5508* style callback returns `true` for elements that have a matching property5509* value, else `false`.5510*5511* If an object is provided for `predicate` the created `_.matches` style5512* callback returns `true` for elements that have the properties of the given5513* object, else `false`.5514*5515* @static5516* @memberOf _5517* @category Array5518* @param {Array} array The array to query.5519* @param {Function|Object|string} [predicate=_.identity] The function invoked5520* per iteration.5521* @param {*} [thisArg] The `this` binding of `predicate`.5522* @returns {Array} Returns the slice of `array`.5523* @example5524*5525* _.takeWhile([1, 2, 3], function(n) {5526* return n < 3;5527* });5528* // => [1, 2]5529*5530* var users = [5531* { 'user': 'barney', 'active': false },5532* { 'user': 'fred', 'active': false},5533* { 'user': 'pebbles', 'active': true }5534* ];5535*5536* // using the `_.matches` callback shorthand5537* _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user');5538* // => ['barney']5539*5540* // using the `_.matchesProperty` callback shorthand5541* _.pluck(_.takeWhile(users, 'active', false), 'user');5542* // => ['barney', 'fred']5543*5544* // using the `_.property` callback shorthand5545* _.pluck(_.takeWhile(users, 'active'), 'user');5546* // => []5547*/5548function takeWhile(array, predicate, thisArg) {5549return (array && array.length)5550? baseWhile(array, getCallback(predicate, thisArg, 3))5551: [];5552}55535554/**5555* Creates an array of unique values, in order, from all of the provided arrays5556* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)5557* for equality comparisons.5558*5559* @static5560* @memberOf _5561* @category Array5562* @param {...Array} [arrays] The arrays to inspect.5563* @returns {Array} Returns the new array of combined values.5564* @example5565*5566* _.union([1, 2], [4, 2], [2, 1]);5567* // => [1, 2, 4]5568*/5569var union = restParam(function(arrays) {5570return baseUniq(baseFlatten(arrays, false, true));5571});55725573/**5574* Creates a duplicate-free version of an array, using5575* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)5576* for equality comparisons, in which only the first occurence of each element5577* is kept. Providing `true` for `isSorted` performs a faster search algorithm5578* for sorted arrays. If an iteratee function is provided it is invoked for5579* each element in the array to generate the criterion by which uniqueness5580* is computed. The `iteratee` is bound to `thisArg` and invoked with three5581* arguments: (value, index, array).5582*5583* If a property name is provided for `iteratee` the created `_.property`5584* style callback returns the property value of the given element.5585*5586* If a value is also provided for `thisArg` the created `_.matchesProperty`5587* style callback returns `true` for elements that have a matching property5588* value, else `false`.5589*5590* If an object is provided for `iteratee` the created `_.matches` style5591* callback returns `true` for elements that have the properties of the given5592* object, else `false`.5593*5594* @static5595* @memberOf _5596* @alias unique5597* @category Array5598* @param {Array} array The array to inspect.5599* @param {boolean} [isSorted] Specify the array is sorted.5600* @param {Function|Object|string} [iteratee] The function invoked per iteration.5601* @param {*} [thisArg] The `this` binding of `iteratee`.5602* @returns {Array} Returns the new duplicate-value-free array.5603* @example5604*5605* _.uniq([2, 1, 2]);5606* // => [2, 1]5607*5608* // using `isSorted`5609* _.uniq([1, 1, 2], true);5610* // => [1, 2]5611*5612* // using an iteratee function5613* _.uniq([1, 2.5, 1.5, 2], function(n) {5614* return this.floor(n);5615* }, Math);5616* // => [1, 2.5]5617*5618* // using the `_.property` callback shorthand5619* _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');5620* // => [{ 'x': 1 }, { 'x': 2 }]5621*/5622function uniq(array, isSorted, iteratee, thisArg) {5623var length = array ? array.length : 0;5624if (!length) {5625return [];5626}5627if (isSorted != null && typeof isSorted != 'boolean') {5628thisArg = iteratee;5629iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;5630isSorted = false;5631}5632var callback = getCallback();5633if (!(iteratee == null && callback === baseCallback)) {5634iteratee = callback(iteratee, thisArg, 3);5635}5636return (isSorted && getIndexOf() == baseIndexOf)5637? sortedUniq(array, iteratee)5638: baseUniq(array, iteratee);5639}56405641/**5642* This method is like `_.zip` except that it accepts an array of grouped5643* elements and creates an array regrouping the elements to their pre-zip5644* configuration.5645*5646* @static5647* @memberOf _5648* @category Array5649* @param {Array} array The array of grouped elements to process.5650* @returns {Array} Returns the new array of regrouped elements.5651* @example5652*5653* var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);5654* // => [['fred', 30, true], ['barney', 40, false]]5655*5656* _.unzip(zipped);5657* // => [['fred', 'barney'], [30, 40], [true, false]]5658*/5659function unzip(array) {5660if (!(array && array.length)) {5661return [];5662}5663var index = -1,5664length = 0;56655666array = arrayFilter(array, function(group) {5667if (isArrayLike(group)) {5668length = nativeMax(group.length, length);5669return true;5670}5671});5672var result = Array(length);5673while (++index < length) {5674result[index] = arrayMap(array, baseProperty(index));5675}5676return result;5677}56785679/**5680* This method is like `_.unzip` except that it accepts an iteratee to specify5681* how regrouped values should be combined. The `iteratee` is bound to `thisArg`5682* and invoked with four arguments: (accumulator, value, index, group).5683*5684* @static5685* @memberOf _5686* @category Array5687* @param {Array} array The array of grouped elements to process.5688* @param {Function} [iteratee] The function to combine regrouped values.5689* @param {*} [thisArg] The `this` binding of `iteratee`.5690* @returns {Array} Returns the new array of regrouped elements.5691* @example5692*5693* var zipped = _.zip([1, 2], [10, 20], [100, 200]);5694* // => [[1, 10, 100], [2, 20, 200]]5695*5696* _.unzipWith(zipped, _.add);5697* // => [3, 30, 300]5698*/5699function unzipWith(array, iteratee, thisArg) {5700var length = array ? array.length : 0;5701if (!length) {5702return [];5703}5704var result = unzip(array);5705if (iteratee == null) {5706return result;5707}5708iteratee = bindCallback(iteratee, thisArg, 4);5709return arrayMap(result, function(group) {5710return arrayReduce(group, iteratee, undefined, true);5711});5712}57135714/**5715* Creates an array excluding all provided values using5716* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)5717* for equality comparisons.5718*5719* @static5720* @memberOf _5721* @category Array5722* @param {Array} array The array to filter.5723* @param {...*} [values] The values to exclude.5724* @returns {Array} Returns the new array of filtered values.5725* @example5726*5727* _.without([1, 2, 1, 3], 1, 2);5728* // => [3]5729*/5730var without = restParam(function(array, values) {5731return isArrayLike(array)5732? baseDifference(array, values)5733: [];5734});57355736/**5737* Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)5738* of the provided arrays.5739*5740* @static5741* @memberOf _5742* @category Array5743* @param {...Array} [arrays] The arrays to inspect.5744* @returns {Array} Returns the new array of values.5745* @example5746*5747* _.xor([1, 2], [4, 2]);5748* // => [1, 4]5749*/5750function xor() {5751var index = -1,5752length = arguments.length;57535754while (++index < length) {5755var array = arguments[index];5756if (isArrayLike(array)) {5757var result = result5758? baseDifference(result, array).concat(baseDifference(array, result))5759: array;5760}5761}5762return result ? baseUniq(result) : [];5763}57645765/**5766* Creates an array of grouped elements, the first of which contains the first5767* elements of the given arrays, the second of which contains the second elements5768* of the given arrays, and so on.5769*5770* @static5771* @memberOf _5772* @category Array5773* @param {...Array} [arrays] The arrays to process.5774* @returns {Array} Returns the new array of grouped elements.5775* @example5776*5777* _.zip(['fred', 'barney'], [30, 40], [true, false]);5778* // => [['fred', 30, true], ['barney', 40, false]]5779*/5780var zip = restParam(unzip);57815782/**5783* The inverse of `_.pairs`; this method returns an object composed from arrays5784* of property names and values. Provide either a single two dimensional array,5785* e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names5786* and one of corresponding values.5787*5788* @static5789* @memberOf _5790* @alias object5791* @category Array5792* @param {Array} props The property names.5793* @param {Array} [values=[]] The property values.5794* @returns {Object} Returns the new object.5795* @example5796*5797* _.zipObject([['fred', 30], ['barney', 40]]);5798* // => { 'fred': 30, 'barney': 40 }5799*5800* _.zipObject(['fred', 'barney'], [30, 40]);5801* // => { 'fred': 30, 'barney': 40 }5802*/5803function zipObject(props, values) {5804var index = -1,5805length = props ? props.length : 0,5806result = {};58075808if (length && !values && !isArray(props[0])) {5809values = [];5810}5811while (++index < length) {5812var key = props[index];5813if (values) {5814result[key] = values[index];5815} else if (key) {5816result[key[0]] = key[1];5817}5818}5819return result;5820}58215822/**5823* This method is like `_.zip` except that it accepts an iteratee to specify5824* how grouped values should be combined. The `iteratee` is bound to `thisArg`5825* and invoked with four arguments: (accumulator, value, index, group).5826*5827* @static5828* @memberOf _5829* @category Array5830* @param {...Array} [arrays] The arrays to process.5831* @param {Function} [iteratee] The function to combine grouped values.5832* @param {*} [thisArg] The `this` binding of `iteratee`.5833* @returns {Array} Returns the new array of grouped elements.5834* @example5835*5836* _.zipWith([1, 2], [10, 20], [100, 200], _.add);5837* // => [111, 222]5838*/5839var zipWith = restParam(function(arrays) {5840var length = arrays.length,5841iteratee = length > 2 ? arrays[length - 2] : undefined,5842thisArg = length > 1 ? arrays[length - 1] : undefined;58435844if (length > 2 && typeof iteratee == 'function') {5845length -= 2;5846} else {5847iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;5848thisArg = undefined;5849}5850arrays.length = length;5851return unzipWith(arrays, iteratee, thisArg);5852});58535854/*------------------------------------------------------------------------*/58555856/**5857* Creates a `lodash` object that wraps `value` with explicit method5858* chaining enabled.5859*5860* @static5861* @memberOf _5862* @category Chain5863* @param {*} value The value to wrap.5864* @returns {Object} Returns the new `lodash` wrapper instance.5865* @example5866*5867* var users = [5868* { 'user': 'barney', 'age': 36 },5869* { 'user': 'fred', 'age': 40 },5870* { 'user': 'pebbles', 'age': 1 }5871* ];5872*5873* var youngest = _.chain(users)5874* .sortBy('age')5875* .map(function(chr) {5876* return chr.user + ' is ' + chr.age;5877* })5878* .first()5879* .value();5880* // => 'pebbles is 1'5881*/5882function chain(value) {5883var result = lodash(value);5884result.__chain__ = true;5885return result;5886}58875888/**5889* This method invokes `interceptor` and returns `value`. The interceptor is5890* bound to `thisArg` and invoked with one argument; (value). The purpose of5891* this method is to "tap into" a method chain in order to perform operations5892* on intermediate results within the chain.5893*5894* @static5895* @memberOf _5896* @category Chain5897* @param {*} value The value to provide to `interceptor`.5898* @param {Function} interceptor The function to invoke.5899* @param {*} [thisArg] The `this` binding of `interceptor`.5900* @returns {*} Returns `value`.5901* @example5902*5903* _([1, 2, 3])5904* .tap(function(array) {5905* array.pop();5906* })5907* .reverse()5908* .value();5909* // => [2, 1]5910*/5911function tap(value, interceptor, thisArg) {5912interceptor.call(thisArg, value);5913return value;5914}59155916/**5917* This method is like `_.tap` except that it returns the result of `interceptor`.5918*5919* @static5920* @memberOf _5921* @category Chain5922* @param {*} value The value to provide to `interceptor`.5923* @param {Function} interceptor The function to invoke.5924* @param {*} [thisArg] The `this` binding of `interceptor`.5925* @returns {*} Returns the result of `interceptor`.5926* @example5927*5928* _(' abc ')5929* .chain()5930* .trim()5931* .thru(function(value) {5932* return [value];5933* })5934* .value();5935* // => ['abc']5936*/5937function thru(value, interceptor, thisArg) {5938return interceptor.call(thisArg, value);5939}59405941/**5942* Enables explicit method chaining on the wrapper object.5943*5944* @name chain5945* @memberOf _5946* @category Chain5947* @returns {Object} Returns the new `lodash` wrapper instance.5948* @example5949*5950* var users = [5951* { 'user': 'barney', 'age': 36 },5952* { 'user': 'fred', 'age': 40 }5953* ];5954*5955* // without explicit chaining5956* _(users).first();5957* // => { 'user': 'barney', 'age': 36 }5958*5959* // with explicit chaining5960* _(users).chain()5961* .first()5962* .pick('user')5963* .value();5964* // => { 'user': 'barney' }5965*/5966function wrapperChain() {5967return chain(this);5968}59695970/**5971* Executes the chained sequence and returns the wrapped result.5972*5973* @name commit5974* @memberOf _5975* @category Chain5976* @returns {Object} Returns the new `lodash` wrapper instance.5977* @example5978*5979* var array = [1, 2];5980* var wrapper = _(array).push(3);5981*5982* console.log(array);5983* // => [1, 2]5984*5985* wrapper = wrapper.commit();5986* console.log(array);5987* // => [1, 2, 3]5988*5989* wrapper.last();5990* // => 35991*5992* console.log(array);5993* // => [1, 2, 3]5994*/5995function wrapperCommit() {5996return new LodashWrapper(this.value(), this.__chain__);5997}59985999/**6000* Creates a clone of the chained sequence planting `value` as the wrapped value.6001*6002* @name plant6003* @memberOf _6004* @category Chain6005* @returns {Object} Returns the new `lodash` wrapper instance.6006* @example6007*6008* var array = [1, 2];6009* var wrapper = _(array).map(function(value) {6010* return Math.pow(value, 2);6011* });6012*6013* var other = [3, 4];6014* var otherWrapper = wrapper.plant(other);6015*6016* otherWrapper.value();6017* // => [9, 16]6018*6019* wrapper.value();6020* // => [1, 4]6021*/6022function wrapperPlant(value) {6023var result,6024parent = this;60256026while (parent instanceof baseLodash) {6027var clone = wrapperClone(parent);6028if (result) {6029previous.__wrapped__ = clone;6030} else {6031result = clone;6032}6033var previous = clone;6034parent = parent.__wrapped__;6035}6036previous.__wrapped__ = value;6037return result;6038}60396040/**6041* Reverses the wrapped array so the first element becomes the last, the6042* second element becomes the second to last, and so on.6043*6044* **Note:** This method mutates the wrapped array.6045*6046* @name reverse6047* @memberOf _6048* @category Chain6049* @returns {Object} Returns the new reversed `lodash` wrapper instance.6050* @example6051*6052* var array = [1, 2, 3];6053*6054* _(array).reverse().value()6055* // => [3, 2, 1]6056*6057* console.log(array);6058* // => [3, 2, 1]6059*/6060function wrapperReverse() {6061var value = this.__wrapped__;6062if (value instanceof LazyWrapper) {6063if (this.__actions__.length) {6064value = new LazyWrapper(this);6065}6066return new LodashWrapper(value.reverse(), this.__chain__);6067}6068return this.thru(function(value) {6069return value.reverse();6070});6071}60726073/**6074* Produces the result of coercing the unwrapped value to a string.6075*6076* @name toString6077* @memberOf _6078* @category Chain6079* @returns {string} Returns the coerced string value.6080* @example6081*6082* _([1, 2, 3]).toString();6083* // => '1,2,3'6084*/6085function wrapperToString() {6086return (this.value() + '');6087}60886089/**6090* Executes the chained sequence to extract the unwrapped value.6091*6092* @name value6093* @memberOf _6094* @alias run, toJSON, valueOf6095* @category Chain6096* @returns {*} Returns the resolved unwrapped value.6097* @example6098*6099* _([1, 2, 3]).value();6100* // => [1, 2, 3]6101*/6102function wrapperValue() {6103return baseWrapperValue(this.__wrapped__, this.__actions__);6104}61056106/*------------------------------------------------------------------------*/61076108/**6109* Creates an array of elements corresponding to the given keys, or indexes,6110* of `collection`. Keys may be specified as individual arguments or as arrays6111* of keys.6112*6113* @static6114* @memberOf _6115* @category Collection6116* @param {Array|Object|string} collection The collection to iterate over.6117* @param {...(number|number[]|string|string[])} [props] The property names6118* or indexes of elements to pick, specified individually or in arrays.6119* @returns {Array} Returns the new array of picked elements.6120* @example6121*6122* _.at(['a', 'b', 'c'], [0, 2]);6123* // => ['a', 'c']6124*6125* _.at(['barney', 'fred', 'pebbles'], 0, 2);6126* // => ['barney', 'pebbles']6127*/6128var at = restParam(function(collection, props) {6129return baseAt(collection, baseFlatten(props));6130});61316132/**6133* Creates an object composed of keys generated from the results of running6134* each element of `collection` through `iteratee`. The corresponding value6135* of each key is the number of times the key was returned by `iteratee`.6136* The `iteratee` is bound to `thisArg` and invoked with three arguments:6137* (value, index|key, collection).6138*6139* If a property name is provided for `iteratee` the created `_.property`6140* style callback returns the property value of the given element.6141*6142* If a value is also provided for `thisArg` the created `_.matchesProperty`6143* style callback returns `true` for elements that have a matching property6144* value, else `false`.6145*6146* If an object is provided for `iteratee` the created `_.matches` style6147* callback returns `true` for elements that have the properties of the given6148* object, else `false`.6149*6150* @static6151* @memberOf _6152* @category Collection6153* @param {Array|Object|string} collection The collection to iterate over.6154* @param {Function|Object|string} [iteratee=_.identity] The function invoked6155* per iteration.6156* @param {*} [thisArg] The `this` binding of `iteratee`.6157* @returns {Object} Returns the composed aggregate object.6158* @example6159*6160* _.countBy([4.3, 6.1, 6.4], function(n) {6161* return Math.floor(n);6162* });6163* // => { '4': 1, '6': 2 }6164*6165* _.countBy([4.3, 6.1, 6.4], function(n) {6166* return this.floor(n);6167* }, Math);6168* // => { '4': 1, '6': 2 }6169*6170* _.countBy(['one', 'two', 'three'], 'length');6171* // => { '3': 2, '5': 1 }6172*/6173var countBy = createAggregator(function(result, value, key) {6174hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);6175});61766177/**6178* Checks if `predicate` returns truthy for **all** elements of `collection`.6179* The predicate is bound to `thisArg` and invoked with three arguments:6180* (value, index|key, collection).6181*6182* If a property name is provided for `predicate` the created `_.property`6183* style callback returns the property value of the given element.6184*6185* If a value is also provided for `thisArg` the created `_.matchesProperty`6186* style callback returns `true` for elements that have a matching property6187* value, else `false`.6188*6189* If an object is provided for `predicate` the created `_.matches` style6190* callback returns `true` for elements that have the properties of the given6191* object, else `false`.6192*6193* @static6194* @memberOf _6195* @alias all6196* @category Collection6197* @param {Array|Object|string} collection The collection to iterate over.6198* @param {Function|Object|string} [predicate=_.identity] The function invoked6199* per iteration.6200* @param {*} [thisArg] The `this` binding of `predicate`.6201* @returns {boolean} Returns `true` if all elements pass the predicate check,6202* else `false`.6203* @example6204*6205* _.every([true, 1, null, 'yes'], Boolean);6206* // => false6207*6208* var users = [6209* { 'user': 'barney', 'active': false },6210* { 'user': 'fred', 'active': false }6211* ];6212*6213* // using the `_.matches` callback shorthand6214* _.every(users, { 'user': 'barney', 'active': false });6215* // => false6216*6217* // using the `_.matchesProperty` callback shorthand6218* _.every(users, 'active', false);6219* // => true6220*6221* // using the `_.property` callback shorthand6222* _.every(users, 'active');6223* // => false6224*/6225function every(collection, predicate, thisArg) {6226var func = isArray(collection) ? arrayEvery : baseEvery;6227if (thisArg && isIterateeCall(collection, predicate, thisArg)) {6228predicate = null;6229}6230if (typeof predicate != 'function' || thisArg !== undefined) {6231predicate = getCallback(predicate, thisArg, 3);6232}6233return func(collection, predicate);6234}62356236/**6237* Iterates over elements of `collection`, returning an array of all elements6238* `predicate` returns truthy for. The predicate is bound to `thisArg` and6239* invoked with three arguments: (value, index|key, collection).6240*6241* If a property name is provided for `predicate` the created `_.property`6242* style callback returns the property value of the given element.6243*6244* If a value is also provided for `thisArg` the created `_.matchesProperty`6245* style callback returns `true` for elements that have a matching property6246* value, else `false`.6247*6248* If an object is provided for `predicate` the created `_.matches` style6249* callback returns `true` for elements that have the properties of the given6250* object, else `false`.6251*6252* @static6253* @memberOf _6254* @alias select6255* @category Collection6256* @param {Array|Object|string} collection The collection to iterate over.6257* @param {Function|Object|string} [predicate=_.identity] The function invoked6258* per iteration.6259* @param {*} [thisArg] The `this` binding of `predicate`.6260* @returns {Array} Returns the new filtered array.6261* @example6262*6263* _.filter([4, 5, 6], function(n) {6264* return n % 2 == 0;6265* });6266* // => [4, 6]6267*6268* var users = [6269* { 'user': 'barney', 'age': 36, 'active': true },6270* { 'user': 'fred', 'age': 40, 'active': false }6271* ];6272*6273* // using the `_.matches` callback shorthand6274* _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');6275* // => ['barney']6276*6277* // using the `_.matchesProperty` callback shorthand6278* _.pluck(_.filter(users, 'active', false), 'user');6279* // => ['fred']6280*6281* // using the `_.property` callback shorthand6282* _.pluck(_.filter(users, 'active'), 'user');6283* // => ['barney']6284*/6285function filter(collection, predicate, thisArg) {6286var func = isArray(collection) ? arrayFilter : baseFilter;6287predicate = getCallback(predicate, thisArg, 3);6288return func(collection, predicate);6289}62906291/**6292* Iterates over elements of `collection`, returning the first element6293* `predicate` returns truthy for. The predicate is bound to `thisArg` and6294* invoked with three arguments: (value, index|key, collection).6295*6296* If a property name is provided for `predicate` the created `_.property`6297* style callback returns the property value of the given element.6298*6299* If a value is also provided for `thisArg` the created `_.matchesProperty`6300* style callback returns `true` for elements that have a matching property6301* value, else `false`.6302*6303* If an object is provided for `predicate` the created `_.matches` style6304* callback returns `true` for elements that have the properties of the given6305* object, else `false`.6306*6307* @static6308* @memberOf _6309* @alias detect6310* @category Collection6311* @param {Array|Object|string} collection The collection to search.6312* @param {Function|Object|string} [predicate=_.identity] The function invoked6313* per iteration.6314* @param {*} [thisArg] The `this` binding of `predicate`.6315* @returns {*} Returns the matched element, else `undefined`.6316* @example6317*6318* var users = [6319* { 'user': 'barney', 'age': 36, 'active': true },6320* { 'user': 'fred', 'age': 40, 'active': false },6321* { 'user': 'pebbles', 'age': 1, 'active': true }6322* ];6323*6324* _.result(_.find(users, function(chr) {6325* return chr.age < 40;6326* }), 'user');6327* // => 'barney'6328*6329* // using the `_.matches` callback shorthand6330* _.result(_.find(users, { 'age': 1, 'active': true }), 'user');6331* // => 'pebbles'6332*6333* // using the `_.matchesProperty` callback shorthand6334* _.result(_.find(users, 'active', false), 'user');6335* // => 'fred'6336*6337* // using the `_.property` callback shorthand6338* _.result(_.find(users, 'active'), 'user');6339* // => 'barney'6340*/6341var find = createFind(baseEach);63426343/**6344* This method is like `_.find` except that it iterates over elements of6345* `collection` from right to left.6346*6347* @static6348* @memberOf _6349* @category Collection6350* @param {Array|Object|string} collection The collection to search.6351* @param {Function|Object|string} [predicate=_.identity] The function invoked6352* per iteration.6353* @param {*} [thisArg] The `this` binding of `predicate`.6354* @returns {*} Returns the matched element, else `undefined`.6355* @example6356*6357* _.findLast([1, 2, 3, 4], function(n) {6358* return n % 2 == 1;6359* });6360* // => 36361*/6362var findLast = createFind(baseEachRight, true);63636364/**6365* Performs a deep comparison between each element in `collection` and the6366* source object, returning the first element that has equivalent property6367* values.6368*6369* **Note:** This method supports comparing arrays, booleans, `Date` objects,6370* numbers, `Object` objects, regexes, and strings. Objects are compared by6371* their own, not inherited, enumerable properties. For comparing a single6372* own or inherited property value see `_.matchesProperty`.6373*6374* @static6375* @memberOf _6376* @category Collection6377* @param {Array|Object|string} collection The collection to search.6378* @param {Object} source The object of property values to match.6379* @returns {*} Returns the matched element, else `undefined`.6380* @example6381*6382* var users = [6383* { 'user': 'barney', 'age': 36, 'active': true },6384* { 'user': 'fred', 'age': 40, 'active': false }6385* ];6386*6387* _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');6388* // => 'barney'6389*6390* _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');6391* // => 'fred'6392*/6393function findWhere(collection, source) {6394return find(collection, baseMatches(source));6395}63966397/**6398* Iterates over elements of `collection` invoking `iteratee` for each element.6399* The `iteratee` is bound to `thisArg` and invoked with three arguments:6400* (value, index|key, collection). Iteratee functions may exit iteration early6401* by explicitly returning `false`.6402*6403* **Note:** As with other "Collections" methods, objects with a "length" property6404* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`6405* may be used for object iteration.6406*6407* @static6408* @memberOf _6409* @alias each6410* @category Collection6411* @param {Array|Object|string} collection The collection to iterate over.6412* @param {Function} [iteratee=_.identity] The function invoked per iteration.6413* @param {*} [thisArg] The `this` binding of `iteratee`.6414* @returns {Array|Object|string} Returns `collection`.6415* @example6416*6417* _([1, 2]).forEach(function(n) {6418* console.log(n);6419* }).value();6420* // => logs each value from left to right and returns the array6421*6422* _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {6423* console.log(n, key);6424* });6425* // => logs each value-key pair and returns the object (iteration order is not guaranteed)6426*/6427var forEach = createForEach(arrayEach, baseEach);64286429/**6430* This method is like `_.forEach` except that it iterates over elements of6431* `collection` from right to left.6432*6433* @static6434* @memberOf _6435* @alias eachRight6436* @category Collection6437* @param {Array|Object|string} collection The collection to iterate over.6438* @param {Function} [iteratee=_.identity] The function invoked per iteration.6439* @param {*} [thisArg] The `this` binding of `iteratee`.6440* @returns {Array|Object|string} Returns `collection`.6441* @example6442*6443* _([1, 2]).forEachRight(function(n) {6444* console.log(n);6445* }).value();6446* // => logs each value from right to left and returns the array6447*/6448var forEachRight = createForEach(arrayEachRight, baseEachRight);64496450/**6451* Creates an object composed of keys generated from the results of running6452* each element of `collection` through `iteratee`. The corresponding value6453* of each key is an array of the elements responsible for generating the key.6454* The `iteratee` is bound to `thisArg` and invoked with three arguments:6455* (value, index|key, collection).6456*6457* If a property name is provided for `iteratee` the created `_.property`6458* style callback returns the property value of the given element.6459*6460* If a value is also provided for `thisArg` the created `_.matchesProperty`6461* style callback returns `true` for elements that have a matching property6462* value, else `false`.6463*6464* If an object is provided for `iteratee` the created `_.matches` style6465* callback returns `true` for elements that have the properties of the given6466* object, else `false`.6467*6468* @static6469* @memberOf _6470* @category Collection6471* @param {Array|Object|string} collection The collection to iterate over.6472* @param {Function|Object|string} [iteratee=_.identity] The function invoked6473* per iteration.6474* @param {*} [thisArg] The `this` binding of `iteratee`.6475* @returns {Object} Returns the composed aggregate object.6476* @example6477*6478* _.groupBy([4.2, 6.1, 6.4], function(n) {6479* return Math.floor(n);6480* });6481* // => { '4': [4.2], '6': [6.1, 6.4] }6482*6483* _.groupBy([4.2, 6.1, 6.4], function(n) {6484* return this.floor(n);6485* }, Math);6486* // => { '4': [4.2], '6': [6.1, 6.4] }6487*6488* // using the `_.property` callback shorthand6489* _.groupBy(['one', 'two', 'three'], 'length');6490* // => { '3': ['one', 'two'], '5': ['three'] }6491*/6492var groupBy = createAggregator(function(result, value, key) {6493if (hasOwnProperty.call(result, key)) {6494result[key].push(value);6495} else {6496result[key] = [value];6497}6498});64996500/**6501* Checks if `value` is in `collection` using6502* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)6503* for equality comparisons. If `fromIndex` is negative, it is used as the offset6504* from the end of `collection`.6505*6506* @static6507* @memberOf _6508* @alias contains, include6509* @category Collection6510* @param {Array|Object|string} collection The collection to search.6511* @param {*} target The value to search for.6512* @param {number} [fromIndex=0] The index to search from.6513* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.6514* @returns {boolean} Returns `true` if a matching element is found, else `false`.6515* @example6516*6517* _.includes([1, 2, 3], 1);6518* // => true6519*6520* _.includes([1, 2, 3], 1, 2);6521* // => false6522*6523* _.includes({ 'user': 'fred', 'age': 40 }, 'fred');6524* // => true6525*6526* _.includes('pebbles', 'eb');6527* // => true6528*/6529function includes(collection, target, fromIndex, guard) {6530var length = collection ? getLength(collection) : 0;6531if (!isLength(length)) {6532collection = values(collection);6533length = collection.length;6534}6535if (!length) {6536return false;6537}6538if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {6539fromIndex = 0;6540} else {6541fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);6542}6543return (typeof collection == 'string' || !isArray(collection) && isString(collection))6544? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)6545: (getIndexOf(collection, target, fromIndex) > -1);6546}65476548/**6549* Creates an object composed of keys generated from the results of running6550* each element of `collection` through `iteratee`. The corresponding value6551* of each key is the last element responsible for generating the key. The6552* iteratee function is bound to `thisArg` and invoked with three arguments:6553* (value, index|key, collection).6554*6555* If a property name is provided for `iteratee` the created `_.property`6556* style callback returns the property value of the given element.6557*6558* If a value is also provided for `thisArg` the created `_.matchesProperty`6559* style callback returns `true` for elements that have a matching property6560* value, else `false`.6561*6562* If an object is provided for `iteratee` the created `_.matches` style6563* callback returns `true` for elements that have the properties of the given6564* object, else `false`.6565*6566* @static6567* @memberOf _6568* @category Collection6569* @param {Array|Object|string} collection The collection to iterate over.6570* @param {Function|Object|string} [iteratee=_.identity] The function invoked6571* per iteration.6572* @param {*} [thisArg] The `this` binding of `iteratee`.6573* @returns {Object} Returns the composed aggregate object.6574* @example6575*6576* var keyData = [6577* { 'dir': 'left', 'code': 97 },6578* { 'dir': 'right', 'code': 100 }6579* ];6580*6581* _.indexBy(keyData, 'dir');6582* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }6583*6584* _.indexBy(keyData, function(object) {6585* return String.fromCharCode(object.code);6586* });6587* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }6588*6589* _.indexBy(keyData, function(object) {6590* return this.fromCharCode(object.code);6591* }, String);6592* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }6593*/6594var indexBy = createAggregator(function(result, value, key) {6595result[key] = value;6596});65976598/**6599* Invokes the method at `path` of each element in `collection`, returning6600* an array of the results of each invoked method. Any additional arguments6601* are provided to each invoked method. If `methodName` is a function it is6602* invoked for, and `this` bound to, each element in `collection`.6603*6604* @static6605* @memberOf _6606* @category Collection6607* @param {Array|Object|string} collection The collection to iterate over.6608* @param {Array|Function|string} path The path of the method to invoke or6609* the function invoked per iteration.6610* @param {...*} [args] The arguments to invoke the method with.6611* @returns {Array} Returns the array of results.6612* @example6613*6614* _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');6615* // => [[1, 5, 7], [1, 2, 3]]6616*6617* _.invoke([123, 456], String.prototype.split, '');6618* // => [['1', '2', '3'], ['4', '5', '6']]6619*/6620var invoke = restParam(function(collection, path, args) {6621var index = -1,6622isFunc = typeof path == 'function',6623isProp = isKey(path),6624result = isArrayLike(collection) ? Array(collection.length) : [];66256626baseEach(collection, function(value) {6627var func = isFunc ? path : ((isProp && value != null) ? value[path] : null);6628result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);6629});6630return result;6631});66326633/**6634* Creates an array of values by running each element in `collection` through6635* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three6636* arguments: (value, index|key, collection).6637*6638* If a property name is provided for `iteratee` the created `_.property`6639* style callback returns the property value of the given element.6640*6641* If a value is also provided for `thisArg` the created `_.matchesProperty`6642* style callback returns `true` for elements that have a matching property6643* value, else `false`.6644*6645* If an object is provided for `iteratee` the created `_.matches` style6646* callback returns `true` for elements that have the properties of the given6647* object, else `false`.6648*6649* Many lodash methods are guarded to work as iteratees for methods like6650* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.6651*6652* The guarded methods are:6653* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,6654* `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,6655* `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,6656* `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,6657* `sum`, `uniq`, and `words`6658*6659* @static6660* @memberOf _6661* @alias collect6662* @category Collection6663* @param {Array|Object|string} collection The collection to iterate over.6664* @param {Function|Object|string} [iteratee=_.identity] The function invoked6665* per iteration.6666* @param {*} [thisArg] The `this` binding of `iteratee`.6667* @returns {Array} Returns the new mapped array.6668* @example6669*6670* function timesThree(n) {6671* return n * 3;6672* }6673*6674* _.map([1, 2], timesThree);6675* // => [3, 6]6676*6677* _.map({ 'a': 1, 'b': 2 }, timesThree);6678* // => [3, 6] (iteration order is not guaranteed)6679*6680* var users = [6681* { 'user': 'barney' },6682* { 'user': 'fred' }6683* ];6684*6685* // using the `_.property` callback shorthand6686* _.map(users, 'user');6687* // => ['barney', 'fred']6688*/6689function map(collection, iteratee, thisArg) {6690var func = isArray(collection) ? arrayMap : baseMap;6691iteratee = getCallback(iteratee, thisArg, 3);6692return func(collection, iteratee);6693}66946695/**6696* Creates an array of elements split into two groups, the first of which6697* contains elements `predicate` returns truthy for, while the second of which6698* contains elements `predicate` returns falsey for. The predicate is bound6699* to `thisArg` and invoked with three arguments: (value, index|key, collection).6700*6701* If a property name is provided for `predicate` the created `_.property`6702* style callback returns the property value of the given element.6703*6704* If a value is also provided for `thisArg` the created `_.matchesProperty`6705* style callback returns `true` for elements that have a matching property6706* value, else `false`.6707*6708* If an object is provided for `predicate` the created `_.matches` style6709* callback returns `true` for elements that have the properties of the given6710* object, else `false`.6711*6712* @static6713* @memberOf _6714* @category Collection6715* @param {Array|Object|string} collection The collection to iterate over.6716* @param {Function|Object|string} [predicate=_.identity] The function invoked6717* per iteration.6718* @param {*} [thisArg] The `this` binding of `predicate`.6719* @returns {Array} Returns the array of grouped elements.6720* @example6721*6722* _.partition([1, 2, 3], function(n) {6723* return n % 2;6724* });6725* // => [[1, 3], [2]]6726*6727* _.partition([1.2, 2.3, 3.4], function(n) {6728* return this.floor(n) % 2;6729* }, Math);6730* // => [[1.2, 3.4], [2.3]]6731*6732* var users = [6733* { 'user': 'barney', 'age': 36, 'active': false },6734* { 'user': 'fred', 'age': 40, 'active': true },6735* { 'user': 'pebbles', 'age': 1, 'active': false }6736* ];6737*6738* var mapper = function(array) {6739* return _.pluck(array, 'user');6740* };6741*6742* // using the `_.matches` callback shorthand6743* _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);6744* // => [['pebbles'], ['barney', 'fred']]6745*6746* // using the `_.matchesProperty` callback shorthand6747* _.map(_.partition(users, 'active', false), mapper);6748* // => [['barney', 'pebbles'], ['fred']]6749*6750* // using the `_.property` callback shorthand6751* _.map(_.partition(users, 'active'), mapper);6752* // => [['fred'], ['barney', 'pebbles']]6753*/6754var partition = createAggregator(function(result, value, key) {6755result[key ? 0 : 1].push(value);6756}, function() { return [[], []]; });67576758/**6759* Gets the property value of `path` from all elements in `collection`.6760*6761* @static6762* @memberOf _6763* @category Collection6764* @param {Array|Object|string} collection The collection to iterate over.6765* @param {Array|string} path The path of the property to pluck.6766* @returns {Array} Returns the property values.6767* @example6768*6769* var users = [6770* { 'user': 'barney', 'age': 36 },6771* { 'user': 'fred', 'age': 40 }6772* ];6773*6774* _.pluck(users, 'user');6775* // => ['barney', 'fred']6776*6777* var userIndex = _.indexBy(users, 'user');6778* _.pluck(userIndex, 'age');6779* // => [36, 40] (iteration order is not guaranteed)6780*/6781function pluck(collection, path) {6782return map(collection, property(path));6783}67846785/**6786* Reduces `collection` to a value which is the accumulated result of running6787* each element in `collection` through `iteratee`, where each successive6788* invocation is supplied the return value of the previous. If `accumulator`6789* is not provided the first element of `collection` is used as the initial6790* value. The `iteratee` is bound to `thisArg` and invoked with four arguments:6791* (accumulator, value, index|key, collection).6792*6793* Many lodash methods are guarded to work as iteratees for methods like6794* `_.reduce`, `_.reduceRight`, and `_.transform`.6795*6796* The guarded methods are:6797* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`6798*6799* @static6800* @memberOf _6801* @alias foldl, inject6802* @category Collection6803* @param {Array|Object|string} collection The collection to iterate over.6804* @param {Function} [iteratee=_.identity] The function invoked per iteration.6805* @param {*} [accumulator] The initial value.6806* @param {*} [thisArg] The `this` binding of `iteratee`.6807* @returns {*} Returns the accumulated value.6808* @example6809*6810* _.reduce([1, 2], function(total, n) {6811* return total + n;6812* });6813* // => 36814*6815* _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {6816* result[key] = n * 3;6817* return result;6818* }, {});6819* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)6820*/6821var reduce = createReduce(arrayReduce, baseEach);68226823/**6824* This method is like `_.reduce` except that it iterates over elements of6825* `collection` from right to left.6826*6827* @static6828* @memberOf _6829* @alias foldr6830* @category Collection6831* @param {Array|Object|string} collection The collection to iterate over.6832* @param {Function} [iteratee=_.identity] The function invoked per iteration.6833* @param {*} [accumulator] The initial value.6834* @param {*} [thisArg] The `this` binding of `iteratee`.6835* @returns {*} Returns the accumulated value.6836* @example6837*6838* var array = [[0, 1], [2, 3], [4, 5]];6839*6840* _.reduceRight(array, function(flattened, other) {6841* return flattened.concat(other);6842* }, []);6843* // => [4, 5, 2, 3, 0, 1]6844*/6845var reduceRight = createReduce(arrayReduceRight, baseEachRight);68466847/**6848* The opposite of `_.filter`; this method returns the elements of `collection`6849* that `predicate` does **not** return truthy for.6850*6851* @static6852* @memberOf _6853* @category Collection6854* @param {Array|Object|string} collection The collection to iterate over.6855* @param {Function|Object|string} [predicate=_.identity] The function invoked6856* per iteration.6857* @param {*} [thisArg] The `this` binding of `predicate`.6858* @returns {Array} Returns the new filtered array.6859* @example6860*6861* _.reject([1, 2, 3, 4], function(n) {6862* return n % 2 == 0;6863* });6864* // => [1, 3]6865*6866* var users = [6867* { 'user': 'barney', 'age': 36, 'active': false },6868* { 'user': 'fred', 'age': 40, 'active': true }6869* ];6870*6871* // using the `_.matches` callback shorthand6872* _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');6873* // => ['barney']6874*6875* // using the `_.matchesProperty` callback shorthand6876* _.pluck(_.reject(users, 'active', false), 'user');6877* // => ['fred']6878*6879* // using the `_.property` callback shorthand6880* _.pluck(_.reject(users, 'active'), 'user');6881* // => ['barney']6882*/6883function reject(collection, predicate, thisArg) {6884var func = isArray(collection) ? arrayFilter : baseFilter;6885predicate = getCallback(predicate, thisArg, 3);6886return func(collection, function(value, index, collection) {6887return !predicate(value, index, collection);6888});6889}68906891/**6892* Gets a random element or `n` random elements from a collection.6893*6894* @static6895* @memberOf _6896* @category Collection6897* @param {Array|Object|string} collection The collection to sample.6898* @param {number} [n] The number of elements to sample.6899* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.6900* @returns {*} Returns the random sample(s).6901* @example6902*6903* _.sample([1, 2, 3, 4]);6904* // => 26905*6906* _.sample([1, 2, 3, 4], 2);6907* // => [3, 1]6908*/6909function sample(collection, n, guard) {6910if (guard ? isIterateeCall(collection, n, guard) : n == null) {6911collection = toIterable(collection);6912var length = collection.length;6913return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;6914}6915var index = -1,6916result = toArray(collection),6917length = result.length,6918lastIndex = length - 1;69196920n = nativeMin(n < 0 ? 0 : (+n || 0), length);6921while (++index < n) {6922var rand = baseRandom(index, lastIndex),6923value = result[rand];69246925result[rand] = result[index];6926result[index] = value;6927}6928result.length = n;6929return result;6930}69316932/**6933* Creates an array of shuffled values, using a version of the6934* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).6935*6936* @static6937* @memberOf _6938* @category Collection6939* @param {Array|Object|string} collection The collection to shuffle.6940* @returns {Array} Returns the new shuffled array.6941* @example6942*6943* _.shuffle([1, 2, 3, 4]);6944* // => [4, 1, 3, 2]6945*/6946function shuffle(collection) {6947return sample(collection, POSITIVE_INFINITY);6948}69496950/**6951* Gets the size of `collection` by returning its length for array-like6952* values or the number of own enumerable properties for objects.6953*6954* @static6955* @memberOf _6956* @category Collection6957* @param {Array|Object|string} collection The collection to inspect.6958* @returns {number} Returns the size of `collection`.6959* @example6960*6961* _.size([1, 2, 3]);6962* // => 36963*6964* _.size({ 'a': 1, 'b': 2 });6965* // => 26966*6967* _.size('pebbles');6968* // => 76969*/6970function size(collection) {6971var length = collection ? getLength(collection) : 0;6972return isLength(length) ? length : keys(collection).length;6973}69746975/**6976* Checks if `predicate` returns truthy for **any** element of `collection`.6977* The function returns as soon as it finds a passing value and does not iterate6978* over the entire collection. The predicate is bound to `thisArg` and invoked6979* with three arguments: (value, index|key, collection).6980*6981* If a property name is provided for `predicate` the created `_.property`6982* style callback returns the property value of the given element.6983*6984* If a value is also provided for `thisArg` the created `_.matchesProperty`6985* style callback returns `true` for elements that have a matching property6986* value, else `false`.6987*6988* If an object is provided for `predicate` the created `_.matches` style6989* callback returns `true` for elements that have the properties of the given6990* object, else `false`.6991*6992* @static6993* @memberOf _6994* @alias any6995* @category Collection6996* @param {Array|Object|string} collection The collection to iterate over.6997* @param {Function|Object|string} [predicate=_.identity] The function invoked6998* per iteration.6999* @param {*} [thisArg] The `this` binding of `predicate`.7000* @returns {boolean} Returns `true` if any element passes the predicate check,7001* else `false`.7002* @example7003*7004* _.some([null, 0, 'yes', false], Boolean);7005* // => true7006*7007* var users = [7008* { 'user': 'barney', 'active': true },7009* { 'user': 'fred', 'active': false }7010* ];7011*7012* // using the `_.matches` callback shorthand7013* _.some(users, { 'user': 'barney', 'active': false });7014* // => false7015*7016* // using the `_.matchesProperty` callback shorthand7017* _.some(users, 'active', false);7018* // => true7019*7020* // using the `_.property` callback shorthand7021* _.some(users, 'active');7022* // => true7023*/7024function some(collection, predicate, thisArg) {7025var func = isArray(collection) ? arraySome : baseSome;7026if (thisArg && isIterateeCall(collection, predicate, thisArg)) {7027predicate = null;7028}7029if (typeof predicate != 'function' || thisArg !== undefined) {7030predicate = getCallback(predicate, thisArg, 3);7031}7032return func(collection, predicate);7033}70347035/**7036* Creates an array of elements, sorted in ascending order by the results of7037* running each element in a collection through `iteratee`. This method performs7038* a stable sort, that is, it preserves the original sort order of equal elements.7039* The `iteratee` is bound to `thisArg` and invoked with three arguments:7040* (value, index|key, collection).7041*7042* If a property name is provided for `iteratee` the created `_.property`7043* style callback returns the property value of the given element.7044*7045* If a value is also provided for `thisArg` the created `_.matchesProperty`7046* style callback returns `true` for elements that have a matching property7047* value, else `false`.7048*7049* If an object is provided for `iteratee` the created `_.matches` style7050* callback returns `true` for elements that have the properties of the given7051* object, else `false`.7052*7053* @static7054* @memberOf _7055* @category Collection7056* @param {Array|Object|string} collection The collection to iterate over.7057* @param {Function|Object|string} [iteratee=_.identity] The function invoked7058* per iteration.7059* @param {*} [thisArg] The `this` binding of `iteratee`.7060* @returns {Array} Returns the new sorted array.7061* @example7062*7063* _.sortBy([1, 2, 3], function(n) {7064* return Math.sin(n);7065* });7066* // => [3, 1, 2]7067*7068* _.sortBy([1, 2, 3], function(n) {7069* return this.sin(n);7070* }, Math);7071* // => [3, 1, 2]7072*7073* var users = [7074* { 'user': 'fred' },7075* { 'user': 'pebbles' },7076* { 'user': 'barney' }7077* ];7078*7079* // using the `_.property` callback shorthand7080* _.pluck(_.sortBy(users, 'user'), 'user');7081* // => ['barney', 'fred', 'pebbles']7082*/7083function sortBy(collection, iteratee, thisArg) {7084if (collection == null) {7085return [];7086}7087if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {7088iteratee = null;7089}7090var index = -1;7091iteratee = getCallback(iteratee, thisArg, 3);70927093var result = baseMap(collection, function(value, key, collection) {7094return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };7095});7096return baseSortBy(result, compareAscending);7097}70987099/**7100* This method is like `_.sortBy` except that it can sort by multiple iteratees7101* or property names.7102*7103* If a property name is provided for an iteratee the created `_.property`7104* style callback returns the property value of the given element.7105*7106* If an object is provided for an iteratee the created `_.matches` style7107* callback returns `true` for elements that have the properties of the given7108* object, else `false`.7109*7110* @static7111* @memberOf _7112* @category Collection7113* @param {Array|Object|string} collection The collection to iterate over.7114* @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees7115* The iteratees to sort by, specified as individual values or arrays of values.7116* @returns {Array} Returns the new sorted array.7117* @example7118*7119* var users = [7120* { 'user': 'fred', 'age': 48 },7121* { 'user': 'barney', 'age': 36 },7122* { 'user': 'fred', 'age': 42 },7123* { 'user': 'barney', 'age': 34 }7124* ];7125*7126* _.map(_.sortByAll(users, ['user', 'age']), _.values);7127* // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]7128*7129* _.map(_.sortByAll(users, 'user', function(chr) {7130* return Math.floor(chr.age / 10);7131* }), _.values);7132* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]7133*/7134var sortByAll = restParam(function(collection, iteratees) {7135if (collection == null) {7136return [];7137}7138var guard = iteratees[2];7139if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) {7140iteratees.length = 1;7141}7142return baseSortByOrder(collection, baseFlatten(iteratees), []);7143});71447145/**7146* This method is like `_.sortByAll` except that it allows specifying the7147* sort orders of the iteratees to sort by. A truthy value in `orders` will7148* sort the corresponding property name in ascending order while a falsey7149* value will sort it in descending order.7150*7151* If a property name is provided for an iteratee the created `_.property`7152* style callback returns the property value of the given element.7153*7154* If an object is provided for an iteratee the created `_.matches` style7155* callback returns `true` for elements that have the properties of the given7156* object, else `false`.7157*7158* @static7159* @memberOf _7160* @category Collection7161* @param {Array|Object|string} collection The collection to iterate over.7162* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.7163* @param {boolean[]} orders The sort orders of `iteratees`.7164* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.7165* @returns {Array} Returns the new sorted array.7166* @example7167*7168* var users = [7169* { 'user': 'fred', 'age': 48 },7170* { 'user': 'barney', 'age': 34 },7171* { 'user': 'fred', 'age': 42 },7172* { 'user': 'barney', 'age': 36 }7173* ];7174*7175* // sort by `user` in ascending order and by `age` in descending order7176* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);7177* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]7178*/7179function sortByOrder(collection, iteratees, orders, guard) {7180if (collection == null) {7181return [];7182}7183if (guard && isIterateeCall(iteratees, orders, guard)) {7184orders = null;7185}7186if (!isArray(iteratees)) {7187iteratees = iteratees == null ? [] : [iteratees];7188}7189if (!isArray(orders)) {7190orders = orders == null ? [] : [orders];7191}7192return baseSortByOrder(collection, iteratees, orders);7193}71947195/**7196* Performs a deep comparison between each element in `collection` and the7197* source object, returning an array of all elements that have equivalent7198* property values.7199*7200* **Note:** This method supports comparing arrays, booleans, `Date` objects,7201* numbers, `Object` objects, regexes, and strings. Objects are compared by7202* their own, not inherited, enumerable properties. For comparing a single7203* own or inherited property value see `_.matchesProperty`.7204*7205* @static7206* @memberOf _7207* @category Collection7208* @param {Array|Object|string} collection The collection to search.7209* @param {Object} source The object of property values to match.7210* @returns {Array} Returns the new filtered array.7211* @example7212*7213* var users = [7214* { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },7215* { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }7216* ];7217*7218* _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');7219* // => ['barney']7220*7221* _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');7222* // => ['fred']7223*/7224function where(collection, source) {7225return filter(collection, baseMatches(source));7226}72277228/*------------------------------------------------------------------------*/72297230/**7231* Gets the number of milliseconds that have elapsed since the Unix epoch7232* (1 January 1970 00:00:00 UTC).7233*7234* @static7235* @memberOf _7236* @category Date7237* @example7238*7239* _.defer(function(stamp) {7240* console.log(_.now() - stamp);7241* }, _.now());7242* // => logs the number of milliseconds it took for the deferred function to be invoked7243*/7244var now = nativeNow || function() {7245return new Date().getTime();7246};72477248/*------------------------------------------------------------------------*/72497250/**7251* The opposite of `_.before`; this method creates a function that invokes7252* `func` once it is called `n` or more times.7253*7254* @static7255* @memberOf _7256* @category Function7257* @param {number} n The number of calls before `func` is invoked.7258* @param {Function} func The function to restrict.7259* @returns {Function} Returns the new restricted function.7260* @example7261*7262* var saves = ['profile', 'settings'];7263*7264* var done = _.after(saves.length, function() {7265* console.log('done saving!');7266* });7267*7268* _.forEach(saves, function(type) {7269* asyncSave({ 'type': type, 'complete': done });7270* });7271* // => logs 'done saving!' after the two async saves have completed7272*/7273function after(n, func) {7274if (typeof func != 'function') {7275if (typeof n == 'function') {7276var temp = n;7277n = func;7278func = temp;7279} else {7280throw new TypeError(FUNC_ERROR_TEXT);7281}7282}7283n = nativeIsFinite(n = +n) ? n : 0;7284return function() {7285if (--n < 1) {7286return func.apply(this, arguments);7287}7288};7289}72907291/**7292* Creates a function that accepts up to `n` arguments ignoring any7293* additional arguments.7294*7295* @static7296* @memberOf _7297* @category Function7298* @param {Function} func The function to cap arguments for.7299* @param {number} [n=func.length] The arity cap.7300* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.7301* @returns {Function} Returns the new function.7302* @example7303*7304* _.map(['6', '8', '10'], _.ary(parseInt, 1));7305* // => [6, 8, 10]7306*/7307function ary(func, n, guard) {7308if (guard && isIterateeCall(func, n, guard)) {7309n = null;7310}7311n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);7312return createWrapper(func, ARY_FLAG, null, null, null, null, n);7313}73147315/**7316* Creates a function that invokes `func`, with the `this` binding and arguments7317* of the created function, while it is called less than `n` times. Subsequent7318* calls to the created function return the result of the last `func` invocation.7319*7320* @static7321* @memberOf _7322* @category Function7323* @param {number} n The number of calls at which `func` is no longer invoked.7324* @param {Function} func The function to restrict.7325* @returns {Function} Returns the new restricted function.7326* @example7327*7328* jQuery('#add').on('click', _.before(5, addContactToList));7329* // => allows adding up to 4 contacts to the list7330*/7331function before(n, func) {7332var result;7333if (typeof func != 'function') {7334if (typeof n == 'function') {7335var temp = n;7336n = func;7337func = temp;7338} else {7339throw new TypeError(FUNC_ERROR_TEXT);7340}7341}7342return function() {7343if (--n > 0) {7344result = func.apply(this, arguments);7345}7346if (n <= 1) {7347func = null;7348}7349return result;7350};7351}73527353/**7354* Creates a function that invokes `func` with the `this` binding of `thisArg`7355* and prepends any additional `_.bind` arguments to those provided to the7356* bound function.7357*7358* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,7359* may be used as a placeholder for partially applied arguments.7360*7361* **Note:** Unlike native `Function#bind` this method does not set the "length"7362* property of bound functions.7363*7364* @static7365* @memberOf _7366* @category Function7367* @param {Function} func The function to bind.7368* @param {*} thisArg The `this` binding of `func`.7369* @param {...*} [partials] The arguments to be partially applied.7370* @returns {Function} Returns the new bound function.7371* @example7372*7373* var greet = function(greeting, punctuation) {7374* return greeting + ' ' + this.user + punctuation;7375* };7376*7377* var object = { 'user': 'fred' };7378*7379* var bound = _.bind(greet, object, 'hi');7380* bound('!');7381* // => 'hi fred!'7382*7383* // using placeholders7384* var bound = _.bind(greet, object, _, '!');7385* bound('hi');7386* // => 'hi fred!'7387*/7388var bind = restParam(function(func, thisArg, partials) {7389var bitmask = BIND_FLAG;7390if (partials.length) {7391var holders = replaceHolders(partials, bind.placeholder);7392bitmask |= PARTIAL_FLAG;7393}7394return createWrapper(func, bitmask, thisArg, partials, holders);7395});73967397/**7398* Binds methods of an object to the object itself, overwriting the existing7399* method. Method names may be specified as individual arguments or as arrays7400* of method names. If no method names are provided all enumerable function7401* properties, own and inherited, of `object` are bound.7402*7403* **Note:** This method does not set the "length" property of bound functions.7404*7405* @static7406* @memberOf _7407* @category Function7408* @param {Object} object The object to bind and assign the bound methods to.7409* @param {...(string|string[])} [methodNames] The object method names to bind,7410* specified as individual method names or arrays of method names.7411* @returns {Object} Returns `object`.7412* @example7413*7414* var view = {7415* 'label': 'docs',7416* 'onClick': function() {7417* console.log('clicked ' + this.label);7418* }7419* };7420*7421* _.bindAll(view);7422* jQuery('#docs').on('click', view.onClick);7423* // => logs 'clicked docs' when the element is clicked7424*/7425var bindAll = restParam(function(object, methodNames) {7426methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);74277428var index = -1,7429length = methodNames.length;74307431while (++index < length) {7432var key = methodNames[index];7433object[key] = createWrapper(object[key], BIND_FLAG, object);7434}7435return object;7436});74377438/**7439* Creates a function that invokes the method at `object[key]` and prepends7440* any additional `_.bindKey` arguments to those provided to the bound function.7441*7442* This method differs from `_.bind` by allowing bound functions to reference7443* methods that may be redefined or don't yet exist.7444* See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)7445* for more details.7446*7447* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic7448* builds, may be used as a placeholder for partially applied arguments.7449*7450* @static7451* @memberOf _7452* @category Function7453* @param {Object} object The object the method belongs to.7454* @param {string} key The key of the method.7455* @param {...*} [partials] The arguments to be partially applied.7456* @returns {Function} Returns the new bound function.7457* @example7458*7459* var object = {7460* 'user': 'fred',7461* 'greet': function(greeting, punctuation) {7462* return greeting + ' ' + this.user + punctuation;7463* }7464* };7465*7466* var bound = _.bindKey(object, 'greet', 'hi');7467* bound('!');7468* // => 'hi fred!'7469*7470* object.greet = function(greeting, punctuation) {7471* return greeting + 'ya ' + this.user + punctuation;7472* };7473*7474* bound('!');7475* // => 'hiya fred!'7476*7477* // using placeholders7478* var bound = _.bindKey(object, 'greet', _, '!');7479* bound('hi');7480* // => 'hiya fred!'7481*/7482var bindKey = restParam(function(object, key, partials) {7483var bitmask = BIND_FLAG | BIND_KEY_FLAG;7484if (partials.length) {7485var holders = replaceHolders(partials, bindKey.placeholder);7486bitmask |= PARTIAL_FLAG;7487}7488return createWrapper(key, bitmask, object, partials, holders);7489});74907491/**7492* Creates a function that accepts one or more arguments of `func` that when7493* called either invokes `func` returning its result, if all `func` arguments7494* have been provided, or returns a function that accepts one or more of the7495* remaining `func` arguments, and so on. The arity of `func` may be specified7496* if `func.length` is not sufficient.7497*7498* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,7499* may be used as a placeholder for provided arguments.7500*7501* **Note:** This method does not set the "length" property of curried functions.7502*7503* @static7504* @memberOf _7505* @category Function7506* @param {Function} func The function to curry.7507* @param {number} [arity=func.length] The arity of `func`.7508* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.7509* @returns {Function} Returns the new curried function.7510* @example7511*7512* var abc = function(a, b, c) {7513* return [a, b, c];7514* };7515*7516* var curried = _.curry(abc);7517*7518* curried(1)(2)(3);7519* // => [1, 2, 3]7520*7521* curried(1, 2)(3);7522* // => [1, 2, 3]7523*7524* curried(1, 2, 3);7525* // => [1, 2, 3]7526*7527* // using placeholders7528* curried(1)(_, 3)(2);7529* // => [1, 2, 3]7530*/7531var curry = createCurry(CURRY_FLAG);75327533/**7534* This method is like `_.curry` except that arguments are applied to `func`7535* in the manner of `_.partialRight` instead of `_.partial`.7536*7537* The `_.curryRight.placeholder` value, which defaults to `_` in monolithic7538* builds, may be used as a placeholder for provided arguments.7539*7540* **Note:** This method does not set the "length" property of curried functions.7541*7542* @static7543* @memberOf _7544* @category Function7545* @param {Function} func The function to curry.7546* @param {number} [arity=func.length] The arity of `func`.7547* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.7548* @returns {Function} Returns the new curried function.7549* @example7550*7551* var abc = function(a, b, c) {7552* return [a, b, c];7553* };7554*7555* var curried = _.curryRight(abc);7556*7557* curried(3)(2)(1);7558* // => [1, 2, 3]7559*7560* curried(2, 3)(1);7561* // => [1, 2, 3]7562*7563* curried(1, 2, 3);7564* // => [1, 2, 3]7565*7566* // using placeholders7567* curried(3)(1, _)(2);7568* // => [1, 2, 3]7569*/7570var curryRight = createCurry(CURRY_RIGHT_FLAG);75717572/**7573* Creates a debounced function that delays invoking `func` until after `wait`7574* milliseconds have elapsed since the last time the debounced function was7575* invoked. The debounced function comes with a `cancel` method to cancel7576* delayed invocations. Provide an options object to indicate that `func`7577* should be invoked on the leading and/or trailing edge of the `wait` timeout.7578* Subsequent calls to the debounced function return the result of the last7579* `func` invocation.7580*7581* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked7582* on the trailing edge of the timeout only if the the debounced function is7583* invoked more than once during the `wait` timeout.7584*7585* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)7586* for details over the differences between `_.debounce` and `_.throttle`.7587*7588* @static7589* @memberOf _7590* @category Function7591* @param {Function} func The function to debounce.7592* @param {number} [wait=0] The number of milliseconds to delay.7593* @param {Object} [options] The options object.7594* @param {boolean} [options.leading=false] Specify invoking on the leading7595* edge of the timeout.7596* @param {number} [options.maxWait] The maximum time `func` is allowed to be7597* delayed before it is invoked.7598* @param {boolean} [options.trailing=true] Specify invoking on the trailing7599* edge of the timeout.7600* @returns {Function} Returns the new debounced function.7601* @example7602*7603* // avoid costly calculations while the window size is in flux7604* jQuery(window).on('resize', _.debounce(calculateLayout, 150));7605*7606* // invoke `sendMail` when the click event is fired, debouncing subsequent calls7607* jQuery('#postbox').on('click', _.debounce(sendMail, 300, {7608* 'leading': true,7609* 'trailing': false7610* }));7611*7612* // ensure `batchLog` is invoked once after 1 second of debounced calls7613* var source = new EventSource('/stream');7614* jQuery(source).on('message', _.debounce(batchLog, 250, {7615* 'maxWait': 10007616* }));7617*7618* // cancel a debounced call7619* var todoChanges = _.debounce(batchLog, 1000);7620* Object.observe(models.todo, todoChanges);7621*7622* Object.observe(models, function(changes) {7623* if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {7624* todoChanges.cancel();7625* }7626* }, ['delete']);7627*7628* // ...at some point `models.todo` is changed7629* models.todo.completed = true;7630*7631* // ...before 1 second has passed `models.todo` is deleted7632* // which cancels the debounced `todoChanges` call7633* delete models.todo;7634*/7635function debounce(func, wait, options) {7636var args,7637maxTimeoutId,7638result,7639stamp,7640thisArg,7641timeoutId,7642trailingCall,7643lastCalled = 0,7644maxWait = false,7645trailing = true;76467647if (typeof func != 'function') {7648throw new TypeError(FUNC_ERROR_TEXT);7649}7650wait = wait < 0 ? 0 : (+wait || 0);7651if (options === true) {7652var leading = true;7653trailing = false;7654} else if (isObject(options)) {7655leading = options.leading;7656maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);7657trailing = 'trailing' in options ? options.trailing : trailing;7658}76597660function cancel() {7661if (timeoutId) {7662clearTimeout(timeoutId);7663}7664if (maxTimeoutId) {7665clearTimeout(maxTimeoutId);7666}7667maxTimeoutId = timeoutId = trailingCall = undefined;7668}76697670function delayed() {7671var remaining = wait - (now() - stamp);7672if (remaining <= 0 || remaining > wait) {7673if (maxTimeoutId) {7674clearTimeout(maxTimeoutId);7675}7676var isCalled = trailingCall;7677maxTimeoutId = timeoutId = trailingCall = undefined;7678if (isCalled) {7679lastCalled = now();7680result = func.apply(thisArg, args);7681if (!timeoutId && !maxTimeoutId) {7682args = thisArg = null;7683}7684}7685} else {7686timeoutId = setTimeout(delayed, remaining);7687}7688}76897690function maxDelayed() {7691if (timeoutId) {7692clearTimeout(timeoutId);7693}7694maxTimeoutId = timeoutId = trailingCall = undefined;7695if (trailing || (maxWait !== wait)) {7696lastCalled = now();7697result = func.apply(thisArg, args);7698if (!timeoutId && !maxTimeoutId) {7699args = thisArg = null;7700}7701}7702}77037704function debounced() {7705args = arguments;7706stamp = now();7707thisArg = this;7708trailingCall = trailing && (timeoutId || !leading);77097710if (maxWait === false) {7711var leadingCall = leading && !timeoutId;7712} else {7713if (!maxTimeoutId && !leading) {7714lastCalled = stamp;7715}7716var remaining = maxWait - (stamp - lastCalled),7717isCalled = remaining <= 0 || remaining > maxWait;77187719if (isCalled) {7720if (maxTimeoutId) {7721maxTimeoutId = clearTimeout(maxTimeoutId);7722}7723lastCalled = stamp;7724result = func.apply(thisArg, args);7725}7726else if (!maxTimeoutId) {7727maxTimeoutId = setTimeout(maxDelayed, remaining);7728}7729}7730if (isCalled && timeoutId) {7731timeoutId = clearTimeout(timeoutId);7732}7733else if (!timeoutId && wait !== maxWait) {7734timeoutId = setTimeout(delayed, wait);7735}7736if (leadingCall) {7737isCalled = true;7738result = func.apply(thisArg, args);7739}7740if (isCalled && !timeoutId && !maxTimeoutId) {7741args = thisArg = null;7742}7743return result;7744}7745debounced.cancel = cancel;7746return debounced;7747}77487749/**7750* Defers invoking the `func` until the current call stack has cleared. Any7751* additional arguments are provided to `func` when it is invoked.7752*7753* @static7754* @memberOf _7755* @category Function7756* @param {Function} func The function to defer.7757* @param {...*} [args] The arguments to invoke the function with.7758* @returns {number} Returns the timer id.7759* @example7760*7761* _.defer(function(text) {7762* console.log(text);7763* }, 'deferred');7764* // logs 'deferred' after one or more milliseconds7765*/7766var defer = restParam(function(func, args) {7767return baseDelay(func, 1, args);7768});77697770/**7771* Invokes `func` after `wait` milliseconds. Any additional arguments are7772* provided to `func` when it is invoked.7773*7774* @static7775* @memberOf _7776* @category Function7777* @param {Function} func The function to delay.7778* @param {number} wait The number of milliseconds to delay invocation.7779* @param {...*} [args] The arguments to invoke the function with.7780* @returns {number} Returns the timer id.7781* @example7782*7783* _.delay(function(text) {7784* console.log(text);7785* }, 1000, 'later');7786* // => logs 'later' after one second7787*/7788var delay = restParam(function(func, wait, args) {7789return baseDelay(func, wait, args);7790});77917792/**7793* Creates a function that returns the result of invoking the provided7794* functions with the `this` binding of the created function, where each7795* successive invocation is supplied the return value of the previous.7796*7797* @static7798* @memberOf _7799* @category Function7800* @param {...Function} [funcs] Functions to invoke.7801* @returns {Function} Returns the new function.7802* @example7803*7804* function square(n) {7805* return n * n;7806* }7807*7808* var addSquare = _.flow(_.add, square);7809* addSquare(1, 2);7810* // => 97811*/7812var flow = createFlow();78137814/**7815* This method is like `_.flow` except that it creates a function that7816* invokes the provided functions from right to left.7817*7818* @static7819* @memberOf _7820* @alias backflow, compose7821* @category Function7822* @param {...Function} [funcs] Functions to invoke.7823* @returns {Function} Returns the new function.7824* @example7825*7826* function square(n) {7827* return n * n;7828* }7829*7830* var addSquare = _.flowRight(square, _.add);7831* addSquare(1, 2);7832* // => 97833*/7834var flowRight = createFlow(true);78357836/**7837* Creates a function that memoizes the result of `func`. If `resolver` is7838* provided it determines the cache key for storing the result based on the7839* arguments provided to the memoized function. By default, the first argument7840* provided to the memoized function is coerced to a string and used as the7841* cache key. The `func` is invoked with the `this` binding of the memoized7842* function.7843*7844* **Note:** The cache is exposed as the `cache` property on the memoized7845* function. Its creation may be customized by replacing the `_.memoize.Cache`7846* constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)7847* method interface of `get`, `has`, and `set`.7848*7849* @static7850* @memberOf _7851* @category Function7852* @param {Function} func The function to have its output memoized.7853* @param {Function} [resolver] The function to resolve the cache key.7854* @returns {Function} Returns the new memoizing function.7855* @example7856*7857* var upperCase = _.memoize(function(string) {7858* return string.toUpperCase();7859* });7860*7861* upperCase('fred');7862* // => 'FRED'7863*7864* // modifying the result cache7865* upperCase.cache.set('fred', 'BARNEY');7866* upperCase('fred');7867* // => 'BARNEY'7868*7869* // replacing `_.memoize.Cache`7870* var object = { 'user': 'fred' };7871* var other = { 'user': 'barney' };7872* var identity = _.memoize(_.identity);7873*7874* identity(object);7875* // => { 'user': 'fred' }7876* identity(other);7877* // => { 'user': 'fred' }7878*7879* _.memoize.Cache = WeakMap;7880* var identity = _.memoize(_.identity);7881*7882* identity(object);7883* // => { 'user': 'fred' }7884* identity(other);7885* // => { 'user': 'barney' }7886*/7887function memoize(func, resolver) {7888if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {7889throw new TypeError(FUNC_ERROR_TEXT);7890}7891var memoized = function() {7892var args = arguments,7893key = resolver ? resolver.apply(this, args) : args[0],7894cache = memoized.cache;78957896if (cache.has(key)) {7897return cache.get(key);7898}7899var result = func.apply(this, args);7900memoized.cache = cache.set(key, result);7901return result;7902};7903memoized.cache = new memoize.Cache;7904return memoized;7905}79067907/**7908* Creates a function that negates the result of the predicate `func`. The7909* `func` predicate is invoked with the `this` binding and arguments of the7910* created function.7911*7912* @static7913* @memberOf _7914* @category Function7915* @param {Function} predicate The predicate to negate.7916* @returns {Function} Returns the new function.7917* @example7918*7919* function isEven(n) {7920* return n % 2 == 0;7921* }7922*7923* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));7924* // => [1, 3, 5]7925*/7926function negate(predicate) {7927if (typeof predicate != 'function') {7928throw new TypeError(FUNC_ERROR_TEXT);7929}7930return function() {7931return !predicate.apply(this, arguments);7932};7933}79347935/**7936* Creates a function that is restricted to invoking `func` once. Repeat calls7937* to the function return the value of the first call. The `func` is invoked7938* with the `this` binding and arguments of the created function.7939*7940* @static7941* @memberOf _7942* @category Function7943* @param {Function} func The function to restrict.7944* @returns {Function} Returns the new restricted function.7945* @example7946*7947* var initialize = _.once(createApplication);7948* initialize();7949* initialize();7950* // `initialize` invokes `createApplication` once7951*/7952function once(func) {7953return before(2, func);7954}79557956/**7957* Creates a function that invokes `func` with `partial` arguments prepended7958* to those provided to the new function. This method is like `_.bind` except7959* it does **not** alter the `this` binding.7960*7961* The `_.partial.placeholder` value, which defaults to `_` in monolithic7962* builds, may be used as a placeholder for partially applied arguments.7963*7964* **Note:** This method does not set the "length" property of partially7965* applied functions.7966*7967* @static7968* @memberOf _7969* @category Function7970* @param {Function} func The function to partially apply arguments to.7971* @param {...*} [partials] The arguments to be partially applied.7972* @returns {Function} Returns the new partially applied function.7973* @example7974*7975* var greet = function(greeting, name) {7976* return greeting + ' ' + name;7977* };7978*7979* var sayHelloTo = _.partial(greet, 'hello');7980* sayHelloTo('fred');7981* // => 'hello fred'7982*7983* // using placeholders7984* var greetFred = _.partial(greet, _, 'fred');7985* greetFred('hi');7986* // => 'hi fred'7987*/7988var partial = createPartial(PARTIAL_FLAG);79897990/**7991* This method is like `_.partial` except that partially applied arguments7992* are appended to those provided to the new function.7993*7994* The `_.partialRight.placeholder` value, which defaults to `_` in monolithic7995* builds, may be used as a placeholder for partially applied arguments.7996*7997* **Note:** This method does not set the "length" property of partially7998* applied functions.7999*8000* @static8001* @memberOf _8002* @category Function8003* @param {Function} func The function to partially apply arguments to.8004* @param {...*} [partials] The arguments to be partially applied.8005* @returns {Function} Returns the new partially applied function.8006* @example8007*8008* var greet = function(greeting, name) {8009* return greeting + ' ' + name;8010* };8011*8012* var greetFred = _.partialRight(greet, 'fred');8013* greetFred('hi');8014* // => 'hi fred'8015*8016* // using placeholders8017* var sayHelloTo = _.partialRight(greet, 'hello', _);8018* sayHelloTo('fred');8019* // => 'hello fred'8020*/8021var partialRight = createPartial(PARTIAL_RIGHT_FLAG);80228023/**8024* Creates a function that invokes `func` with arguments arranged according8025* to the specified indexes where the argument value at the first index is8026* provided as the first argument, the argument value at the second index is8027* provided as the second argument, and so on.8028*8029* @static8030* @memberOf _8031* @category Function8032* @param {Function} func The function to rearrange arguments for.8033* @param {...(number|number[])} indexes The arranged argument indexes,8034* specified as individual indexes or arrays of indexes.8035* @returns {Function} Returns the new function.8036* @example8037*8038* var rearged = _.rearg(function(a, b, c) {8039* return [a, b, c];8040* }, 2, 0, 1);8041*8042* rearged('b', 'c', 'a')8043* // => ['a', 'b', 'c']8044*8045* var map = _.rearg(_.map, [1, 0]);8046* map(function(n) {8047* return n * 3;8048* }, [1, 2, 3]);8049* // => [3, 6, 9]8050*/8051var rearg = restParam(function(func, indexes) {8052return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes));8053});80548055/**8056* Creates a function that invokes `func` with the `this` binding of the8057* created function and arguments from `start` and beyond provided as an array.8058*8059* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).8060*8061* @static8062* @memberOf _8063* @category Function8064* @param {Function} func The function to apply a rest parameter to.8065* @param {number} [start=func.length-1] The start position of the rest parameter.8066* @returns {Function} Returns the new function.8067* @example8068*8069* var say = _.restParam(function(what, names) {8070* return what + ' ' + _.initial(names).join(', ') +8071* (_.size(names) > 1 ? ', & ' : '') + _.last(names);8072* });8073*8074* say('hello', 'fred', 'barney', 'pebbles');8075* // => 'hello fred, barney, & pebbles'8076*/8077function restParam(func, start) {8078if (typeof func != 'function') {8079throw new TypeError(FUNC_ERROR_TEXT);8080}8081start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);8082return function() {8083var args = arguments,8084index = -1,8085length = nativeMax(args.length - start, 0),8086rest = Array(length);80878088while (++index < length) {8089rest[index] = args[start + index];8090}8091switch (start) {8092case 0: return func.call(this, rest);8093case 1: return func.call(this, args[0], rest);8094case 2: return func.call(this, args[0], args[1], rest);8095}8096var otherArgs = Array(start + 1);8097index = -1;8098while (++index < start) {8099otherArgs[index] = args[index];8100}8101otherArgs[start] = rest;8102return func.apply(this, otherArgs);8103};8104}81058106/**8107* Creates a function that invokes `func` with the `this` binding of the created8108* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).8109*8110* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).8111*8112* @static8113* @memberOf _8114* @category Function8115* @param {Function} func The function to spread arguments over.8116* @returns {Function} Returns the new function.8117* @example8118*8119* var say = _.spread(function(who, what) {8120* return who + ' says ' + what;8121* });8122*8123* say(['fred', 'hello']);8124* // => 'fred says hello'8125*8126* // with a Promise8127* var numbers = Promise.all([8128* Promise.resolve(40),8129* Promise.resolve(36)8130* ]);8131*8132* numbers.then(_.spread(function(x, y) {8133* return x + y;8134* }));8135* // => a Promise of 768136*/8137function spread(func) {8138if (typeof func != 'function') {8139throw new TypeError(FUNC_ERROR_TEXT);8140}8141return function(array) {8142return func.apply(this, array);8143};8144}81458146/**8147* Creates a throttled function that only invokes `func` at most once per8148* every `wait` milliseconds. The throttled function comes with a `cancel`8149* method to cancel delayed invocations. Provide an options object to indicate8150* that `func` should be invoked on the leading and/or trailing edge of the8151* `wait` timeout. Subsequent calls to the throttled function return the8152* result of the last `func` call.8153*8154* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked8155* on the trailing edge of the timeout only if the the throttled function is8156* invoked more than once during the `wait` timeout.8157*8158* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)8159* for details over the differences between `_.throttle` and `_.debounce`.8160*8161* @static8162* @memberOf _8163* @category Function8164* @param {Function} func The function to throttle.8165* @param {number} [wait=0] The number of milliseconds to throttle invocations to.8166* @param {Object} [options] The options object.8167* @param {boolean} [options.leading=true] Specify invoking on the leading8168* edge of the timeout.8169* @param {boolean} [options.trailing=true] Specify invoking on the trailing8170* edge of the timeout.8171* @returns {Function} Returns the new throttled function.8172* @example8173*8174* // avoid excessively updating the position while scrolling8175* jQuery(window).on('scroll', _.throttle(updatePosition, 100));8176*8177* // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes8178* jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {8179* 'trailing': false8180* }));8181*8182* // cancel a trailing throttled call8183* jQuery(window).on('popstate', throttled.cancel);8184*/8185function throttle(func, wait, options) {8186var leading = true,8187trailing = true;81888189if (typeof func != 'function') {8190throw new TypeError(FUNC_ERROR_TEXT);8191}8192if (options === false) {8193leading = false;8194} else if (isObject(options)) {8195leading = 'leading' in options ? !!options.leading : leading;8196trailing = 'trailing' in options ? !!options.trailing : trailing;8197}8198debounceOptions.leading = leading;8199debounceOptions.maxWait = +wait;8200debounceOptions.trailing = trailing;8201return debounce(func, wait, debounceOptions);8202}82038204/**8205* Creates a function that provides `value` to the wrapper function as its8206* first argument. Any additional arguments provided to the function are8207* appended to those provided to the wrapper function. The wrapper is invoked8208* with the `this` binding of the created function.8209*8210* @static8211* @memberOf _8212* @category Function8213* @param {*} value The value to wrap.8214* @param {Function} wrapper The wrapper function.8215* @returns {Function} Returns the new function.8216* @example8217*8218* var p = _.wrap(_.escape, function(func, text) {8219* return '<p>' + func(text) + '</p>';8220* });8221*8222* p('fred, barney, & pebbles');8223* // => '<p>fred, barney, & pebbles</p>'8224*/8225function wrap(value, wrapper) {8226wrapper = wrapper == null ? identity : wrapper;8227return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []);8228}82298230/*------------------------------------------------------------------------*/82318232/**8233* Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,8234* otherwise they are assigned by reference. If `customizer` is provided it is8235* invoked to produce the cloned values. If `customizer` returns `undefined`8236* cloning is handled by the method instead. The `customizer` is bound to8237* `thisArg` and invoked with two argument; (value [, index|key, object]).8238*8239* **Note:** This method is loosely based on the8240* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).8241* The enumerable properties of `arguments` objects and objects created by8242* constructors other than `Object` are cloned to plain `Object` objects. An8243* empty object is returned for uncloneable values such as functions, DOM nodes,8244* Maps, Sets, and WeakMaps.8245*8246* @static8247* @memberOf _8248* @category Lang8249* @param {*} value The value to clone.8250* @param {boolean} [isDeep] Specify a deep clone.8251* @param {Function} [customizer] The function to customize cloning values.8252* @param {*} [thisArg] The `this` binding of `customizer`.8253* @returns {*} Returns the cloned value.8254* @example8255*8256* var users = [8257* { 'user': 'barney' },8258* { 'user': 'fred' }8259* ];8260*8261* var shallow = _.clone(users);8262* shallow[0] === users[0];8263* // => true8264*8265* var deep = _.clone(users, true);8266* deep[0] === users[0];8267* // => false8268*8269* // using a customizer callback8270* var el = _.clone(document.body, function(value) {8271* if (_.isElement(value)) {8272* return value.cloneNode(false);8273* }8274* });8275*8276* el === document.body8277* // => false8278* el.nodeName8279* // => BODY8280* el.childNodes.length;8281* // => 08282*/8283function clone(value, isDeep, customizer, thisArg) {8284if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {8285isDeep = false;8286}8287else if (typeof isDeep == 'function') {8288thisArg = customizer;8289customizer = isDeep;8290isDeep = false;8291}8292return typeof customizer == 'function'8293? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))8294: baseClone(value, isDeep);8295}82968297/**8298* Creates a deep clone of `value`. If `customizer` is provided it is invoked8299* to produce the cloned values. If `customizer` returns `undefined` cloning8300* is handled by the method instead. The `customizer` is bound to `thisArg`8301* and invoked with two argument; (value [, index|key, object]).8302*8303* **Note:** This method is loosely based on the8304* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).8305* The enumerable properties of `arguments` objects and objects created by8306* constructors other than `Object` are cloned to plain `Object` objects. An8307* empty object is returned for uncloneable values such as functions, DOM nodes,8308* Maps, Sets, and WeakMaps.8309*8310* @static8311* @memberOf _8312* @category Lang8313* @param {*} value The value to deep clone.8314* @param {Function} [customizer] The function to customize cloning values.8315* @param {*} [thisArg] The `this` binding of `customizer`.8316* @returns {*} Returns the deep cloned value.8317* @example8318*8319* var users = [8320* { 'user': 'barney' },8321* { 'user': 'fred' }8322* ];8323*8324* var deep = _.cloneDeep(users);8325* deep[0] === users[0];8326* // => false8327*8328* // using a customizer callback8329* var el = _.cloneDeep(document.body, function(value) {8330* if (_.isElement(value)) {8331* return value.cloneNode(true);8332* }8333* });8334*8335* el === document.body8336* // => false8337* el.nodeName8338* // => BODY8339* el.childNodes.length;8340* // => 208341*/8342function cloneDeep(value, customizer, thisArg) {8343return typeof customizer == 'function'8344? baseClone(value, true, bindCallback(customizer, thisArg, 1))8345: baseClone(value, true);8346}83478348/**8349* Checks if `value` is greater than `other`.8350*8351* @static8352* @memberOf _8353* @category Lang8354* @param {*} value The value to compare.8355* @param {*} other The other value to compare.8356* @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`.8357* @example8358*8359* _.gt(3, 1);8360* // => true8361*8362* _.gt(3, 3);8363* // => false8364*8365* _.gt(1, 3);8366* // => false8367*/8368function gt(value, other) {8369return value > other;8370}83718372/**8373* Checks if `value` is greater than or equal to `other`.8374*8375* @static8376* @memberOf _8377* @category Lang8378* @param {*} value The value to compare.8379* @param {*} other The other value to compare.8380* @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`.8381* @example8382*8383* _.gte(3, 1);8384* // => true8385*8386* _.gte(3, 3);8387* // => true8388*8389* _.gte(1, 3);8390* // => false8391*/8392function gte(value, other) {8393return value >= other;8394}83958396/**8397* Checks if `value` is classified as an `arguments` object.8398*8399* @static8400* @memberOf _8401* @category Lang8402* @param {*} value The value to check.8403* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8404* @example8405*8406* _.isArguments(function() { return arguments; }());8407* // => true8408*8409* _.isArguments([1, 2, 3]);8410* // => false8411*/8412function isArguments(value) {8413return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag;8414}84158416/**8417* Checks if `value` is classified as an `Array` object.8418*8419* @static8420* @memberOf _8421* @category Lang8422* @param {*} value The value to check.8423* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8424* @example8425*8426* _.isArray([1, 2, 3]);8427* // => true8428*8429* _.isArray(function() { return arguments; }());8430* // => false8431*/8432var isArray = nativeIsArray || function(value) {8433return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;8434};84358436/**8437* Checks if `value` is classified as a boolean primitive or object.8438*8439* @static8440* @memberOf _8441* @category Lang8442* @param {*} value The value to check.8443* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8444* @example8445*8446* _.isBoolean(false);8447* // => true8448*8449* _.isBoolean(null);8450* // => false8451*/8452function isBoolean(value) {8453return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);8454}84558456/**8457* Checks if `value` is classified as a `Date` object.8458*8459* @static8460* @memberOf _8461* @category Lang8462* @param {*} value The value to check.8463* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8464* @example8465*8466* _.isDate(new Date);8467* // => true8468*8469* _.isDate('Mon April 23 2012');8470* // => false8471*/8472function isDate(value) {8473return isObjectLike(value) && objToString.call(value) == dateTag;8474}84758476/**8477* Checks if `value` is a DOM element.8478*8479* @static8480* @memberOf _8481* @category Lang8482* @param {*} value The value to check.8483* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.8484* @example8485*8486* _.isElement(document.body);8487* // => true8488*8489* _.isElement('<body>');8490* // => false8491*/8492function isElement(value) {8493return !!value && value.nodeType === 1 && isObjectLike(value) &&8494(objToString.call(value).indexOf('Element') > -1);8495}8496// Fallback for environments without DOM support.8497if (!support.dom) {8498isElement = function(value) {8499return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);8500};8501}85028503/**8504* Checks if `value` is empty. A value is considered empty unless it is an8505* `arguments` object, array, string, or jQuery-like collection with a length8506* greater than `0` or an object with own enumerable properties.8507*8508* @static8509* @memberOf _8510* @category Lang8511* @param {Array|Object|string} value The value to inspect.8512* @returns {boolean} Returns `true` if `value` is empty, else `false`.8513* @example8514*8515* _.isEmpty(null);8516* // => true8517*8518* _.isEmpty(true);8519* // => true8520*8521* _.isEmpty(1);8522* // => true8523*8524* _.isEmpty([1, 2, 3]);8525* // => false8526*8527* _.isEmpty({ 'a': 1 });8528* // => false8529*/8530function isEmpty(value) {8531if (value == null) {8532return true;8533}8534if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||8535(isObjectLike(value) && isFunction(value.splice)))) {8536return !value.length;8537}8538return !keys(value).length;8539}85408541/**8542* Performs a deep comparison between two values to determine if they are8543* equivalent. If `customizer` is provided it is invoked to compare values.8544* If `customizer` returns `undefined` comparisons are handled by the method8545* instead. The `customizer` is bound to `thisArg` and invoked with three8546* arguments: (value, other [, index|key]).8547*8548* **Note:** This method supports comparing arrays, booleans, `Date` objects,8549* numbers, `Object` objects, regexes, and strings. Objects are compared by8550* their own, not inherited, enumerable properties. Functions and DOM nodes8551* are **not** supported. Provide a customizer function to extend support8552* for comparing other values.8553*8554* @static8555* @memberOf _8556* @alias eq8557* @category Lang8558* @param {*} value The value to compare.8559* @param {*} other The other value to compare.8560* @param {Function} [customizer] The function to customize value comparisons.8561* @param {*} [thisArg] The `this` binding of `customizer`.8562* @returns {boolean} Returns `true` if the values are equivalent, else `false`.8563* @example8564*8565* var object = { 'user': 'fred' };8566* var other = { 'user': 'fred' };8567*8568* object == other;8569* // => false8570*8571* _.isEqual(object, other);8572* // => true8573*8574* // using a customizer callback8575* var array = ['hello', 'goodbye'];8576* var other = ['hi', 'goodbye'];8577*8578* _.isEqual(array, other, function(value, other) {8579* if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {8580* return true;8581* }8582* });8583* // => true8584*/8585function isEqual(value, other, customizer, thisArg) {8586customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;8587var result = customizer ? customizer(value, other) : undefined;8588return result === undefined ? baseIsEqual(value, other, customizer) : !!result;8589}85908591/**8592* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,8593* `SyntaxError`, `TypeError`, or `URIError` object.8594*8595* @static8596* @memberOf _8597* @category Lang8598* @param {*} value The value to check.8599* @returns {boolean} Returns `true` if `value` is an error object, else `false`.8600* @example8601*8602* _.isError(new Error);8603* // => true8604*8605* _.isError(Error);8606* // => false8607*/8608function isError(value) {8609return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;8610}86118612/**8613* Checks if `value` is a finite primitive number.8614*8615* **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite).8616*8617* @static8618* @memberOf _8619* @category Lang8620* @param {*} value The value to check.8621* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.8622* @example8623*8624* _.isFinite(10);8625* // => true8626*8627* _.isFinite('10');8628* // => false8629*8630* _.isFinite(true);8631* // => false8632*8633* _.isFinite(Object(10));8634* // => false8635*8636* _.isFinite(Infinity);8637* // => false8638*/8639var isFinite = nativeNumIsFinite || function(value) {8640return typeof value == 'number' && nativeIsFinite(value);8641};86428643/**8644* Checks if `value` is classified as a `Function` object.8645*8646* @static8647* @memberOf _8648* @category Lang8649* @param {*} value The value to check.8650* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8651* @example8652*8653* _.isFunction(_);8654* // => true8655*8656* _.isFunction(/abc/);8657* // => false8658*/8659var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {8660// The use of `Object#toString` avoids issues with the `typeof` operator8661// in older versions of Chrome and Safari which return 'function' for regexes8662// and Safari 8 equivalents which return 'object' for typed array constructors.8663return objToString.call(value) == funcTag;8664};86658666/**8667* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.8668* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)8669*8670* @static8671* @memberOf _8672* @category Lang8673* @param {*} value The value to check.8674* @returns {boolean} Returns `true` if `value` is an object, else `false`.8675* @example8676*8677* _.isObject({});8678* // => true8679*8680* _.isObject([1, 2, 3]);8681* // => true8682*8683* _.isObject(1);8684* // => false8685*/8686function isObject(value) {8687// Avoid a V8 JIT bug in Chrome 19-20.8688// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.8689var type = typeof value;8690return !!value && (type == 'object' || type == 'function');8691}86928693/**8694* Performs a deep comparison between `object` and `source` to determine if8695* `object` contains equivalent property values. If `customizer` is provided8696* it is invoked to compare values. If `customizer` returns `undefined`8697* comparisons are handled by the method instead. The `customizer` is bound8698* to `thisArg` and invoked with three arguments: (value, other, index|key).8699*8700* **Note:** This method supports comparing properties of arrays, booleans,8701* `Date` objects, numbers, `Object` objects, regexes, and strings. Functions8702* and DOM nodes are **not** supported. Provide a customizer function to extend8703* support for comparing other values.8704*8705* @static8706* @memberOf _8707* @category Lang8708* @param {Object} object The object to inspect.8709* @param {Object} source The object of property values to match.8710* @param {Function} [customizer] The function to customize value comparisons.8711* @param {*} [thisArg] The `this` binding of `customizer`.8712* @returns {boolean} Returns `true` if `object` is a match, else `false`.8713* @example8714*8715* var object = { 'user': 'fred', 'age': 40 };8716*8717* _.isMatch(object, { 'age': 40 });8718* // => true8719*8720* _.isMatch(object, { 'age': 36 });8721* // => false8722*8723* // using a customizer callback8724* var object = { 'greeting': 'hello' };8725* var source = { 'greeting': 'hi' };8726*8727* _.isMatch(object, source, function(value, other) {8728* return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined;8729* });8730* // => true8731*/8732function isMatch(object, source, customizer, thisArg) {8733customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;8734return baseIsMatch(object, getMatchData(source), customizer);8735}87368737/**8738* Checks if `value` is `NaN`.8739*8740* **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4)8741* which returns `true` for `undefined` and other non-numeric values.8742*8743* @static8744* @memberOf _8745* @category Lang8746* @param {*} value The value to check.8747* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.8748* @example8749*8750* _.isNaN(NaN);8751* // => true8752*8753* _.isNaN(new Number(NaN));8754* // => true8755*8756* isNaN(undefined);8757* // => true8758*8759* _.isNaN(undefined);8760* // => false8761*/8762function isNaN(value) {8763// An `NaN` primitive is the only value that is not equal to itself.8764// Perform the `toStringTag` check first to avoid errors with some host objects in IE.8765return isNumber(value) && value != +value;8766}87678768/**8769* Checks if `value` is a native function.8770*8771* @static8772* @memberOf _8773* @category Lang8774* @param {*} value The value to check.8775* @returns {boolean} Returns `true` if `value` is a native function, else `false`.8776* @example8777*8778* _.isNative(Array.prototype.push);8779* // => true8780*8781* _.isNative(_);8782* // => false8783*/8784function isNative(value) {8785if (value == null) {8786return false;8787}8788if (objToString.call(value) == funcTag) {8789return reIsNative.test(fnToString.call(value));8790}8791return isObjectLike(value) && reIsHostCtor.test(value);8792}87938794/**8795* Checks if `value` is `null`.8796*8797* @static8798* @memberOf _8799* @category Lang8800* @param {*} value The value to check.8801* @returns {boolean} Returns `true` if `value` is `null`, else `false`.8802* @example8803*8804* _.isNull(null);8805* // => true8806*8807* _.isNull(void 0);8808* // => false8809*/8810function isNull(value) {8811return value === null;8812}88138814/**8815* Checks if `value` is classified as a `Number` primitive or object.8816*8817* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified8818* as numbers, use the `_.isFinite` method.8819*8820* @static8821* @memberOf _8822* @category Lang8823* @param {*} value The value to check.8824* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8825* @example8826*8827* _.isNumber(8.4);8828* // => true8829*8830* _.isNumber(NaN);8831* // => true8832*8833* _.isNumber('8.4');8834* // => false8835*/8836function isNumber(value) {8837return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);8838}88398840/**8841* Checks if `value` is a plain object, that is, an object created by the8842* `Object` constructor or one with a `[[Prototype]]` of `null`.8843*8844* **Note:** This method assumes objects created by the `Object` constructor8845* have no inherited enumerable properties.8846*8847* @static8848* @memberOf _8849* @category Lang8850* @param {*} value The value to check.8851* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.8852* @example8853*8854* function Foo() {8855* this.a = 1;8856* }8857*8858* _.isPlainObject(new Foo);8859* // => false8860*8861* _.isPlainObject([1, 2, 3]);8862* // => false8863*8864* _.isPlainObject({ 'x': 0, 'y': 0 });8865* // => true8866*8867* _.isPlainObject(Object.create(null));8868* // => true8869*/8870var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {8871if (!(value && objToString.call(value) == objectTag)) {8872return false;8873}8874var valueOf = getNative(value, 'valueOf'),8875objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);88768877return objProto8878? (value == objProto || getPrototypeOf(value) == objProto)8879: shimIsPlainObject(value);8880};88818882/**8883* Checks if `value` is classified as a `RegExp` object.8884*8885* @static8886* @memberOf _8887* @category Lang8888* @param {*} value The value to check.8889* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8890* @example8891*8892* _.isRegExp(/abc/);8893* // => true8894*8895* _.isRegExp('/abc/');8896* // => false8897*/8898function isRegExp(value) {8899return isObjectLike(value) && objToString.call(value) == regexpTag;8900}89018902/**8903* Checks if `value` is classified as a `String` primitive or object.8904*8905* @static8906* @memberOf _8907* @category Lang8908* @param {*} value The value to check.8909* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8910* @example8911*8912* _.isString('abc');8913* // => true8914*8915* _.isString(1);8916* // => false8917*/8918function isString(value) {8919return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);8920}89218922/**8923* Checks if `value` is classified as a typed array.8924*8925* @static8926* @memberOf _8927* @category Lang8928* @param {*} value The value to check.8929* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.8930* @example8931*8932* _.isTypedArray(new Uint8Array);8933* // => true8934*8935* _.isTypedArray([]);8936* // => false8937*/8938function isTypedArray(value) {8939return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];8940}89418942/**8943* Checks if `value` is `undefined`.8944*8945* @static8946* @memberOf _8947* @category Lang8948* @param {*} value The value to check.8949* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.8950* @example8951*8952* _.isUndefined(void 0);8953* // => true8954*8955* _.isUndefined(null);8956* // => false8957*/8958function isUndefined(value) {8959return value === undefined;8960}89618962/**8963* Checks if `value` is less than `other`.8964*8965* @static8966* @memberOf _8967* @category Lang8968* @param {*} value The value to compare.8969* @param {*} other The other value to compare.8970* @returns {boolean} Returns `true` if `value` is less than `other`, else `false`.8971* @example8972*8973* _.lt(1, 3);8974* // => true8975*8976* _.lt(3, 3);8977* // => false8978*8979* _.lt(3, 1);8980* // => false8981*/8982function lt(value, other) {8983return value < other;8984}89858986/**8987* Checks if `value` is less than or equal to `other`.8988*8989* @static8990* @memberOf _8991* @category Lang8992* @param {*} value The value to compare.8993* @param {*} other The other value to compare.8994* @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`.8995* @example8996*8997* _.lte(1, 3);8998* // => true8999*9000* _.lte(3, 3);9001* // => true9002*9003* _.lte(3, 1);9004* // => false9005*/9006function lte(value, other) {9007return value <= other;9008}90099010/**9011* Converts `value` to an array.9012*9013* @static9014* @memberOf _9015* @category Lang9016* @param {*} value The value to convert.9017* @returns {Array} Returns the converted array.9018* @example9019*9020* (function() {9021* return _.toArray(arguments).slice(1);9022* }(1, 2, 3));9023* // => [2, 3]9024*/9025function toArray(value) {9026var length = value ? getLength(value) : 0;9027if (!isLength(length)) {9028return values(value);9029}9030if (!length) {9031return [];9032}9033return arrayCopy(value);9034}90359036/**9037* Converts `value` to a plain object flattening inherited enumerable9038* properties of `value` to own properties of the plain object.9039*9040* @static9041* @memberOf _9042* @category Lang9043* @param {*} value The value to convert.9044* @returns {Object} Returns the converted plain object.9045* @example9046*9047* function Foo() {9048* this.b = 2;9049* }9050*9051* Foo.prototype.c = 3;9052*9053* _.assign({ 'a': 1 }, new Foo);9054* // => { 'a': 1, 'b': 2 }9055*9056* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));9057* // => { 'a': 1, 'b': 2, 'c': 3 }9058*/9059function toPlainObject(value) {9060return baseCopy(value, keysIn(value));9061}90629063/*------------------------------------------------------------------------*/90649065/**9066* Assigns own enumerable properties of source object(s) to the destination9067* object. Subsequent sources overwrite property assignments of previous sources.9068* If `customizer` is provided it is invoked to produce the assigned values.9069* The `customizer` is bound to `thisArg` and invoked with five arguments:9070* (objectValue, sourceValue, key, object, source).9071*9072* **Note:** This method mutates `object` and is based on9073* [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).9074*9075* @static9076* @memberOf _9077* @alias extend9078* @category Object9079* @param {Object} object The destination object.9080* @param {...Object} [sources] The source objects.9081* @param {Function} [customizer] The function to customize assigned values.9082* @param {*} [thisArg] The `this` binding of `customizer`.9083* @returns {Object} Returns `object`.9084* @example9085*9086* _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });9087* // => { 'user': 'fred', 'age': 40 }9088*9089* // using a customizer callback9090* var defaults = _.partialRight(_.assign, function(value, other) {9091* return _.isUndefined(value) ? other : value;9092* });9093*9094* defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });9095* // => { 'user': 'barney', 'age': 36 }9096*/9097var assign = createAssigner(function(object, source, customizer) {9098return customizer9099? assignWith(object, source, customizer)9100: baseAssign(object, source);9101});91029103/**9104* Creates an object that inherits from the given `prototype` object. If a9105* `properties` object is provided its own enumerable properties are assigned9106* to the created object.9107*9108* @static9109* @memberOf _9110* @category Object9111* @param {Object} prototype The object to inherit from.9112* @param {Object} [properties] The properties to assign to the object.9113* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.9114* @returns {Object} Returns the new object.9115* @example9116*9117* function Shape() {9118* this.x = 0;9119* this.y = 0;9120* }9121*9122* function Circle() {9123* Shape.call(this);9124* }9125*9126* Circle.prototype = _.create(Shape.prototype, {9127* 'constructor': Circle9128* });9129*9130* var circle = new Circle;9131* circle instanceof Circle;9132* // => true9133*9134* circle instanceof Shape;9135* // => true9136*/9137function create(prototype, properties, guard) {9138var result = baseCreate(prototype);9139if (guard && isIterateeCall(prototype, properties, guard)) {9140properties = null;9141}9142return properties ? baseAssign(result, properties) : result;9143}91449145/**9146* Assigns own enumerable properties of source object(s) to the destination9147* object for all destination properties that resolve to `undefined`. Once a9148* property is set, additional values of the same property are ignored.9149*9150* **Note:** This method mutates `object`.9151*9152* @static9153* @memberOf _9154* @category Object9155* @param {Object} object The destination object.9156* @param {...Object} [sources] The source objects.9157* @returns {Object} Returns `object`.9158* @example9159*9160* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });9161* // => { 'user': 'barney', 'age': 36 }9162*/9163var defaults = restParam(function(args) {9164var object = args[0];9165if (object == null) {9166return object;9167}9168args.push(assignDefaults);9169return assign.apply(undefined, args);9170});91719172/**9173* This method is like `_.find` except that it returns the key of the first9174* element `predicate` returns truthy for instead of the element itself.9175*9176* If a property name is provided for `predicate` the created `_.property`9177* style callback returns the property value of the given element.9178*9179* If a value is also provided for `thisArg` the created `_.matchesProperty`9180* style callback returns `true` for elements that have a matching property9181* value, else `false`.9182*9183* If an object is provided for `predicate` the created `_.matches` style9184* callback returns `true` for elements that have the properties of the given9185* object, else `false`.9186*9187* @static9188* @memberOf _9189* @category Object9190* @param {Object} object The object to search.9191* @param {Function|Object|string} [predicate=_.identity] The function invoked9192* per iteration.9193* @param {*} [thisArg] The `this` binding of `predicate`.9194* @returns {string|undefined} Returns the key of the matched element, else `undefined`.9195* @example9196*9197* var users = {9198* 'barney': { 'age': 36, 'active': true },9199* 'fred': { 'age': 40, 'active': false },9200* 'pebbles': { 'age': 1, 'active': true }9201* };9202*9203* _.findKey(users, function(chr) {9204* return chr.age < 40;9205* });9206* // => 'barney' (iteration order is not guaranteed)9207*9208* // using the `_.matches` callback shorthand9209* _.findKey(users, { 'age': 1, 'active': true });9210* // => 'pebbles'9211*9212* // using the `_.matchesProperty` callback shorthand9213* _.findKey(users, 'active', false);9214* // => 'fred'9215*9216* // using the `_.property` callback shorthand9217* _.findKey(users, 'active');9218* // => 'barney'9219*/9220var findKey = createFindKey(baseForOwn);92219222/**9223* This method is like `_.findKey` except that it iterates over elements of9224* a collection in the opposite order.9225*9226* If a property name is provided for `predicate` the created `_.property`9227* style callback returns the property value of the given element.9228*9229* If a value is also provided for `thisArg` the created `_.matchesProperty`9230* style callback returns `true` for elements that have a matching property9231* value, else `false`.9232*9233* If an object is provided for `predicate` the created `_.matches` style9234* callback returns `true` for elements that have the properties of the given9235* object, else `false`.9236*9237* @static9238* @memberOf _9239* @category Object9240* @param {Object} object The object to search.9241* @param {Function|Object|string} [predicate=_.identity] The function invoked9242* per iteration.9243* @param {*} [thisArg] The `this` binding of `predicate`.9244* @returns {string|undefined} Returns the key of the matched element, else `undefined`.9245* @example9246*9247* var users = {9248* 'barney': { 'age': 36, 'active': true },9249* 'fred': { 'age': 40, 'active': false },9250* 'pebbles': { 'age': 1, 'active': true }9251* };9252*9253* _.findLastKey(users, function(chr) {9254* return chr.age < 40;9255* });9256* // => returns `pebbles` assuming `_.findKey` returns `barney`9257*9258* // using the `_.matches` callback shorthand9259* _.findLastKey(users, { 'age': 36, 'active': true });9260* // => 'barney'9261*9262* // using the `_.matchesProperty` callback shorthand9263* _.findLastKey(users, 'active', false);9264* // => 'fred'9265*9266* // using the `_.property` callback shorthand9267* _.findLastKey(users, 'active');9268* // => 'pebbles'9269*/9270var findLastKey = createFindKey(baseForOwnRight);92719272/**9273* Iterates over own and inherited enumerable properties of an object invoking9274* `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked9275* with three arguments: (value, key, object). Iteratee functions may exit9276* iteration early by explicitly returning `false`.9277*9278* @static9279* @memberOf _9280* @category Object9281* @param {Object} object The object to iterate over.9282* @param {Function} [iteratee=_.identity] The function invoked per iteration.9283* @param {*} [thisArg] The `this` binding of `iteratee`.9284* @returns {Object} Returns `object`.9285* @example9286*9287* function Foo() {9288* this.a = 1;9289* this.b = 2;9290* }9291*9292* Foo.prototype.c = 3;9293*9294* _.forIn(new Foo, function(value, key) {9295* console.log(key);9296* });9297* // => logs 'a', 'b', and 'c' (iteration order is not guaranteed)9298*/9299var forIn = createForIn(baseFor);93009301/**9302* This method is like `_.forIn` except that it iterates over properties of9303* `object` in the opposite order.9304*9305* @static9306* @memberOf _9307* @category Object9308* @param {Object} object The object to iterate over.9309* @param {Function} [iteratee=_.identity] The function invoked per iteration.9310* @param {*} [thisArg] The `this` binding of `iteratee`.9311* @returns {Object} Returns `object`.9312* @example9313*9314* function Foo() {9315* this.a = 1;9316* this.b = 2;9317* }9318*9319* Foo.prototype.c = 3;9320*9321* _.forInRight(new Foo, function(value, key) {9322* console.log(key);9323* });9324* // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c'9325*/9326var forInRight = createForIn(baseForRight);93279328/**9329* Iterates over own enumerable properties of an object invoking `iteratee`9330* for each property. The `iteratee` is bound to `thisArg` and invoked with9331* three arguments: (value, key, object). Iteratee functions may exit iteration9332* early by explicitly returning `false`.9333*9334* @static9335* @memberOf _9336* @category Object9337* @param {Object} object The object to iterate over.9338* @param {Function} [iteratee=_.identity] The function invoked per iteration.9339* @param {*} [thisArg] The `this` binding of `iteratee`.9340* @returns {Object} Returns `object`.9341* @example9342*9343* function Foo() {9344* this.a = 1;9345* this.b = 2;9346* }9347*9348* Foo.prototype.c = 3;9349*9350* _.forOwn(new Foo, function(value, key) {9351* console.log(key);9352* });9353* // => logs 'a' and 'b' (iteration order is not guaranteed)9354*/9355var forOwn = createForOwn(baseForOwn);93569357/**9358* This method is like `_.forOwn` except that it iterates over properties of9359* `object` in the opposite order.9360*9361* @static9362* @memberOf _9363* @category Object9364* @param {Object} object The object to iterate over.9365* @param {Function} [iteratee=_.identity] The function invoked per iteration.9366* @param {*} [thisArg] The `this` binding of `iteratee`.9367* @returns {Object} Returns `object`.9368* @example9369*9370* function Foo() {9371* this.a = 1;9372* this.b = 2;9373* }9374*9375* Foo.prototype.c = 3;9376*9377* _.forOwnRight(new Foo, function(value, key) {9378* console.log(key);9379* });9380* // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'9381*/9382var forOwnRight = createForOwn(baseForOwnRight);93839384/**9385* Creates an array of function property names from all enumerable properties,9386* own and inherited, of `object`.9387*9388* @static9389* @memberOf _9390* @alias methods9391* @category Object9392* @param {Object} object The object to inspect.9393* @returns {Array} Returns the new array of property names.9394* @example9395*9396* _.functions(_);9397* // => ['after', 'ary', 'assign', ...]9398*/9399function functions(object) {9400return baseFunctions(object, keysIn(object));9401}94029403/**9404* Gets the property value at `path` of `object`. If the resolved value is9405* `undefined` the `defaultValue` is used in its place.9406*9407* @static9408* @memberOf _9409* @category Object9410* @param {Object} object The object to query.9411* @param {Array|string} path The path of the property to get.9412* @param {*} [defaultValue] The value returned if the resolved value is `undefined`.9413* @returns {*} Returns the resolved value.9414* @example9415*9416* var object = { 'a': [{ 'b': { 'c': 3 } }] };9417*9418* _.get(object, 'a[0].b.c');9419* // => 39420*9421* _.get(object, ['a', '0', 'b', 'c']);9422* // => 39423*9424* _.get(object, 'a.b.c', 'default');9425* // => 'default'9426*/9427function get(object, path, defaultValue) {9428var result = object == null ? undefined : baseGet(object, toPath(path), path + '');9429return result === undefined ? defaultValue : result;9430}94319432/**9433* Checks if `path` is a direct property.9434*9435* @static9436* @memberOf _9437* @category Object9438* @param {Object} object The object to query.9439* @param {Array|string} path The path to check.9440* @returns {boolean} Returns `true` if `path` is a direct property, else `false`.9441* @example9442*9443* var object = { 'a': { 'b': { 'c': 3 } } };9444*9445* _.has(object, 'a');9446* // => true9447*9448* _.has(object, 'a.b.c');9449* // => true9450*9451* _.has(object, ['a', 'b', 'c']);9452* // => true9453*/9454function has(object, path) {9455if (object == null) {9456return false;9457}9458var result = hasOwnProperty.call(object, path);9459if (!result && !isKey(path)) {9460path = toPath(path);9461object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));9462if (object == null) {9463return false;9464}9465path = last(path);9466result = hasOwnProperty.call(object, path);9467}9468return result || (isLength(object.length) && isIndex(path, object.length) &&9469(isArray(object) || isArguments(object)));9470}94719472/**9473* Creates an object composed of the inverted keys and values of `object`.9474* If `object` contains duplicate values, subsequent values overwrite property9475* assignments of previous values unless `multiValue` is `true`.9476*9477* @static9478* @memberOf _9479* @category Object9480* @param {Object} object The object to invert.9481* @param {boolean} [multiValue] Allow multiple values per key.9482* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.9483* @returns {Object} Returns the new inverted object.9484* @example9485*9486* var object = { 'a': 1, 'b': 2, 'c': 1 };9487*9488* _.invert(object);9489* // => { '1': 'c', '2': 'b' }9490*9491* // with `multiValue`9492* _.invert(object, true);9493* // => { '1': ['a', 'c'], '2': ['b'] }9494*/9495function invert(object, multiValue, guard) {9496if (guard && isIterateeCall(object, multiValue, guard)) {9497multiValue = null;9498}9499var index = -1,9500props = keys(object),9501length = props.length,9502result = {};95039504while (++index < length) {9505var key = props[index],9506value = object[key];95079508if (multiValue) {9509if (hasOwnProperty.call(result, value)) {9510result[value].push(key);9511} else {9512result[value] = [key];9513}9514}9515else {9516result[value] = key;9517}9518}9519return result;9520}95219522/**9523* Creates an array of the own enumerable property names of `object`.9524*9525* **Note:** Non-object values are coerced to objects. See the9526* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)9527* for more details.9528*9529* @static9530* @memberOf _9531* @category Object9532* @param {Object} object The object to query.9533* @returns {Array} Returns the array of property names.9534* @example9535*9536* function Foo() {9537* this.a = 1;9538* this.b = 2;9539* }9540*9541* Foo.prototype.c = 3;9542*9543* _.keys(new Foo);9544* // => ['a', 'b'] (iteration order is not guaranteed)9545*9546* _.keys('hi');9547* // => ['0', '1']9548*/9549var keys = !nativeKeys ? shimKeys : function(object) {9550var Ctor = object == null ? null : object.constructor;9551if ((typeof Ctor == 'function' && Ctor.prototype === object) ||9552(typeof object != 'function' && isArrayLike(object))) {9553return shimKeys(object);9554}9555return isObject(object) ? nativeKeys(object) : [];9556};95579558/**9559* Creates an array of the own and inherited enumerable property names of `object`.9560*9561* **Note:** Non-object values are coerced to objects.9562*9563* @static9564* @memberOf _9565* @category Object9566* @param {Object} object The object to query.9567* @returns {Array} Returns the array of property names.9568* @example9569*9570* function Foo() {9571* this.a = 1;9572* this.b = 2;9573* }9574*9575* Foo.prototype.c = 3;9576*9577* _.keysIn(new Foo);9578* // => ['a', 'b', 'c'] (iteration order is not guaranteed)9579*/9580function keysIn(object) {9581if (object == null) {9582return [];9583}9584if (!isObject(object)) {9585object = Object(object);9586}9587var length = object.length;9588length = (length && isLength(length) &&9589(isArray(object) || isArguments(object)) && length) || 0;95909591var Ctor = object.constructor,9592index = -1,9593isProto = typeof Ctor == 'function' && Ctor.prototype === object,9594result = Array(length),9595skipIndexes = length > 0;95969597while (++index < length) {9598result[index] = (index + '');9599}9600for (var key in object) {9601if (!(skipIndexes && isIndex(key, length)) &&9602!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {9603result.push(key);9604}9605}9606return result;9607}96089609/**9610* The opposite of `_.mapValues`; this method creates an object with the9611* same values as `object` and keys generated by running each own enumerable9612* property of `object` through `iteratee`.9613*9614* @static9615* @memberOf _9616* @category Object9617* @param {Object} object The object to iterate over.9618* @param {Function|Object|string} [iteratee=_.identity] The function invoked9619* per iteration.9620* @param {*} [thisArg] The `this` binding of `iteratee`.9621* @returns {Object} Returns the new mapped object.9622* @example9623*9624* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {9625* return key + value;9626* });9627* // => { 'a1': 1, 'b2': 2 }9628*/9629var mapKeys = createObjectMapper(true);96309631/**9632* Creates an object with the same keys as `object` and values generated by9633* running each own enumerable property of `object` through `iteratee`. The9634* iteratee function is bound to `thisArg` and invoked with three arguments:9635* (value, key, object).9636*9637* If a property name is provided for `iteratee` the created `_.property`9638* style callback returns the property value of the given element.9639*9640* If a value is also provided for `thisArg` the created `_.matchesProperty`9641* style callback returns `true` for elements that have a matching property9642* value, else `false`.9643*9644* If an object is provided for `iteratee` the created `_.matches` style9645* callback returns `true` for elements that have the properties of the given9646* object, else `false`.9647*9648* @static9649* @memberOf _9650* @category Object9651* @param {Object} object The object to iterate over.9652* @param {Function|Object|string} [iteratee=_.identity] The function invoked9653* per iteration.9654* @param {*} [thisArg] The `this` binding of `iteratee`.9655* @returns {Object} Returns the new mapped object.9656* @example9657*9658* _.mapValues({ 'a': 1, 'b': 2 }, function(n) {9659* return n * 3;9660* });9661* // => { 'a': 3, 'b': 6 }9662*9663* var users = {9664* 'fred': { 'user': 'fred', 'age': 40 },9665* 'pebbles': { 'user': 'pebbles', 'age': 1 }9666* };9667*9668* // using the `_.property` callback shorthand9669* _.mapValues(users, 'age');9670* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)9671*/9672var mapValues = createObjectMapper();96739674/**9675* Recursively merges own enumerable properties of the source object(s), that9676* don't resolve to `undefined` into the destination object. Subsequent sources9677* overwrite property assignments of previous sources. If `customizer` is9678* provided it is invoked to produce the merged values of the destination and9679* source properties. If `customizer` returns `undefined` merging is handled9680* by the method instead. The `customizer` is bound to `thisArg` and invoked9681* with five arguments: (objectValue, sourceValue, key, object, source).9682*9683* @static9684* @memberOf _9685* @category Object9686* @param {Object} object The destination object.9687* @param {...Object} [sources] The source objects.9688* @param {Function} [customizer] The function to customize assigned values.9689* @param {*} [thisArg] The `this` binding of `customizer`.9690* @returns {Object} Returns `object`.9691* @example9692*9693* var users = {9694* 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]9695* };9696*9697* var ages = {9698* 'data': [{ 'age': 36 }, { 'age': 40 }]9699* };9700*9701* _.merge(users, ages);9702* // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }9703*9704* // using a customizer callback9705* var object = {9706* 'fruits': ['apple'],9707* 'vegetables': ['beet']9708* };9709*9710* var other = {9711* 'fruits': ['banana'],9712* 'vegetables': ['carrot']9713* };9714*9715* _.merge(object, other, function(a, b) {9716* if (_.isArray(a)) {9717* return a.concat(b);9718* }9719* });9720* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }9721*/9722var merge = createAssigner(baseMerge);97239724/**9725* The opposite of `_.pick`; this method creates an object composed of the9726* own and inherited enumerable properties of `object` that are not omitted.9727*9728* @static9729* @memberOf _9730* @category Object9731* @param {Object} object The source object.9732* @param {Function|...(string|string[])} [predicate] The function invoked per9733* iteration or property names to omit, specified as individual property9734* names or arrays of property names.9735* @param {*} [thisArg] The `this` binding of `predicate`.9736* @returns {Object} Returns the new object.9737* @example9738*9739* var object = { 'user': 'fred', 'age': 40 };9740*9741* _.omit(object, 'age');9742* // => { 'user': 'fred' }9743*9744* _.omit(object, _.isNumber);9745* // => { 'user': 'fred' }9746*/9747var omit = restParam(function(object, props) {9748if (object == null) {9749return {};9750}9751if (typeof props[0] != 'function') {9752var props = arrayMap(baseFlatten(props), String);9753return pickByArray(object, baseDifference(keysIn(object), props));9754}9755var predicate = bindCallback(props[0], props[1], 3);9756return pickByCallback(object, function(value, key, object) {9757return !predicate(value, key, object);9758});9759});97609761/**9762* Creates a two dimensional array of the key-value pairs for `object`,9763* e.g. `[[key1, value1], [key2, value2]]`.9764*9765* @static9766* @memberOf _9767* @category Object9768* @param {Object} object The object to query.9769* @returns {Array} Returns the new array of key-value pairs.9770* @example9771*9772* _.pairs({ 'barney': 36, 'fred': 40 });9773* // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)9774*/9775function pairs(object) {9776object = toObject(object);97779778var index = -1,9779props = keys(object),9780length = props.length,9781result = Array(length);97829783while (++index < length) {9784var key = props[index];9785result[index] = [key, object[key]];9786}9787return result;9788}97899790/**9791* Creates an object composed of the picked `object` properties. Property9792* names may be specified as individual arguments or as arrays of property9793* names. If `predicate` is provided it is invoked for each property of `object`9794* picking the properties `predicate` returns truthy for. The predicate is9795* bound to `thisArg` and invoked with three arguments: (value, key, object).9796*9797* @static9798* @memberOf _9799* @category Object9800* @param {Object} object The source object.9801* @param {Function|...(string|string[])} [predicate] The function invoked per9802* iteration or property names to pick, specified as individual property9803* names or arrays of property names.9804* @param {*} [thisArg] The `this` binding of `predicate`.9805* @returns {Object} Returns the new object.9806* @example9807*9808* var object = { 'user': 'fred', 'age': 40 };9809*9810* _.pick(object, 'user');9811* // => { 'user': 'fred' }9812*9813* _.pick(object, _.isString);9814* // => { 'user': 'fred' }9815*/9816var pick = restParam(function(object, props) {9817if (object == null) {9818return {};9819}9820return typeof props[0] == 'function'9821? pickByCallback(object, bindCallback(props[0], props[1], 3))9822: pickByArray(object, baseFlatten(props));9823});98249825/**9826* This method is like `_.get` except that if the resolved value is a function9827* it is invoked with the `this` binding of its parent object and its result9828* is returned.9829*9830* @static9831* @memberOf _9832* @category Object9833* @param {Object} object The object to query.9834* @param {Array|string} path The path of the property to resolve.9835* @param {*} [defaultValue] The value returned if the resolved value is `undefined`.9836* @returns {*} Returns the resolved value.9837* @example9838*9839* var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };9840*9841* _.result(object, 'a[0].b.c1');9842* // => 39843*9844* _.result(object, 'a[0].b.c2');9845* // => 49846*9847* _.result(object, 'a.b.c', 'default');9848* // => 'default'9849*9850* _.result(object, 'a.b.c', _.constant('default'));9851* // => 'default'9852*/9853function result(object, path, defaultValue) {9854var result = object == null ? undefined : object[path];9855if (result === undefined) {9856if (object != null && !isKey(path, object)) {9857path = toPath(path);9858object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));9859result = object == null ? undefined : object[last(path)];9860}9861result = result === undefined ? defaultValue : result;9862}9863return isFunction(result) ? result.call(object) : result;9864}98659866/**9867* Sets the property value of `path` on `object`. If a portion of `path`9868* does not exist it is created.9869*9870* @static9871* @memberOf _9872* @category Object9873* @param {Object} object The object to augment.9874* @param {Array|string} path The path of the property to set.9875* @param {*} value The value to set.9876* @returns {Object} Returns `object`.9877* @example9878*9879* var object = { 'a': [{ 'b': { 'c': 3 } }] };9880*9881* _.set(object, 'a[0].b.c', 4);9882* console.log(object.a[0].b.c);9883* // => 49884*9885* _.set(object, 'x[0].y.z', 5);9886* console.log(object.x[0].y.z);9887* // => 59888*/9889function set(object, path, value) {9890if (object == null) {9891return object;9892}9893var pathKey = (path + '');9894path = (object[pathKey] != null || isKey(path, object)) ? [pathKey] : toPath(path);98959896var index = -1,9897length = path.length,9898lastIndex = length - 1,9899nested = object;99009901while (nested != null && ++index < length) {9902var key = path[index];9903if (isObject(nested)) {9904if (index == lastIndex) {9905nested[key] = value;9906} else if (nested[key] == null) {9907nested[key] = isIndex(path[index + 1]) ? [] : {};9908}9909}9910nested = nested[key];9911}9912return object;9913}99149915/**9916* An alternative to `_.reduce`; this method transforms `object` to a new9917* `accumulator` object which is the result of running each of its own enumerable9918* properties through `iteratee`, with each invocation potentially mutating9919* the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked9920* with four arguments: (accumulator, value, key, object). Iteratee functions9921* may exit iteration early by explicitly returning `false`.9922*9923* @static9924* @memberOf _9925* @category Object9926* @param {Array|Object} object The object to iterate over.9927* @param {Function} [iteratee=_.identity] The function invoked per iteration.9928* @param {*} [accumulator] The custom accumulator value.9929* @param {*} [thisArg] The `this` binding of `iteratee`.9930* @returns {*} Returns the accumulated value.9931* @example9932*9933* _.transform([2, 3, 4], function(result, n) {9934* result.push(n *= n);9935* return n % 2 == 0;9936* });9937* // => [4, 9]9938*9939* _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) {9940* result[key] = n * 3;9941* });9942* // => { 'a': 3, 'b': 6 }9943*/9944function transform(object, iteratee, accumulator, thisArg) {9945var isArr = isArray(object) || isTypedArray(object);9946iteratee = getCallback(iteratee, thisArg, 4);99479948if (accumulator == null) {9949if (isArr || isObject(object)) {9950var Ctor = object.constructor;9951if (isArr) {9952accumulator = isArray(object) ? new Ctor : [];9953} else {9954accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null);9955}9956} else {9957accumulator = {};9958}9959}9960(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {9961return iteratee(accumulator, value, index, object);9962});9963return accumulator;9964}99659966/**9967* Creates an array of the own enumerable property values of `object`.9968*9969* **Note:** Non-object values are coerced to objects.9970*9971* @static9972* @memberOf _9973* @category Object9974* @param {Object} object The object to query.9975* @returns {Array} Returns the array of property values.9976* @example9977*9978* function Foo() {9979* this.a = 1;9980* this.b = 2;9981* }9982*9983* Foo.prototype.c = 3;9984*9985* _.values(new Foo);9986* // => [1, 2] (iteration order is not guaranteed)9987*9988* _.values('hi');9989* // => ['h', 'i']9990*/9991function values(object) {9992return baseValues(object, keys(object));9993}99949995/**9996* Creates an array of the own and inherited enumerable property values9997* of `object`.9998*9999* **Note:** Non-object values are coerced to objects.10000*10001* @static10002* @memberOf _10003* @category Object10004* @param {Object} object The object to query.10005* @returns {Array} Returns the array of property values.10006* @example10007*10008* function Foo() {10009* this.a = 1;10010* this.b = 2;10011* }10012*10013* Foo.prototype.c = 3;10014*10015* _.valuesIn(new Foo);10016* // => [1, 2, 3] (iteration order is not guaranteed)10017*/10018function valuesIn(object) {10019return baseValues(object, keysIn(object));10020}1002110022/*------------------------------------------------------------------------*/1002310024/**10025* Checks if `n` is between `start` and up to but not including, `end`. If10026* `end` is not specified it is set to `start` with `start` then set to `0`.10027*10028* @static10029* @memberOf _10030* @category Number10031* @param {number} n The number to check.10032* @param {number} [start=0] The start of the range.10033* @param {number} end The end of the range.10034* @returns {boolean} Returns `true` if `n` is in the range, else `false`.10035* @example10036*10037* _.inRange(3, 2, 4);10038* // => true10039*10040* _.inRange(4, 8);10041* // => true10042*10043* _.inRange(4, 2);10044* // => false10045*10046* _.inRange(2, 2);10047* // => false10048*10049* _.inRange(1.2, 2);10050* // => true10051*10052* _.inRange(5.2, 4);10053* // => false10054*/10055function inRange(value, start, end) {10056start = +start || 0;10057if (typeof end === 'undefined') {10058end = start;10059start = 0;10060} else {10061end = +end || 0;10062}10063return value >= nativeMin(start, end) && value < nativeMax(start, end);10064}1006510066/**10067* Produces a random number between `min` and `max` (inclusive). If only one10068* argument is provided a number between `0` and the given number is returned.10069* If `floating` is `true`, or either `min` or `max` are floats, a floating-point10070* number is returned instead of an integer.10071*10072* @static10073* @memberOf _10074* @category Number10075* @param {number} [min=0] The minimum possible value.10076* @param {number} [max=1] The maximum possible value.10077* @param {boolean} [floating] Specify returning a floating-point number.10078* @returns {number} Returns the random number.10079* @example10080*10081* _.random(0, 5);10082* // => an integer between 0 and 510083*10084* _.random(5);10085* // => also an integer between 0 and 510086*10087* _.random(5, true);10088* // => a floating-point number between 0 and 510089*10090* _.random(1.2, 5.2);10091* // => a floating-point number between 1.2 and 5.210092*/10093function random(min, max, floating) {10094if (floating && isIterateeCall(min, max, floating)) {10095max = floating = null;10096}10097var noMin = min == null,10098noMax = max == null;1009910100if (floating == null) {10101if (noMax && typeof min == 'boolean') {10102floating = min;10103min = 1;10104}10105else if (typeof max == 'boolean') {10106floating = max;10107noMax = true;10108}10109}10110if (noMin && noMax) {10111max = 1;10112noMax = false;10113}10114min = +min || 0;10115if (noMax) {10116max = min;10117min = 0;10118} else {10119max = +max || 0;10120}10121if (floating || min % 1 || max % 1) {10122var rand = nativeRandom();10123return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max);10124}10125return baseRandom(min, max);10126}1012710128/*------------------------------------------------------------------------*/1012910130/**10131* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).10132*10133* @static10134* @memberOf _10135* @category String10136* @param {string} [string=''] The string to convert.10137* @returns {string} Returns the camel cased string.10138* @example10139*10140* _.camelCase('Foo Bar');10141* // => 'fooBar'10142*10143* _.camelCase('--foo-bar');10144* // => 'fooBar'10145*10146* _.camelCase('__foo_bar__');10147* // => 'fooBar'10148*/10149var camelCase = createCompounder(function(result, word, index) {10150word = word.toLowerCase();10151return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);10152});1015310154/**10155* Capitalizes the first character of `string`.10156*10157* @static10158* @memberOf _10159* @category String10160* @param {string} [string=''] The string to capitalize.10161* @returns {string} Returns the capitalized string.10162* @example10163*10164* _.capitalize('fred');10165* // => 'Fred'10166*/10167function capitalize(string) {10168string = baseToString(string);10169return string && (string.charAt(0).toUpperCase() + string.slice(1));10170}1017110172/**10173* Deburrs `string` by converting [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)10174* to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).10175*10176* @static10177* @memberOf _10178* @category String10179* @param {string} [string=''] The string to deburr.10180* @returns {string} Returns the deburred string.10181* @example10182*10183* _.deburr('déjà vu');10184* // => 'deja vu'10185*/10186function deburr(string) {10187string = baseToString(string);10188return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');10189}1019010191/**10192* Checks if `string` ends with the given target string.10193*10194* @static10195* @memberOf _10196* @category String10197* @param {string} [string=''] The string to search.10198* @param {string} [target] The string to search for.10199* @param {number} [position=string.length] The position to search from.10200* @returns {boolean} Returns `true` if `string` ends with `target`, else `false`.10201* @example10202*10203* _.endsWith('abc', 'c');10204* // => true10205*10206* _.endsWith('abc', 'b');10207* // => false10208*10209* _.endsWith('abc', 'b', 2);10210* // => true10211*/10212function endsWith(string, target, position) {10213string = baseToString(string);10214target = (target + '');1021510216var length = string.length;10217position = position === undefined10218? length10219: nativeMin(position < 0 ? 0 : (+position || 0), length);1022010221position -= target.length;10222return position >= 0 && string.indexOf(target, position) == position;10223}1022410225/**10226* Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to10227* their corresponding HTML entities.10228*10229* **Note:** No other characters are escaped. To escape additional characters10230* use a third-party library like [_he_](https://mths.be/he).10231*10232* Though the ">" character is escaped for symmetry, characters like10233* ">" and "/" don't need escaping in HTML and have no special meaning10234* unless they're part of a tag or unquoted attribute value.10235* See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)10236* (under "semi-related fun fact") for more details.10237*10238* Backticks are escaped because in Internet Explorer < 9, they can break out10239* of attribute values or HTML comments. See [#59](https://html5sec.org/#59),10240* [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and10241* [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/)10242* for more details.10243*10244* When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping)10245* to reduce XSS vectors.10246*10247* @static10248* @memberOf _10249* @category String10250* @param {string} [string=''] The string to escape.10251* @returns {string} Returns the escaped string.10252* @example10253*10254* _.escape('fred, barney, & pebbles');10255* // => 'fred, barney, & pebbles'10256*/10257function escape(string) {10258// Reset `lastIndex` because in IE < 9 `String#replace` does not.10259string = baseToString(string);10260return (string && reHasUnescapedHtml.test(string))10261? string.replace(reUnescapedHtml, escapeHtmlChar)10262: string;10263}1026410265/**10266* Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",10267* "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.10268*10269* @static10270* @memberOf _10271* @category String10272* @param {string} [string=''] The string to escape.10273* @returns {string} Returns the escaped string.10274* @example10275*10276* _.escapeRegExp('[lodash](https://lodash.com/)');10277* // => '\[lodash\]\(https:\/\/lodash\.com\/\)'10278*/10279function escapeRegExp(string) {10280string = baseToString(string);10281return (string && reHasRegExpChars.test(string))10282? string.replace(reRegExpChars, '\\$&')10283: string;10284}1028510286/**10287* Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).10288*10289* @static10290* @memberOf _10291* @category String10292* @param {string} [string=''] The string to convert.10293* @returns {string} Returns the kebab cased string.10294* @example10295*10296* _.kebabCase('Foo Bar');10297* // => 'foo-bar'10298*10299* _.kebabCase('fooBar');10300* // => 'foo-bar'10301*10302* _.kebabCase('__foo_bar__');10303* // => 'foo-bar'10304*/10305var kebabCase = createCompounder(function(result, word, index) {10306return result + (index ? '-' : '') + word.toLowerCase();10307});1030810309/**10310* Pads `string` on the left and right sides if it's shorter than `length`.10311* Padding characters are truncated if they can't be evenly divided by `length`.10312*10313* @static10314* @memberOf _10315* @category String10316* @param {string} [string=''] The string to pad.10317* @param {number} [length=0] The padding length.10318* @param {string} [chars=' '] The string used as padding.10319* @returns {string} Returns the padded string.10320* @example10321*10322* _.pad('abc', 8);10323* // => ' abc '10324*10325* _.pad('abc', 8, '_-');10326* // => '_-abc_-_'10327*10328* _.pad('abc', 3);10329* // => 'abc'10330*/10331function pad(string, length, chars) {10332string = baseToString(string);10333length = +length;1033410335var strLength = string.length;10336if (strLength >= length || !nativeIsFinite(length)) {10337return string;10338}10339var mid = (length - strLength) / 2,10340leftLength = floor(mid),10341rightLength = ceil(mid);1034210343chars = createPadding('', rightLength, chars);10344return chars.slice(0, leftLength) + string + chars;10345}1034610347/**10348* Pads `string` on the left side if it's shorter than `length`. Padding10349* characters are truncated if they exceed `length`.10350*10351* @static10352* @memberOf _10353* @category String10354* @param {string} [string=''] The string to pad.10355* @param {number} [length=0] The padding length.10356* @param {string} [chars=' '] The string used as padding.10357* @returns {string} Returns the padded string.10358* @example10359*10360* _.padLeft('abc', 6);10361* // => ' abc'10362*10363* _.padLeft('abc', 6, '_-');10364* // => '_-_abc'10365*10366* _.padLeft('abc', 3);10367* // => 'abc'10368*/10369var padLeft = createPadDir();1037010371/**10372* Pads `string` on the right side if it's shorter than `length`. Padding10373* characters are truncated if they exceed `length`.10374*10375* @static10376* @memberOf _10377* @category String10378* @param {string} [string=''] The string to pad.10379* @param {number} [length=0] The padding length.10380* @param {string} [chars=' '] The string used as padding.10381* @returns {string} Returns the padded string.10382* @example10383*10384* _.padRight('abc', 6);10385* // => 'abc '10386*10387* _.padRight('abc', 6, '_-');10388* // => 'abc_-_'10389*10390* _.padRight('abc', 3);10391* // => 'abc'10392*/10393var padRight = createPadDir(true);1039410395/**10396* Converts `string` to an integer of the specified radix. If `radix` is10397* `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,10398* in which case a `radix` of `16` is used.10399*10400* **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E)10401* of `parseInt`.10402*10403* @static10404* @memberOf _10405* @category String10406* @param {string} string The string to convert.10407* @param {number} [radix] The radix to interpret `value` by.10408* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10409* @returns {number} Returns the converted integer.10410* @example10411*10412* _.parseInt('08');10413* // => 810414*10415* _.map(['6', '08', '10'], _.parseInt);10416* // => [6, 8, 10]10417*/10418function parseInt(string, radix, guard) {10419if (guard && isIterateeCall(string, radix, guard)) {10420radix = 0;10421}10422return nativeParseInt(string, radix);10423}10424// Fallback for environments with pre-ES5 implementations.10425if (nativeParseInt(whitespace + '08') != 8) {10426parseInt = function(string, radix, guard) {10427// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.10428// Chrome fails to trim leading <BOM> whitespace characters.10429// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.10430if (guard ? isIterateeCall(string, radix, guard) : radix == null) {10431radix = 0;10432} else if (radix) {10433radix = +radix;10434}10435string = trim(string);10436return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));10437};10438}1043910440/**10441* Repeats the given string `n` times.10442*10443* @static10444* @memberOf _10445* @category String10446* @param {string} [string=''] The string to repeat.10447* @param {number} [n=0] The number of times to repeat the string.10448* @returns {string} Returns the repeated string.10449* @example10450*10451* _.repeat('*', 3);10452* // => '***'10453*10454* _.repeat('abc', 2);10455* // => 'abcabc'10456*10457* _.repeat('abc', 0);10458* // => ''10459*/10460function repeat(string, n) {10461var result = '';10462string = baseToString(string);10463n = +n;10464if (n < 1 || !string || !nativeIsFinite(n)) {10465return result;10466}10467// Leverage the exponentiation by squaring algorithm for a faster repeat.10468// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.10469do {10470if (n % 2) {10471result += string;10472}10473n = floor(n / 2);10474string += string;10475} while (n);1047610477return result;10478}1047910480/**10481* Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case).10482*10483* @static10484* @memberOf _10485* @category String10486* @param {string} [string=''] The string to convert.10487* @returns {string} Returns the snake cased string.10488* @example10489*10490* _.snakeCase('Foo Bar');10491* // => 'foo_bar'10492*10493* _.snakeCase('fooBar');10494* // => 'foo_bar'10495*10496* _.snakeCase('--foo-bar');10497* // => 'foo_bar'10498*/10499var snakeCase = createCompounder(function(result, word, index) {10500return result + (index ? '_' : '') + word.toLowerCase();10501});1050210503/**10504* Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).10505*10506* @static10507* @memberOf _10508* @category String10509* @param {string} [string=''] The string to convert.10510* @returns {string} Returns the start cased string.10511* @example10512*10513* _.startCase('--foo-bar');10514* // => 'Foo Bar'10515*10516* _.startCase('fooBar');10517* // => 'Foo Bar'10518*10519* _.startCase('__foo_bar__');10520* // => 'Foo Bar'10521*/10522var startCase = createCompounder(function(result, word, index) {10523return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));10524});1052510526/**10527* Checks if `string` starts with the given target string.10528*10529* @static10530* @memberOf _10531* @category String10532* @param {string} [string=''] The string to search.10533* @param {string} [target] The string to search for.10534* @param {number} [position=0] The position to search from.10535* @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.10536* @example10537*10538* _.startsWith('abc', 'a');10539* // => true10540*10541* _.startsWith('abc', 'b');10542* // => false10543*10544* _.startsWith('abc', 'b', 1);10545* // => true10546*/10547function startsWith(string, target, position) {10548string = baseToString(string);10549position = position == null10550? 010551: nativeMin(position < 0 ? 0 : (+position || 0), string.length);1055210553return string.lastIndexOf(target, position) == position;10554}1055510556/**10557* Creates a compiled template function that can interpolate data properties10558* in "interpolate" delimiters, HTML-escape interpolated data properties in10559* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data10560* properties may be accessed as free variables in the template. If a setting10561* object is provided it takes precedence over `_.templateSettings` values.10562*10563* **Note:** In the development build `_.template` utilizes10564* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)10565* for easier debugging.10566*10567* For more information on precompiling templates see10568* [lodash's custom builds documentation](https://lodash.com/custom-builds).10569*10570* For more information on Chrome extension sandboxes see10571* [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).10572*10573* @static10574* @memberOf _10575* @category String10576* @param {string} [string=''] The template string.10577* @param {Object} [options] The options object.10578* @param {RegExp} [options.escape] The HTML "escape" delimiter.10579* @param {RegExp} [options.evaluate] The "evaluate" delimiter.10580* @param {Object} [options.imports] An object to import into the template as free variables.10581* @param {RegExp} [options.interpolate] The "interpolate" delimiter.10582* @param {string} [options.sourceURL] The sourceURL of the template's compiled source.10583* @param {string} [options.variable] The data object variable name.10584* @param- {Object} [otherOptions] Enables the legacy `options` param signature.10585* @returns {Function} Returns the compiled template function.10586* @example10587*10588* // using the "interpolate" delimiter to create a compiled template10589* var compiled = _.template('hello <%= user %>!');10590* compiled({ 'user': 'fred' });10591* // => 'hello fred!'10592*10593* // using the HTML "escape" delimiter to escape data property values10594* var compiled = _.template('<b><%- value %></b>');10595* compiled({ 'value': '<script>' });10596* // => '<b><script></b>'10597*10598* // using the "evaluate" delimiter to execute JavaScript and generate HTML10599* var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');10600* compiled({ 'users': ['fred', 'barney'] });10601* // => '<li>fred</li><li>barney</li>'10602*10603* // using the internal `print` function in "evaluate" delimiters10604* var compiled = _.template('<% print("hello " + user); %>!');10605* compiled({ 'user': 'barney' });10606* // => 'hello barney!'10607*10608* // using the ES delimiter as an alternative to the default "interpolate" delimiter10609* var compiled = _.template('hello ${ user }!');10610* compiled({ 'user': 'pebbles' });10611* // => 'hello pebbles!'10612*10613* // using custom template delimiters10614* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;10615* var compiled = _.template('hello {{ user }}!');10616* compiled({ 'user': 'mustache' });10617* // => 'hello mustache!'10618*10619* // using backslashes to treat delimiters as plain text10620* var compiled = _.template('<%= "\\<%- value %\\>" %>');10621* compiled({ 'value': 'ignored' });10622* // => '<%- value %>'10623*10624* // using the `imports` option to import `jQuery` as `jq`10625* var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';10626* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });10627* compiled({ 'users': ['fred', 'barney'] });10628* // => '<li>fred</li><li>barney</li>'10629*10630* // using the `sourceURL` option to specify a custom sourceURL for the template10631* var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });10632* compiled(data);10633* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector10634*10635* // using the `variable` option to ensure a with-statement isn't used in the compiled template10636* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });10637* compiled.source;10638* // => function(data) {10639* // var __t, __p = '';10640* // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';10641* // return __p;10642* // }10643*10644* // using the `source` property to inline compiled templates for meaningful10645* // line numbers in error messages and a stack trace10646* fs.writeFileSync(path.join(cwd, 'jst.js'), '\10647* var JST = {\10648* "main": ' + _.template(mainText).source + '\10649* };\10650* ');10651*/10652function template(string, options, otherOptions) {10653// Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/)10654// and Laura Doktorova's doT.js (https://github.com/olado/doT).10655var settings = lodash.templateSettings;1065610657if (otherOptions && isIterateeCall(string, options, otherOptions)) {10658options = otherOptions = null;10659}10660string = baseToString(string);10661options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);1066210663var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults),10664importsKeys = keys(imports),10665importsValues = baseValues(imports, importsKeys);1066610667var isEscaping,10668isEvaluating,10669index = 0,10670interpolate = options.interpolate || reNoMatch,10671source = "__p += '";1067210673// Compile the regexp to match each delimiter.10674var reDelimiters = RegExp(10675(options.escape || reNoMatch).source + '|' +10676interpolate.source + '|' +10677(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +10678(options.evaluate || reNoMatch).source + '|$'10679, 'g');1068010681// Use a sourceURL for easier debugging.10682var sourceURL = '//# sourceURL=' +10683('sourceURL' in options10684? options.sourceURL10685: ('lodash.templateSources[' + (++templateCounter) + ']')10686) + '\n';1068710688string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {10689interpolateValue || (interpolateValue = esTemplateValue);1069010691// Escape characters that can't be included in string literals.10692source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);1069310694// Replace delimiters with snippets.10695if (escapeValue) {10696isEscaping = true;10697source += "' +\n__e(" + escapeValue + ") +\n'";10698}10699if (evaluateValue) {10700isEvaluating = true;10701source += "';\n" + evaluateValue + ";\n__p += '";10702}10703if (interpolateValue) {10704source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";10705}10706index = offset + match.length;1070710708// The JS engine embedded in Adobe products requires returning the `match`10709// string in order to produce the correct `offset` value.10710return match;10711});1071210713source += "';\n";1071410715// If `variable` is not specified wrap a with-statement around the generated10716// code to add the data object to the top of the scope chain.10717var variable = options.variable;10718if (!variable) {10719source = 'with (obj) {\n' + source + '\n}\n';10720}10721// Cleanup code by stripping empty strings.10722source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)10723.replace(reEmptyStringMiddle, '$1')10724.replace(reEmptyStringTrailing, '$1;');1072510726// Frame code as the function body.10727source = 'function(' + (variable || 'obj') + ') {\n' +10728(variable10729? ''10730: 'obj || (obj = {});\n'10731) +10732"var __t, __p = ''" +10733(isEscaping10734? ', __e = _.escape'10735: ''10736) +10737(isEvaluating10738? ', __j = Array.prototype.join;\n' +10739"function print() { __p += __j.call(arguments, '') }\n"10740: ';\n'10741) +10742source +10743'return __p\n}';1074410745var result = attempt(function() {10746return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);10747});1074810749// Provide the compiled function's source by its `toString` method or10750// the `source` property as a convenience for inlining compiled templates.10751result.source = source;10752if (isError(result)) {10753throw result;10754}10755return result;10756}1075710758/**10759* Removes leading and trailing whitespace or specified characters from `string`.10760*10761* @static10762* @memberOf _10763* @category String10764* @param {string} [string=''] The string to trim.10765* @param {string} [chars=whitespace] The characters to trim.10766* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10767* @returns {string} Returns the trimmed string.10768* @example10769*10770* _.trim(' abc ');10771* // => 'abc'10772*10773* _.trim('-_-abc-_-', '_-');10774* // => 'abc'10775*10776* _.map([' foo ', ' bar '], _.trim);10777* // => ['foo', 'bar']10778*/10779function trim(string, chars, guard) {10780var value = string;10781string = baseToString(string);10782if (!string) {10783return string;10784}10785if (guard ? isIterateeCall(value, chars, guard) : chars == null) {10786return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);10787}10788chars = (chars + '');10789return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);10790}1079110792/**10793* Removes leading whitespace or specified characters from `string`.10794*10795* @static10796* @memberOf _10797* @category String10798* @param {string} [string=''] The string to trim.10799* @param {string} [chars=whitespace] The characters to trim.10800* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10801* @returns {string} Returns the trimmed string.10802* @example10803*10804* _.trimLeft(' abc ');10805* // => 'abc '10806*10807* _.trimLeft('-_-abc-_-', '_-');10808* // => 'abc-_-'10809*/10810function trimLeft(string, chars, guard) {10811var value = string;10812string = baseToString(string);10813if (!string) {10814return string;10815}10816if (guard ? isIterateeCall(value, chars, guard) : chars == null) {10817return string.slice(trimmedLeftIndex(string));10818}10819return string.slice(charsLeftIndex(string, (chars + '')));10820}1082110822/**10823* Removes trailing whitespace or specified characters from `string`.10824*10825* @static10826* @memberOf _10827* @category String10828* @param {string} [string=''] The string to trim.10829* @param {string} [chars=whitespace] The characters to trim.10830* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10831* @returns {string} Returns the trimmed string.10832* @example10833*10834* _.trimRight(' abc ');10835* // => ' abc'10836*10837* _.trimRight('-_-abc-_-', '_-');10838* // => '-_-abc'10839*/10840function trimRight(string, chars, guard) {10841var value = string;10842string = baseToString(string);10843if (!string) {10844return string;10845}10846if (guard ? isIterateeCall(value, chars, guard) : chars == null) {10847return string.slice(0, trimmedRightIndex(string) + 1);10848}10849return string.slice(0, charsRightIndex(string, (chars + '')) + 1);10850}1085110852/**10853* Truncates `string` if it's longer than the given maximum string length.10854* The last characters of the truncated string are replaced with the omission10855* string which defaults to "...".10856*10857* @static10858* @memberOf _10859* @category String10860* @param {string} [string=''] The string to truncate.10861* @param {Object|number} [options] The options object or maximum string length.10862* @param {number} [options.length=30] The maximum string length.10863* @param {string} [options.omission='...'] The string to indicate text is omitted.10864* @param {RegExp|string} [options.separator] The separator pattern to truncate to.10865* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10866* @returns {string} Returns the truncated string.10867* @example10868*10869* _.trunc('hi-diddly-ho there, neighborino');10870* // => 'hi-diddly-ho there, neighbo...'10871*10872* _.trunc('hi-diddly-ho there, neighborino', 24);10873* // => 'hi-diddly-ho there, n...'10874*10875* _.trunc('hi-diddly-ho there, neighborino', {10876* 'length': 24,10877* 'separator': ' '10878* });10879* // => 'hi-diddly-ho there,...'10880*10881* _.trunc('hi-diddly-ho there, neighborino', {10882* 'length': 24,10883* 'separator': /,? +/10884* });10885* // => 'hi-diddly-ho there...'10886*10887* _.trunc('hi-diddly-ho there, neighborino', {10888* 'omission': ' [...]'10889* });10890* // => 'hi-diddly-ho there, neig [...]'10891*/10892function trunc(string, options, guard) {10893if (guard && isIterateeCall(string, options, guard)) {10894options = null;10895}10896var length = DEFAULT_TRUNC_LENGTH,10897omission = DEFAULT_TRUNC_OMISSION;1089810899if (options != null) {10900if (isObject(options)) {10901var separator = 'separator' in options ? options.separator : separator;10902length = 'length' in options ? (+options.length || 0) : length;10903omission = 'omission' in options ? baseToString(options.omission) : omission;10904} else {10905length = +options || 0;10906}10907}10908string = baseToString(string);10909if (length >= string.length) {10910return string;10911}10912var end = length - omission.length;10913if (end < 1) {10914return omission;10915}10916var result = string.slice(0, end);10917if (separator == null) {10918return result + omission;10919}10920if (isRegExp(separator)) {10921if (string.slice(end).search(separator)) {10922var match,10923newEnd,10924substring = string.slice(0, end);1092510926if (!separator.global) {10927separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g');10928}10929separator.lastIndex = 0;10930while ((match = separator.exec(substring))) {10931newEnd = match.index;10932}10933result = result.slice(0, newEnd == null ? end : newEnd);10934}10935} else if (string.indexOf(separator, end) != end) {10936var index = result.lastIndexOf(separator);10937if (index > -1) {10938result = result.slice(0, index);10939}10940}10941return result + omission;10942}1094310944/**10945* The inverse of `_.escape`; this method converts the HTML entities10946* `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their10947* corresponding characters.10948*10949* **Note:** No other HTML entities are unescaped. To unescape additional HTML10950* entities use a third-party library like [_he_](https://mths.be/he).10951*10952* @static10953* @memberOf _10954* @category String10955* @param {string} [string=''] The string to unescape.10956* @returns {string} Returns the unescaped string.10957* @example10958*10959* _.unescape('fred, barney, & pebbles');10960* // => 'fred, barney, & pebbles'10961*/10962function unescape(string) {10963string = baseToString(string);10964return (string && reHasEscapedHtml.test(string))10965? string.replace(reEscapedHtml, unescapeHtmlChar)10966: string;10967}1096810969/**10970* Splits `string` into an array of its words.10971*10972* @static10973* @memberOf _10974* @category String10975* @param {string} [string=''] The string to inspect.10976* @param {RegExp|string} [pattern] The pattern to match words.10977* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.10978* @returns {Array} Returns the words of `string`.10979* @example10980*10981* _.words('fred, barney, & pebbles');10982* // => ['fred', 'barney', 'pebbles']10983*10984* _.words('fred, barney, & pebbles', /[^, ]+/g);10985* // => ['fred', 'barney', '&', 'pebbles']10986*/10987function words(string, pattern, guard) {10988if (guard && isIterateeCall(string, pattern, guard)) {10989pattern = null;10990}10991string = baseToString(string);10992return string.match(pattern || reWords) || [];10993}1099410995/*------------------------------------------------------------------------*/1099610997/**10998* Attempts to invoke `func`, returning either the result or the caught error10999* object. Any additional arguments are provided to `func` when it is invoked.11000*11001* @static11002* @memberOf _11003* @category Utility11004* @param {Function} func The function to attempt.11005* @returns {*} Returns the `func` result or error object.11006* @example11007*11008* // avoid throwing errors for invalid selectors11009* var elements = _.attempt(function(selector) {11010* return document.querySelectorAll(selector);11011* }, '>_>');11012*11013* if (_.isError(elements)) {11014* elements = [];11015* }11016*/11017var attempt = restParam(function(func, args) {11018try {11019return func.apply(undefined, args);11020} catch(e) {11021return isError(e) ? e : new Error(e);11022}11023});1102411025/**11026* Creates a function that invokes `func` with the `this` binding of `thisArg`11027* and arguments of the created function. If `func` is a property name the11028* created callback returns the property value for a given element. If `func`11029* is an object the created callback returns `true` for elements that contain11030* the equivalent object properties, otherwise it returns `false`.11031*11032* @static11033* @memberOf _11034* @alias iteratee11035* @category Utility11036* @param {*} [func=_.identity] The value to convert to a callback.11037* @param {*} [thisArg] The `this` binding of `func`.11038* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.11039* @returns {Function} Returns the callback.11040* @example11041*11042* var users = [11043* { 'user': 'barney', 'age': 36 },11044* { 'user': 'fred', 'age': 40 }11045* ];11046*11047* // wrap to create custom callback shorthands11048* _.callback = _.wrap(_.callback, function(callback, func, thisArg) {11049* var match = /^(.+?)__([gl]t)(.+)$/.exec(func);11050* if (!match) {11051* return callback(func, thisArg);11052* }11053* return function(object) {11054* return match[2] == 'gt'11055* ? object[match[1]] > match[3]11056* : object[match[1]] < match[3];11057* };11058* });11059*11060* _.filter(users, 'age__gt36');11061* // => [{ 'user': 'fred', 'age': 40 }]11062*/11063function callback(func, thisArg, guard) {11064if (guard && isIterateeCall(func, thisArg, guard)) {11065thisArg = null;11066}11067return isObjectLike(func)11068? matches(func)11069: baseCallback(func, thisArg);11070}1107111072/**11073* Creates a function that returns `value`.11074*11075* @static11076* @memberOf _11077* @category Utility11078* @param {*} value The value to return from the new function.11079* @returns {Function} Returns the new function.11080* @example11081*11082* var object = { 'user': 'fred' };11083* var getter = _.constant(object);11084*11085* getter() === object;11086* // => true11087*/11088function constant(value) {11089return function() {11090return value;11091};11092}1109311094/**11095* This method returns the first argument provided to it.11096*11097* @static11098* @memberOf _11099* @category Utility11100* @param {*} value Any value.11101* @returns {*} Returns `value`.11102* @example11103*11104* var object = { 'user': 'fred' };11105*11106* _.identity(object) === object;11107* // => true11108*/11109function identity(value) {11110return value;11111}1111211113/**11114* Creates a function that performs a deep comparison between a given object11115* and `source`, returning `true` if the given object has equivalent property11116* values, else `false`.11117*11118* **Note:** This method supports comparing arrays, booleans, `Date` objects,11119* numbers, `Object` objects, regexes, and strings. Objects are compared by11120* their own, not inherited, enumerable properties. For comparing a single11121* own or inherited property value see `_.matchesProperty`.11122*11123* @static11124* @memberOf _11125* @category Utility11126* @param {Object} source The object of property values to match.11127* @returns {Function} Returns the new function.11128* @example11129*11130* var users = [11131* { 'user': 'barney', 'age': 36, 'active': true },11132* { 'user': 'fred', 'age': 40, 'active': false }11133* ];11134*11135* _.filter(users, _.matches({ 'age': 40, 'active': false }));11136* // => [{ 'user': 'fred', 'age': 40, 'active': false }]11137*/11138function matches(source) {11139return baseMatches(baseClone(source, true));11140}1114111142/**11143* Creates a function that compares the property value of `path` on a given11144* object to `value`.11145*11146* **Note:** This method supports comparing arrays, booleans, `Date` objects,11147* numbers, `Object` objects, regexes, and strings. Objects are compared by11148* their own, not inherited, enumerable properties.11149*11150* @static11151* @memberOf _11152* @category Utility11153* @param {Array|string} path The path of the property to get.11154* @param {*} srcValue The value to match.11155* @returns {Function} Returns the new function.11156* @example11157*11158* var users = [11159* { 'user': 'barney' },11160* { 'user': 'fred' }11161* ];11162*11163* _.find(users, _.matchesProperty('user', 'fred'));11164* // => { 'user': 'fred' }11165*/11166function matchesProperty(path, srcValue) {11167return baseMatchesProperty(path, baseClone(srcValue, true));11168}1116911170/**11171* Creates a function that invokes the method at `path` on a given object.11172* Any additional arguments are provided to the invoked method.11173*11174* @static11175* @memberOf _11176* @category Utility11177* @param {Array|string} path The path of the method to invoke.11178* @param {...*} [args] The arguments to invoke the method with.11179* @returns {Function} Returns the new function.11180* @example11181*11182* var objects = [11183* { 'a': { 'b': { 'c': _.constant(2) } } },11184* { 'a': { 'b': { 'c': _.constant(1) } } }11185* ];11186*11187* _.map(objects, _.method('a.b.c'));11188* // => [2, 1]11189*11190* _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c');11191* // => [1, 2]11192*/11193var method = restParam(function(path, args) {11194return function(object) {11195return invokePath(object, path, args);11196};11197});1119811199/**11200* The opposite of `_.method`; this method creates a function that invokes11201* the method at a given path on `object`. Any additional arguments are11202* provided to the invoked method.11203*11204* @static11205* @memberOf _11206* @category Utility11207* @param {Object} object The object to query.11208* @param {...*} [args] The arguments to invoke the method with.11209* @returns {Function} Returns the new function.11210* @example11211*11212* var array = _.times(3, _.constant),11213* object = { 'a': array, 'b': array, 'c': array };11214*11215* _.map(['a[2]', 'c[0]'], _.methodOf(object));11216* // => [2, 0]11217*11218* _.map([['a', '2'], ['c', '0']], _.methodOf(object));11219* // => [2, 0]11220*/11221var methodOf = restParam(function(object, args) {11222return function(path) {11223return invokePath(object, path, args);11224};11225});1122611227/**11228* Adds all own enumerable function properties of a source object to the11229* destination object. If `object` is a function then methods are added to11230* its prototype as well.11231*11232* **Note:** Use `_.runInContext` to create a pristine `lodash` function to11233* avoid conflicts caused by modifying the original.11234*11235* @static11236* @memberOf _11237* @category Utility11238* @param {Function|Object} [object=lodash] The destination object.11239* @param {Object} source The object of functions to add.11240* @param {Object} [options] The options object.11241* @param {boolean} [options.chain=true] Specify whether the functions added11242* are chainable.11243* @returns {Function|Object} Returns `object`.11244* @example11245*11246* function vowels(string) {11247* return _.filter(string, function(v) {11248* return /[aeiou]/i.test(v);11249* });11250* }11251*11252* _.mixin({ 'vowels': vowels });11253* _.vowels('fred');11254* // => ['e']11255*11256* _('fred').vowels().value();11257* // => ['e']11258*11259* _.mixin({ 'vowels': vowels }, { 'chain': false });11260* _('fred').vowels();11261* // => ['e']11262*/11263function mixin(object, source, options) {11264if (options == null) {11265var isObj = isObject(source),11266props = isObj ? keys(source) : null,11267methodNames = (props && props.length) ? baseFunctions(source, props) : null;1126811269if (!(methodNames ? methodNames.length : isObj)) {11270methodNames = false;11271options = source;11272source = object;11273object = this;11274}11275}11276if (!methodNames) {11277methodNames = baseFunctions(source, keys(source));11278}11279var chain = true,11280index = -1,11281isFunc = isFunction(object),11282length = methodNames.length;1128311284if (options === false) {11285chain = false;11286} else if (isObject(options) && 'chain' in options) {11287chain = options.chain;11288}11289while (++index < length) {11290var methodName = methodNames[index],11291func = source[methodName];1129211293object[methodName] = func;11294if (isFunc) {11295object.prototype[methodName] = (function(func) {11296return function() {11297var chainAll = this.__chain__;11298if (chain || chainAll) {11299var result = object(this.__wrapped__),11300actions = result.__actions__ = arrayCopy(this.__actions__);1130111302actions.push({ 'func': func, 'args': arguments, 'thisArg': object });11303result.__chain__ = chainAll;11304return result;11305}11306var args = [this.value()];11307push.apply(args, arguments);11308return func.apply(object, args);11309};11310}(func));11311}11312}11313return object;11314}1131511316/**11317* Reverts the `_` variable to its previous value and returns a reference to11318* the `lodash` function.11319*11320* @static11321* @memberOf _11322* @category Utility11323* @returns {Function} Returns the `lodash` function.11324* @example11325*11326* var lodash = _.noConflict();11327*/11328function noConflict() {11329context._ = oldDash;11330return this;11331}1133211333/**11334* A no-operation function that returns `undefined` regardless of the11335* arguments it receives.11336*11337* @static11338* @memberOf _11339* @category Utility11340* @example11341*11342* var object = { 'user': 'fred' };11343*11344* _.noop(object) === undefined;11345* // => true11346*/11347function noop() {11348// No operation performed.11349}1135011351/**11352* Creates a function that returns the property value at `path` on a11353* given object.11354*11355* @static11356* @memberOf _11357* @category Utility11358* @param {Array|string} path The path of the property to get.11359* @returns {Function} Returns the new function.11360* @example11361*11362* var objects = [11363* { 'a': { 'b': { 'c': 2 } } },11364* { 'a': { 'b': { 'c': 1 } } }11365* ];11366*11367* _.map(objects, _.property('a.b.c'));11368* // => [2, 1]11369*11370* _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');11371* // => [1, 2]11372*/11373function property(path) {11374return isKey(path) ? baseProperty(path) : basePropertyDeep(path);11375}1137611377/**11378* The opposite of `_.property`; this method creates a function that returns11379* the property value at a given path on `object`.11380*11381* @static11382* @memberOf _11383* @category Utility11384* @param {Object} object The object to query.11385* @returns {Function} Returns the new function.11386* @example11387*11388* var array = [0, 1, 2],11389* object = { 'a': array, 'b': array, 'c': array };11390*11391* _.map(['a[2]', 'c[0]'], _.propertyOf(object));11392* // => [2, 0]11393*11394* _.map([['a', '2'], ['c', '0']], _.propertyOf(object));11395* // => [2, 0]11396*/11397function propertyOf(object) {11398return function(path) {11399return baseGet(object, toPath(path), path + '');11400};11401}1140211403/**11404* Creates an array of numbers (positive and/or negative) progressing from11405* `start` up to, but not including, `end`. If `end` is not specified it is11406* set to `start` with `start` then set to `0`. If `end` is less than `start`11407* a zero-length range is created unless a negative `step` is specified.11408*11409* @static11410* @memberOf _11411* @category Utility11412* @param {number} [start=0] The start of the range.11413* @param {number} end The end of the range.11414* @param {number} [step=1] The value to increment or decrement by.11415* @returns {Array} Returns the new array of numbers.11416* @example11417*11418* _.range(4);11419* // => [0, 1, 2, 3]11420*11421* _.range(1, 5);11422* // => [1, 2, 3, 4]11423*11424* _.range(0, 20, 5);11425* // => [0, 5, 10, 15]11426*11427* _.range(0, -4, -1);11428* // => [0, -1, -2, -3]11429*11430* _.range(1, 4, 0);11431* // => [1, 1, 1]11432*11433* _.range(0);11434* // => []11435*/11436function range(start, end, step) {11437if (step && isIterateeCall(start, end, step)) {11438end = step = null;11439}11440start = +start || 0;11441step = step == null ? 1 : (+step || 0);1144211443if (end == null) {11444end = start;11445start = 0;11446} else {11447end = +end || 0;11448}11449// Use `Array(length)` so engines like Chakra and V8 avoid slower modes.11450// See https://youtu.be/XAqIpGU8ZZk#t=17m25s for more details.11451var index = -1,11452length = nativeMax(ceil((end - start) / (step || 1)), 0),11453result = Array(length);1145411455while (++index < length) {11456result[index] = start;11457start += step;11458}11459return result;11460}1146111462/**11463* Invokes the iteratee function `n` times, returning an array of the results11464* of each invocation. The `iteratee` is bound to `thisArg` and invoked with11465* one argument; (index).11466*11467* @static11468* @memberOf _11469* @category Utility11470* @param {number} n The number of times to invoke `iteratee`.11471* @param {Function} [iteratee=_.identity] The function invoked per iteration.11472* @param {*} [thisArg] The `this` binding of `iteratee`.11473* @returns {Array} Returns the array of results.11474* @example11475*11476* var diceRolls = _.times(3, _.partial(_.random, 1, 6, false));11477* // => [3, 6, 4]11478*11479* _.times(3, function(n) {11480* mage.castSpell(n);11481* });11482* // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2`11483*11484* _.times(3, function(n) {11485* this.cast(n);11486* }, mage);11487* // => also invokes `mage.castSpell(n)` three times11488*/11489function times(n, iteratee, thisArg) {11490n = floor(n);1149111492// Exit early to avoid a JSC JIT bug in Safari 811493// where `Array(0)` is treated as `Array(1)`.11494if (n < 1 || !nativeIsFinite(n)) {11495return [];11496}11497var index = -1,11498result = Array(nativeMin(n, MAX_ARRAY_LENGTH));1149911500iteratee = bindCallback(iteratee, thisArg, 1);11501while (++index < n) {11502if (index < MAX_ARRAY_LENGTH) {11503result[index] = iteratee(index);11504} else {11505iteratee(index);11506}11507}11508return result;11509}1151011511/**11512* Generates a unique ID. If `prefix` is provided the ID is appended to it.11513*11514* @static11515* @memberOf _11516* @category Utility11517* @param {string} [prefix] The value to prefix the ID with.11518* @returns {string} Returns the unique ID.11519* @example11520*11521* _.uniqueId('contact_');11522* // => 'contact_104'11523*11524* _.uniqueId();11525* // => '105'11526*/11527function uniqueId(prefix) {11528var id = ++idCounter;11529return baseToString(prefix) + id;11530}1153111532/*------------------------------------------------------------------------*/1153311534/**11535* Adds two numbers.11536*11537* @static11538* @memberOf _11539* @category Math11540* @param {number} augend The first number to add.11541* @param {number} addend The second number to add.11542* @returns {number} Returns the sum.11543* @example11544*11545* _.add(6, 4);11546* // => 1011547*/11548function add(augend, addend) {11549return (+augend || 0) + (+addend || 0);11550}1155111552/**11553* Gets the maximum value of `collection`. If `collection` is empty or falsey11554* `-Infinity` is returned. If an iteratee function is provided it is invoked11555* for each value in `collection` to generate the criterion by which the value11556* is ranked. The `iteratee` is bound to `thisArg` and invoked with three11557* arguments: (value, index, collection).11558*11559* If a property name is provided for `iteratee` the created `_.property`11560* style callback returns the property value of the given element.11561*11562* If a value is also provided for `thisArg` the created `_.matchesProperty`11563* style callback returns `true` for elements that have a matching property11564* value, else `false`.11565*11566* If an object is provided for `iteratee` the created `_.matches` style11567* callback returns `true` for elements that have the properties of the given11568* object, else `false`.11569*11570* @static11571* @memberOf _11572* @category Math11573* @param {Array|Object|string} collection The collection to iterate over.11574* @param {Function|Object|string} [iteratee] The function invoked per iteration.11575* @param {*} [thisArg] The `this` binding of `iteratee`.11576* @returns {*} Returns the maximum value.11577* @example11578*11579* _.max([4, 2, 8, 6]);11580* // => 811581*11582* _.max([]);11583* // => -Infinity11584*11585* var users = [11586* { 'user': 'barney', 'age': 36 },11587* { 'user': 'fred', 'age': 40 }11588* ];11589*11590* _.max(users, function(chr) {11591* return chr.age;11592* });11593* // => { 'user': 'fred', 'age': 40 }11594*11595* // using the `_.property` callback shorthand11596* _.max(users, 'age');11597* // => { 'user': 'fred', 'age': 40 }11598*/11599var max = createExtremum(gt, NEGATIVE_INFINITY);1160011601/**11602* Gets the minimum value of `collection`. If `collection` is empty or falsey11603* `Infinity` is returned. If an iteratee function is provided it is invoked11604* for each value in `collection` to generate the criterion by which the value11605* is ranked. The `iteratee` is bound to `thisArg` and invoked with three11606* arguments: (value, index, collection).11607*11608* If a property name is provided for `iteratee` the created `_.property`11609* style callback returns the property value of the given element.11610*11611* If a value is also provided for `thisArg` the created `_.matchesProperty`11612* style callback returns `true` for elements that have a matching property11613* value, else `false`.11614*11615* If an object is provided for `iteratee` the created `_.matches` style11616* callback returns `true` for elements that have the properties of the given11617* object, else `false`.11618*11619* @static11620* @memberOf _11621* @category Math11622* @param {Array|Object|string} collection The collection to iterate over.11623* @param {Function|Object|string} [iteratee] The function invoked per iteration.11624* @param {*} [thisArg] The `this` binding of `iteratee`.11625* @returns {*} Returns the minimum value.11626* @example11627*11628* _.min([4, 2, 8, 6]);11629* // => 211630*11631* _.min([]);11632* // => Infinity11633*11634* var users = [11635* { 'user': 'barney', 'age': 36 },11636* { 'user': 'fred', 'age': 40 }11637* ];11638*11639* _.min(users, function(chr) {11640* return chr.age;11641* });11642* // => { 'user': 'barney', 'age': 36 }11643*11644* // using the `_.property` callback shorthand11645* _.min(users, 'age');11646* // => { 'user': 'barney', 'age': 36 }11647*/11648var min = createExtremum(lt, POSITIVE_INFINITY);1164911650/**11651* Gets the sum of the values in `collection`.11652*11653* @static11654* @memberOf _11655* @category Math11656* @param {Array|Object|string} collection The collection to iterate over.11657* @param {Function|Object|string} [iteratee] The function invoked per iteration.11658* @param {*} [thisArg] The `this` binding of `iteratee`.11659* @returns {number} Returns the sum.11660* @example11661*11662* _.sum([4, 6]);11663* // => 1011664*11665* _.sum({ 'a': 4, 'b': 6 });11666* // => 1011667*11668* var objects = [11669* { 'n': 4 },11670* { 'n': 6 }11671* ];11672*11673* _.sum(objects, function(object) {11674* return object.n;11675* });11676* // => 1011677*11678* // using the `_.property` callback shorthand11679* _.sum(objects, 'n');11680* // => 1011681*/11682function sum(collection, iteratee, thisArg) {11683if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {11684iteratee = null;11685}11686var callback = getCallback(),11687noIteratee = iteratee == null;1168811689if (!(noIteratee && callback === baseCallback)) {11690noIteratee = false;11691iteratee = callback(iteratee, thisArg, 3);11692}11693return noIteratee11694? arraySum(isArray(collection) ? collection : toIterable(collection))11695: baseSum(collection, iteratee);11696}1169711698/*------------------------------------------------------------------------*/1169911700// Ensure wrappers are instances of `baseLodash`.11701lodash.prototype = baseLodash.prototype;1170211703LodashWrapper.prototype = baseCreate(baseLodash.prototype);11704LodashWrapper.prototype.constructor = LodashWrapper;1170511706LazyWrapper.prototype = baseCreate(baseLodash.prototype);11707LazyWrapper.prototype.constructor = LazyWrapper;1170811709// Add functions to the `Map` cache.11710MapCache.prototype['delete'] = mapDelete;11711MapCache.prototype.get = mapGet;11712MapCache.prototype.has = mapHas;11713MapCache.prototype.set = mapSet;1171411715// Add functions to the `Set` cache.11716SetCache.prototype.push = cachePush;1171711718// Assign cache to `_.memoize`.11719memoize.Cache = MapCache;1172011721// Add functions that return wrapped values when chaining.11722lodash.after = after;11723lodash.ary = ary;11724lodash.assign = assign;11725lodash.at = at;11726lodash.before = before;11727lodash.bind = bind;11728lodash.bindAll = bindAll;11729lodash.bindKey = bindKey;11730lodash.callback = callback;11731lodash.chain = chain;11732lodash.chunk = chunk;11733lodash.compact = compact;11734lodash.constant = constant;11735lodash.countBy = countBy;11736lodash.create = create;11737lodash.curry = curry;11738lodash.curryRight = curryRight;11739lodash.debounce = debounce;11740lodash.defaults = defaults;11741lodash.defer = defer;11742lodash.delay = delay;11743lodash.difference = difference;11744lodash.drop = drop;11745lodash.dropRight = dropRight;11746lodash.dropRightWhile = dropRightWhile;11747lodash.dropWhile = dropWhile;11748lodash.fill = fill;11749lodash.filter = filter;11750lodash.flatten = flatten;11751lodash.flattenDeep = flattenDeep;11752lodash.flow = flow;11753lodash.flowRight = flowRight;11754lodash.forEach = forEach;11755lodash.forEachRight = forEachRight;11756lodash.forIn = forIn;11757lodash.forInRight = forInRight;11758lodash.forOwn = forOwn;11759lodash.forOwnRight = forOwnRight;11760lodash.functions = functions;11761lodash.groupBy = groupBy;11762lodash.indexBy = indexBy;11763lodash.initial = initial;11764lodash.intersection = intersection;11765lodash.invert = invert;11766lodash.invoke = invoke;11767lodash.keys = keys;11768lodash.keysIn = keysIn;11769lodash.map = map;11770lodash.mapKeys = mapKeys;11771lodash.mapValues = mapValues;11772lodash.matches = matches;11773lodash.matchesProperty = matchesProperty;11774lodash.memoize = memoize;11775lodash.merge = merge;11776lodash.method = method;11777lodash.methodOf = methodOf;11778lodash.mixin = mixin;11779lodash.negate = negate;11780lodash.omit = omit;11781lodash.once = once;11782lodash.pairs = pairs;11783lodash.partial = partial;11784lodash.partialRight = partialRight;11785lodash.partition = partition;11786lodash.pick = pick;11787lodash.pluck = pluck;11788lodash.property = property;11789lodash.propertyOf = propertyOf;11790lodash.pull = pull;11791lodash.pullAt = pullAt;11792lodash.range = range;11793lodash.rearg = rearg;11794lodash.reject = reject;11795lodash.remove = remove;11796lodash.rest = rest;11797lodash.restParam = restParam;11798lodash.set = set;11799lodash.shuffle = shuffle;11800lodash.slice = slice;11801lodash.sortBy = sortBy;11802lodash.sortByAll = sortByAll;11803lodash.sortByOrder = sortByOrder;11804lodash.spread = spread;11805lodash.take = take;11806lodash.takeRight = takeRight;11807lodash.takeRightWhile = takeRightWhile;11808lodash.takeWhile = takeWhile;11809lodash.tap = tap;11810lodash.throttle = throttle;11811lodash.thru = thru;11812lodash.times = times;11813lodash.toArray = toArray;11814lodash.toPlainObject = toPlainObject;11815lodash.transform = transform;11816lodash.union = union;11817lodash.uniq = uniq;11818lodash.unzip = unzip;11819lodash.unzipWith = unzipWith;11820lodash.values = values;11821lodash.valuesIn = valuesIn;11822lodash.where = where;11823lodash.without = without;11824lodash.wrap = wrap;11825lodash.xor = xor;11826lodash.zip = zip;11827lodash.zipObject = zipObject;11828lodash.zipWith = zipWith;1182911830// Add aliases.11831lodash.backflow = flowRight;11832lodash.collect = map;11833lodash.compose = flowRight;11834lodash.each = forEach;11835lodash.eachRight = forEachRight;11836lodash.extend = assign;11837lodash.iteratee = callback;11838lodash.methods = functions;11839lodash.object = zipObject;11840lodash.select = filter;11841lodash.tail = rest;11842lodash.unique = uniq;1184311844// Add functions to `lodash.prototype`.11845mixin(lodash, lodash);1184611847/*------------------------------------------------------------------------*/1184811849// Add functions that return unwrapped values when chaining.11850lodash.add = add;11851lodash.attempt = attempt;11852lodash.camelCase = camelCase;11853lodash.capitalize = capitalize;11854lodash.clone = clone;11855lodash.cloneDeep = cloneDeep;11856lodash.deburr = deburr;11857lodash.endsWith = endsWith;11858lodash.escape = escape;11859lodash.escapeRegExp = escapeRegExp;11860lodash.every = every;11861lodash.find = find;11862lodash.findIndex = findIndex;11863lodash.findKey = findKey;11864lodash.findLast = findLast;11865lodash.findLastIndex = findLastIndex;11866lodash.findLastKey = findLastKey;11867lodash.findWhere = findWhere;11868lodash.first = first;11869lodash.get = get;11870lodash.gt = gt;11871lodash.gte = gte;11872lodash.has = has;11873lodash.identity = identity;11874lodash.includes = includes;11875lodash.indexOf = indexOf;11876lodash.inRange = inRange;11877lodash.isArguments = isArguments;11878lodash.isArray = isArray;11879lodash.isBoolean = isBoolean;11880lodash.isDate = isDate;11881lodash.isElement = isElement;11882lodash.isEmpty = isEmpty;11883lodash.isEqual = isEqual;11884lodash.isError = isError;11885lodash.isFinite = isFinite;11886lodash.isFunction = isFunction;11887lodash.isMatch = isMatch;11888lodash.isNaN = isNaN;11889lodash.isNative = isNative;11890lodash.isNull = isNull;11891lodash.isNumber = isNumber;11892lodash.isObject = isObject;11893lodash.isPlainObject = isPlainObject;11894lodash.isRegExp = isRegExp;11895lodash.isString = isString;11896lodash.isTypedArray = isTypedArray;11897lodash.isUndefined = isUndefined;11898lodash.kebabCase = kebabCase;11899lodash.last = last;11900lodash.lastIndexOf = lastIndexOf;11901lodash.lt = lt;11902lodash.lte = lte;11903lodash.max = max;11904lodash.min = min;11905lodash.noConflict = noConflict;11906lodash.noop = noop;11907lodash.now = now;11908lodash.pad = pad;11909lodash.padLeft = padLeft;11910lodash.padRight = padRight;11911lodash.parseInt = parseInt;11912lodash.random = random;11913lodash.reduce = reduce;11914lodash.reduceRight = reduceRight;11915lodash.repeat = repeat;11916lodash.result = result;11917lodash.runInContext = runInContext;11918lodash.size = size;11919lodash.snakeCase = snakeCase;11920lodash.some = some;11921lodash.sortedIndex = sortedIndex;11922lodash.sortedLastIndex = sortedLastIndex;11923lodash.startCase = startCase;11924lodash.startsWith = startsWith;11925lodash.sum = sum;11926lodash.template = template;11927lodash.trim = trim;11928lodash.trimLeft = trimLeft;11929lodash.trimRight = trimRight;11930lodash.trunc = trunc;11931lodash.unescape = unescape;11932lodash.uniqueId = uniqueId;11933lodash.words = words;1193411935// Add aliases.11936lodash.all = every;11937lodash.any = some;11938lodash.contains = includes;11939lodash.eq = isEqual;11940lodash.detect = find;11941lodash.foldl = reduce;11942lodash.foldr = reduceRight;11943lodash.head = first;11944lodash.include = includes;11945lodash.inject = reduce;1194611947mixin(lodash, (function() {11948var source = {};11949baseForOwn(lodash, function(func, methodName) {11950if (!lodash.prototype[methodName]) {11951source[methodName] = func;11952}11953});11954return source;11955}()), false);1195611957/*------------------------------------------------------------------------*/1195811959// Add functions capable of returning wrapped and unwrapped values when chaining.11960lodash.sample = sample;1196111962lodash.prototype.sample = function(n) {11963if (!this.__chain__ && n == null) {11964return sample(this.value());11965}11966return this.thru(function(value) {11967return sample(value, n);11968});11969};1197011971/*------------------------------------------------------------------------*/1197211973/**11974* The semantic version number.11975*11976* @static11977* @memberOf _11978* @type string11979*/11980lodash.VERSION = VERSION;1198111982// Assign default placeholders.11983arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {11984lodash[methodName].placeholder = lodash;11985});1198611987// Add `LazyWrapper` methods that accept an `iteratee` value.11988arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) {11989var isFilter = type != LAZY_MAP_FLAG,11990isDropWhile = type == LAZY_DROP_WHILE_FLAG;1199111992LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {11993var filtered = this.__filtered__,11994result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(),11995iteratees = result.__iteratees__ || (result.__iteratees__ = []);1199611997iteratees.push({11998'done': false,11999'count': 0,12000'index': 0,12001'iteratee': getCallback(iteratee, thisArg, 1),12002'limit': -1,12003'type': type12004});1200512006result.__filtered__ = filtered || isFilter;12007return result;12008};12009});1201012011// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.12012arrayEach(['drop', 'take'], function(methodName, index) {12013var whileName = methodName + 'While';1201412015LazyWrapper.prototype[methodName] = function(n) {12016var filtered = this.__filtered__,12017result = (filtered && !index) ? this.dropWhile() : this.clone();1201812019n = n == null ? 1 : nativeMax(floor(n) || 0, 0);12020if (filtered) {12021if (index) {12022result.__takeCount__ = nativeMin(result.__takeCount__, n);12023} else {12024last(result.__iteratees__).limit = n;12025}12026} else {12027var views = result.__views__ || (result.__views__ = []);12028views.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });12029}12030return result;12031};1203212033LazyWrapper.prototype[methodName + 'Right'] = function(n) {12034return this.reverse()[methodName](n).reverse();12035};1203612037LazyWrapper.prototype[methodName + 'RightWhile'] = function(predicate, thisArg) {12038return this.reverse()[whileName](predicate, thisArg).reverse();12039};12040});1204112042// Add `LazyWrapper` methods for `_.first` and `_.last`.12043arrayEach(['first', 'last'], function(methodName, index) {12044var takeName = 'take' + (index ? 'Right' : '');1204512046LazyWrapper.prototype[methodName] = function() {12047return this[takeName](1).value()[0];12048};12049});1205012051// Add `LazyWrapper` methods for `_.initial` and `_.rest`.12052arrayEach(['initial', 'rest'], function(methodName, index) {12053var dropName = 'drop' + (index ? '' : 'Right');1205412055LazyWrapper.prototype[methodName] = function() {12056return this[dropName](1);12057};12058});1205912060// Add `LazyWrapper` methods for `_.pluck` and `_.where`.12061arrayEach(['pluck', 'where'], function(methodName, index) {12062var operationName = index ? 'filter' : 'map',12063createCallback = index ? baseMatches : property;1206412065LazyWrapper.prototype[methodName] = function(value) {12066return this[operationName](createCallback(value));12067};12068});1206912070LazyWrapper.prototype.compact = function() {12071return this.filter(identity);12072};1207312074LazyWrapper.prototype.reject = function(predicate, thisArg) {12075predicate = getCallback(predicate, thisArg, 1);12076return this.filter(function(value) {12077return !predicate(value);12078});12079};1208012081LazyWrapper.prototype.slice = function(start, end) {12082start = start == null ? 0 : (+start || 0);1208312084var result = this;12085if (start < 0) {12086result = this.takeRight(-start);12087} else if (start) {12088result = this.drop(start);12089}12090if (end !== undefined) {12091end = (+end || 0);12092result = end < 0 ? result.dropRight(-end) : result.take(end - start);12093}12094return result;12095};1209612097LazyWrapper.prototype.toArray = function() {12098return this.drop(0);12099};1210012101// Add `LazyWrapper` methods to `lodash.prototype`.12102baseForOwn(LazyWrapper.prototype, function(func, methodName) {12103var lodashFunc = lodash[methodName];12104if (!lodashFunc) {12105return;12106}12107var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),12108retUnwrapped = /^(?:first|last)$/.test(methodName);1210912110lodash.prototype[methodName] = function() {12111var args = arguments,12112chainAll = this.__chain__,12113value = this.__wrapped__,12114isHybrid = !!this.__actions__.length,12115isLazy = value instanceof LazyWrapper,12116iteratee = args[0],12117useLazy = isLazy || isArray(value);1211812119if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {12120// avoid lazy use if the iteratee has a "length" value other than `1`12121isLazy = useLazy = false;12122}12123var onlyLazy = isLazy && !isHybrid;12124if (retUnwrapped && !chainAll) {12125return onlyLazy12126? func.call(value)12127: lodashFunc.call(lodash, this.value());12128}12129var interceptor = function(value) {12130var otherArgs = [value];12131push.apply(otherArgs, args);12132return lodashFunc.apply(lodash, otherArgs);12133};12134if (useLazy) {12135var wrapper = onlyLazy ? value : new LazyWrapper(this),12136result = func.apply(wrapper, args);1213712138if (!retUnwrapped && (isHybrid || result.__actions__)) {12139var actions = result.__actions__ || (result.__actions__ = []);12140actions.push({ 'func': thru, 'args': [interceptor], 'thisArg': lodash });12141}12142return new LodashWrapper(result, chainAll);12143}12144return this.thru(interceptor);12145};12146});1214712148// Add `Array` and `String` methods to `lodash.prototype`.12149arrayEach(['concat', 'join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) {12150var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName],12151chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',12152retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName);1215312154lodash.prototype[methodName] = function() {12155var args = arguments;12156if (retUnwrapped && !this.__chain__) {12157return func.apply(this.value(), args);12158}12159return this[chainName](function(value) {12160return func.apply(value, args);12161});12162};12163});1216412165// Map minified function names to their real names.12166baseForOwn(LazyWrapper.prototype, function(func, methodName) {12167var lodashFunc = lodash[methodName];12168if (lodashFunc) {12169var key = lodashFunc.name,12170names = realNames[key] || (realNames[key] = []);1217112172names.push({ 'name': methodName, 'func': lodashFunc });12173}12174});1217512176realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }];1217712178// Add functions to the lazy wrapper.12179LazyWrapper.prototype.clone = lazyClone;12180LazyWrapper.prototype.reverse = lazyReverse;12181LazyWrapper.prototype.value = lazyValue;1218212183// Add chaining functions to the `lodash` wrapper.12184lodash.prototype.chain = wrapperChain;12185lodash.prototype.commit = wrapperCommit;12186lodash.prototype.plant = wrapperPlant;12187lodash.prototype.reverse = wrapperReverse;12188lodash.prototype.toString = wrapperToString;12189lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;1219012191// Add function aliases to the `lodash` wrapper.12192lodash.prototype.collect = lodash.prototype.map;12193lodash.prototype.head = lodash.prototype.first;12194lodash.prototype.select = lodash.prototype.filter;12195lodash.prototype.tail = lodash.prototype.rest;1219612197return lodash;12198}1219912200/*--------------------------------------------------------------------------*/1220112202// Export lodash.12203var _ = runInContext();1220412205// Some AMD build optimizers like r.js check for condition patterns like the following:12206if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {12207// Expose lodash to the global object when an AMD loader is present to avoid12208// errors in cases where lodash is loaded by a script tag and not intended12209// as an AMD module. See http://requirejs.org/docs/errors.html#mismatch for12210// more details.12211root._ = _;1221212213// Define as an anonymous module so, through path mapping, it can be12214// referenced as the "underscore" module.12215define(function() {12216return _;12217});12218}12219// Check for `exports` after `define` in case a build optimizer adds an `exports` object.12220else if (freeExports && freeModule) {12221// Export for Node.js or RingoJS.12222if (moduleExports) {12223(freeModule.exports = _)._ = _;12224}12225// Export for Rhino with CommonJS support.12226else {12227freeExports._ = _;12228}12229}12230else {12231// Export for a browser or Rhino.12232root._ = _;12233}12234}.call(this));122351223612237