diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 4b5989e39..f9ab23b2d 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -23,8 +23,8 @@ CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, - ARY_FLAG = 128, - REARG_FLAG = 256; + REARG_FLAG = 128, + ARY_FLAG = 256; /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, @@ -45,9 +45,6 @@ /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; - /** Used to generate unique IDs. */ - var idCounter = 0; - /** Used to match empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, @@ -55,7 +52,9 @@ /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, - reUnescapedHtml = /[&<>"'`]/g; + reUnescapedHtml = /[&<>"'`]/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, @@ -81,7 +80,7 @@ /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters (excluding mathematical operators). */ + /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; /** Used to ensure capturing order of template delimiters. */ @@ -92,7 +91,8 @@ * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) * for more details. */ - var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g; + var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, + reHasRegExpChars = RegExp(reRegExpChars.source); /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; @@ -285,8 +285,8 @@ /*--------------------------------------------------------------------------*/ /** - * A specialized version of `_.forEach` for arrays without support for - * callback shorthands or `this` binding. + * A specialized version of `_.forEach` for arrays without support for callback + * shorthands or `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -333,7 +333,7 @@ * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns `true` if all elements pass the predicate check, - * else `false` + * else `false`. */ function arrayEvery(array, predicate) { var index = -1, @@ -399,7 +399,7 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray=false] Specify using the first element of + * @param {boolean} [initFromArray] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ @@ -424,13 +424,12 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray=false] Specify using the last element of + * @param {boolean} [initFromArray] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; - if (initFromArray && length) { accumulator = array[--length]; } @@ -487,8 +486,7 @@ } /** - * The base implementation of `_.indexOf` without support for `fromIndex` - * bounds checks and binary searches. + * The base implementation of `_.indexOf` without support for binary searches. * * @private * @param {Array} array The array to search. @@ -521,7 +519,7 @@ */ function baseSlice(array) { var index = -1, - length = array ? array.length : 0, + length = array.length, result = Array(length); while (++index < length) { @@ -638,7 +636,7 @@ } /** - * Used by `_.deburr` to convert latin-1 to basic latin letters. + * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * * @private * @param {string} letter The matched letter to deburr. @@ -678,7 +676,7 @@ * @private * @param {Array} array The array to search. * @param {number} [fromIndex] The index to search from. - * @param {boolean} [fromRight=false] Specify iterating from right to left. + * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched `NaN`, else `-1`. */ function indexOfNaN(array, fromIndex, fromRight) { @@ -715,11 +713,11 @@ }()); /** - * Checks if `value` is valid array-like index. + * Checks if `value` is a valid array-like index. * * @private * @param {*} value The value to check. - * @param {number} [length] The upper bound of a valid index. + * @param {number} [length] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { @@ -746,7 +744,7 @@ * @param {number} charCode The character code to inspect. * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. */ - function isWhitespace(charCode) { + function isSpace(charCode) { return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); } @@ -815,7 +813,7 @@ var index = -1, length = string.length; - while (++index < length && isWhitespace(string.charCodeAt(index))) {} + while (++index < length && isSpace(string.charCodeAt(index))) {} return index; } @@ -830,7 +828,7 @@ function trimmedRightIndex(string) { var index = string.length; - while (index-- && isWhitespace(string.charCodeAt(index))) {} + while (index-- && isSpace(string.charCodeAt(index))) {} return index; } @@ -905,9 +903,15 @@ /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; + /** Used to the length of n-tuples for `_.unzip`. */ + var getLength = baseProperty('length'); + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; + /** Used to generate unique IDs. */ + var idCounter = 0; + /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; @@ -949,8 +953,7 @@ }()); /* Native method references for those with the same name as other `lodash` methods. */ - var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, - nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, + var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, @@ -964,11 +967,12 @@ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - /** Used as references for the max length and index of an array. */ + /** Used as references for the maximum length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - /** Used as the size, in bytes, of each Float64Array element. */ + /** Used as the size, in bytes, of each `Float64Array` element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** @@ -1013,8 +1017,16 @@ /** * Creates a `lodash` object which wraps `value` to enable intuitive chaining. - * The execution of chained methods is deferred until `_#value` is implicitly - * or explicitly called. Explicit chaining may be enabled by using `_.chain`. + * Methods that operate on and return arrays, collections, and functions can + * be chained together. Methods that return a boolean or single value will + * automatically end the chain returning the unwrapped value. Explicit chaining + * may be enabled using `_.chain`. The execution of chained methods is lazy, + * that is, execution is deferred until `_#value` is implicitly or explicitly + * called. + * + * Lazy evaluation allows several methods to support shortcut fusion. Shortcut + * fusion is an optimization that merges iteratees to avoid creating intermediate + * arrays and reduce the number of iteratee executions. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. @@ -1023,7 +1035,12 @@ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, * and `unshift` * - * The wrapper functions that are chainable by default are: + * The wrapper functons that support shortcut fusion are: + * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`, + * `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`, + * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where` + * + * The chainable wrapper functions are: * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, * `callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`, * `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, @@ -1040,19 +1057,19 @@ * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, * `without`, `wrap`, `xor`, `zip`, and `zipObject` * - * The wrapper functions that are non-chainable by default are: + * The wrapper functions that are **not** chainable by default are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, - * `isFunction`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, - * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, - * `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, - * `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, - * `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `unescape`, `uniqueId`, `value`, and `words` + * `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, + * `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, + * `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, + * `sortedIndex`, `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` * * The wrapper function `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. @@ -1096,7 +1113,7 @@ * * @private * @param {*} value The value to wrap. - * @param {boolean} [chainAll=false] Enable chaining for all wrapper methods. + * @param {boolean} [chainAll] Enable chaining for all wrapper methods. * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. */ function LodashWrapper(value, chainAll, actions) { @@ -1572,6 +1589,19 @@ /*------------------------------------------------------------------------*/ + /** + * Converts an `arguments` object to a plain `Object` object. + * + * @private + * @param {Object} args The `arguments` object to convert. + * @returns {Object} Returns the new converted object. + */ + function argsToObject(args) { + var result = { 'length': 0 }; + push.apply(result, args); + return result; + } + /** * A specialized version of `_.max` for arrays without support for iteratees. * @@ -1647,7 +1677,7 @@ /** * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `this` binding. + * multiple sources, and `this` binding `customizer` functions. * * @private * @param {Object} object The destination object. @@ -1680,7 +1710,7 @@ */ function baseAt(collection, props) { var index = -1, - length = collection ? collection.length : 0, + length = collection.length, isArr = isLength(length), propsLength = props.length, result = Array(propsLength); @@ -1697,6 +1727,49 @@ return result; } + /** + * The base implementation of `binaryIndex` which supports large arrays and + * determining the insert index for `NaN` and `undefined`. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest, instead + * of the lowest, index at which a value should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseBinaryIndex(array, value, iteratee, retHighest) { + iteratee = iteratee == null ? identity : iteratee; + value = iteratee(value); + + var low = 0, + high = array.length, + valIsNaN = value !== value, + valIsUndef = typeof value == 'undefined'; + + while (low < high) { + var mid = floor((low + high) / 2), + computed = iteratee(array[mid]), + isReflexive = computed === computed; + + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || typeof computed != 'undefined'); + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + /** * The base implementation of `_.bindAll` without support for individual * method name arguments. @@ -1718,76 +1791,39 @@ } /** - * The base implementation of `_.callback`. + * The base implementation of `_.callback` which supports specifying the + * number of arguments to provide to `func`. * * @private * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns the new function. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. */ function baseCallback(func, thisArg, argCount) { var type = typeof func; if (type == 'function') { - if (typeof thisArg == 'undefined') { - return func; - } - var data = getData(func); - if (typeof data == 'undefined') { - var support = lodash.support; - if (support.funcNames) { - data = !func.name; - } - data = data || !support.funcDecomp; - if (!data) { - var source = fnToString.call(func); - if (!support.funcNames) { - data = !reFuncName.test(source); - } - if (!data) { - // Check if `func` references the `this` keyword and store the result. - data = reThis.test(source) || isNative(func); - baseSetData(func, data); - } - } - } - // Exit early if there are no `this` references or `func` is bound. - if (data === false || (data !== true && data[1] & BIND_FLAG)) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - case 5: return function(value, other, key, object, source) { - return func.call(thisArg, value, other, key, object, source); - }; - } - return function() { - return func.apply(thisArg, arguments); - }; + return (typeof thisArg != 'undefined' && isBindable(func)) + ? bindCallback(func, thisArg, argCount) + : func; } if (func == null) { return identity; } // Handle "_.pluck" and "_.where" style callback shorthands. - return type == 'object' ? matches(func) : property(func); + return type == 'object' + ? baseMatches(func, argCount) + : baseProperty(argCount ? String(func) : func); } /** * The base implementation of `_.clone` without support for argument juggling - * and `this` binding. + * and `this` binding `customizer` functions. * * @private * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @param {Function} [customizer] The function to customize cloning values. * @param {string} [key] The key of `value`. * @param {Object} [object] The object `value` belongs to. @@ -1848,22 +1884,33 @@ * @param {Object} prototype The object to inherit from. * @returns {Object} Returns the new object. */ - function baseCreate(prototype) { - return isObject(prototype) ? nativeCreate(prototype) : {}; - } - // Fallback for environments without `Object.create`. - if (!nativeCreate) { - baseCreate = (function() { - function Object() {} - return function(prototype) { - if (isObject(prototype)) { - Object.prototype = prototype; - var result = new Object; - Object.prototype = null; - } - return result || context.Object(); - }; - }()); + var baseCreate = (function() { + function Object() {} + return function(prototype) { + if (isObject(prototype)) { + Object.prototype = prototype; + var result = new Object; + Object.prototype = null; + } + return result || context.Object(); + }; + }()); + + /** + * The base implementation of `_.delay` and `_.defer` which accepts an index + * of where to slice the arguments to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Object} args The `arguments` object to slice and provide to `func`. + * @returns {number} Returns the timer id. + */ + function baseDelay(func, wait, args, fromIndex) { + if (!isFunction(func)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, slice(args, fromIndex)); }, wait); } /** @@ -2010,7 +2057,7 @@ * @param {Array|Object|string} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey=false] Specify returning the key of the found + * @param {boolean} [retKey] Specify returning the key of the found * element instead of the element itself. * @returns {*} Returns the found element or its key, else `undefined`. */ @@ -2032,8 +2079,8 @@ * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep=false] Specify a deep flatten. - * @param {boolean} [isStrict=false] Restrict flattening to arrays and `arguments` objects. + * @param {boolean} [isDeep] Specify a deep flatten. + * @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects. * @param {number} [fromIndex=0] The index to start from. * @returns {Array} Returns the new flattened array. */ @@ -2179,206 +2226,9 @@ return result; } - /** - * The base implementation of `_.isEqual`, without support for `thisArg` - * binding, which allows partial "_.where" style comparisons. - * - * @private - * @param {*} value The value to compare to `other`. - * @param {*} other The value to compare to `value`. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isWhere=false] Specify performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `value` objects. - * @param {Array} [stackB=[]] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { - var result = (customizer && !stackA) ? customizer(value, other) : undefined; - if (typeof result != 'undefined') { - return !!result; - } - // Exit early for identical values. - if (value === other) { - // Treat `+0` vs. `-0` as not equal. - return value !== 0 || (1 / value == 1 / other); - } - var valType = typeof value, - othType = typeof other; - - // Exit early for unlike primitive values. - if (!(valType == 'number' && othType == 'number') && (value == null || other == null || - (valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object'))) { - return false; - } - var valClass = toString.call(value), - valIsArg = valClass == argsClass, - othClass = toString.call(other), - othIsArg = othClass == argsClass; - - if (valIsArg) { - valClass = objectClass; - } - if (othIsArg) { - othClass = objectClass; - } - var valIsArr = arrayLikeClasses[valClass], - valIsErr = valClass == errorClass, - valIsObj = valClass == objectClass && !isHostObject(value), - othIsObj = othClass == objectClass && !isHostObject(other); - - var isSameClass = valClass == othClass; - if (isSameClass && valIsArr) { - var valLength = value.length, - othLength = other.length; - - if (valLength != othLength && !(isWhere && othLength > valLength)) { - return false; - } - } - else { - // Unwrap `lodash` wrapped values. - var valWrapped = valIsObj && hasOwnProperty.call(value, '__wrapped__'), - othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (valWrapped || othWrapped) { - return baseIsEqual(valWrapped ? value.value() : value, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); - } - if (!isSameClass) { - return false; - } - if (valIsErr || valIsObj) { - if (!lodash.support.argsClass) { - valIsArg = isArguments(value); - othIsArg = isArguments(other); - } - // In older versions of Opera, `arguments` objects have `Array` constructors. - var valCtor = valIsArg ? Object : value.constructor, - othCtor = othIsArg ? Object : other.constructor; - - if (valIsErr) { - // Error objects of different types are not equal. - if (valCtor.prototype.name != othCtor.prototype.name) { - return false; - } - } - else { - var valHasCtor = !valIsArg && hasOwnProperty.call(value, 'constructor'), - othHasCtor = !othIsArg && hasOwnProperty.call(other, 'constructor'); - - if (valHasCtor != othHasCtor) { - return false; - } - if (!valHasCtor) { - // Non `Object` object instances with different constructors are not equal. - if (valCtor != othCtor && ('constructor' in value && 'constructor' in other) && - !(typeof valCtor == 'function' && valCtor instanceof valCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; - } - } - } - var valProps = valIsErr ? ['message', 'name'] : keys(value), - othProps = valIsErr ? valProps : keys(other); - - if (valIsArg) { - valProps.push('length'); - } - if (othIsArg) { - othProps.push('length'); - } - valLength = valProps.length; - othLength = othProps.length; - if (valLength != othLength && !isWhere) { - return false; - } - } - else { - switch (valClass) { - case boolClass: - case dateClass: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. - return +value == +other; - - case numberClass: - // Treat `NaN` vs. `NaN` as equal. - return (value != +value) - ? other != +other - // But, treat `-0` vs. `+0` as not equal. - : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); - - case regexpClass: - case stringClass: - // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and - // treat strings primitives and string objects as equal. - return value == String(other); - } - return false; - } - } - // Assume cyclic structures are equal. - // The algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). - stackA || (stackA = []); - stackB || (stackB = []); - - var index = stackA.length; - while (index--) { - if (stackA[index] == value) { - return stackB[index] == other; - } - } - // Add `value` and `other` to the stack of traversed objects. - stackA.push(value); - stackB.push(other); - - // Recursively compare objects and arrays (susceptible to call stack limits). - result = true; - if (valIsArr) { - // Deep compare the contents, ignoring non-numeric properties. - while (result && ++index < valLength) { - var valValue = value[index]; - if (isWhere) { - var othIndex = othLength; - while (othIndex--) { - result = baseIsEqual(valValue, other[othIndex], customizer, isWhere, stackA, stackB); - if (result) { - break; - } - } - } else { - var othValue = other[index]; - result = customizer ? customizer(valValue, othValue, index) : undefined; - if (typeof result == 'undefined') { - result = baseIsEqual(valValue, othValue, customizer, isWhere, stackA, stackB); - } - } - } - } - else { - while (result && ++index < valLength) { - var key = valProps[index]; - result = valIsErr || hasOwnProperty.call(other, key); - - if (result) { - valValue = value[key]; - othValue = other[key]; - result = customizer ? customizer(valValue, othValue, key) : undefined; - if (typeof result == 'undefined') { - result = baseIsEqual(valValue, othValue, customizer, isWhere, stackA, stackB); - } - } - } - } - stackA.pop(); - stackB.pop(); - - return !!result; - } - /** * The base implementation of `_.invoke` which requires additional arguments - * be provided as an array of arguments rather than individually. + * to be provided as an array of arguments rather than individually. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2400,6 +2250,162 @@ return result; } + /** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare to `other`. + * @param {*} other The value to compare to `value`. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { + // Exit early for identical values. + if (value === other) { + // Treat `+0` vs. `-0` as not equal. + return value !== 0 || (1 / value == 1 / other); + } + var valType = typeof value, + othType = typeof other; + + // Exit early for unlike primitive values. + if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || + value == null || other == null) { + // Return `false` unless both values are `NaN`. + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); + } + + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * a deep comparison between objects and tracks traversed objects enabling + * objects with circular references to be compared. + * + * @private + * @param {Array} object The object to compare to `other`. + * @param {Array} other The object to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing objects. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `value` objects. + * @param {Array} [stackB=[]] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, equalFunc, customizer, isWhere, stackA, stackB) { + var objClass = isArray(object) ? arrayClass : toString.call(object), + objIsArg = objClass == argsClass, + objIsArr = !objIsArg && arrayLikeClasses[objClass], + othClass = isArray(other) ? arrayClass : toString.call(other), + othIsArg = othClass == argsClass, + othIsArr = !othIsArg && arrayLikeClasses[othClass]; + + if (!lodash.support.argsClass) { + objIsArg = !objIsArr && typeof object.length == 'number' && isArguments(object); + othIsArg = !othIsArr && typeof other.length == 'number' && isArguments(other); + } + if (objIsArg) { + object = argsToObject(object); + objClass = objectClass; + } + if (othIsArg) { + other = argsToObject(other); + othClass = objectClass; + } + var objIsObj = objClass == objectClass && !isHostObject(object), + othIsObj = othClass == objectClass && !isHostObject(other), + isSameClass = objClass == othClass; + + if (isSameClass && !(objIsArr || objIsObj)) { + return equalByClass(object, other, objClass); + } + var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (valWrapped || othWrapped) { + return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); + } + if (!isSameClass) { + return false; + } + // Assume cyclic structures are equal. + // The algorithm for detecting cyclic structures is adapted from ES 5.1 + // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + // Add `object` and `other` to the stack of traversed objects. + stackA.push(object); + stackB.push(other); + + // Recursively compare objects and arrays (susceptible to call stack limits). + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB); + + stackA.pop(); + stackB.pop(); + + return result; + } + + /** + * The base implementation of `_.isMatch` without support for callback + * shorthands or `this` binding. + * + * @private + * @param {Object} source The object to inspect. + * @param {Array} props The source property names to match. + * @param {Array} values The source values to match. + * @param {Array} strictCompareFlags Strict comparison flags for source values. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, props, values, strictCompareFlags, customizer) { + var length = props.length; + if (object == null) { + return !length; + } + var index = -1, + noCustomizer = !customizer; + + while (++index < length) { + if ((noCustomizer && strictCompareFlags[index]) + ? values[index] !== object[props[index]] + : !hasOwnProperty.call(object, props[index]) + ) { + return false; + } + } + index = -1; + while (++index < length) { + var key = props[index]; + if (noCustomizer && strictCompareFlags[index]) { + var result = hasOwnProperty.call(object, key); + } else { + var objValue = object[key], + srcValue = values[index]; + + result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (typeof result == 'undefined') { + result = baseIsEqual(srcValue, objValue, customizer, true); + } + } + if (!result) { + return false; + } + } + return true; + } + /** * The base implementation of `_.map` without support for callback shorthands * or `this` binding. @@ -2418,9 +2424,48 @@ return result; } + /** + * The base implementation of `_.matches` which supports specifying whether + * `source` is cloned. + * + * @private + * @param {Object} source The object of property values to match. + * @param {boolean} [isCloned] Specify cloning the source object. + * @returns {Function} Returns the new function. + */ + function baseMatches(source, isCloned) { + var props = keys(source), + length = props.length; + + if (length == 1) { + var key = props[0], + value = source[key]; + + if (isStrictComparable(value)) { + return function(object) { + return object != null && value === object[key] && hasOwnProperty.call(object, key); + }; + } + } + var notCloned = !isCloned, + values = Array(length), + strictCompareFlags = Array(length); + + while (length--) { + value = source[props[length]]; + var isStrict = isStrictComparable(value); + + values[length] = (isStrict || notCloned) ? value : baseClone(value, true, clonePassthru); + strictCompareFlags[length] = isStrict; + } + return function(object) { + return baseIsMatch(object, props, values, strictCompareFlags); + }; + } + /** * The base implementation of `_.merge` without support for argument juggling, - * multiple sources, and `this` binding. + * multiple sources, and `this` binding `customizer` functions. * * @private * @param {Object} object The destination object. @@ -2481,6 +2526,19 @@ return object; } + /** + * The base implementation of `_.property` which does not coerce `key` to a string. + * + * @private + * @param {string} key The name of the property to retrieve. + * @returns {Function} Returns the new function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + /** * The base implementation of `_.pullAt` without support for individual * index arguments. @@ -2574,49 +2632,6 @@ return !!result; } - /** - * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` without - * support for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The function invoked per iteration. - * @param {boolean} [retHighest=false] Specify returning the highest, instead - * of the lowest, index at which a value should be inserted into `array`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndex(array, value, iteratee, retHighest) { - var low = 0, - high = array ? array.length : low; - - value = iteratee(value); - - var valIsNaN = value !== value, - valIsUndef = typeof value == 'undefined'; - - while (low < high) { - var mid = floor((low + high) / 2), - computed = iteratee(array[mid]), - isReflexive = computed === computed; - - if (valIsNaN) { - var setLow = isReflexive || retHighest; - } else if (valIsUndef) { - setLow = isReflexive && (retHighest || typeof computed != 'undefined'); - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return nativeMin(high, MAX_ARRAY_INDEX); - } - /** * The base implementation of `_.uniq` without support for callback shorthands * and `this` binding. @@ -2675,13 +2690,12 @@ * returned by `keysFunc`. * * @private - * @param {Object} object The object to inspect. - * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. * @returns {Object} Returns the array of property values. */ - function baseValues(object, keysFunc) { + function baseValues(object, props) { var index = -1, - props = keysFunc(object), length = props.length, result = Array(length); @@ -2720,6 +2734,78 @@ return result; } + /** + * Performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. If + * `iteratee` is provided it is invoked for `value` and each element of + * `array` to compute their sort ranking. The iteratee is invoked with one + * argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee] The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest, instead + * of the lowest, index at which a value should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function binaryIndex(array, value, iteratee, retHighest) { + var low = 0, + high = array ? array.length : low; + + if (high && (iteratee || value !== value || typeof value == 'undefined' || high > HALF_MAX_ARRAY_LENGTH)) { + return baseBinaryIndex(array, value, iteratee, retHighest); + } + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if (retHighest ? (computed <= value) : (computed < value)) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + + /** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ + function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (typeof thisArg == 'undefined') { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + /** * Creates a clone of the given array buffer. * @@ -2879,7 +2965,7 @@ } // Juggle arguments. if (length > 3 && typeof arguments[length - 2] == 'function') { - var customizer = baseCallback(arguments[--length - 1], arguments[length--], 5); + var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); } else if (length > 2 && typeof arguments[length - 1] == 'function') { customizer = arguments[--length]; } @@ -2974,11 +3060,11 @@ * @param {Array} [partialsRight] The arguments to append to those provided to the new function. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [arity] The arity of `func`. * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. */ - function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary) { + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, @@ -3024,7 +3110,7 @@ if (!isCurryBound) { bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } - var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, newArity, ary); + var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity); result.placeholder = placeholder; return result; } @@ -3034,7 +3120,7 @@ func = thisBinding[key]; } if (argPos) { - args = arrayReduceRight(argPos, reorder, args); + args = reorder(args, argPos); } if (isAry && ary < args.length) { args.length = ary; @@ -3118,17 +3204,17 @@ * 16 - `_.curryRight` * 32 - `_.partial` * 64 - `_.partialRight` - * 128 - `_.ary` - * 256 - `_.rearg` + * 128 - `_.rearg` + * 256 - `_.ary` * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to be partially applied. * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [arity] The arity of `func`. * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. */ - function createWrapper(func, bitmask, thisArg, partials, holders, argPos, arity, ary) { + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { var isBindKey = bitmask & BIND_KEY_FLAG; if (!isBindKey && !isFunction(func)) { throw new TypeError(FUNC_ERROR_TEXT); @@ -3148,14 +3234,14 @@ partials = holders = null; } var data = !isBindKey && getData(func), - newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary]; + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; if (data && data !== true) { mergeData(newData, data); } - newData[8] = newData[8] == null + newData[9] = newData[9] == null ? (isBindKey ? 0 : newData[0].length) - : (nativeMax(newData[8] - length, 0) || 0); + : (nativeMax(newData[9] - length, 0) || 0); bitmask = newData[1]; if (bitmask == BIND_FLAG) { @@ -3169,6 +3255,160 @@ return setter(result, newData); } + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare to `other`. + * @param {Array} other The array to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing arrays. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, equalFunc, customizer, isWhere, stackA, stackB) { + var index = -1, + arrLength = array.length, + othLength = other.length, + result = true; + + if (arrLength != othLength && !(isWhere && othLength > arrLength)) { + return false; + } + // Deep compare the contents, ignoring non-numeric properties. + while (result && ++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + result = undefined; + if (customizer) { + result = isWhere + ? customizer(othValue, arrValue, index) + : customizer(arrValue, othValue, index); + } + if (typeof result == 'undefined') { + if (isWhere) { + var othIndex = othLength; + while (othIndex--) { + othValue = other[othIndex]; + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + if (result) { + break; + } + } + } else { + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + } + } + } + return !!result; + } + + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `[[Class]]`. + * + * **Note:** This function only supports comparing values with `[[Class]]` + * values of `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} value The object to compare to `other`. + * @param {Object} other The object to compare to `object`. + * @param {string} className The `[[Class]]` of the objects to compare. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByClass(object, other, className) { + switch (className) { + case boolClass: + case dateClass: + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + return +object == +other; + + case errorClass: + return object.name == other.name && object.message == other.message; + + case numberClass: + // Treat `NaN` vs. `NaN` as equal. + return (object != +object) + ? other != +other + // But, treat `-0` vs. `+0` as not equal. + : (object == 0 ? ((1 / object) == (1 / other)) : object == +other); + + case regexpClass: + case stringClass: + // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and + // treat strings primitives and string objects as equal. + return object == String(other); + } + return false; + } + + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare to `other`. + * @param {Object} other The object to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, equalFunc, customizer, isWhere, stackA, stackB) { + var objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; + + if (objLength != othLength && !isWhere) { + return false; + } + var hasCtor, + index = -1; + + while (++index < objLength) { + var key = objProps[index], + result = hasOwnProperty.call(other, key); + + if (result) { + var objValue = object[key], + othValue = other[key]; + + result = undefined; + if (customizer) { + result = isWhere + ? customizer(othValue, objValue, key) + : customizer(objValue, othValue, key); + } + if (typeof result == 'undefined') { + result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB); + } + } + if (!result) { + return false; + } + hasCtor || (hasCtor = key == 'constructor'); + } + if (!hasCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { + return false; + } + } + return true; + } + /** * Gets the appropriate "callback" function. If the `_.callback` method is * customized this function returns the custom method, otherwise it returns @@ -3243,7 +3483,7 @@ * * @private * @param {Array} array The array to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Array} Returns the initialized array clone. */ function initArrayClone(array, isDeep) { @@ -3269,7 +3509,7 @@ * * @private * @param {Object} object The object to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {null|Object} Returns the initialized object clone if an object * is cloneable, else `null`. */ @@ -3333,6 +3573,31 @@ (arrayLikeClasses[toString.call(value)] || (!lodash.support.argsClass && isArguments(value)))) || false; } + /** + * Checks if `func` is eligible for `this` binding. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is eligible, else `false`. + */ + function isBindable(func) { + var support = lodash.support, + result = !(support.funcNames ? func.name : support.funcDecomp); + + if (!result) { + var source = fnToString.call(func); + if (!support.funcNames) { + result = !reFuncName.test(source); + } + if (!result) { + // Check if `func` references the `this` keyword and store the result. + result = reThis.test(source) || isNative(func); + baseSetData(func, result); + } + } + return result; + } + /** * Checks if `value` is cloneable. * @@ -3417,13 +3682,13 @@ var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG), isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG), argPos = (isRearg ? data : source)[7], - ary = (isAry ? data : source)[9]; + ary = (isAry ? data : source)[8]; - var isCommon = !(bitmask >= ARY_FLAG && srcBitmask > bindFlags) && - !(bitmask > bindFlags && srcBitmask >= ARY_FLAG); + var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) && + !(bitmask > bindFlags && srcBitmask >= REARG_FLAG); var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) && - (bitmask < ARY_FLAG || ((isRearg || isAry) && argPos[0].length <= ary)); + (bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary)); // Exit early if metadata can't be merged. if (!(isCommon || isCombo)) { @@ -3449,22 +3714,18 @@ data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value); data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]); } - // Append argument positions. + // Use source `argPos` if available. value = source[7]; if (value) { - argPos = data[7]; - value = data[7] = baseSlice(value); - if (argPos) { - push.apply(value, argPos); - } - } - // Use source `arity` if one is not provided. - if (data[8] == null) { - data[8] = source[8]; + data[7] = baseSlice(value); } // Use source `ary` if it's smaller. if (srcBitmask & ARY_FLAG) { - data[9] = data[9] == null ? source[9] : nativeMin(data[9], source[9]); + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; } // Use source `func` and merge bitmasks. data[0] = source[0]; @@ -3557,7 +3818,7 @@ lastCalled = 0; return function(key, value) { - var stamp = now ? now() : 0, + var stamp = now(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; @@ -3626,7 +3887,7 @@ length = propsLength && object.length, support = lodash.support; - var allowIndexes = typeof length == 'number' && length > 0 && + var allowIndexes = length && isLength(length) && (isArray(object) || (support.nonEnumStrings && isString(object)) || (support.nonEnumArgs && isArguments(object))); @@ -4078,7 +4339,7 @@ * @memberOf _ * @category Array * @param {Array} array The array to flatten. - * @param {boolean} [isDeep=false] Specify a deep flatten. + * @param {boolean} [isDeep] Specify a deep flatten. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the new flattened array. * @example @@ -4156,7 +4417,7 @@ if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else if (fromIndex) { - var index = sortedIndex(array, value), + var index = binaryIndex(array, value), other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; @@ -4294,7 +4555,7 @@ if (typeof fromIndex == 'number') { index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; } else if (fromIndex) { - index = sortedLastIndex(array, value) - 1; + index = binaryIndex(array, value, null, true) - 1; var other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; } @@ -4315,9 +4576,8 @@ * * **Notes:** * - Unlike `_.without`, this method mutates `array`. - * - `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`, + * except that `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * for more details. * * @static @@ -4495,11 +4755,11 @@ } /** - * Uses a binary search to determine the lowest index at which a value should - * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iteratee function is provided it is invoked for `value` - * and each element of `array` to compute their sort ranking. The iteratee - * is bound to `thisArg` and invoked with one argument; (value). + * Uses a binary search to determine the lowest index at which `value` should + * be inserted into `array` in order to maintain its sort order. If an iteratee + * function is provided it is invoked for `value` and each element of `array` + * to compute their sort ranking. The iteratee is bound to `thisArg` and + * invoked with one argument; (value). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -4511,7 +4771,7 @@ * @static * @memberOf _ * @category Array - * @param {Array} array The array to inspect. + * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked * per iteration. If a property name or object is provided it is used to @@ -4540,19 +4800,19 @@ * // => 1 */ function sortedIndex(array, value, iteratee, thisArg) { - iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); - return baseSortedIndex(array, value, iteratee); + iteratee = iteratee == null ? iteratee : getCallback(iteratee, thisArg, 1); + return binaryIndex(array, value, iteratee); } /** * This method is like `_.sortedIndex` except that it returns the highest - * index at which a value should be inserted into a given sorted array in - * order to maintain the sort order of the array. + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. * * @static * @memberOf _ * @category Array - * @param {Array} array The array to inspect. + * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked * per iteration. If a property name or object is provided it is used to @@ -4566,8 +4826,8 @@ * // => 4 */ function sortedLastIndex(array, value, iteratee, thisArg) { - iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); - return baseSortedIndex(array, value, iteratee, true); + iteratee = iteratee == null ? iteratee : getCallback(iteratee, thisArg, 1); + return binaryIndex(array, value, iteratee, true); } /** @@ -4780,7 +5040,7 @@ * @alias unique * @category Array * @param {Array} array The array to inspect. - * @param {boolean} [isSorted=false] Specify the array is sorted. + * @param {boolean} [isSorted] Specify the array is sorted. * @param {Function|Object|string} [iteratee] The function invoked per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. @@ -4814,9 +5074,10 @@ iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; } - if (iteratee != null) { - iteratee = getCallback(iteratee, thisArg, 3); - } + iteratee = iteratee == null + ? iteratee + : getCallback(iteratee, thisArg, 3); + return (isSorted && getIndexOf() == baseIndexOf) ? sortedUniq(array, iteratee) : baseUniq(array, iteratee); @@ -4842,11 +5103,11 @@ */ function unzip(array) { var index = -1, - length = isObject(length = max(array, 'length')) && length.length || 0, + length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0, result = Array(length); while (++index < length) { - result[index] = pluck(array, index); + result[index] = arrayMap(array, baseProperty(index)); } return result; } @@ -5164,7 +5425,8 @@ * // => ['fred', 'pebbles'] */ function at(collection) { - if (!collection || isLength(collection.length)) { + var length = collection ? collection.length : 0; + if (isLength(length)) { collection = toIterable(collection); } return baseAt(collection, baseFlatten(arguments, false, false, 1)); @@ -5204,7 +5466,6 @@ */ function includes(collection, target, fromIndex) { var length = collection ? collection.length : 0; - if (!isLength(length)) { collection = values(collection); length = collection.length; @@ -5486,7 +5747,7 @@ function forEach(collection, iteratee, thisArg) { return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) ? arrayEach(collection, iteratee) - : baseEach(collection, baseCallback(iteratee, thisArg, 3)); + : baseEach(collection, bindCallback(iteratee, thisArg, 3)); } /** @@ -5509,15 +5770,15 @@ function forEachRight(collection, iteratee, thisArg) { return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, baseCallback(iteratee, thisArg, 3)); + : baseEachRight(collection, bindCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding - * value of each key is an array of the elements responsible for generating - * the key. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index|key, collection). + * each element of `collection` through `iteratee`. The corresponding value + * of each key is an array of the elements responsible for generating the key. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -6244,12 +6505,15 @@ */ function toArray(collection) { var length = collection ? collection.length : 0; - if (isLength(length)) { - return (lodash.support.unindexedChars && isString(collection)) - ? collection.split('') - : baseSlice(collection); + if (!isLength(length)) { + return values(collection); } - return values(collection); + if (!length) { + return []; + } + return (lodash.support.unindexedChars && isString(collection)) + ? collection.split('') + : baseSlice(collection); } /** @@ -6285,9 +6549,27 @@ /*------------------------------------------------------------------------*/ + /** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Date + * @example + * + * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); + * // => logs the number of milliseconds it took for the deferred function to be invoked + */ + var now = nativeNow || function() { + return new Date().getTime(); + }; + + /*------------------------------------------------------------------------*/ + /** * The opposite of `_.before`; this method creates a function that invokes - * `func` only after it is called `n` times. + * `func` once it is called `n` or more times. * * @static * @memberOf _ @@ -6347,7 +6629,7 @@ n = null; } n = n == null ? func.length : (+n || 0); - return createWrapper(func, ARY_FLAG, null, null, null, null, null, n); + return createWrapper(func, ARY_FLAG, null, null, null, null, n); } /** @@ -6402,7 +6684,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. + * @param {*} thisArg The `this` binding of `func`. * @param {...*} [args] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example @@ -6566,7 +6848,7 @@ if (guard && isIterateeCall(func, arity, guard)) { arity = null; } - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, arity); + var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity); result.placeholder = curry.placeholder; return result; } @@ -6612,7 +6894,7 @@ if (guard && isIterateeCall(func, arity, guard)) { arity = null; } - var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, guard ? null : arity); + var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity); result.placeholder = curryRight.placeholder; return result; } @@ -6809,11 +7091,7 @@ * // logs 'deferred' after one or more milliseconds */ function defer(func) { - if (!isFunction(func)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var args = arguments; - return setTimeout(function() { func.apply(undefined, slice(args, 1)); }, 1); + return baseDelay(func, 1, arguments, 1); } /** @@ -6833,11 +7111,7 @@ * // => logs 'later' after one second */ function delay(func, wait) { - if (!isFunction(func)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var args = arguments; - return setTimeout(function() { func.apply(undefined, slice(args, 2)); }, wait); + return baseDelay(func, wait, arguments, 2); } /** @@ -7037,7 +7311,9 @@ * initialize(); * // `initialize` invokes `createApplication` once */ - var once = createWrapper(before, PARTIAL_FLAG, null, [2]); + function once(func) { + return before(func, 2); + } /** * Creates a function that invokes `func` with `partial` arguments prepended @@ -7144,9 +7420,7 @@ */ function rearg(func) { var indexes = baseFlatten(arguments, false, false, 1); - return indexes.length - ? createWrapper(func, REARG_FLAG, null, null, null, [indexes]) - : createWrapper(func); + return createWrapper(func, REARG_FLAG, null, null, null, indexes); } /** @@ -7252,7 +7526,7 @@ * @memberOf _ * @category Lang * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @param {Function} [customizer] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `customizer`. * @returns {*} Returns the cloned value. @@ -7288,7 +7562,7 @@ customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; isDeep = false; } - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return baseClone(value, isDeep, customizer); } @@ -7336,7 +7610,7 @@ * // => false */ function cloneDeep(value, customizer, thisArg) { - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return baseClone(value, true, customizer); } @@ -7457,9 +7731,9 @@ } /** - * Checks if a collection is empty. A value is considered empty unless it is - * an array-like value with a length greater than `0` or an object with own - * enumerable properties. + * Checks if a value is empty. A value is considered empty unless it is an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. * * @static * @memberOf _ @@ -7529,16 +7803,18 @@ * var words = ['hello', 'goodbye']; * var otherWords = ['hi', 'goodbye']; * - * _.isEqual(words, otherWords, function() { - * return _.every(arguments, _.bind(RegExp.prototype.test, /^h(?:i|ello)$/)) || undefined; + * _.isEqual(words, otherWords, function(value, other) { + * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; * }); * // => true */ function isEqual(value, other, customizer, thisArg) { - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 3); - return (!customizer && isStrictComparable(value) && isStrictComparable(other)) - ? value === other - : baseIsEqual(value, other, customizer); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + if (!customizer && isStrictComparable(value) && isStrictComparable(other)) { + return value === other; + } + var result = customizer ? customizer(value, other) : undefined; + return typeof result == 'undefined' ? baseIsEqual(value, other, customizer) : !!result; } /** @@ -7559,7 +7835,7 @@ * // => false */ function isError(value) { - return (isObjectLike(value) && toString.call(value) == errorClass) || false; + return (isObjectLike(value) && typeof value.message == 'string' && toString.call(value) == errorClass) || false; } /** @@ -7656,6 +7932,67 @@ return type == 'function' || (value && type == 'object') || false; } + /** + * Performs a deep comparison between `object` and `source` to determine if + * `object` contains equivalent property values. If `customizer` is provided + * it is invoked to compare values. If `customizer` returns `undefined` + * comparisons are handled by the method instead. The `customizer` is bound + * to `thisArg` and invoked with three arguments; (value, other, key). + * + * **Note:** This method supports comparing properties of arrays, booleans, + * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions + * and DOM nodes are **not** supported. Provide a customizer function to extend + * support for comparing other values. + * + * @static + * @memberOf _ + * @category Lang + * @param {Object} source The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize comparing values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.isMatch(object, { 'age': 40 }); + * // => true + * + * _.isMatch(object, { 'age': 36 }); + * // => false + * + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatch(object, source, function(value, other) { + * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + * }); + * // => true + */ + function isMatch(object, source, customizer, thisArg) { + var props = keys(source), + length = props.length; + + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + if (!customizer && length == 1) { + var key = props[0], + value = source[key]; + + if (isStrictComparable(value)) { + return object != null && value === object[key] && hasOwnProperty.call(object, key); + } + } + var values = Array(length), + strictCompareFlags = Array(length); + + while (length--) { + value = values[length] = source[props[length]]; + strictCompareFlags[length] = isStrictComparable(value); + } + return baseIsMatch(object, props, values, strictCompareFlags, customizer); + } + /** * Checks if `value` is `NaN`. * @@ -7884,7 +8221,7 @@ * @returns {Object} Returns the destination object. * @example * - * _.assign({ 'user': 'fred' }, { 'age': 40 }, { 'status': 'busy' }); + * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred', 'status': 'busy' }); * // => { 'user': 'fred', 'age': 40, 'status': 'busy' } * * var defaults = _.partialRight(_.assign, function(value, other) { @@ -7941,9 +8278,6 @@ * object for all destination properties that resolve to `undefined`. Once a * property is set, additional defaults of the same property are ignored. * - * **Note:** See the [documentation example of `_.partialRight`](https://lodash.com/docs#partialRight) - * for a deep version of this method. - * * @static * @memberOf _ * @category Object @@ -8081,7 +8415,7 @@ */ function forIn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); } return baseFor(object, iteratee, keysIn); } @@ -8112,7 +8446,7 @@ * // => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z' */ function forInRight(object, iteratee, thisArg) { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); return baseForRight(object, iteratee, keysIn); } @@ -8138,7 +8472,7 @@ */ function forOwn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); } return baseForOwn(object, iteratee); } @@ -8162,7 +8496,7 @@ * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' */ function forOwnRight(object, iteratee, thisArg) { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); return baseForRight(object, iteratee, keys); } @@ -8213,7 +8547,7 @@ * @memberOf _ * @category Object * @param {Object} object The object to invert. - * @param {boolean} [multiValue=false] Allow multiple values per key. + * @param {boolean} [multiValue] Allow multiple values per key. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Object} Returns the new inverted object. * @example @@ -8282,8 +8616,7 @@ length = object.length; } if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof length == 'number' && length > 0) || - (lodash.support.enumPrototypes && typeof object == 'function')) { + (typeof object == 'function' ? lodash.support.enumPrototypes : (length && isLength(length)))) { return shimKeys(object); } return isObject(object) ? nativeKeys(object) : []; @@ -8319,7 +8652,7 @@ var length = object.length, support = lodash.support; - length = (typeof length == 'number' && length > 0 && + length = (length && isLength(length) && (isArray(object) || (support.nonEnumStrings && isString(object)) || (support.nonEnumArgs && isArguments(object))) && length) || 0; @@ -8406,7 +8739,7 @@ function mapValues(object, iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); - var result = {} + var result = {}; baseForOwn(object, function(value, key, object) { result[key] = iteratee(value, key, object); }); @@ -8461,7 +8794,8 @@ var merge = createAssigner(baseMerge); /** - * Creates a shallow clone of `object` excluding the specified properties. + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable properties of `object` that are not omitted. * Property names may be specified as individual arguments or as arrays of * property names. If `predicate` is provided it is invoked for each property * of `object` omitting the properties `predicate` returns truthy for. The @@ -8479,12 +8813,12 @@ * @returns {Object} Returns the new object. * @example * - * _.omit({ 'user': 'fred', 'age': 40 }, 'age'); + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.omit(object, 'age'); * // => { 'user': 'fred' } * - * _.omit({ 'user': 'fred', 'age': 40 }, function(value) { - * return typeof value == 'number'; - * }); + * _.omit(object, _.isNumber); * // => { 'user': 'fred' } */ function omit(object, predicate, thisArg) { @@ -8529,12 +8863,11 @@ } /** - * Creates a shallow clone of `object` composed of the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If `predicate` is provided it is invoked for each property - * of `object` picking the properties `predicate` returns truthy for. The - * predicate is bound to `thisArg` and invoked with three arguments; - * (value, key, object). + * Creates an object composed of the picked `object` properties. Property + * names may be specified as individual arguments or as arrays of property + * names. If `predicate` is provided it is invoked for each property of `object` + * picking the properties `predicate` returns truthy for. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, key, object). * * @static * @memberOf _ @@ -8547,12 +8880,12 @@ * @returns {Object} Returns the new object. * @example * - * _.pick({ 'user': 'fred', '_userid': 'fred1' }, 'user'); + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.pick(object, 'user'); * // => { 'user': 'fred' } * - * _.pick({ 'user': 'fred', '_userid': 'fred1' }, function(value, key) { - * return key.charAt(0) != '_'; - * }); + * _.pick(object, _.isString); * // => { 'user': 'fred' } */ function pick(object, predicate, thisArg) { @@ -8564,13 +8897,51 @@ : pickByArray(object, baseFlatten(arguments, false, false, 1)); } + /** + * Resolves the value of property `key` on `object`. If the value of `key` is + * a function it is invoked with the `this` binding of `object` and its result + * is returned, else the property value is returned. If the property value is + * `undefined` the `defaultValue` is used in its place. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {string} key The name of the property to resolve. + * @param {*} [defaultValue] The value returned if the property value + * resolves to `undefined`. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'user': 'fred', 'age': _.constant(40) }; + * + * _.result(object, 'user'); + * // => 'fred' + * + * _.result(object, 'age'); + * // => 40 + * + * _.result(object, 'status', 'busy'); + * // => 'busy' + * + * _.result(object, 'status', _.constant('busy')); + * // => 'busy' + */ + function result(object, key, defaultValue) { + var value = object == null ? undefined : object[key]; + if (typeof value == 'undefined') { + value = defaultValue; + } + return isFunction(value) ? value.call(object) : value; + } + /** * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable properties through `iteratee`, with each invocation potentially - * mutating the `accumulator` object. The `iteratee` is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, key, object). Iterator - * functions may exit iteration early by explicitly returning `false`. + * `accumulator` object which is the result of running each of its own enumerable + * properties through `iteratee`, with each invocation potentially mutating + * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked + * with four arguments; (accumulator, value, key, object). Iterator functions + * may exit iteration early by explicitly returning `false`. * * @static * @memberOf _ @@ -8623,7 +8994,7 @@ * @static * @memberOf _ * @category Object - * @param {Object} object The object to inspect. + * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * @@ -8638,7 +9009,7 @@ * // => [2, 1] (iteration order is not guaranteed) */ function values(object) { - return baseValues(object, keys); + return baseValues(object, keys(object)); } /** @@ -8648,7 +9019,7 @@ * @static * @memberOf _ * @category Object - * @param {Object} object The object to inspect. + * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * @@ -8663,7 +9034,71 @@ * // => [2, 1, 0] (iteration order is not guaranteed) */ function valuesIn(object) { - return baseValues(object, keysIn); + return baseValues(object, keysIn(object)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Produces a random number between `min` and `max` (inclusive). If only one + * argument is provided a number between `0` and the given number is returned. + * If `floating` is `true`, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. + * + * @static + * @memberOf _ + * @category Number + * @param {number} [min=0] The minimum possible value. + * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = null; + } + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (noMax && typeof min == 'boolean') { + floating = min; + min = 1; + } + else if (typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + (rand * (max - min + parseFloat('1e-' + (String(rand).length - 1)))), max); + } + return baseRandom(min, max); } /*------------------------------------------------------------------------*/ @@ -8796,7 +9231,7 @@ function escape(string) { // Reset `lastIndex` because in IE < 9 `String#replace` does not. string = string == null ? '' : String(string); - return string && (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string)) + return (string && reHasUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; } @@ -8817,7 +9252,7 @@ */ function escapeRegExp(string) { string = string == null ? '' : String(string); - return string && (reRegExpChars.lastIndex = 0, reRegExpChars.test(string)) + return (string && reHasRegExpChars.test(string)) ? string.replace(reRegExpChars, '\\$&') : string; } @@ -8942,6 +9377,44 @@ return string ? (string + createPad(string, length, chars)) : string; } + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, + * in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the ES5 implementation of `parseInt`. + * See the [ES5 spec](http://es5.github.io/#E) for more details. + * + * @static + * @memberOf _ + * @category String + * @param {string} string The string to parse. + * @param {number} [radix] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + function parseInt(string, radix, guard) { + if (guard && isIterateeCall(string, radix, guard)) { + radix = 0; + } + return nativeParseInt(string, radix); + } + // Fallback for environments with pre-ES5 implementations. + if (nativeParseInt(whitespace + '08') != 8) { + parseInt = function(string, radix, guard) { + // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and + // Chrome fails to trim leading whitespace characters. + // See https://code.google.com/p/v8/issues/detail?id=3109. + radix = (guard && isIterateeCall(string, radix, guard)) ? 0 : +radix; + string = trim(string); + return nativeParseInt(string, radix || (reHexPrefix.test(string) ? 16 : 10)); + }; + } + /** * Repeats the given string `n` times. * @@ -9050,7 +9523,7 @@ * [Lo-Dash's custom builds documentation](https://lodash.com/custom-builds). * * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](http://developer.chrome.com/stable/extensions/sandboxingEval.html). + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). * * @static * @memberOf _ @@ -9140,11 +9613,11 @@ options = otherOptions = null; } string = String(string == null ? '' : string); - options = assign({}, otherOptions || options, settings, assignOwnDefaults); + options = baseAssign(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); - var imports = assign({}, options.imports, settings.imports, assignOwnDefaults), + var imports = baseAssign(baseAssign({}, options.imports), settings.imports, assignOwnDefaults), importsKeys = keys(imports), - importsValues = values(imports); + importsValues = baseValues(imports, importsKeys); var isEscaping, isEvaluating, @@ -9162,8 +9635,11 @@ // Use a sourceURL for easier debugging. // See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl. - var sourceURL = 'sourceURL' in options ? options.sourceURL : ('/lodash/template/source[' + (++templateCounter) + ']'); - sourceURL = sourceURL ? ('//# sourceURL=' + sourceURL + '\n') : ''; + var sourceURL = '//# sourceURL=' + + ('sourceURL' in options + ? options.sourceURL + : ('/lodash/template/source[' + (++templateCounter) + ']') + ) + '\n'; string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); @@ -9254,11 +9730,12 @@ * // => 'fred' */ function trim(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -9284,11 +9761,12 @@ * // => 'fred-_-' */ function trimLeft(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -9314,11 +9792,12 @@ * // => '-_-fred' */ function trimRight(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -9428,7 +9907,7 @@ */ function unescape(string) { string = string == null ? '' : String(string); - return string && (reEscapedHtml.lastIndex = 0, reEscapedHtml.test(string)) + return (string && reHasEscapedHtml.test(string)) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string; } @@ -9452,10 +9931,10 @@ * // => ['fred', 'barney', '&', 'pebbles'] */ function words(string, pattern, guard) { - string = string != null && String(string); if (guard && isIterateeCall(string, pattern, guard)) { pattern = null; } + string = string != null && String(string); return (string && string.match(pattern || reWords)) || []; } @@ -9500,9 +9979,9 @@ * @alias iteratee * @category Utility * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. + * @param {*} [thisArg] The `this` binding of `func`. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new function. + * @returns {Function} Returns the callback. * @example * * var users = [ @@ -9572,8 +10051,8 @@ /** * Creates a "_.where" style predicate function which performs a deep comparison - * between a given object and the `source` object, returning `true` if the given - * object has equivalent property values, else `false`. + * between a given object and `source`, returning `true` if the given object + * has equivalent property values, else `false`. * * @static * @memberOf _ @@ -9596,54 +10075,7 @@ * // => { 'user': 'barney', 'age': 36 } */ function matches(source) { - var props = keys(source), - length = props.length; - - if (length == 1) { - var key = props[0], - value = source[key]; - - if (isStrictComparable(value)) { - return function(object) { - return object != null && value === object[key] && hasOwnProperty.call(object, key); - }; - } - } - var index = length, - values = Array(length), - strictCompareFlags = Array(length); - - while (index--) { - value = source[props[index]]; - var isStrict = isStrictComparable(value); - - values[index] = isStrict ? value : baseClone(value, true, clonePassthru); - strictCompareFlags[index] = isStrict; - } - return function(object) { - index = length; - if (object == null) { - return !index; - } - while (index--) { - if (strictCompareFlags[index] - ? values[index] !== object[props[index]] - : !hasOwnProperty.call(object, props[index]) - ) { - return false; - } - } - index = length; - while (index--) { - if (strictCompareFlags[index] - ? !hasOwnProperty.call(object, props[index]) - : !baseIsEqual(values[index], object[props[index]], null, true) - ) { - return false; - } - } - return true; - }; + return baseMatches(source, true); } /** @@ -9760,60 +10192,6 @@ // No operation performed. } - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Utility - * @example - * - * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked - */ - var now = nativeNow || function() { - return new Date().getTime(); - }; - - /** - * Converts `value` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, - * in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the ES5 implementation of `parseInt`. - * See the [ES5 spec](http://es5.github.io/#E) for more details. - * - * @static - * @memberOf _ - * @category Utility - * @param {string} value The value to parse. - * @param {number} [radix] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {number} Returns the converted integer. - * @example - * - * _.parseInt('08'); - * // => 8 - */ - function parseInt(value, radix, guard) { - if (guard && isIterateeCall(value, radix, guard)) { - radix = 0; - } - return nativeParseInt(value, radix); - } - // Fallback for environments with pre-ES5 implementations. - if (nativeParseInt(whitespace + '08') != 8) { - parseInt = function(value, radix, guard) { - // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and - // Chrome fails to trim leading whitespace characters. - // See https://code.google.com/p/v8/issues/detail?id=3109. - value = trim(value); - radix = (guard && isIterateeCall(value, radix, guard)) ? 0 : +radix; - return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10)); - }; - } - /** * Creates a "_.pluck" style function which returns the property value * of `key` on a given object. @@ -9839,10 +10217,7 @@ * // => ['barney', 'fred'] */ function property(key) { - key = String(key); - return function(object) { - return object == null ? undefined : object[key]; - }; + return baseProperty(String(key)); } /** @@ -9870,68 +10245,6 @@ }; } - /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number is returned. - * If `floating` is `true`, or either `min` or `max` are floats, a floating-point - * number is returned instead of an integer. - * - * @static - * @memberOf _ - * @category Utility - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. - * @param {boolean} [floating=false] Specify returning a floating-point number. - * @returns {number} Returns the random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(min, max, floating) { - if (floating && isIterateeCall(min, max, floating)) { - max = floating = null; - } - var noMin = min == null, - noMax = max == null; - - if (floating == null) { - if (noMax && typeof min == 'boolean') { - floating = min; - min = 1; - } - else if (typeof max == 'boolean') { - floating = max; - noMax = true; - } - } - if (noMin && noMax) { - max = 1; - noMax = false; - } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; - } - if (floating || min % 1 || max % 1) { - var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + (String(rand).length - 1)))), max); - } - return baseRandom(min, max); - } - /** * Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. If `start` is less than `end` a @@ -9990,47 +10303,6 @@ return result; } - /** - * Resolves the value of property `key` on `object`. If `key` is a function - * it is invoked with the `this` binding of `object` and its result returned, - * else the property value is returned. If `object` is `null` or `undefined` - * then `undefined` is returned. If a default value is provided it is returned - * if the property value resolves to `undefined`. - * - * @static - * @memberOf _ - * @category Utility - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to resolve. - * @param {*} [defaultValue] The value returned if the property value - * resolves to `undefined`. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { - * 'user': 'fred', - * 'age': function() { - * return 40; - * } - * }; - * - * _.result(object, 'user'); - * // => 'fred' - * - * _.result(object, 'age'); - * // => 40 - * - * _.result(object, 'status', 'busy'); - * // => 'busy' - */ - function result(object, key, defaultValue) { - var value = object == null ? undefined : object[key]; - if (typeof value == 'undefined') { - return defaultValue; - } - return isFunction(value) ? object[key]() : value; - } - /** * Invokes the iteratee function `n` times, returning an array of the results * of each invocation. The `iteratee` is bound to `thisArg` and invoked with @@ -10062,11 +10334,10 @@ if (n < 1 || !nativeIsFinite(n)) { return []; } - iteratee = baseCallback(iteratee, thisArg, 1); - var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); + iteratee = bindCallback(iteratee, thisArg, 1); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { result[index] = iteratee(index); @@ -10264,6 +10535,7 @@ lodash.isError = isError; lodash.isFinite = isFinite; lodash.isFunction = isFunction; + lodash.isMatch = isMatch; lodash.isNaN = isNaN; lodash.isNative = isNative; lodash.isNull = isNull; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 4dd76ff1c..b21423df8 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,83 +4,85 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function A(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Zt(n){for(var t=-1,r=n.length,e=ro;++to(t,a)&&e.push(a);return e}function or(n,t){var r=n?n.length:0;if(!Zr(r))return gr(n,t);for(var e=-1,u=re(n);++ec))return false}else{var g=p&&Ou.call(n,"__wrapped__"),h=h&&Ou.call(t,"__wrapped__");if(g||h)return yr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!a&&!p){switch(f){case _t:case bt:return+n==+t;case At:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Et:case It:return n==_u(t)}return false}if(Bt.support.argsClass||(c=Pe(n),i=Pe(t)),g=c?yu:n.constructor,f=i?yu:t.constructor,a){if(g.prototype.name!=f.prototype.name)return false -}else if(p=!c&&Ou.call(n,"constructor"),h=!i&&Ou.call(t,"constructor"),p!=h||!p&&g!=f&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof f=="function"&&f instanceof f))return false;if(g=a?["message","name"]:Eo(n),f=a?g:Eo(t),c&&g.push("length"),i&&f.push("length"),c=g.length,p=f.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),f=u.length;f--;)if(u[f]==n)return o[f]==t;if(u.push(n),o.push(t),i=true,l)for(;i&&++fe(a,s)&&((t||i)&&a.push(s),f.push(c))}return f}function Ir(n,t){for(var r=-1,e=t(n),u=e.length,o=su(u);++rt||null==r)return r;if(3=i&&r<=a&&(e=L&&t>u||e>u&&t>=L)||o)&&(t&R&&(n[2]=h[2],r|=e&R?0:F),(e=h[3])&&(u=n[3],n[3]=u?Rr(u,e,h[4]):f(e),n[4]=u?A(n[3],Y):f(h[4])),(e=h[5])&&(u=n[5],n[5]=u?Sr(u,e,h[6]):f(e),n[6]=u?A(n[5],Y):f(h[6])),(e=h[7])&&(o=n[7],e=n[7]=f(e),o&&Lu.apply(e,o)),null==n[8]&&(n[8]=h[8]),t&L&&(n[9]=null==n[9]?h[9]:Ju(n[9],h[9])),n[0]=h[0],n[1]=r) -}return n[8]=null==n[8]?l?0:n[0].length:Gu(n[8]-c,0)||0,t=n[1],(h?so:go)(t==R?Wr(n[0],n[2]):t!=N&&t!=(R|N)||n[4].length?Lr.apply(null,n):Pr.apply(null,n),n)}function zr(n,t,r){var e=Bt.callback||eu,e=e===eu?tr:e;return r?e(n,t,r):e}function Dr(n,t,r){var e=Bt.indexOf||ae,e=e===ae?l:e;return n?e(n,t,r):e}function Mr(n,t){var r=-1,e=n.length,u=new n.constructor(e);if(!t)for(;++rt?0:t)}function ue(n,t,r){return(r?Yr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,fe(n,0,0>t?0:t)}function oe(n,t,r){var e=-1,u=n?n.length:0;for(t=zr(t,r,3);++er?Gu(e+r,0):r||0;else if(r)return r=ce(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return l(n,t,r)}function le(n){return ee(n,1)}function fe(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&Yr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return f(n);for(u=t>r?0:r-t,r=su(u);++er?Gu(e+r,0):r||0:0,typeof n=="string"||!wo(n)&&Ye(n)?ri||r===to&&r===a)&&(i=r,a=n) -}),a}function je(n,t){return xe(n,cu(t))}function Ee(n,t,r,e){return(wo(n)?u:xr)(n,zr(t,e,4),r,3>arguments.length,or)}function Ie(n,t,r,e){return(wo(n)?o:xr)(n,zr(t,e,4),r,3>arguments.length,ir)}function Oe(n){n=te(n);for(var t=-1,r=n.length,e=su(r);++t=r||r>t?(a&&Wu(a),r=p,a=s=p=C,r&&(h=Ro(),l=n.apply(c,i),s||a||(i=c=null))):s=Bu(e,r)}function u(){s&&Wu(s),a=s=p=C,(v||g!==t)&&(h=Ro(),l=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,f=Ro(),c=this,p=v&&(s||!d),false===g)var r=d&&!s;else{a||d||(h=f);var o=g-(f-h),y=0>=o||o>g;y?(a&&(a=Wu(a)),h=f,l=n.apply(c,i)):a||(a=Bu(u,o))}return y&&s?s=Wu(s):s||t===g||(s=Bu(e,t)),r&&(y=true,l=n.apply(c,i)),!y||s||a||(i=c=null),l}var i,a,l,f,c,s,p,h=0,g=false,v=true;if(!De(n))throw new bu(V);if(t=0>t?0:t,true===r)var d=true,v=false; -else Me(r)&&(d=r.leading,g="maxWait"in r&&Gu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Wu(s),a&&Wu(a),a=s=p=C},o}function Ne(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,De))throw new bu(V);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Ue(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o -}if(!De(n)||t&&!De(t))throw new bu(V);return r.cache=new Ue.Cache,r}function Le(n){var t=fe(arguments,1),r=A(t,Le.placeholder);return Br(n,N,null,t,r)}function $e(n){var t=fe(arguments,1),r=A(t,$e.placeholder);return Br(n,U,null,t,r)}function Pe(n){return Zr(w(n)?n.length:C)&&ku.call(n)==yt||false}function Be(n){return n&&1===n.nodeType&&w(n)&&(Bt.support.nodeClass?-1t||null==n||!Yu(t))return r;n=_u(n);do t%2&&(r+=n),t=Nu(t/2),n+=n;while(t);return r}function nu(n,t,r){return(n=null==n?"":_u(n))?(r?Yr(n,t,r):null==t)?n.slice(j(n),E(n)+1):(t=_u(t),n.slice(p(n,t),h(n,t)+1)):n}function tu(n,t,r){return n=null!=n&&_u(n),r&&Yr(n,t,r)&&(t=null),n&&n.match(t||ht)||[]}function ru(n){try{return n()}catch(t){return ze(t)?t:hu(t)}}function eu(n,t,r){return r&&Yr(n,t,r)&&(t=null),tr(n,t)}function uu(n){return function(){return n}}function ou(n){return n}function iu(n){var t=Eo(n),r=t.length; -if(1==r){var e=t[0],u=n[e];if(Gr(u))return function(n){return null!=n&&u===n[e]&&Ou.call(n,e)}}for(var o=r,i=su(r),a=su(r);o--;){var u=n[t[o]],l=Gr(u);i[o]=l?u:rr(u,true,kr),a[o]=l}return function(n){if(o=r,null==n)return!o;for(;o--;)if(a[o]?i[o]!==n[t[o]]:!Ou.call(n,t[o]))return false;for(o=r;o--;)if(a[o]?!Ou.call(n,t[o]):!yr(i[o],n[t[o]],null,true))return false;return true}}function au(n,t,r){var e=true,u=Me(t),o=null==r,i=o&&u&&Eo(t),a=i&&dr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=dr(t,Eo(t))),false===r?e=false:Me(r)&&"chain"in r&&(e=r.chain),r=-1,u=De(n); -for(o=a.length;++r=z)return r}else n=0;return so(r,e)}}(),vo=Fr(function(n,t,r){Ou.call(n,r)?++n[r]:n[r]=1}),yo=Fr(function(n,t,r){Ou.call(n,r)?n[r].push(t):n[r]=[t]}),mo=Fr(function(n,t,r){n[r]=t}),_o=Fr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]] -}),bo=Br(ke,N,null,[2]);co.argsClass||(Pe=function(n){return Zr(w(n)?n.length:C)&&Ou.call(n,"callee")&&!$u.call(n,"callee")||false});var wo=Vu||function(n){return w(n)&&Zr(n.length)&&ku.call(n)==mt||false};co.dom||(Be=function(n){return n&&1===n.nodeType&&w(n)&&!Ao(n)||false});var xo=Hu||function(n){return typeof n=="number"&&Yu(n)};(De(/x/)||Du&&!De(Du))&&(De=function(n){return ku.call(n)==xt});var Ao=Uu?function(n){if(!n||ku.call(n)!=jt||!Bt.support.argsClass&&Pe(n))return false;var t=n.valueOf,r=qe(t)&&(r=Uu(t))&&Uu(r); -return r?n==r||Uu(n)==r:Qr(n)}:Qr,jo=Tr(Qt),Eo=Zu?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},Bt.ary=function(n,t,r){return r&&Yr(n,t,r)&&(t=null),t=null==t?n.length:+t||0,Br(n,L,null,null,null,null,null,t)},Bt.assign=jo,Bt.at=function(n){return(!n||Zr(n.length))&&(n=te(n)),nr(n,cr(arguments,false,false,1))},Bt.before=ke,Bt.bind=Re,Bt.bindAll=function(n){for(var t=n,r=1(s?Vt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Vt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i)}return c},Bt.invert=function(n,t,r){r&&Yr(n,t,r)&&(t=null),r=-1;for(var e=Eo(n),u=e.length,o={};++rt?0:t)},Bt.takeRight=function(n,t,r){return(r?Yr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,fe(n,0>t?0:t) -},Bt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=zr(t,r,3);e--&&t(n[e],e,n););return fe(n,e+1)},Bt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=zr(t,r,3);++en||!Yu(n))return[];t=tr(t,r,1),r=-1;for(var e=su(Ju(n,eo));++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Bt.escape=function(n){return(n=null==n?"":_u(n))&&(Q.lastIndex=0,Q.test(n))?n.replace(Q,y):n},Bt.escapeRegExp=He,Bt.every=ye,Bt.find=_e,Bt.findIndex=oe,Bt.findKey=function(n,t,r){return t=zr(t,r,3),fr(n,t,gr,true) -},Bt.findLast=function(n,t,r){return t=zr(t,r,3),fr(n,t,ir)},Bt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=zr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Bt.findLastKey=function(n,t,r){return t=zr(t,r,3),fr(n,t,vr,true)},Bt.findWhere=function(n,t){return _e(n,iu(t))},Bt.first=ie,Bt.has=function(n,t){return n?Ou.call(n,t):false},Bt.identity=ou,Bt.includes=de,Bt.indexOf=ae,Bt.isArguments=Pe,Bt.isArray=wo,Bt.isBoolean=function(n){return true===n||false===n||w(n)&&ku.call(n)==_t||false},Bt.isDate=function(n){return w(n)&&ku.call(n)==bt||false -},Bt.isElement=Be,Bt.isEmpty=function(n){if(null==n)return true;var t=n.length;return Zr(t)&&(wo(n)||Ye(n)||Pe(n)||w(n)&&De(n.splice))?!t:!Eo(n).length},Bt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&tr(r,e,3),!r&&Gr(n)&&Gr(t)?n===t:yr(n,t,r)},Bt.isError=ze,Bt.isFinite=xo,Bt.isFunction=De,Bt.isNaN=function(n){return Ke(n)&&n!=+n},Bt.isNative=qe,Bt.isNull=function(n){return null===n},Bt.isNumber=Ke,Bt.isObject=Me,Bt.isPlainObject=Ao,Bt.isRegExp=Ve,Bt.isString=Ye,Bt.isUndefined=function(n){return typeof n=="undefined" -},Bt.kebabCase=Co,Bt.last=function(n){var t=n?n.length:0;return t?n[t-1]:C},Bt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Gu(e+r,0):Ju(r||0,e-1))+1;else if(r)return u=se(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Bt.max=Ae,Bt.min=function(n,t,r){r&&Yr(n,t,r)&&(t=null);var e=null==t,u=e&&wo(n),o=!u&&Ye(n);if(e&&!o)return Zt(u?n:te(n));var i=ro,a=i;return t=e&&o?s:zr(t,r,3),or(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Bt.template=function(n,t,r){var e=Bt.templateSettings;r&&Yr(n,t,r)&&(t=r=null),n=_u(null==n?"":n),t=jo({},r||t,e,Ht),r=jo({},t.imports,e.imports,Ht); -var u,o,i=Eo(r),a=Je(r),l=0;r=t.interpolate||ft;var f="__p+='";if(r=mu((t.escape||ft).source+"|"+r.source+"|"+(r===rt?et:ft).source+"|"+(t.evaluate||ft).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),f+=n.slice(l,c).replace(pt,m),r&&(u=true,f+="'+__e("+r+")+'"),a&&(o=true,f+="';"+a+";\n__p+='"),e&&(f+="'+((__t=("+e+"))==null?'':__t)+'"),l=c+t.length,t}),f+="';",(t=t.variable)||(f="with(obj){"+f+"}"),f=(o?f.replace(G,""):f).replace(J,"$1").replace(X,"$1;"),f="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}",t=ru(function(){return gu(i,"return "+f).apply(C,a) -}),t.source=f,ze(t))throw t;return t},Bt.trim=nu,Bt.trimLeft=function(n,t,r){return(n=null==n?"":_u(n))?(r?Yr(n,t,r):null==t)?n.slice(j(n)):(t=_u(t),n.slice(p(n,t))):n},Bt.trimRight=function(n,t,r){return(n=null==n?"":_u(n))?(r?Yr(n,t,r):null==t)?n.slice(0,E(n)+1):(t=_u(t),n.slice(0,h(n,t)+1)):n},Bt.trunc=function(n,t,r){r&&Yr(n,t,r)&&(t=null);var e=P;if(r=B,Me(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?_u(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":_u(n),e>=n.length)return n; -if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(Ve(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=mu(u.source,(ut.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Bt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Bt.sample(t,n)}):Bt.sample(this.value())},Bt.VERSION=k,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Bt[n].placeholder=Bt}),n(["filter","map","takeWhile"],function(n,t){var r=t==M; -Dt.prototype[n]=function(n,e){n=zr(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==K&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";Dt.prototype[n]=function(e){e=null==e?1:Gu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Ju(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},Dt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse() -},Dt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");Dt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Dt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?iu:cu;Dt.prototype[n]=function(n){return this[r](e(n))}}),Dt.prototype.dropWhile=function(n,t){n=zr(n,t,3);var r,e,u=0>this.dir; -return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},Dt.prototype.reject=function(n,t){return n=zr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Dt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},gr(Dt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Bt.prototype[t]=function(){function e(n){return n=[n],Lu.apply(n,o),Bt[t].apply(Bt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,a=!!this.__actions__.length,l=u instanceof Dt,f=l&&!a; -return r&&!i?f?n.call(u):Bt[t](this.value()):l||wo(u)?(u=n.apply(f?u:new Dt(this),o),r||!a&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:Bt,name:"thru"}),new zt(u,i)):this.thru(e)}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=wu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n),u=co.spliceObjects||!/^(?:pop|shift|splice)$/.test(n)?t:function(){var n=t.apply(this,arguments);return 0===this.length&&delete this[0],n -};Bt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?u.apply(this.value(),n):this[r](function(t){return u.apply(t,n)})}}),Dt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new Dt(this.wrapped);return e.actions=n?f(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?f(t):null,e.takeCount=this.takeCount,e.views=r?f(r):null,e},Dt.prototype.reverse=function(){var n=this.filtered,t=n?new Dt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t -},Dt.prototype.value=function(){var n=this.wrapped.value();if(!wo(n))return Or(n,this.actions);var t,r=this.dir,e=0>r,u=n.length;t=u;for(var o=this.views,i=0,a=-1,l=o?o.length:0;++a"'`]/g,nt=/<%-([\s\S]+?)%>/g,tt=/<%([\s\S]+?)%>/g,rt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ut=/\w*$/,ot=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,at=/^\[object .+?Constructor\]$/,lt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ft=/($^)/,ct=/[.*+?^${}()|[\]\/\\]/g,st=/\bthis\b/,pt=/['\n\r\u2028\u2029\\]/g,ht=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),gt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",vt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),dt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),yt="[object Arguments]",mt="[object Array]",_t="[object Boolean]",bt="[object Date]",wt="[object Error]",xt="[object Function]",At="[object Number]",jt="[object Object]",Et="[object RegExp]",It="[object String]",Ot="[object ArrayBuffer]",Ct="[object Float32Array]",kt="[object Float64Array]",Rt="[object Int8Array]",St="[object Int16Array]",Ft="[object Int32Array]",Tt="[object Uint8Array]",Wt="[object Uint8ClampedArray]",Nt="[object Uint16Array]",Ut="[object Uint32Array]",Lt={}; -Lt[yt]=Lt[mt]=Lt[Ct]=Lt[kt]=Lt[Rt]=Lt[St]=Lt[Ft]=Lt[Tt]=Lt[Wt]=Lt[Nt]=Lt[Ut]=true,Lt[Ot]=Lt[_t]=Lt[bt]=Lt[wt]=Lt[xt]=Lt["[object Map]"]=Lt[At]=Lt[jt]=Lt[Et]=Lt["[object Set]"]=Lt[It]=Lt["[object WeakMap]"]=false;var $t={};$t[yt]=$t[mt]=$t[Ot]=$t[_t]=$t[bt]=$t[Ct]=$t[kt]=$t[Rt]=$t[St]=$t[Ft]=$t[At]=$t[jt]=$t[Et]=$t[It]=$t[Tt]=$t[Wt]=$t[Nt]=$t[Ut]=true,$t[wt]=$t[xt]=$t["[object Map]"]=$t["[object Set]"]=$t["[object WeakMap]"]=false;var Pt={leading:false,maxWait:0,trailing:false},Bt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},zt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Dt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Mt={"function":true,object:true},qt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Kt=Mt[typeof window]&&window!==(this&&this.window)?window:this,Vt=Mt[typeof exports]&&exports&&!exports.nodeType&&exports,Yt=Mt[typeof module]&&module&&!module.nodeType&&module,Zt=Vt&&Yt&&typeof global=="object"&&global; -!Zt||Zt.global!==Zt&&Zt.window!==Zt&&Zt.self!==Zt||(Kt=Zt);var Gt=Yt&&Yt.exports===Vt&&Vt,Jt=function(){try{String({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Xt=O();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Kt._=Xt, define(function(){return Xt})):Vt&&Yt?Gt?(Yt.exports=Xt)._=Xt:Vt._=Xt:Kt._=Xt}).call(this); \ No newline at end of file +return r}function i(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function A(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Xt(n){for(var t=-1,r=n.length,e=lo;++to(t,a)&&e.push(a);return e}function fr(n,t){var r=n?n.length:0;if(!oe(r))return yr(n,t);for(var e=-1,u=pe(n);++ee(a,s)&&((t||i)&&a.push(s),l.push(c))}return l}function Ur(n,t){for(var r=-1,e=t.length,u=yu(e);++rpo)){u=r,u=null==u?pu:u,t=u(t),o=0,r=n.length;for(var i=t!==t,a=typeof t=="undefined";o>>1,i=n[r],(e?i<=t:it||null==r)return r; +if(3=o&&r<=i&&(e=L&&t>u||e>u&&t>=L)||o)&&(t&k&&(n[2]=h[2],r|=e&k?0:U),(e=h[3])&&(u=n[3],n[3]=u?$r(u,e,h[4]):l(e),n[4]=u?A(n[3],Y):l(h[4])),(e=h[5])&&(u=n[5],n[5]=u?Pr(u,e,h[6]):l(e),n[6]=u?A(n[5],Y):l(h[6])),(e=h[7])&&(n[7]=l(e)),t&$&&(n[8]=null==n[8]?h[8]:eo(n[8],h[8])),null==n[9]&&(n[9]=h[9]),n[0]=h[0],n[1]=r) +}return n[9]=null==n[9]?f?0:n[0].length:ro(n[9]-c,0)||0,t=n[1],(h?wo:jo)(t==k?Dr(n[0],n[2]):t!=W&&t!=(k|W)||n[4].length?Kr.apply(null,n):Yr.apply(null,n),n)}function Gr(n,t,r,e,u,o,i){var a=-1,f=n.length,l=t.length,c=true;if(f!=l&&(!u||l<=f))return false;for(;c&&++at?0:t)}function ge(n,t,r){return(r?ue(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,_e(n,0,0>t?0:t)}function ve(n,t,r){var e=-1,u=n?n.length:0;for(t=Hr(t,r,3);++er?ro(e+r,0):r||0;else if(r)return r=Tr(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return f(n,t,r)}function me(n){return he(n,1) +}function _e(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&ue(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=yu(u);++e>>0,u=yu(r);++tr?ro(e+r,0):r||0:0,typeof n=="string"||!ko(n)&&Qe(n)?rarguments.length,fr)}function Ue(n,t,r,e){return(ko(n)?o:Rr)(n,Hr(t,e,4),r,3>arguments.length,lr)}function Fe(n){n=se(n);for(var t=-1,r=n.length,e=yu(r);++t=r||r>t?(a&&Du(a),r=p,a=s=p=C,r&&(h=Ro(),f=n.apply(c,i),s||a||(i=c=null))):s=Zu(e,r)}function u(){s&&Du(s),a=s=p=C,(v||g!==t)&&(h=Ro(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=Ro(),c=this,p=v&&(s||!d),false===g)var r=d&&!s;else{a||d||(h=l);var o=g-(l-h),y=0>=o||o>g;y?(a&&(a=Du(a)),h=l,f=n.apply(c,i)):a||(a=Zu(u,o))}return y&&s?s=Du(s):s||t===g||(s=Zu(e,t)),r&&(y=true,f=n.apply(c,i)),!y||s||a||(i=c=null),f}var i,a,f,l,c,s,p,h=0,g=false,v=true;if(!Ze(n))throw new Ou(V);if(t=0>t?0:t,true===r)var d=true,v=false; +else Ge(r)&&(d=r.leading,g="maxWait"in r&&ro(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Du(s),a&&Du(a),a=s=p=C},o}function ze(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Ze))throw new Ou(V);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function De(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o +}if(!Ze(n)||t&&!Ze(t))throw new Ou(V);return r.cache=new De.Cache,r}function Me(n){var t=_e(arguments,1),r=A(t,Me.placeholder);return Zr(n,W,null,t,r)}function qe(n){var t=_e(arguments,1),r=A(t,qe.placeholder);return Zr(n,N,null,t,r)}function Ke(n){return oe(w(n)?n.length:C)&&Lu.call(n)==_t||false}function Ve(n){return n&&1===n.nodeType&&w(n)&&(Dt.support.nodeClass?-1t||null==n||!no(t))return r;n=Eu(n);do t%2&&(r+=n),t=Mu(t/2),n+=n;while(t);return r}function au(n,t,r){var e=n;return(n=null==n?"":Eu(n))?(r?ue(e,t,r):null==t)?n.slice(j(n),E(n)+1):(t=Eu(t),n.slice(p(n,t),h(n,t)+1)):n}function fu(n,t,r){return r&&ue(n,t,r)&&(t=null),(n=null!=n&&Eu(n))&&n.match(t||vt)||[]}function lu(n){try{return n()}catch(t){return Ye(t)?t:_u(t)}}function cu(n,t,r){return r&&ue(n,t,r)&&(t=null),ur(n,t)}function su(n){return function(){return n +}}function pu(n){return n}function hu(n){return Er(n,true)}function gu(n,t,r){var e=true,u=Ge(t),o=null==r,i=o&&u&&To(t),a=i&&_r(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=_r(t,To(t))),false===r?e=false:Ge(r)&&"chain"in r&&(e=r.chain),r=-1,u=Ze(n);for(o=a.length;++r>>1,ho=Hu?Hu.BYTES_PER_ELEMENT:0,go=wu.pow(2,53)-1,vo=Xu&&new Xu,yo={};yo[kt]=x.Float32Array,yo[St]=x.Float64Array,yo[Ut]=x.Int8Array,yo[Ft]=x.Int16Array,yo[Tt]=x.Int32Array,yo[Wt]=x.Uint8Array,yo[Nt]=x.Uint8ClampedArray,yo[Lt]=x.Uint16Array,yo[$t]=x.Uint32Array; +var mo={};mo[bt]=mo[xt]=mo[Et]={constructor:true,toLocaleString:true,toString:true,valueOf:true},mo[wt]=mo[Ct]={constructor:true,toString:true,valueOf:true},mo[At]=mo[jt]=mo[It]={constructor:true,toString:true},mo[Ot]={constructor:true},n(mt,function(n){for(var t in mo)if(Tu.call(mo,t)){var r=mo[t];r[n]=Tu.call(r,n)}});var _o=Dt.support={};!function(n){function t(){this.x=1}var r={0:1,length:1},e=[];t.prototype={valueOf:1,y:1};for(var u in new t)e.push(u);_o.argsClass=Lu.call(arguments)==_t,_o.enumErrorProps=Vu.call(Cu,"message")||Vu.call(Cu,"name"),_o.enumPrototypes=Vu.call(t,"prototype"),_o.funcDecomp=!Je(x.WinRTError)&&ht.test(I),_o.funcNames=typeof bu.name=="string",_o.nodeClass=Lu.call(Su)!=Ot,_o.nonEnumStrings=!Vu.call("x",0),_o.nonEnumShadows=!/valueOf/.test(e),_o.ownLast="x"!=e[0],_o.spliceObjects=(Gu.call(r,0,1),!r[0]),_o.unindexedChars="xx"!="x"[0]+Au("x")[0]; +try{_o.dom=11===Su.createDocumentFragment().nodeType}catch(o){_o.dom=false}try{_o.nonEnumArgs=!Vu.call(arguments,1)}catch(i){_o.nonEnumArgs=true}}(0,0),Dt.templateSettings={escape:tt,evaluate:rt,interpolate:et,variable:"",imports:{_:Dt}};var bo=function(){function n(){}return function(t){if(Ge(t)){n.prototype=t;var r=new n;n.prototype=null}return r||x.Object()}}(),wo=vo?function(n,t){return vo.set(n,t),n}:pu;Bu||(Nr=Pu&&Ju?function(n){var t=n.byteLength,r=Hu?Mu(t/ho):0,e=r*ho,u=new Pu(t);if(r){var o=new Hu(u,0,r); +o.set(new Hu(n,0,r))}return t!=e&&(o=new Ju(u,e),o.set(new Ju(n,e))),u}:su(null));var xo=Yu?function(n){return new Vt(n)}:su(null),Ao=vo?function(n){return vo.get(n)}:vu,jo=function(){var n=0,t=0;return function(r,e){var u=Ro(),o=D-(u-t);if(t=u,0=z)return r}else n=0;return wo(r,e)}}(),Eo=Br(function(n,t,r){Tu.call(n,r)?++n[r]:n[r]=1}),Oo=Br(function(n,t,r){Tu.call(n,r)?n[r].push(t):n[r]=[t]}),Io=Br(function(n,t,r){n[r]=t}),Co=Br(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]] +}),Ro=uo||function(){return(new mu).getTime()};_o.argsClass||(Ke=function(n){return oe(w(n)?n.length:C)&&Tu.call(n,"callee")&&!Vu.call(n,"callee")||false});var ko=Qu||function(n){return w(n)&&oe(n.length)&&Lu.call(n)==bt||false};_o.dom||(Ve=function(n){return n&&1===n.nodeType&&w(n)&&!Uo(n)||false});var So=oo||function(n){return typeof n=="number"&&no(n)};(Ze(/x/)||Ju&&!Ze(Ju))&&(Ze=function(n){return Lu.call(n)==jt});var Uo=qu?function(n){if(!n||Lu.call(n)!=Ot||!Dt.support.argsClass&&Ke(n))return false;var t=n.valueOf,r=Je(t)&&(r=qu(t))&&qu(r); +return r?n==r||qu(n)==r:le(n)}:le,Fo=zr(rr),To=to?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||(typeof n=="function"?Dt.support.enumPrototypes:r&&oe(r))?ce(n):Ge(n)?to(n):[]}:ce,Wo=zr(Or),No=Mr(function(n,t,r){return t=t.toLowerCase(),r?n+t.charAt(0).toUpperCase()+t.slice(1):t}),Lo=Mr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()});8!=io(dt+"08")&&(ou=function(n,t,r){return t=r&&ue(n,t,r)?0:+t,n=au(n),io(n,t||(at.test(n)?16:10))});var $o=Mr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase() +});return Mt.prototype=Dt.prototype,Kt.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},Kt.prototype.get=function(n){return"__proto__"==n?C:this.__data__[n]},Kt.prototype.has=function(n){return"__proto__"!=n&&Tu.call(this.__data__,n)},Kt.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this},Vt.prototype.push=function(n){var t=this.data,r=typeof n;"number"==r?t[r][n]=true:t.set.add(n)},De.Cache=Kt,Dt.after=function(n,t){if(!Ze(t)){if(!Ze(n))throw new Ou(V); +var r=n;n=t,t=r}return n=no(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Dt.ary=function(n,t,r){return r&&ue(n,t,r)&&(t=null),t=null==t?n.length:+t||0,Zr(n,$,null,null,null,null,t)},Dt.assign=Fo,Dt.at=function(n){return oe(n?n.length:0)&&(n=se(n)),er(n,hr(arguments,false,false,1))},Dt.before=We,Dt.bind=Ne,Dt.bindAll=function(n){for(var t=n,r=1(s?Zt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Zt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i) +}return c},Dt.invert=function(n,t,r){r&&ue(n,t,r)&&(t=null),r=-1;for(var e=To(n),u=e.length,o={};++rt?0:t)},Dt.takeRight=function(n,t,r){return(r?ue(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,_e(n,0>t?0:t) +},Dt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Hr(t,r,3);e--&&t(n[e],e,n););return _e(n,e+1)},Dt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Hr(t,r,3);++en||!no(n))return[];var e=-1,u=yu(eo(n,co));for(t=Wr(t,r,1);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Dt.escape=function(n){return(n=null==n?"":Eu(n))&&nt.test(n)?n.replace(H,y):n},Dt.escapeRegExp=uu,Dt.every=Ee,Dt.find=Ie,Dt.findIndex=ve,Dt.findKey=function(n,t,r){return t=Hr(t,r,3),pr(n,t,yr,true) +},Dt.findLast=function(n,t,r){return t=Hr(t,r,3),pr(n,t,lr)},Dt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Hr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Dt.findLastKey=function(n,t,r){return t=Hr(t,r,3),pr(n,t,mr,true)},Dt.findWhere=function(n,t){return Ie(n,hu(t))},Dt.first=de,Dt.has=function(n,t){return n?Tu.call(n,t):false},Dt.identity=pu,Dt.includes=je,Dt.indexOf=ye,Dt.isArguments=Ke,Dt.isArray=ko,Dt.isBoolean=function(n){return true===n||false===n||w(n)&&Lu.call(n)==wt||false},Dt.isDate=function(n){return w(n)&&Lu.call(n)==xt||false +},Dt.isElement=Ve,Dt.isEmpty=function(n){if(null==n)return true;var t=n.length;return oe(t)&&(ko(n)||Qe(n)||Ke(n)||w(n)&&Ze(n.splice))?!t:!To(n).length},Dt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Wr(r,e,3),!r&&ie(n)&&ie(t)?n===t:(e=r?r(n,t):C,typeof e=="undefined"?wr(n,t,r):!!e)},Dt.isError=Ye,Dt.isFinite=So,Dt.isFunction=Ze,Dt.isMatch=function(n,t,r,e){var u=To(t),o=u.length;if(r=typeof r=="function"&&Wr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],ie(e))return null!=n&&e===n[i]&&Tu.call(n,i) +}for(var i=yu(o),a=yu(o);o--;)e=i[o]=t[u[o]],a[o]=ie(e);return Ar(n,u,i,a,r)},Dt.isNaN=function(n){return Xe(n)&&n!=+n},Dt.isNative=Je,Dt.isNull=function(n){return null===n},Dt.isNumber=Xe,Dt.isObject=Ge,Dt.isPlainObject=Uo,Dt.isRegExp=He,Dt.isString=Qe,Dt.isUndefined=function(n){return typeof n=="undefined"},Dt.kebabCase=Lo,Dt.last=function(n){var t=n?n.length:0;return t?n[t-1]:C},Dt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?ro(e+r,0):eo(r||0,e-1))+1; +else if(r)return u=Tr(n,t,null,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Dt.max=function(n,t,r){r&&ue(n,t,r)&&(t=null);var e=null==t,u=e&&ko(n),o=!u&&Qe(n);if(e&&!o)return Jt(u?n:se(n));var i=fo,a=i;return t=e&&o?s:Hr(t,r,3),fr(n,function(n,r,e){r=t(n,r,e),(r>i||r===fo&&r===a)&&(i=r,a=n)}),a},Dt.min=function(n,t,r){r&&ue(n,t,r)&&(t=null);var e=null==t,u=e&&ko(n),o=!u&&Qe(n);if(e&&!o)return Xt(u?n:se(n));var i=lo,a=i;return t=e&&o?s:Hr(t,r,3),fr(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r +},Dt.template=function(n,t,r){var e=Dt.templateSettings;r&&ue(n,t,r)&&(t=r=null),n=Eu(null==n?"":n),t=rr(rr({},r||t),e,tr),r=rr(rr({},t.imports),e.imports,tr);var u,o,i=To(r),a=Ur(r,i),f=0;r=t.interpolate||ct;var l="__p+='";r=ju((t.escape||ct).source+"|"+r.source+"|"+(r===et?ut:ct).source+"|"+(t.evaluate||ct).source+"|$","g");var c="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(gt,m),r&&(u=true,l+="'+__e("+r+")+'"),a&&(o=true,l+="';"+a+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),f=c+t.length,t +}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(Z,""):l).replace(G,"$1").replace(J,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=lu(function(){return bu(i,c+"return "+l).apply(C,a)}),t.source=l,Ye(t))throw t;return t},Dt.trim=au,Dt.trimLeft=function(n,t,r){var e=n;return(n=null==n?"":Eu(n))?(r?ue(e,t,r):null==t)?n.slice(j(n)):(t=Eu(t),n.slice(p(n,t))):n +},Dt.trimRight=function(n,t,r){var e=n;return(n=null==n?"":Eu(n))?(r?ue(e,t,r):null==t)?n.slice(0,E(n)+1):(t=Eu(t),n.slice(0,h(n,t)+1)):n},Dt.trunc=function(n,t,r){r&&ue(n,t,r)&&(t=null);var e=P;if(r=B,Ge(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?Eu(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":Eu(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(He(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=ju(u.source,(ot.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index; +t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n) +},Dt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Dt.sample(t,n)}):Dt.sample(this.value())},Dt.VERSION=R,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Dt[n].placeholder=Dt}),n(["filter","map","takeWhile"],function(n,t){var r=t==M;qt.prototype[n]=function(n,e){n=Hr(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==K&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While"; +qt.prototype[n]=function(e){e=null==e?1:ro(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?eo(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},qt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},qt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");qt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); +qt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?hu:du;qt.prototype[n]=function(n){return this[r](e(n))}}),qt.prototype.dropWhile=function(n,t){n=Hr(n,t,3);var r,e,u=0>this.dir;return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},qt.prototype.reject=function(n,t){return n=Hr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},qt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n); +return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},yr(qt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Dt.prototype[t]=function(){function e(n){return n=[n],Ku.apply(n,o),Dt[t].apply(Dt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,a=!!this.__actions__.length,f=u instanceof qt,l=f&&!a;return r&&!i?l?n.call(u):Dt[t](this.value()):f||ko(u)?(u=n.apply(l?u:new qt(this),o),r||!a&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:Dt,name:"thru"}),new Mt(u,i)):this.thru(e) +}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Iu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n),u=_o.spliceObjects||!/^(?:pop|shift|splice)$/.test(n)?t:function(){var n=t.apply(this,arguments);return 0===this.length&&delete this[0],n};Dt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?u.apply(this.value(),n):this[r](function(t){return u.apply(t,n)})}}),qt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new qt(this.wrapped); +return e.actions=n?l(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?l(t):null,e.takeCount=this.takeCount,e.views=r?l(r):null,e},qt.prototype.reverse=function(){var n=this.filtered,t=n?new qt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t},qt.prototype.value=function(){var n=this.wrapped.value();if(!ko(n))return Fr(n,this.actions);var t,r=this.dir,e=0>r,u=n.length;t=u;for(var o=this.views,i=0,a=-1,f=o?o.length:0;++a"'`]/g,Q=RegExp(X.source),nt=RegExp(H.source),tt=/<%-([\s\S]+?)%>/g,rt=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,ut=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ot=/\w*$/,it=/^\s*function[ \n\r\t]+\w/,at=/^0[xX]/,ft=/^\[object .+?Constructor\]$/,lt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ct=/($^)/,st=/[.*+?^${}()|[\]\/\\]/g,pt=RegExp(st.source),ht=/\bthis\b/,gt=/['\n\r\u2028\u2029\\]/g,vt=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),dt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",yt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),_t="[object Arguments]",bt="[object Array]",wt="[object Boolean]",xt="[object Date]",At="[object Error]",jt="[object Function]",Et="[object Number]",Ot="[object Object]",It="[object RegExp]",Ct="[object String]",Rt="[object ArrayBuffer]",kt="[object Float32Array]",St="[object Float64Array]",Ut="[object Int8Array]",Ft="[object Int16Array]",Tt="[object Int32Array]",Wt="[object Uint8Array]",Nt="[object Uint8ClampedArray]",Lt="[object Uint16Array]",$t="[object Uint32Array]",Pt={}; +Pt[_t]=Pt[bt]=Pt[kt]=Pt[St]=Pt[Ut]=Pt[Ft]=Pt[Tt]=Pt[Wt]=Pt[Nt]=Pt[Lt]=Pt[$t]=true,Pt[Rt]=Pt[wt]=Pt[xt]=Pt[At]=Pt[jt]=Pt["[object Map]"]=Pt[Et]=Pt[Ot]=Pt[It]=Pt["[object Set]"]=Pt[Ct]=Pt["[object WeakMap]"]=false;var Bt={};Bt[_t]=Bt[bt]=Bt[Rt]=Bt[wt]=Bt[xt]=Bt[kt]=Bt[St]=Bt[Ut]=Bt[Ft]=Bt[Tt]=Bt[Et]=Bt[Ot]=Bt[It]=Bt[Ct]=Bt[Wt]=Bt[Nt]=Bt[Lt]=Bt[$t]=true,Bt[At]=Bt[jt]=Bt["[object Map]"]=Bt["[object Set]"]=Bt["[object WeakMap]"]=false;var zt={leading:false,maxWait:0,trailing:false},Dt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Mt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Kt={"function":true,object:true},Vt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Yt=Kt[typeof window]&&window!==(this&&this.window)?window:this,Zt=Kt[typeof exports]&&exports&&!exports.nodeType&&exports,Gt=Kt[typeof module]&&module&&!module.nodeType&&module,Jt=Zt&&Gt&&typeof global=="object"&&global; +!Jt||Jt.global!==Jt&&Jt.window!==Jt&&Jt.self!==Jt||(Yt=Jt);var Xt=Gt&&Gt.exports===Zt&&Zt,Ht=function(){try{String({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Qt=I();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Yt._=Qt, define(function(){return Qt})):Zt&&Gt?Xt?(Gt.exports=Qt)._=Qt:Zt._=Qt:Yt._=Qt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 24e69a53d..ce133e011 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -23,8 +23,8 @@ CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, - ARY_FLAG = 128, - REARG_FLAG = 256; + REARG_FLAG = 128, + ARY_FLAG = 256; /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, @@ -45,9 +45,6 @@ /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; - /** Used to generate unique IDs. */ - var idCounter = 0; - /** Used to match empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, @@ -55,7 +52,9 @@ /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, - reUnescapedHtml = /[&<>"'`]/g; + reUnescapedHtml = /[&<>"'`]/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, @@ -81,7 +80,7 @@ /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters (excluding mathematical operators). */ + /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; /** Used to ensure capturing order of template delimiters. */ @@ -92,7 +91,8 @@ * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) * for more details. */ - var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g; + var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, + reHasRegExpChars = RegExp(reRegExpChars.source); /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; @@ -279,8 +279,8 @@ /*--------------------------------------------------------------------------*/ /** - * A specialized version of `_.forEach` for arrays without support for - * callback shorthands or `this` binding. + * A specialized version of `_.forEach` for arrays without support for callback + * shorthands or `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -327,7 +327,7 @@ * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns `true` if all elements pass the predicate check, - * else `false` + * else `false`. */ function arrayEvery(array, predicate) { var index = -1, @@ -393,7 +393,7 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray=false] Specify using the first element of + * @param {boolean} [initFromArray] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ @@ -418,13 +418,12 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray=false] Specify using the last element of + * @param {boolean} [initFromArray] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; - if (initFromArray && length) { accumulator = array[--length]; } @@ -481,8 +480,7 @@ } /** - * The base implementation of `_.indexOf` without support for `fromIndex` - * bounds checks and binary searches. + * The base implementation of `_.indexOf` without support for binary searches. * * @private * @param {Array} array The array to search. @@ -515,7 +513,7 @@ */ function baseSlice(array) { var index = -1, - length = array ? array.length : 0, + length = array.length, result = Array(length); while (++index < length) { @@ -632,7 +630,7 @@ } /** - * Used by `_.deburr` to convert latin-1 to basic latin letters. + * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * * @private * @param {string} letter The matched letter to deburr. @@ -672,7 +670,7 @@ * @private * @param {Array} array The array to search. * @param {number} [fromIndex] The index to search from. - * @param {boolean} [fromRight=false] Specify iterating from right to left. + * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched `NaN`, else `-1`. */ function indexOfNaN(array, fromIndex, fromRight) { @@ -689,11 +687,11 @@ } /** - * Checks if `value` is valid array-like index. + * Checks if `value` is a valid array-like index. * * @private * @param {*} value The value to check. - * @param {number} [length] The upper bound of a valid index. + * @param {number} [length] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { @@ -720,7 +718,7 @@ * @param {number} charCode The character code to inspect. * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. */ - function isWhitespace(charCode) { + function isSpace(charCode) { return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); } @@ -789,7 +787,7 @@ var index = -1, length = string.length; - while (++index < length && isWhitespace(string.charCodeAt(index))) {} + while (++index < length && isSpace(string.charCodeAt(index))) {} return index; } @@ -804,7 +802,7 @@ function trimmedRightIndex(string) { var index = string.length; - while (index-- && isWhitespace(string.charCodeAt(index))) {} + while (index-- && isSpace(string.charCodeAt(index))) {} return index; } @@ -877,9 +875,15 @@ /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; + /** Used to the length of n-tuples for `_.unzip`. */ + var getLength = baseProperty('length'); + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; + /** Used to generate unique IDs. */ + var idCounter = 0; + /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; @@ -921,8 +925,7 @@ }()); /* Native method references for those with the same name as other `lodash` methods. */ - var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, - nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, + var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, @@ -936,11 +939,12 @@ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - /** Used as references for the max length and index of an array. */ + /** Used as references for the maximum length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - /** Used as the size, in bytes, of each Float64Array element. */ + /** Used as the size, in bytes, of each `Float64Array` element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** @@ -957,8 +961,16 @@ /** * Creates a `lodash` object which wraps `value` to enable intuitive chaining. - * The execution of chained methods is deferred until `_#value` is implicitly - * or explicitly called. Explicit chaining may be enabled by using `_.chain`. + * Methods that operate on and return arrays, collections, and functions can + * be chained together. Methods that return a boolean or single value will + * automatically end the chain returning the unwrapped value. Explicit chaining + * may be enabled using `_.chain`. The execution of chained methods is lazy, + * that is, execution is deferred until `_#value` is implicitly or explicitly + * called. + * + * Lazy evaluation allows several methods to support shortcut fusion. Shortcut + * fusion is an optimization that merges iteratees to avoid creating intermediate + * arrays and reduce the number of iteratee executions. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. @@ -967,7 +979,12 @@ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, * and `unshift` * - * The wrapper functions that are chainable by default are: + * The wrapper functons that support shortcut fusion are: + * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`, + * `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`, + * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where` + * + * The chainable wrapper functions are: * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, * `callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`, * `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, @@ -984,19 +1001,19 @@ * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, * `without`, `wrap`, `xor`, `zip`, and `zipObject` * - * The wrapper functions that are non-chainable by default are: + * The wrapper functions that are **not** chainable by default are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, - * `isFunction`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, - * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, - * `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, - * `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, - * `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `unescape`, `uniqueId`, `value`, and `words` + * `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, + * `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, + * `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, + * `sortedIndex`, `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` * * The wrapper function `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. @@ -1040,7 +1057,7 @@ * * @private * @param {*} value The value to wrap. - * @param {boolean} [chainAll=false] Enable chaining for all wrapper methods. + * @param {boolean} [chainAll] Enable chaining for all wrapper methods. * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. */ function LodashWrapper(value, chainAll, actions) { @@ -1415,6 +1432,19 @@ /*------------------------------------------------------------------------*/ + /** + * Converts an `arguments` object to a plain `Object` object. + * + * @private + * @param {Object} args The `arguments` object to convert. + * @returns {Object} Returns the new converted object. + */ + function argsToObject(args) { + var result = { 'length': 0 }; + push.apply(result, args); + return result; + } + /** * A specialized version of `_.max` for arrays without support for iteratees. * @@ -1490,7 +1520,7 @@ /** * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `this` binding. + * multiple sources, and `this` binding `customizer` functions. * * @private * @param {Object} object The destination object. @@ -1523,7 +1553,7 @@ */ function baseAt(collection, props) { var index = -1, - length = collection ? collection.length : 0, + length = collection.length, isArr = isLength(length), propsLength = props.length, result = Array(propsLength); @@ -1540,6 +1570,49 @@ return result; } + /** + * The base implementation of `binaryIndex` which supports large arrays and + * determining the insert index for `NaN` and `undefined`. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest, instead + * of the lowest, index at which a value should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseBinaryIndex(array, value, iteratee, retHighest) { + iteratee = iteratee == null ? identity : iteratee; + value = iteratee(value); + + var low = 0, + high = array.length, + valIsNaN = value !== value, + valIsUndef = typeof value == 'undefined'; + + while (low < high) { + var mid = floor((low + high) / 2), + computed = iteratee(array[mid]), + isReflexive = computed === computed; + + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || typeof computed != 'undefined'); + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + /** * The base implementation of `_.bindAll` without support for individual * method name arguments. @@ -1561,76 +1634,39 @@ } /** - * The base implementation of `_.callback`. + * The base implementation of `_.callback` which supports specifying the + * number of arguments to provide to `func`. * * @private * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns the new function. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. */ function baseCallback(func, thisArg, argCount) { var type = typeof func; if (type == 'function') { - if (typeof thisArg == 'undefined') { - return func; - } - var data = getData(func); - if (typeof data == 'undefined') { - var support = lodash.support; - if (support.funcNames) { - data = !func.name; - } - data = data || !support.funcDecomp; - if (!data) { - var source = fnToString.call(func); - if (!support.funcNames) { - data = !reFuncName.test(source); - } - if (!data) { - // Check if `func` references the `this` keyword and store the result. - data = reThis.test(source) || isNative(func); - baseSetData(func, data); - } - } - } - // Exit early if there are no `this` references or `func` is bound. - if (data === false || (data !== true && data[1] & BIND_FLAG)) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - case 5: return function(value, other, key, object, source) { - return func.call(thisArg, value, other, key, object, source); - }; - } - return function() { - return func.apply(thisArg, arguments); - }; + return (typeof thisArg != 'undefined' && isBindable(func)) + ? bindCallback(func, thisArg, argCount) + : func; } if (func == null) { return identity; } // Handle "_.pluck" and "_.where" style callback shorthands. - return type == 'object' ? matches(func) : property(func); + return type == 'object' + ? baseMatches(func, argCount) + : baseProperty(argCount ? String(func) : func); } /** * The base implementation of `_.clone` without support for argument juggling - * and `this` binding. + * and `this` binding `customizer` functions. * * @private * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @param {Function} [customizer] The function to customize cloning values. * @param {string} [key] The key of `value`. * @param {Object} [object] The object `value` belongs to. @@ -1691,22 +1727,33 @@ * @param {Object} prototype The object to inherit from. * @returns {Object} Returns the new object. */ - function baseCreate(prototype) { - return isObject(prototype) ? nativeCreate(prototype) : {}; - } - // Fallback for environments without `Object.create`. - if (!nativeCreate) { - baseCreate = (function() { - function Object() {} - return function(prototype) { - if (isObject(prototype)) { - Object.prototype = prototype; - var result = new Object; - Object.prototype = null; - } - return result || context.Object(); - }; - }()); + var baseCreate = (function() { + function Object() {} + return function(prototype) { + if (isObject(prototype)) { + Object.prototype = prototype; + var result = new Object; + Object.prototype = null; + } + return result || context.Object(); + }; + }()); + + /** + * The base implementation of `_.delay` and `_.defer` which accepts an index + * of where to slice the arguments to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Object} args The `arguments` object to slice and provide to `func`. + * @returns {number} Returns the timer id. + */ + function baseDelay(func, wait, args, fromIndex) { + if (!isFunction(func)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, slice(args, fromIndex)); }, wait); } /** @@ -1853,7 +1900,7 @@ * @param {Array|Object|string} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey=false] Specify returning the key of the found + * @param {boolean} [retKey] Specify returning the key of the found * element instead of the element itself. * @returns {*} Returns the found element or its key, else `undefined`. */ @@ -1875,8 +1922,8 @@ * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep=false] Specify a deep flatten. - * @param {boolean} [isStrict=false] Restrict flattening to arrays and `arguments` objects. + * @param {boolean} [isDeep] Specify a deep flatten. + * @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects. * @param {number} [fromIndex=0] The index to start from. * @returns {Array} Returns the new flattened array. */ @@ -2022,202 +2069,9 @@ return result; } - /** - * The base implementation of `_.isEqual`, without support for `thisArg` - * binding, which allows partial "_.where" style comparisons. - * - * @private - * @param {*} value The value to compare to `other`. - * @param {*} other The value to compare to `value`. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isWhere=false] Specify performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `value` objects. - * @param {Array} [stackB=[]] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { - var result = (customizer && !stackA) ? customizer(value, other) : undefined; - if (typeof result != 'undefined') { - return !!result; - } - // Exit early for identical values. - if (value === other) { - // Treat `+0` vs. `-0` as not equal. - return value !== 0 || (1 / value == 1 / other); - } - var valType = typeof value, - othType = typeof other; - - // Exit early for unlike primitive values. - if (!(valType == 'number' && othType == 'number') && (value == null || other == null || - (valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object'))) { - return false; - } - var valClass = toString.call(value), - valIsArg = valClass == argsClass, - othClass = toString.call(other), - othIsArg = othClass == argsClass; - - if (valIsArg) { - valClass = objectClass; - } - if (othIsArg) { - othClass = objectClass; - } - var valIsArr = arrayLikeClasses[valClass], - valIsErr = valClass == errorClass, - valIsObj = valClass == objectClass, - othIsObj = othClass == objectClass; - - var isSameClass = valClass == othClass; - if (isSameClass && valIsArr) { - var valLength = value.length, - othLength = other.length; - - if (valLength != othLength && !(isWhere && othLength > valLength)) { - return false; - } - } - else { - // Unwrap `lodash` wrapped values. - var valWrapped = valIsObj && hasOwnProperty.call(value, '__wrapped__'), - othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (valWrapped || othWrapped) { - return baseIsEqual(valWrapped ? value.value() : value, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); - } - if (!isSameClass) { - return false; - } - if (valIsErr || valIsObj) { - // In older versions of Opera, `arguments` objects have `Array` constructors. - var valCtor = valIsArg ? Object : value.constructor, - othCtor = othIsArg ? Object : other.constructor; - - if (valIsErr) { - // Error objects of different types are not equal. - if (valCtor.prototype.name != othCtor.prototype.name) { - return false; - } - } - else { - var valHasCtor = !valIsArg && hasOwnProperty.call(value, 'constructor'), - othHasCtor = !othIsArg && hasOwnProperty.call(other, 'constructor'); - - if (valHasCtor != othHasCtor) { - return false; - } - if (!valHasCtor) { - // Non `Object` object instances with different constructors are not equal. - if (valCtor != othCtor && ('constructor' in value && 'constructor' in other) && - !(typeof valCtor == 'function' && valCtor instanceof valCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; - } - } - } - var valProps = valIsErr ? ['message', 'name'] : keys(value), - othProps = valIsErr ? valProps : keys(other); - - if (valIsArg) { - valProps.push('length'); - } - if (othIsArg) { - othProps.push('length'); - } - valLength = valProps.length; - othLength = othProps.length; - if (valLength != othLength && !isWhere) { - return false; - } - } - else { - switch (valClass) { - case boolClass: - case dateClass: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. - return +value == +other; - - case numberClass: - // Treat `NaN` vs. `NaN` as equal. - return (value != +value) - ? other != +other - // But, treat `-0` vs. `+0` as not equal. - : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); - - case regexpClass: - case stringClass: - // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and - // treat strings primitives and string objects as equal. - return value == String(other); - } - return false; - } - } - // Assume cyclic structures are equal. - // The algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). - stackA || (stackA = []); - stackB || (stackB = []); - - var index = stackA.length; - while (index--) { - if (stackA[index] == value) { - return stackB[index] == other; - } - } - // Add `value` and `other` to the stack of traversed objects. - stackA.push(value); - stackB.push(other); - - // Recursively compare objects and arrays (susceptible to call stack limits). - result = true; - if (valIsArr) { - // Deep compare the contents, ignoring non-numeric properties. - while (result && ++index < valLength) { - var valValue = value[index]; - if (isWhere) { - var othIndex = othLength; - while (othIndex--) { - result = baseIsEqual(valValue, other[othIndex], customizer, isWhere, stackA, stackB); - if (result) { - break; - } - } - } else { - var othValue = other[index]; - result = customizer ? customizer(valValue, othValue, index) : undefined; - if (typeof result == 'undefined') { - result = baseIsEqual(valValue, othValue, customizer, isWhere, stackA, stackB); - } - } - } - } - else { - while (result && ++index < valLength) { - var key = valProps[index]; - result = valIsErr || hasOwnProperty.call(other, key); - - if (result) { - valValue = value[key]; - othValue = other[key]; - result = customizer ? customizer(valValue, othValue, key) : undefined; - if (typeof result == 'undefined') { - result = baseIsEqual(valValue, othValue, customizer, isWhere, stackA, stackB); - } - } - } - } - stackA.pop(); - stackB.pop(); - - return !!result; - } - /** * The base implementation of `_.invoke` which requires additional arguments - * be provided as an array of arguments rather than individually. + * to be provided as an array of arguments rather than individually. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2239,6 +2093,158 @@ return result; } + /** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare to `other`. + * @param {*} other The value to compare to `value`. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { + // Exit early for identical values. + if (value === other) { + // Treat `+0` vs. `-0` as not equal. + return value !== 0 || (1 / value == 1 / other); + } + var valType = typeof value, + othType = typeof other; + + // Exit early for unlike primitive values. + if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || + value == null || other == null) { + // Return `false` unless both values are `NaN`. + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); + } + + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * a deep comparison between objects and tracks traversed objects enabling + * objects with circular references to be compared. + * + * @private + * @param {Array} object The object to compare to `other`. + * @param {Array} other The object to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing objects. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `value` objects. + * @param {Array} [stackB=[]] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, equalFunc, customizer, isWhere, stackA, stackB) { + var objClass = isArray(object) ? arrayClass : toString.call(object), + objIsArg = objClass == argsClass, + objIsArr = !objIsArg && arrayLikeClasses[objClass], + othClass = isArray(other) ? arrayClass : toString.call(other), + othIsArg = othClass == argsClass, + othIsArr = !othIsArg && arrayLikeClasses[othClass]; + + if (objIsArg) { + object = argsToObject(object); + objClass = objectClass; + } + if (othIsArg) { + other = argsToObject(other); + othClass = objectClass; + } + var objIsObj = objClass == objectClass, + othIsObj = othClass == objectClass, + isSameClass = objClass == othClass; + + if (isSameClass && !(objIsArr || objIsObj)) { + return equalByClass(object, other, objClass); + } + var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (valWrapped || othWrapped) { + return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); + } + if (!isSameClass) { + return false; + } + // Assume cyclic structures are equal. + // The algorithm for detecting cyclic structures is adapted from ES 5.1 + // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + // Add `object` and `other` to the stack of traversed objects. + stackA.push(object); + stackB.push(other); + + // Recursively compare objects and arrays (susceptible to call stack limits). + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB); + + stackA.pop(); + stackB.pop(); + + return result; + } + + /** + * The base implementation of `_.isMatch` without support for callback + * shorthands or `this` binding. + * + * @private + * @param {Object} source The object to inspect. + * @param {Array} props The source property names to match. + * @param {Array} values The source values to match. + * @param {Array} strictCompareFlags Strict comparison flags for source values. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, props, values, strictCompareFlags, customizer) { + var length = props.length; + if (object == null) { + return !length; + } + var index = -1, + noCustomizer = !customizer; + + while (++index < length) { + if ((noCustomizer && strictCompareFlags[index]) + ? values[index] !== object[props[index]] + : !hasOwnProperty.call(object, props[index]) + ) { + return false; + } + } + index = -1; + while (++index < length) { + var key = props[index]; + if (noCustomizer && strictCompareFlags[index]) { + var result = hasOwnProperty.call(object, key); + } else { + var objValue = object[key], + srcValue = values[index]; + + result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (typeof result == 'undefined') { + result = baseIsEqual(srcValue, objValue, customizer, true); + } + } + if (!result) { + return false; + } + } + return true; + } + /** * The base implementation of `_.map` without support for callback shorthands * or `this` binding. @@ -2257,9 +2263,48 @@ return result; } + /** + * The base implementation of `_.matches` which supports specifying whether + * `source` is cloned. + * + * @private + * @param {Object} source The object of property values to match. + * @param {boolean} [isCloned] Specify cloning the source object. + * @returns {Function} Returns the new function. + */ + function baseMatches(source, isCloned) { + var props = keys(source), + length = props.length; + + if (length == 1) { + var key = props[0], + value = source[key]; + + if (isStrictComparable(value)) { + return function(object) { + return object != null && value === object[key] && hasOwnProperty.call(object, key); + }; + } + } + var notCloned = !isCloned, + values = Array(length), + strictCompareFlags = Array(length); + + while (length--) { + value = source[props[length]]; + var isStrict = isStrictComparable(value); + + values[length] = (isStrict || notCloned) ? value : baseClone(value, true, clonePassthru); + strictCompareFlags[length] = isStrict; + } + return function(object) { + return baseIsMatch(object, props, values, strictCompareFlags); + }; + } + /** * The base implementation of `_.merge` without support for argument juggling, - * multiple sources, and `this` binding. + * multiple sources, and `this` binding `customizer` functions. * * @private * @param {Object} object The destination object. @@ -2320,6 +2365,19 @@ return object; } + /** + * The base implementation of `_.property` which does not coerce `key` to a string. + * + * @private + * @param {string} key The name of the property to retrieve. + * @returns {Function} Returns the new function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + /** * The base implementation of `_.pullAt` without support for individual * index arguments. @@ -2413,49 +2471,6 @@ return !!result; } - /** - * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` without - * support for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The function invoked per iteration. - * @param {boolean} [retHighest=false] Specify returning the highest, instead - * of the lowest, index at which a value should be inserted into `array`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndex(array, value, iteratee, retHighest) { - var low = 0, - high = array ? array.length : low; - - value = iteratee(value); - - var valIsNaN = value !== value, - valIsUndef = typeof value == 'undefined'; - - while (low < high) { - var mid = floor((low + high) / 2), - computed = iteratee(array[mid]), - isReflexive = computed === computed; - - if (valIsNaN) { - var setLow = isReflexive || retHighest; - } else if (valIsUndef) { - setLow = isReflexive && (retHighest || typeof computed != 'undefined'); - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return nativeMin(high, MAX_ARRAY_INDEX); - } - /** * The base implementation of `_.uniq` without support for callback shorthands * and `this` binding. @@ -2514,13 +2529,12 @@ * returned by `keysFunc`. * * @private - * @param {Object} object The object to inspect. - * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. * @returns {Object} Returns the array of property values. */ - function baseValues(object, keysFunc) { + function baseValues(object, props) { var index = -1, - props = keysFunc(object), length = props.length, result = Array(length); @@ -2559,6 +2573,78 @@ return result; } + /** + * Performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. If + * `iteratee` is provided it is invoked for `value` and each element of + * `array` to compute their sort ranking. The iteratee is invoked with one + * argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee] The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest, instead + * of the lowest, index at which a value should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function binaryIndex(array, value, iteratee, retHighest) { + var low = 0, + high = array ? array.length : low; + + if (high && (iteratee || value !== value || typeof value == 'undefined' || high > HALF_MAX_ARRAY_LENGTH)) { + return baseBinaryIndex(array, value, iteratee, retHighest); + } + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if (retHighest ? (computed <= value) : (computed < value)) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + + /** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ + function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (typeof thisArg == 'undefined') { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + /** * Creates a clone of the given array buffer. * @@ -2718,7 +2804,7 @@ } // Juggle arguments. if (length > 3 && typeof arguments[length - 2] == 'function') { - var customizer = baseCallback(arguments[--length - 1], arguments[length--], 5); + var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); } else if (length > 2 && typeof arguments[length - 1] == 'function') { customizer = arguments[--length]; } @@ -2813,11 +2899,11 @@ * @param {Array} [partialsRight] The arguments to append to those provided to the new function. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [arity] The arity of `func`. * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. */ - function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary) { + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, @@ -2863,7 +2949,7 @@ if (!isCurryBound) { bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } - var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, newArity, ary); + var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity); result.placeholder = placeholder; return result; } @@ -2873,7 +2959,7 @@ func = thisBinding[key]; } if (argPos) { - args = arrayReduceRight(argPos, reorder, args); + args = reorder(args, argPos); } if (isAry && ary < args.length) { args.length = ary; @@ -2957,17 +3043,17 @@ * 16 - `_.curryRight` * 32 - `_.partial` * 64 - `_.partialRight` - * 128 - `_.ary` - * 256 - `_.rearg` + * 128 - `_.rearg` + * 256 - `_.ary` * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to be partially applied. * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [arity] The arity of `func`. * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. */ - function createWrapper(func, bitmask, thisArg, partials, holders, argPos, arity, ary) { + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { var isBindKey = bitmask & BIND_KEY_FLAG; if (!isBindKey && !isFunction(func)) { throw new TypeError(FUNC_ERROR_TEXT); @@ -2987,14 +3073,14 @@ partials = holders = null; } var data = !isBindKey && getData(func), - newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary]; + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; if (data && data !== true) { mergeData(newData, data); } - newData[8] = newData[8] == null + newData[9] = newData[9] == null ? (isBindKey ? 0 : newData[0].length) - : (nativeMax(newData[8] - length, 0) || 0); + : (nativeMax(newData[9] - length, 0) || 0); bitmask = newData[1]; if (bitmask == BIND_FLAG) { @@ -3008,6 +3094,160 @@ return setter(result, newData); } + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare to `other`. + * @param {Array} other The array to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing arrays. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, equalFunc, customizer, isWhere, stackA, stackB) { + var index = -1, + arrLength = array.length, + othLength = other.length, + result = true; + + if (arrLength != othLength && !(isWhere && othLength > arrLength)) { + return false; + } + // Deep compare the contents, ignoring non-numeric properties. + while (result && ++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + result = undefined; + if (customizer) { + result = isWhere + ? customizer(othValue, arrValue, index) + : customizer(arrValue, othValue, index); + } + if (typeof result == 'undefined') { + if (isWhere) { + var othIndex = othLength; + while (othIndex--) { + othValue = other[othIndex]; + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + if (result) { + break; + } + } + } else { + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + } + } + } + return !!result; + } + + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `[[Class]]`. + * + * **Note:** This function only supports comparing values with `[[Class]]` + * values of `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} value The object to compare to `other`. + * @param {Object} other The object to compare to `object`. + * @param {string} className The `[[Class]]` of the objects to compare. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByClass(object, other, className) { + switch (className) { + case boolClass: + case dateClass: + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + return +object == +other; + + case errorClass: + return object.name == other.name && object.message == other.message; + + case numberClass: + // Treat `NaN` vs. `NaN` as equal. + return (object != +object) + ? other != +other + // But, treat `-0` vs. `+0` as not equal. + : (object == 0 ? ((1 / object) == (1 / other)) : object == +other); + + case regexpClass: + case stringClass: + // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and + // treat strings primitives and string objects as equal. + return object == String(other); + } + return false; + } + + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare to `other`. + * @param {Object} other The object to compare to `value`. + * @param {Function} equalFunc The function to determine equivalents of arbitrary values. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, equalFunc, customizer, isWhere, stackA, stackB) { + var objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; + + if (objLength != othLength && !isWhere) { + return false; + } + var hasCtor, + index = -1; + + while (++index < objLength) { + var key = objProps[index], + result = hasOwnProperty.call(other, key); + + if (result) { + var objValue = object[key], + othValue = other[key]; + + result = undefined; + if (customizer) { + result = isWhere + ? customizer(othValue, objValue, key) + : customizer(objValue, othValue, key); + } + if (typeof result == 'undefined') { + result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB); + } + } + if (!result) { + return false; + } + hasCtor || (hasCtor = key == 'constructor'); + } + if (!hasCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { + return false; + } + } + return true; + } + /** * Gets the appropriate "callback" function. If the `_.callback` method is * customized this function returns the custom method, otherwise it returns @@ -3082,7 +3322,7 @@ * * @private * @param {Array} array The array to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Array} Returns the initialized array clone. */ function initArrayClone(array, isDeep) { @@ -3108,7 +3348,7 @@ * * @private * @param {Object} object The object to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {null|Object} Returns the initialized object clone if an object * is cloneable, else `null`. */ @@ -3168,6 +3408,31 @@ (arrayLikeClasses[toString.call(value)])) || false; } + /** + * Checks if `func` is eligible for `this` binding. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is eligible, else `false`. + */ + function isBindable(func) { + var support = lodash.support, + result = !(support.funcNames ? func.name : support.funcDecomp); + + if (!result) { + var source = fnToString.call(func); + if (!support.funcNames) { + result = !reFuncName.test(source); + } + if (!result) { + // Check if `func` references the `this` keyword and store the result. + result = reThis.test(source) || isNative(func); + baseSetData(func, result); + } + } + return result; + } + /** * Checks if `value` is cloneable. * @@ -3252,13 +3517,13 @@ var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG), isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG), argPos = (isRearg ? data : source)[7], - ary = (isAry ? data : source)[9]; + ary = (isAry ? data : source)[8]; - var isCommon = !(bitmask >= ARY_FLAG && srcBitmask > bindFlags) && - !(bitmask > bindFlags && srcBitmask >= ARY_FLAG); + var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) && + !(bitmask > bindFlags && srcBitmask >= REARG_FLAG); var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) && - (bitmask < ARY_FLAG || ((isRearg || isAry) && argPos[0].length <= ary)); + (bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary)); // Exit early if metadata can't be merged. if (!(isCommon || isCombo)) { @@ -3284,22 +3549,18 @@ data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value); data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]); } - // Append argument positions. + // Use source `argPos` if available. value = source[7]; if (value) { - argPos = data[7]; - value = data[7] = baseSlice(value); - if (argPos) { - push.apply(value, argPos); - } - } - // Use source `arity` if one is not provided. - if (data[8] == null) { - data[8] = source[8]; + data[7] = baseSlice(value); } // Use source `ary` if it's smaller. if (srcBitmask & ARY_FLAG) { - data[9] = data[9] == null ? source[9] : nativeMin(data[9], source[9]); + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; } // Use source `func` and merge bitmasks. data[0] = source[0]; @@ -3392,7 +3653,7 @@ lastCalled = 0; return function(key, value) { - var stamp = now ? now() : 0, + var stamp = now(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; @@ -3453,7 +3714,7 @@ length = propsLength && object.length, support = lodash.support; - var allowIndexes = typeof length == 'number' && length > 0 && + var allowIndexes = length && isLength(length) && (isArray(object) || (support.nonEnumArgs && isArguments(object))); var index = -1, @@ -3891,7 +4152,7 @@ * @memberOf _ * @category Array * @param {Array} array The array to flatten. - * @param {boolean} [isDeep=false] Specify a deep flatten. + * @param {boolean} [isDeep] Specify a deep flatten. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the new flattened array. * @example @@ -3969,7 +4230,7 @@ if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else if (fromIndex) { - var index = sortedIndex(array, value), + var index = binaryIndex(array, value), other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; @@ -4107,7 +4368,7 @@ if (typeof fromIndex == 'number') { index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; } else if (fromIndex) { - index = sortedLastIndex(array, value) - 1; + index = binaryIndex(array, value, null, true) - 1; var other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; } @@ -4128,9 +4389,8 @@ * * **Notes:** * - Unlike `_.without`, this method mutates `array`. - * - `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`, + * except that `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * for more details. * * @static @@ -4308,11 +4568,11 @@ } /** - * Uses a binary search to determine the lowest index at which a value should - * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iteratee function is provided it is invoked for `value` - * and each element of `array` to compute their sort ranking. The iteratee - * is bound to `thisArg` and invoked with one argument; (value). + * Uses a binary search to determine the lowest index at which `value` should + * be inserted into `array` in order to maintain its sort order. If an iteratee + * function is provided it is invoked for `value` and each element of `array` + * to compute their sort ranking. The iteratee is bound to `thisArg` and + * invoked with one argument; (value). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -4324,7 +4584,7 @@ * @static * @memberOf _ * @category Array - * @param {Array} array The array to inspect. + * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked * per iteration. If a property name or object is provided it is used to @@ -4353,19 +4613,19 @@ * // => 1 */ function sortedIndex(array, value, iteratee, thisArg) { - iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); - return baseSortedIndex(array, value, iteratee); + iteratee = iteratee == null ? iteratee : getCallback(iteratee, thisArg, 1); + return binaryIndex(array, value, iteratee); } /** * This method is like `_.sortedIndex` except that it returns the highest - * index at which a value should be inserted into a given sorted array in - * order to maintain the sort order of the array. + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. * * @static * @memberOf _ * @category Array - * @param {Array} array The array to inspect. + * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked * per iteration. If a property name or object is provided it is used to @@ -4379,8 +4639,8 @@ * // => 4 */ function sortedLastIndex(array, value, iteratee, thisArg) { - iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); - return baseSortedIndex(array, value, iteratee, true); + iteratee = iteratee == null ? iteratee : getCallback(iteratee, thisArg, 1); + return binaryIndex(array, value, iteratee, true); } /** @@ -4593,7 +4853,7 @@ * @alias unique * @category Array * @param {Array} array The array to inspect. - * @param {boolean} [isSorted=false] Specify the array is sorted. + * @param {boolean} [isSorted] Specify the array is sorted. * @param {Function|Object|string} [iteratee] The function invoked per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. @@ -4627,9 +4887,10 @@ iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; } - if (iteratee != null) { - iteratee = getCallback(iteratee, thisArg, 3); - } + iteratee = iteratee == null + ? iteratee + : getCallback(iteratee, thisArg, 3); + return (isSorted && getIndexOf() == baseIndexOf) ? sortedUniq(array, iteratee) : baseUniq(array, iteratee); @@ -4655,11 +4916,11 @@ */ function unzip(array) { var index = -1, - length = isObject(length = max(array, 'length')) && length.length || 0, + length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0, result = Array(length); while (++index < length) { - result[index] = pluck(array, index); + result[index] = arrayMap(array, baseProperty(index)); } return result; } @@ -4977,7 +5238,8 @@ * // => ['fred', 'pebbles'] */ function at(collection) { - if (!collection || isLength(collection.length)) { + var length = collection ? collection.length : 0; + if (isLength(length)) { collection = toIterable(collection); } return baseAt(collection, baseFlatten(arguments, false, false, 1)); @@ -5017,7 +5279,6 @@ */ function includes(collection, target, fromIndex) { var length = collection ? collection.length : 0; - if (!isLength(length)) { collection = values(collection); length = collection.length; @@ -5299,7 +5560,7 @@ function forEach(collection, iteratee, thisArg) { return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) ? arrayEach(collection, iteratee) - : baseEach(collection, baseCallback(iteratee, thisArg, 3)); + : baseEach(collection, bindCallback(iteratee, thisArg, 3)); } /** @@ -5322,15 +5583,15 @@ function forEachRight(collection, iteratee, thisArg) { return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, baseCallback(iteratee, thisArg, 3)); + : baseEachRight(collection, bindCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding - * value of each key is an array of the elements responsible for generating - * the key. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index|key, collection). + * each element of `collection` through `iteratee`. The corresponding value + * of each key is an array of the elements responsible for generating the key. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -6057,10 +6318,13 @@ */ function toArray(collection) { var length = collection ? collection.length : 0; - if (isLength(length)) { - return baseSlice(collection); + if (!isLength(length)) { + return values(collection); } - return values(collection); + if (!length) { + return []; + } + return baseSlice(collection); } /** @@ -6096,9 +6360,27 @@ /*------------------------------------------------------------------------*/ + /** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Date + * @example + * + * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); + * // => logs the number of milliseconds it took for the deferred function to be invoked + */ + var now = nativeNow || function() { + return new Date().getTime(); + }; + + /*------------------------------------------------------------------------*/ + /** * The opposite of `_.before`; this method creates a function that invokes - * `func` only after it is called `n` times. + * `func` once it is called `n` or more times. * * @static * @memberOf _ @@ -6158,7 +6440,7 @@ n = null; } n = n == null ? func.length : (+n || 0); - return createWrapper(func, ARY_FLAG, null, null, null, null, null, n); + return createWrapper(func, ARY_FLAG, null, null, null, null, n); } /** @@ -6213,7 +6495,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. + * @param {*} thisArg The `this` binding of `func`. * @param {...*} [args] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example @@ -6377,7 +6659,7 @@ if (guard && isIterateeCall(func, arity, guard)) { arity = null; } - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, arity); + var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity); result.placeholder = curry.placeholder; return result; } @@ -6423,7 +6705,7 @@ if (guard && isIterateeCall(func, arity, guard)) { arity = null; } - var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, guard ? null : arity); + var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity); result.placeholder = curryRight.placeholder; return result; } @@ -6620,11 +6902,7 @@ * // logs 'deferred' after one or more milliseconds */ function defer(func) { - if (!isFunction(func)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var args = arguments; - return setTimeout(function() { func.apply(undefined, slice(args, 1)); }, 1); + return baseDelay(func, 1, arguments, 1); } /** @@ -6644,11 +6922,7 @@ * // => logs 'later' after one second */ function delay(func, wait) { - if (!isFunction(func)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var args = arguments; - return setTimeout(function() { func.apply(undefined, slice(args, 2)); }, wait); + return baseDelay(func, wait, arguments, 2); } /** @@ -6848,7 +7122,9 @@ * initialize(); * // `initialize` invokes `createApplication` once */ - var once = createWrapper(before, PARTIAL_FLAG, null, [2]); + function once(func) { + return before(func, 2); + } /** * Creates a function that invokes `func` with `partial` arguments prepended @@ -6955,9 +7231,7 @@ */ function rearg(func) { var indexes = baseFlatten(arguments, false, false, 1); - return indexes.length - ? createWrapper(func, REARG_FLAG, null, null, null, [indexes]) - : createWrapper(func); + return createWrapper(func, REARG_FLAG, null, null, null, indexes); } /** @@ -7063,7 +7337,7 @@ * @memberOf _ * @category Lang * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {boolean} [isDeep] Specify a deep clone. * @param {Function} [customizer] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `customizer`. * @returns {*} Returns the cloned value. @@ -7099,7 +7373,7 @@ customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; isDeep = false; } - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return baseClone(value, isDeep, customizer); } @@ -7147,7 +7421,7 @@ * // => false */ function cloneDeep(value, customizer, thisArg) { - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return baseClone(value, true, customizer); } @@ -7260,9 +7534,9 @@ } /** - * Checks if a collection is empty. A value is considered empty unless it is - * an array-like value with a length greater than `0` or an object with own - * enumerable properties. + * Checks if a value is empty. A value is considered empty unless it is an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. * * @static * @memberOf _ @@ -7332,16 +7606,18 @@ * var words = ['hello', 'goodbye']; * var otherWords = ['hi', 'goodbye']; * - * _.isEqual(words, otherWords, function() { - * return _.every(arguments, _.bind(RegExp.prototype.test, /^h(?:i|ello)$/)) || undefined; + * _.isEqual(words, otherWords, function(value, other) { + * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; * }); * // => true */ function isEqual(value, other, customizer, thisArg) { - customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 3); - return (!customizer && isStrictComparable(value) && isStrictComparable(other)) - ? value === other - : baseIsEqual(value, other, customizer); + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + if (!customizer && isStrictComparable(value) && isStrictComparable(other)) { + return value === other; + } + var result = customizer ? customizer(value, other) : undefined; + return typeof result == 'undefined' ? baseIsEqual(value, other, customizer) : !!result; } /** @@ -7362,7 +7638,7 @@ * // => false */ function isError(value) { - return (isObjectLike(value) && toString.call(value) == errorClass) || false; + return (isObjectLike(value) && typeof value.message == 'string' && toString.call(value) == errorClass) || false; } /** @@ -7459,6 +7735,67 @@ return type == 'function' || (value && type == 'object') || false; } + /** + * Performs a deep comparison between `object` and `source` to determine if + * `object` contains equivalent property values. If `customizer` is provided + * it is invoked to compare values. If `customizer` returns `undefined` + * comparisons are handled by the method instead. The `customizer` is bound + * to `thisArg` and invoked with three arguments; (value, other, key). + * + * **Note:** This method supports comparing properties of arrays, booleans, + * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions + * and DOM nodes are **not** supported. Provide a customizer function to extend + * support for comparing other values. + * + * @static + * @memberOf _ + * @category Lang + * @param {Object} source The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize comparing values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.isMatch(object, { 'age': 40 }); + * // => true + * + * _.isMatch(object, { 'age': 36 }); + * // => false + * + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatch(object, source, function(value, other) { + * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + * }); + * // => true + */ + function isMatch(object, source, customizer, thisArg) { + var props = keys(source), + length = props.length; + + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + if (!customizer && length == 1) { + var key = props[0], + value = source[key]; + + if (isStrictComparable(value)) { + return object != null && value === object[key] && hasOwnProperty.call(object, key); + } + } + var values = Array(length), + strictCompareFlags = Array(length); + + while (length--) { + value = values[length] = source[props[length]]; + strictCompareFlags[length] = isStrictComparable(value); + } + return baseIsMatch(object, props, values, strictCompareFlags, customizer); + } + /** * Checks if `value` is `NaN`. * @@ -7686,7 +8023,7 @@ * @returns {Object} Returns the destination object. * @example * - * _.assign({ 'user': 'fred' }, { 'age': 40 }, { 'status': 'busy' }); + * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred', 'status': 'busy' }); * // => { 'user': 'fred', 'age': 40, 'status': 'busy' } * * var defaults = _.partialRight(_.assign, function(value, other) { @@ -7743,9 +8080,6 @@ * object for all destination properties that resolve to `undefined`. Once a * property is set, additional defaults of the same property are ignored. * - * **Note:** See the [documentation example of `_.partialRight`](https://lodash.com/docs#partialRight) - * for a deep version of this method. - * * @static * @memberOf _ * @category Object @@ -7883,7 +8217,7 @@ */ function forIn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); } return baseFor(object, iteratee, keysIn); } @@ -7914,7 +8248,7 @@ * // => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z' */ function forInRight(object, iteratee, thisArg) { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); return baseForRight(object, iteratee, keysIn); } @@ -7940,7 +8274,7 @@ */ function forOwn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); } return baseForOwn(object, iteratee); } @@ -7964,7 +8298,7 @@ * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' */ function forOwnRight(object, iteratee, thisArg) { - iteratee = baseCallback(iteratee, thisArg, 3); + iteratee = bindCallback(iteratee, thisArg, 3); return baseForRight(object, iteratee, keys); } @@ -8015,7 +8349,7 @@ * @memberOf _ * @category Object * @param {Object} object The object to invert. - * @param {boolean} [multiValue=false] Allow multiple values per key. + * @param {boolean} [multiValue] Allow multiple values per key. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Object} Returns the new inverted object. * @example @@ -8084,7 +8418,7 @@ length = object.length; } if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof length == 'number' && length > 0)) { + (typeof object != 'function' && (length && isLength(length)))) { return shimKeys(object); } return isObject(object) ? nativeKeys(object) : []; @@ -8118,7 +8452,7 @@ object = Object(object); } var length = object.length; - length = (typeof length == 'number' && length > 0 && + length = (length && isLength(length) && (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0; var Ctor = object.constructor, @@ -8178,7 +8512,7 @@ function mapValues(object, iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); - var result = {} + var result = {}; baseForOwn(object, function(value, key, object) { result[key] = iteratee(value, key, object); }); @@ -8233,7 +8567,8 @@ var merge = createAssigner(baseMerge); /** - * Creates a shallow clone of `object` excluding the specified properties. + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable properties of `object` that are not omitted. * Property names may be specified as individual arguments or as arrays of * property names. If `predicate` is provided it is invoked for each property * of `object` omitting the properties `predicate` returns truthy for. The @@ -8251,12 +8586,12 @@ * @returns {Object} Returns the new object. * @example * - * _.omit({ 'user': 'fred', 'age': 40 }, 'age'); + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.omit(object, 'age'); * // => { 'user': 'fred' } * - * _.omit({ 'user': 'fred', 'age': 40 }, function(value) { - * return typeof value == 'number'; - * }); + * _.omit(object, _.isNumber); * // => { 'user': 'fred' } */ function omit(object, predicate, thisArg) { @@ -8301,12 +8636,11 @@ } /** - * Creates a shallow clone of `object` composed of the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If `predicate` is provided it is invoked for each property - * of `object` picking the properties `predicate` returns truthy for. The - * predicate is bound to `thisArg` and invoked with three arguments; - * (value, key, object). + * Creates an object composed of the picked `object` properties. Property + * names may be specified as individual arguments or as arrays of property + * names. If `predicate` is provided it is invoked for each property of `object` + * picking the properties `predicate` returns truthy for. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, key, object). * * @static * @memberOf _ @@ -8319,12 +8653,12 @@ * @returns {Object} Returns the new object. * @example * - * _.pick({ 'user': 'fred', '_userid': 'fred1' }, 'user'); + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.pick(object, 'user'); * // => { 'user': 'fred' } * - * _.pick({ 'user': 'fred', '_userid': 'fred1' }, function(value, key) { - * return key.charAt(0) != '_'; - * }); + * _.pick(object, _.isString); * // => { 'user': 'fred' } */ function pick(object, predicate, thisArg) { @@ -8336,13 +8670,51 @@ : pickByArray(object, baseFlatten(arguments, false, false, 1)); } + /** + * Resolves the value of property `key` on `object`. If the value of `key` is + * a function it is invoked with the `this` binding of `object` and its result + * is returned, else the property value is returned. If the property value is + * `undefined` the `defaultValue` is used in its place. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {string} key The name of the property to resolve. + * @param {*} [defaultValue] The value returned if the property value + * resolves to `undefined`. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'user': 'fred', 'age': _.constant(40) }; + * + * _.result(object, 'user'); + * // => 'fred' + * + * _.result(object, 'age'); + * // => 40 + * + * _.result(object, 'status', 'busy'); + * // => 'busy' + * + * _.result(object, 'status', _.constant('busy')); + * // => 'busy' + */ + function result(object, key, defaultValue) { + var value = object == null ? undefined : object[key]; + if (typeof value == 'undefined') { + value = defaultValue; + } + return isFunction(value) ? value.call(object) : value; + } + /** * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable properties through `iteratee`, with each invocation potentially - * mutating the `accumulator` object. The `iteratee` is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, key, object). Iterator - * functions may exit iteration early by explicitly returning `false`. + * `accumulator` object which is the result of running each of its own enumerable + * properties through `iteratee`, with each invocation potentially mutating + * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked + * with four arguments; (accumulator, value, key, object). Iterator functions + * may exit iteration early by explicitly returning `false`. * * @static * @memberOf _ @@ -8395,7 +8767,7 @@ * @static * @memberOf _ * @category Object - * @param {Object} object The object to inspect. + * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * @@ -8410,7 +8782,7 @@ * // => [2, 1] (iteration order is not guaranteed) */ function values(object) { - return baseValues(object, keys); + return baseValues(object, keys(object)); } /** @@ -8420,7 +8792,7 @@ * @static * @memberOf _ * @category Object - * @param {Object} object The object to inspect. + * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * @@ -8435,7 +8807,71 @@ * // => [2, 1, 0] (iteration order is not guaranteed) */ function valuesIn(object) { - return baseValues(object, keysIn); + return baseValues(object, keysIn(object)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Produces a random number between `min` and `max` (inclusive). If only one + * argument is provided a number between `0` and the given number is returned. + * If `floating` is `true`, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. + * + * @static + * @memberOf _ + * @category Number + * @param {number} [min=0] The minimum possible value. + * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = null; + } + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (noMax && typeof min == 'boolean') { + floating = min; + min = 1; + } + else if (typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + (rand * (max - min + parseFloat('1e-' + (String(rand).length - 1)))), max); + } + return baseRandom(min, max); } /*------------------------------------------------------------------------*/ @@ -8568,7 +9004,7 @@ function escape(string) { // Reset `lastIndex` because in IE < 9 `String#replace` does not. string = string == null ? '' : String(string); - return string && (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string)) + return (string && reHasUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; } @@ -8589,7 +9025,7 @@ */ function escapeRegExp(string) { string = string == null ? '' : String(string); - return string && (reRegExpChars.lastIndex = 0, reRegExpChars.test(string)) + return (string && reHasRegExpChars.test(string)) ? string.replace(reRegExpChars, '\\$&') : string; } @@ -8714,6 +9150,44 @@ return string ? (string + createPad(string, length, chars)) : string; } + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, + * in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the ES5 implementation of `parseInt`. + * See the [ES5 spec](http://es5.github.io/#E) for more details. + * + * @static + * @memberOf _ + * @category String + * @param {string} string The string to parse. + * @param {number} [radix] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + function parseInt(string, radix, guard) { + if (guard && isIterateeCall(string, radix, guard)) { + radix = 0; + } + return nativeParseInt(string, radix); + } + // Fallback for environments with pre-ES5 implementations. + if (nativeParseInt(whitespace + '08') != 8) { + parseInt = function(string, radix, guard) { + // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and + // Chrome fails to trim leading whitespace characters. + // See https://code.google.com/p/v8/issues/detail?id=3109. + radix = (guard && isIterateeCall(string, radix, guard)) ? 0 : +radix; + string = trim(string); + return nativeParseInt(string, radix || (reHexPrefix.test(string) ? 16 : 10)); + }; + } + /** * Repeats the given string `n` times. * @@ -8822,7 +9296,7 @@ * [Lo-Dash's custom builds documentation](https://lodash.com/custom-builds). * * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](http://developer.chrome.com/stable/extensions/sandboxingEval.html). + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). * * @static * @memberOf _ @@ -8912,11 +9386,11 @@ options = otherOptions = null; } string = String(string == null ? '' : string); - options = assign({}, otherOptions || options, settings, assignOwnDefaults); + options = baseAssign(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); - var imports = assign({}, options.imports, settings.imports, assignOwnDefaults), + var imports = baseAssign(baseAssign({}, options.imports), settings.imports, assignOwnDefaults), importsKeys = keys(imports), - importsValues = values(imports); + importsValues = baseValues(imports, importsKeys); var isEscaping, isEvaluating, @@ -8934,8 +9408,11 @@ // Use a sourceURL for easier debugging. // See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl. - var sourceURL = 'sourceURL' in options ? options.sourceURL : ('/lodash/template/source[' + (++templateCounter) + ']'); - sourceURL = sourceURL ? ('//# sourceURL=' + sourceURL + '\n') : ''; + var sourceURL = '//# sourceURL=' + + ('sourceURL' in options + ? options.sourceURL + : ('/lodash/template/source[' + (++templateCounter) + ']') + ) + '\n'; string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); @@ -9026,11 +9503,12 @@ * // => 'fred' */ function trim(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -9056,11 +9534,12 @@ * // => 'fred-_-' */ function trimLeft(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -9086,11 +9565,12 @@ * // => '-_-fred' */ function trimRight(string, chars, guard) { + var value = string; string = string == null ? '' : String(string); if (!string) { return string; } - if (guard ? isIterateeCall(string, chars, guard) : chars == null) { + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -9200,7 +9680,7 @@ */ function unescape(string) { string = string == null ? '' : String(string); - return string && (reEscapedHtml.lastIndex = 0, reEscapedHtml.test(string)) + return (string && reHasEscapedHtml.test(string)) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string; } @@ -9224,10 +9704,10 @@ * // => ['fred', 'barney', '&', 'pebbles'] */ function words(string, pattern, guard) { - string = string != null && String(string); if (guard && isIterateeCall(string, pattern, guard)) { pattern = null; } + string = string != null && String(string); return (string && string.match(pattern || reWords)) || []; } @@ -9272,9 +9752,9 @@ * @alias iteratee * @category Utility * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. + * @param {*} [thisArg] The `this` binding of `func`. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new function. + * @returns {Function} Returns the callback. * @example * * var users = [ @@ -9344,8 +9824,8 @@ /** * Creates a "_.where" style predicate function which performs a deep comparison - * between a given object and the `source` object, returning `true` if the given - * object has equivalent property values, else `false`. + * between a given object and `source`, returning `true` if the given object + * has equivalent property values, else `false`. * * @static * @memberOf _ @@ -9368,54 +9848,7 @@ * // => { 'user': 'barney', 'age': 36 } */ function matches(source) { - var props = keys(source), - length = props.length; - - if (length == 1) { - var key = props[0], - value = source[key]; - - if (isStrictComparable(value)) { - return function(object) { - return object != null && value === object[key] && hasOwnProperty.call(object, key); - }; - } - } - var index = length, - values = Array(length), - strictCompareFlags = Array(length); - - while (index--) { - value = source[props[index]]; - var isStrict = isStrictComparable(value); - - values[index] = isStrict ? value : baseClone(value, true, clonePassthru); - strictCompareFlags[index] = isStrict; - } - return function(object) { - index = length; - if (object == null) { - return !index; - } - while (index--) { - if (strictCompareFlags[index] - ? values[index] !== object[props[index]] - : !hasOwnProperty.call(object, props[index]) - ) { - return false; - } - } - index = length; - while (index--) { - if (strictCompareFlags[index] - ? !hasOwnProperty.call(object, props[index]) - : !baseIsEqual(values[index], object[props[index]], null, true) - ) { - return false; - } - } - return true; - }; + return baseMatches(source, true); } /** @@ -9532,60 +9965,6 @@ // No operation performed. } - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Utility - * @example - * - * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked - */ - var now = nativeNow || function() { - return new Date().getTime(); - }; - - /** - * Converts `value` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, - * in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the ES5 implementation of `parseInt`. - * See the [ES5 spec](http://es5.github.io/#E) for more details. - * - * @static - * @memberOf _ - * @category Utility - * @param {string} value The value to parse. - * @param {number} [radix] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {number} Returns the converted integer. - * @example - * - * _.parseInt('08'); - * // => 8 - */ - function parseInt(value, radix, guard) { - if (guard && isIterateeCall(value, radix, guard)) { - radix = 0; - } - return nativeParseInt(value, radix); - } - // Fallback for environments with pre-ES5 implementations. - if (nativeParseInt(whitespace + '08') != 8) { - parseInt = function(value, radix, guard) { - // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and - // Chrome fails to trim leading whitespace characters. - // See https://code.google.com/p/v8/issues/detail?id=3109. - value = trim(value); - radix = (guard && isIterateeCall(value, radix, guard)) ? 0 : +radix; - return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10)); - }; - } - /** * Creates a "_.pluck" style function which returns the property value * of `key` on a given object. @@ -9611,10 +9990,7 @@ * // => ['barney', 'fred'] */ function property(key) { - key = String(key); - return function(object) { - return object == null ? undefined : object[key]; - }; + return baseProperty(String(key)); } /** @@ -9642,68 +10018,6 @@ }; } - /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number is returned. - * If `floating` is `true`, or either `min` or `max` are floats, a floating-point - * number is returned instead of an integer. - * - * @static - * @memberOf _ - * @category Utility - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. - * @param {boolean} [floating=false] Specify returning a floating-point number. - * @returns {number} Returns the random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(min, max, floating) { - if (floating && isIterateeCall(min, max, floating)) { - max = floating = null; - } - var noMin = min == null, - noMax = max == null; - - if (floating == null) { - if (noMax && typeof min == 'boolean') { - floating = min; - min = 1; - } - else if (typeof max == 'boolean') { - floating = max; - noMax = true; - } - } - if (noMin && noMax) { - max = 1; - noMax = false; - } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; - } - if (floating || min % 1 || max % 1) { - var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + (String(rand).length - 1)))), max); - } - return baseRandom(min, max); - } - /** * Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. If `start` is less than `end` a @@ -9762,47 +10076,6 @@ return result; } - /** - * Resolves the value of property `key` on `object`. If `key` is a function - * it is invoked with the `this` binding of `object` and its result returned, - * else the property value is returned. If `object` is `null` or `undefined` - * then `undefined` is returned. If a default value is provided it is returned - * if the property value resolves to `undefined`. - * - * @static - * @memberOf _ - * @category Utility - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to resolve. - * @param {*} [defaultValue] The value returned if the property value - * resolves to `undefined`. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { - * 'user': 'fred', - * 'age': function() { - * return 40; - * } - * }; - * - * _.result(object, 'user'); - * // => 'fred' - * - * _.result(object, 'age'); - * // => 40 - * - * _.result(object, 'status', 'busy'); - * // => 'busy' - */ - function result(object, key, defaultValue) { - var value = object == null ? undefined : object[key]; - if (typeof value == 'undefined') { - return defaultValue; - } - return isFunction(value) ? object[key]() : value; - } - /** * Invokes the iteratee function `n` times, returning an array of the results * of each invocation. The `iteratee` is bound to `thisArg` and invoked with @@ -9834,11 +10107,10 @@ if (n < 1 || !nativeIsFinite(n)) { return []; } - iteratee = baseCallback(iteratee, thisArg, 1); - var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); + iteratee = bindCallback(iteratee, thisArg, 1); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { result[index] = iteratee(index); @@ -10036,6 +10308,7 @@ lodash.isError = isError; lodash.isFinite = isFinite; lodash.isFunction = isFunction; + lodash.isMatch = isMatch; lodash.isNaN = isNaN; lodash.isNative = isNative; lodash.isNull = isNull; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index b4223d5fd..5b6b0126e 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,81 +4,81 @@ * Build: `lodash modern -o ./dist/lodash.js` */ ;(function(){function n(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function A(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n){for(var t=-1,r=n.length,e=Xu;++to(t,a)&&e.push(a);return e}function er(n,t){var r=n?n.length:0;if(!Kr(r))return pr(n,t);for(var e=-1,u=Qr(n);++ec))return false}else{var g=p&&xu.call(n,"__wrapped__"),h=h&&xu.call(t,"__wrapped__");if(g||h)return vr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!a&&!p){switch(l){case mt:case _t:return+n==+t;case xt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case jt:case It:return n==du(t)}return false}if(g=c?gu:n.constructor,l=i?gu:t.constructor,a){if(g.prototype.name!=l.prototype.name)return false -}else if(p=!c&&xu.call(n,"constructor"),h=!i&&xu.call(t,"constructor"),p!=h||!p&&g!=l&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof l=="function"&&l instanceof l))return false;if(g=a?["message","name"]:mo(n),l=a?g:mo(t),c&&g.push("length"),i&&l.push("length"),c=g.length,p=l.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;if(u.push(n),o.push(t),i=true,f)for(;i&&++le(a,s)&&((t||i)&&a.push(s),l.push(c))}return l}function jr(n,t){for(var r=-1,e=t(n),u=e.length,o=fu(u);++rt||null==r)return r;if(3=i&&r<=a&&(e<$||(p||s)&&o[0].length<=g),(!(e>=$&&t>u||e>u&&t>=$)||o)&&(t&C&&(n[2]=h[2],r|=e&C?0:T),(e=h[3])&&(u=n[3],n[3]=u?Or(u,e,h[4]):l(e),n[4]=u?A(n[3],Y):l(h[4])),(e=h[5])&&(u=n[5],n[5]=u?Rr(u,e,h[6]):l(e),n[6]=u?A(n[5],Y):l(h[6])),(e=h[7])&&(o=n[7],e=n[7]=l(e),o&&Tu.apply(e,o)),null==n[8]&&(n[8]=h[8]),t&$&&(n[9]=null==n[9]?h[9]:Ku(n[9],h[9])),n[0]=h[0],n[1]=r) -}return n[8]=null==n[8]?f?0:n[0].length:Pu(n[8]-c,0)||0,t=n[1],(h?uo:ao)(t==C?Tr(n[0],n[2]):t!=F&&t!=(C|F)||n[4].length?Fr.apply(null,n):$r.apply(null,n),n)}function Lr(n,t,r){var e=Lt.callback||nu,e=e===nu?Qt:e;return r?e(n,t,r):e}function zr(n,t,r){var e=Lt.indexOf||ue,e=e===ue?f:e;return n?e(n,t,r):e}function Dr(n,t){var r=-1,e=n.length,u=new n.constructor(e);if(!t)for(;++rt?0:t)}function te(n,t,r){return(r?Pr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ie(n,0,0>t?0:t)}function re(n,t,r){var e=-1,u=n?n.length:0;for(t=Lr(t,r,3);++er?Pu(e+r,0):r||0;else if(r)return r=ae(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return f(n,t,r)}function oe(n){return ne(n,1)}function ie(n,t,r){var e=-1,u=n?n.length:0,o=typeof r; -if(r&&"number"!=o&&Pr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=fu(u);++er?Pu(e+r,0):r||0:0,typeof n=="string"||!ho(n)&&Pe(n)?ri||r===Ju&&r===a)&&(i=r,a=n)}),a}function we(n,t){return _e(n,au(t))}function xe(n,t,r,e){return(ho(n)?u:br)(n,Lr(t,e,4),r,3>arguments.length,er)}function Ae(n,t,r,e){return(ho(n)?o:br)(n,Lr(t,e,4),r,3>arguments.length,ur)}function je(n){n=Hr(n);for(var t=-1,r=n.length,e=fu(r);++t=r||r>t?(a&&Ru(a),r=p,a=s=p=O,r&&(h=Ao(),f=n.apply(c,i),s||a||(i=c=null))):s=Fu(e,r)}function u(){s&&Ru(s),a=s=p=O,(v||g!==t)&&(h=Ao(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=Ao(),c=this,p=v&&(s||!d),false===g)var r=d&&!s;else{a||d||(h=l);var o=g-(l-h),y=0>=o||o>g;y?(a&&(a=Ru(a)),h=l,f=n.apply(c,i)):a||(a=Fu(u,o)) -}return y&&s?s=Ru(s):s||t===g||(s=Fu(e,t)),r&&(y=true,f=n.apply(c,i)),!y||s||a||(i=c=null),f}var i,a,f,l,c,s,p,h=0,g=false,v=true;if(!Le(n))throw new yu(V);if(t=0>t?0:t,true===r)var d=true,v=false;else ze(r)&&(d=r.leading,g="maxWait"in r&&Pu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Ru(s),a&&Ru(a),a=s=p=O},o}function Te(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Le))throw new yu(V);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e); -return e}}function We(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(!Le(n)||t&&!Le(t))throw new yu(V);return r.cache=new We.Cache,r}function Ne(n){var t=ie(arguments,1),r=A(t,Ne.placeholder);return Br(n,F,null,t,r)}function Fe(n){var t=ie(arguments,1),r=A(t,Fe.placeholder);return Br(n,U,null,t,r)}function Ue(n){return Kr(w(n)?n.length:O)&&ju.call(n)==dt||false}function $e(n){return n&&1===n.nodeType&&w(n)&&-1t||null==n||!Mu(t))return r; -n=du(n);do t%2&&(r+=n),t=Cu(t/2),n+=n;while(t);return r}function Xe(n,t,r){return(n=null==n?"":du(n))?(r?Pr(n,t,r):null==t)?n.slice(j(n),I(n)+1):(t=du(t),n.slice(p(n,t),h(n,t)+1)):n}function He(n,t,r){return n=null!=n&&du(n),r&&Pr(n,t,r)&&(t=null),n&&n.match(t||ht)||[]}function Qe(n){try{return n()}catch(t){return Be(t)?t:cu(t)}}function nu(n,t,r){return r&&Pr(n,t,r)&&(t=null),Qt(n,t)}function tu(n){return function(){return n}}function ru(n){return n}function eu(n){var t=mo(n),r=t.length;if(1==r){var e=t[0],u=n[e]; -if(Vr(u))return function(n){return null!=n&&u===n[e]&&xu.call(n,e)}}for(var o=r,i=fu(r),a=fu(r);o--;){var u=n[t[o]],f=Vr(u);i[o]=f?u:nr(u,true,Er),a[o]=f}return function(n){if(o=r,null==n)return!o;for(;o--;)if(a[o]?i[o]!==n[t[o]]:!xu.call(n,t[o]))return false;for(o=r;o--;)if(a[o]?!xu.call(n,t[o]):!vr(i[o],n[t[o]],null,true))return false;return true}}function uu(n,t,r){var e=true,u=ze(t),o=null==r,i=o&&u&&mo(t),a=i&&gr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=gr(t,mo(t))),false===r?e=false:ze(r)&&"chain"in r&&(e=r.chain),r=-1,u=Le(n); -for(o=a.length;++r=D)return r}else n=0;return uo(r,e)}}(),fo=Cr(function(n,t,r){xu.call(n,r)?++n[r]:n[r]=1}),lo=Cr(function(n,t,r){xu.call(n,r)?n[r].push(t):n[r]=[t]}),co=Cr(function(n,t,r){n[r]=t}),so=Cr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),po=Br(ke,F,null,[2]),ho=Du||function(n){return w(n)&&Kr(n.length)&&ju.call(n)==yt||false -};eo.dom||($e=function(n){return n&&1===n.nodeType&&w(n)&&!vo(n)||false});var go=Yu||function(n){return typeof n=="number"&&Mu(n)};(Le(/x/)||$u&&!Le($u))&&(Le=function(n){return ju.call(n)==wt});var vo=Su?function(n){if(!n||ju.call(n)!=At)return false;var t=n.valueOf,r=De(t)&&(r=Su(t))&&Su(r);return r?n==r||Su(n)==r:Jr(n)}:Jr,yo=Sr(Xt),mo=qu?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},Lt.ary=function(n,t,r){return r&&Pr(n,t,r)&&(t=null),t=null==t?n.length:+t||0,Br(n,$,null,null,null,null,null,t)},Lt.assign=yo,Lt.at=function(n){return(!n||Kr(n.length))&&(n=Hr(n)),Ht(n,fr(arguments,false,false,1)) -},Lt.before=ke,Lt.bind=Ee,Lt.bindAll=function(n){for(var t=n,r=1(s?Kt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Kt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i)}return c},Lt.invert=function(n,t,r){r&&Pr(n,t,r)&&(t=null),r=-1; -for(var e=mo(n),u=e.length,o={};++rt?0:t)},Lt.takeRight=function(n,t,r){return(r?Pr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ie(n,0>t?0:t)},Lt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Lr(t,r,3);e--&&t(n[e],e,n););return ie(n,e+1)},Lt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0; -for(t=Lr(t,r,3);++en||!Mu(n))return[];t=Qt(t,r,1),r=-1;for(var e=fu(Ku(n,Hu));++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Lt.escape=function(n){return(n=null==n?"":du(n))&&(Q.lastIndex=0,Q.test(n))?n.replace(Q,y):n},Lt.escapeRegExp=Ge,Lt.every=ge,Lt.find=de,Lt.findIndex=re,Lt.findKey=function(n,t,r){return t=Lr(t,r,3),ar(n,t,pr,true) -},Lt.findLast=function(n,t,r){return t=Lr(t,r,3),ar(n,t,ur)},Lt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Lr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Lt.findLastKey=function(n,t,r){return t=Lr(t,r,3),ar(n,t,hr,true)},Lt.findWhere=function(n,t){return de(n,eu(t))},Lt.first=ee,Lt.has=function(n,t){return n?xu.call(n,t):false},Lt.identity=ru,Lt.includes=he,Lt.indexOf=ue,Lt.isArguments=Ue,Lt.isArray=ho,Lt.isBoolean=function(n){return true===n||false===n||w(n)&&ju.call(n)==mt||false},Lt.isDate=function(n){return w(n)&&ju.call(n)==_t||false -},Lt.isElement=$e,Lt.isEmpty=function(n){if(null==n)return true;var t=n.length;return Kr(t)&&(ho(n)||Pe(n)||Ue(n)||w(n)&&Le(n.splice))?!t:!mo(n).length},Lt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Qt(r,e,3),!r&&Vr(n)&&Vr(t)?n===t:vr(n,t,r)},Lt.isError=Be,Lt.isFinite=go,Lt.isFunction=Le,Lt.isNaN=function(n){return Me(n)&&n!=+n},Lt.isNative=De,Lt.isNull=function(n){return null===n},Lt.isNumber=Me,Lt.isObject=ze,Lt.isPlainObject=vo,Lt.isRegExp=qe,Lt.isString=Pe,Lt.isUndefined=function(n){return typeof n=="undefined" -},Lt.kebabCase=wo,Lt.last=function(n){var t=n?n.length:0;return t?n[t-1]:O},Lt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Pu(e+r,0):Ku(r||0,e-1))+1;else if(r)return u=fe(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Lt.max=be,Lt.min=function(n,t,r){r&&Pr(n,t,r)&&(t=null);var e=null==t,u=e&&ho(n),o=!u&&Pe(n);if(e&&!o)return Yt(u?n:Hr(n));var i=Xu,a=i;return t=e&&o?s:Lr(t,r,3),er(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Lt.template=function(n,t,r){var e=Lt.templateSettings;r&&Pr(n,t,r)&&(t=r=null),n=du(null==n?"":n),t=yo({},r||t,e,Jt),r=yo({},t.imports,e.imports,Jt); -var u,o,i=mo(r),a=Ye(r),f=0;r=t.interpolate||lt;var l="__p+='";if(r=vu((t.escape||lt).source+"|"+r.source+"|"+(r===rt?et:lt).source+"|"+(t.evaluate||lt).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(pt,m),r&&(u=true,l+="'+__e("+r+")+'"),a&&(o=true,l+="';"+a+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),f=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(G,""):l).replace(J,"$1").replace(X,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Qe(function(){return su(i,"return "+l).apply(O,a) -}),t.source=l,Be(t))throw t;return t},Lt.trim=Xe,Lt.trimLeft=function(n,t,r){return(n=null==n?"":du(n))?(r?Pr(n,t,r):null==t)?n.slice(j(n)):(t=du(t),n.slice(p(n,t))):n},Lt.trimRight=function(n,t,r){return(n=null==n?"":du(n))?(r?Pr(n,t,r):null==t)?n.slice(0,I(n)+1):(t=du(t),n.slice(0,h(n,t)+1)):n},Lt.trunc=function(n,t,r){r&&Pr(n,t,r)&&(t=null);var e=L;if(r=z,ze(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?du(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":du(n),e>=n.length)return n; -if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(qe(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=vu(u.source,(ut.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Lt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Lt.sample(t,n)}):Lt.sample(this.value())},Lt.VERSION=R,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Lt[n].placeholder=Lt}),n(["filter","map","takeWhile"],function(n,t){var r=t==q; -Dt.prototype[n]=function(n,e){n=Lr(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==K&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";Dt.prototype[n]=function(e){e=null==e?1:Pu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Ku(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},Dt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse() -},Dt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");Dt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Dt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?eu:au;Dt.prototype[n]=function(n){return this[r](e(n))}}),Dt.prototype.dropWhile=function(n,t){n=Lr(n,t,3);var r,e,u=0>this.dir; -return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},Dt.prototype.reject=function(n,t){return n=Lr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Dt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},pr(Dt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Lt.prototype[t]=function(){function e(n){return n=[n],Tu.apply(n,o),Lt[t].apply(Lt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,a=!!this.__actions__.length,f=u instanceof Dt,l=f&&!a; -return r&&!i?l?n.call(u):Lt[t](this.value()):f||ho(u)?(u=n.apply(l?u:new Dt(this),o),r||!a&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:Lt,name:"thru"}),new zt(u,i)):this.thru(e)}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=mu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Lt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)}) -}}),Dt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new Dt(this.wrapped);return e.actions=n?l(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?l(t):null,e.takeCount=this.takeCount,e.views=r?l(r):null,e},Dt.prototype.reverse=function(){var n=this.filtered,t=n?new Dt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t},Dt.prototype.value=function(){var n=this.wrapped.value();if(!ho(n))return Ir(n,this.actions);var t,r=this.dir,e=0>r,u=n.length; -t=u;for(var o=this.views,i=0,a=-1,f=o?o.length:0;++a"'`]/g,nt=/<%-([\s\S]+?)%>/g,tt=/<%([\s\S]+?)%>/g,rt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ut=/\w*$/,ot=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,at=/^\[object .+?Constructor\]$/,ft=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,lt=/($^)/,ct=/[.*+?^${}()|[\]\/\\]/g,st=/\bthis\b/,pt=/['\n\r\u2028\u2029\\]/g,ht=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),gt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",vt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),dt="[object Arguments]",yt="[object Array]",mt="[object Boolean]",_t="[object Date]",bt="[object Error]",wt="[object Function]",xt="[object Number]",At="[object Object]",jt="[object RegExp]",It="[object String]",kt="[object ArrayBuffer]",Et="[object Float32Array]",Ot="[object Float64Array]",Rt="[object Int8Array]",Ct="[object Int16Array]",St="[object Int32Array]",Tt="[object Uint8Array]",Wt="[object Uint8ClampedArray]",Nt="[object Uint16Array]",Ft="[object Uint32Array]",Ut={}; -Ut[dt]=Ut[yt]=Ut[Et]=Ut[Ot]=Ut[Rt]=Ut[Ct]=Ut[St]=Ut[Tt]=Ut[Wt]=Ut[Nt]=Ut[Ft]=true,Ut[kt]=Ut[mt]=Ut[_t]=Ut[bt]=Ut[wt]=Ut["[object Map]"]=Ut[xt]=Ut[At]=Ut[jt]=Ut["[object Set]"]=Ut[It]=Ut["[object WeakMap]"]=false;var $t={};$t[dt]=$t[yt]=$t[kt]=$t[mt]=$t[_t]=$t[Et]=$t[Ot]=$t[Rt]=$t[Ct]=$t[St]=$t[xt]=$t[At]=$t[jt]=$t[It]=$t[Tt]=$t[Wt]=$t[Nt]=$t[Ft]=true,$t[bt]=$t[wt]=$t["[object Map]"]=$t["[object Set]"]=$t["[object WeakMap]"]=false;var Bt={leading:false,maxWait:0,trailing:false},Lt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},zt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Dt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Mt={"function":true,object:true},qt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Pt=Mt[typeof window]&&window!==(this&&this.window)?window:this,Kt=Mt[typeof exports]&&exports&&!exports.nodeType&&exports,Vt=Mt[typeof module]&&module&&!module.nodeType&&module,Yt=Kt&&Vt&&typeof global=="object"&&global; -!Yt||Yt.global!==Yt&&Yt.window!==Yt&&Yt.self!==Yt||(Pt=Yt);var Zt=Vt&&Vt.exports===Kt&&Kt,Gt=E();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Pt._=Gt, define(function(){return Gt})):Kt&&Vt?Zt?(Vt.exports=Gt)._=Gt:Kt._=Gt:Pt._=Gt}).call(this); \ No newline at end of file +return r}function i(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function A(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Jt(n){for(var t=-1,r=n.length,e=uo;++to(t,a)&&e.push(a);return e}function ir(n,t){var r=n?n.length:0;if(!re(r))return vr(n,t);for(var e=-1,u=le(n);++ee(a,s)&&((t||i)&&a.push(s),l.push(c))}return l}function Cr(n,t){for(var r=-1,e=t.length,u=gu(e);++rao)){u=r,u=null==u?lu:u,t=u(t),o=0,r=n.length;for(var i=t!==t,a=typeof t=="undefined";o>>1,i=n[r],(e?i<=t:it||null==r)return r;if(3=o&&r<=i&&(e=L&&t>u||e>u&&t>=L)||o)&&(t&C&&(n[2]=h[2],r|=e&C?0:T),(e=h[3])&&(u=n[3],n[3]=u?Ur(u,e,h[4]):l(e),n[4]=u?A(n[3],Y):l(h[4])),(e=h[5])&&(u=n[5],n[5]=u?Lr(u,e,h[6]):l(e),n[6]=u?A(n[5],Y):l(h[6])),(e=h[7])&&(n[7]=l(e)),t&$&&(n[8]=null==n[8]?h[8]:Hu(n[8],h[8])),null==n[9]&&(n[9]=h[9]),n[0]=h[0],n[1]=r)}return n[9]=null==n[9]?f?0:n[0].length:Xu(n[9]-c,0)||0,t=n[1],(h?ho:yo)(t==C?zr(n[0],n[2]):t!=F&&t!=(C|F)||n[4].length?qr.apply(null,n):Kr.apply(null,n),n)}function Yr(n,t,r,e,u,o,i){var a=-1,f=n.length,l=t.length,c=true; +if(f!=l&&(!u||l<=f))return false;for(;c&&++at?0:t)}function se(n,t,r){return(r?te(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,de(n,0,0>t?0:t)}function pe(n,t,r){var e=-1,u=n?n.length:0;for(t=Jr(t,r,3);++er?Xu(e+r,0):r||0;else if(r)return r=Tr(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return f(n,t,r)}function ve(n){return ce(n,1) +}function de(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&te(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=gu(u);++e>>0,u=gu(r);++tr?Xu(e+r,0):r||0:0,typeof n=="string"||!Ao(n)&&Je(n)?rarguments.length,ir)}function Oe(n,t,r,e){return(Ao(n)?o:kr)(n,Jr(t,e,4),r,3>arguments.length,ar)}function Ce(n){n=fe(n);for(var t=-1,r=n.length,e=gu(r);++t=r||r>t?(a&&Lu(a),r=p,a=s=p=I,r&&(h=xo(),f=n.apply(c,i),s||a||(i=c=null))):s=qu(e,r)}function u(){s&&Lu(s),a=s=p=I,(v||g!==t)&&(h=xo(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=xo(),c=this,p=v&&(s||!d),false===g)var r=d&&!s;else{a||d||(h=l);var o=g-(l-h),y=0>=o||o>g;y?(a&&(a=Lu(a)),h=l,f=n.apply(c,i)):a||(a=qu(u,o))}return y&&s?s=Lu(s):s||t===g||(s=qu(e,t)),r&&(y=true,f=n.apply(c,i)),!y||s||a||(i=c=null),f}var i,a,f,l,c,s,p,h=0,g=false,v=true;if(!Ke(n))throw new Au(V);if(t=0>t?0:t,true===r)var d=true,v=false; +else Ve(r)&&(d=r.leading,g="maxWait"in r&&Xu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Lu(s),a&&Lu(a),a=s=p=I},o}function $e(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Ke))throw new Au(V);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Be(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o +}if(!Ke(n)||t&&!Ke(t))throw new Au(V);return r.cache=new Be.Cache,r}function ze(n){var t=de(arguments,1),r=A(t,ze.placeholder);return Vr(n,F,null,t,r)}function De(n){var t=de(arguments,1),r=A(t,De.placeholder);return Vr(n,U,null,t,r)}function Me(n){return re(w(n)?n.length:I)&&Tu.call(n)==mt||false}function qe(n){return n&&1===n.nodeType&&w(n)&&-1t||null==n||!Gu(t))return r;n=xu(n);do t%2&&(r+=n),t=$u(t/2),n+=n;while(t);return r}function uu(n,t,r){var e=n;return(n=null==n?"":xu(n))?(r?te(e,t,r):null==t)?n.slice(j(n),E(n)+1):(t=xu(t),n.slice(p(n,t),h(n,t)+1)):n +}function ou(n,t,r){return r&&te(n,t,r)&&(t=null),(n=null!=n&&xu(n))&&n.match(t||vt)||[]}function iu(n){try{return n()}catch(t){return Pe(t)?t:du(t)}}function au(n,t,r){return r&&te(n,t,r)&&(t=null),rr(n,t)}function fu(n){return function(){return n}}function lu(n){return n}function cu(n){return Ar(n,true)}function su(n,t,r){var e=true,u=Ve(t),o=null==r,i=o&&u&&ko(t),a=i&&yr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=yr(t,ko(t))),false===r?e=false:Ve(r)&&"chain"in r&&(e=r.chain),r=-1,u=Ke(n); +for(o=a.length;++r>>1,fo=Yu?Yu.BYTES_PER_ELEMENT:0,lo=mu.pow(2,53)-1,co=Vu&&new Vu,so=Dt.support={};!function(n){so.funcDecomp=!Ye(x.WinRTError)&&ht.test(k),so.funcNames=typeof yu.name=="string";try{so.dom=11===Ru.createDocumentFragment().nodeType}catch(t){so.dom=false +}try{so.nonEnumArgs=!Du.call(arguments,1)}catch(r){so.nonEnumArgs=true}}(0,0),Dt.templateSettings={escape:tt,evaluate:rt,interpolate:et,variable:"",imports:{_:Dt}};var po=function(){function n(){}return function(t){if(Ve(t)){n.prototype=t;var r=new n;n.prototype=null}return r||x.Object()}}(),ho=co?function(n,t){return co.set(n,t),n}:lu;Fu||(Nr=Nu&&Ku?function(n){var t=n.byteLength,r=Yu?$u(t/fo):0,e=r*fo,u=new Nu(t);if(r){var o=new Yu(u,0,r);o.set(new Yu(n,0,r))}return t!=e&&(o=new Ku(u,e),o.set(new Ku(n,e))),u +}:fu(null));var go=Mu?function(n){return new Kt(n)}:fu(null),vo=co?function(n){return co.get(n)}:pu,yo=function(){var n=0,t=0;return function(r,e){var u=xo(),o=M-(u-t);if(t=u,0=D)return r}else n=0;return ho(r,e)}}(),mo=$r(function(n,t,r){Ou.call(n,r)?++n[r]:n[r]=1}),_o=$r(function(n,t,r){Ou.call(n,r)?n[r].push(t):n[r]=[t]}),bo=$r(function(n,t,r){n[r]=t}),wo=$r(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),xo=Qu||function(){return(new vu).getTime()},Ao=Zu||function(n){return w(n)&&re(n.length)&&Tu.call(n)==_t||false +};so.dom||(qe=function(n){return n&&1===n.nodeType&&w(n)&&!Eo(n)||false});var jo=no||function(n){return typeof n=="number"&&Gu(n)};(Ke(/x/)||Ku&&!Ke(Ku))&&(Ke=function(n){return Tu.call(n)==At});var Eo=Bu?function(n){if(!n||Tu.call(n)!=Et)return false;var t=n.valueOf,r=Ye(t)&&(r=Bu(t))&&Bu(r);return r?n==r||Bu(n)==r:ie(n)}:ie,Ro=Br(nr),ko=Ju?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&r&&re(r)?ae(n):Ve(n)?Ju(n):[]}:ae,Io=Br(jr),Oo=Dr(function(n,t,r){return t=t.toLowerCase(),r?n+t.charAt(0).toUpperCase()+t.slice(1):t +}),Co=Dr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()});8!=to(dt+"08")&&(ru=function(n,t,r){return t=r&&te(n,t,r)?0:+t,n=uu(n),to(n,t||(at.test(n)?16:10))});var So=Dr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()});return Mt.prototype=Dt.prototype,Pt.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},Pt.prototype.get=function(n){return"__proto__"==n?I:this.__data__[n]},Pt.prototype.has=function(n){return"__proto__"!=n&&Ou.call(this.__data__,n)},Pt.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this +},Kt.prototype.push=function(n){var t=this.data,r=typeof n;"number"==r?t[r][n]=true:t.set.add(n)},Be.Cache=Pt,Dt.after=function(n,t){if(!Ke(t)){if(!Ke(n))throw new Au(V);var r=n;n=t,t=r}return n=Gu(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Dt.ary=function(n,t,r){return r&&te(n,t,r)&&(t=null),t=null==t?n.length:+t||0,Vr(n,$,null,null,null,null,t)},Dt.assign=Ro,Dt.at=function(n){return re(n?n.length:0)&&(n=fe(n)),tr(n,sr(arguments,false,false,1))},Dt.before=Te,Dt.bind=We,Dt.bindAll=function(n){for(var t=n,r=1(s?Yt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Yt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i)}return c},Dt.invert=function(n,t,r){r&&te(n,t,r)&&(t=null),r=-1;for(var e=ko(n),u=e.length,o={};++rt?0:t)},Dt.takeRight=function(n,t,r){return(r?te(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,de(n,0>t?0:t) +},Dt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Jr(t,r,3);e--&&t(n[e],e,n););return de(n,e+1)},Dt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Jr(t,r,3);++en||!Gu(n))return[];var e=-1,u=gu(Hu(n,oo));for(t=Wr(t,r,1);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Dt.escape=function(n){return(n=null==n?"":xu(n))&&nt.test(n)?n.replace(H,y):n},Dt.escapeRegExp=tu,Dt.every=xe,Dt.find=je,Dt.findIndex=pe,Dt.findKey=function(n,t,r){return t=Jr(t,r,3),cr(n,t,vr,true) +},Dt.findLast=function(n,t,r){return t=Jr(t,r,3),cr(n,t,ar)},Dt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Jr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Dt.findLastKey=function(n,t,r){return t=Jr(t,r,3),cr(n,t,dr,true)},Dt.findWhere=function(n,t){return je(n,cu(t))},Dt.first=he,Dt.has=function(n,t){return n?Ou.call(n,t):false},Dt.identity=lu,Dt.includes=we,Dt.indexOf=ge,Dt.isArguments=Me,Dt.isArray=Ao,Dt.isBoolean=function(n){return true===n||false===n||w(n)&&Tu.call(n)==bt||false},Dt.isDate=function(n){return w(n)&&Tu.call(n)==wt||false +},Dt.isElement=qe,Dt.isEmpty=function(n){if(null==n)return true;var t=n.length;return re(t)&&(Ao(n)||Je(n)||Me(n)||w(n)&&Ke(n.splice))?!t:!ko(n).length},Dt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Wr(r,e,3),!r&&ee(n)&&ee(t)?n===t:(e=r?r(n,t):I,typeof e=="undefined"?_r(n,t,r):!!e)},Dt.isError=Pe,Dt.isFinite=jo,Dt.isFunction=Ke,Dt.isMatch=function(n,t,r,e){var u=ko(t),o=u.length;if(r=typeof r=="function"&&Wr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],ee(e))return null!=n&&e===n[i]&&Ou.call(n,i) +}for(var i=gu(o),a=gu(o);o--;)e=i[o]=t[u[o]],a[o]=ee(e);return wr(n,u,i,a,r)},Dt.isNaN=function(n){return Ze(n)&&n!=+n},Dt.isNative=Ye,Dt.isNull=function(n){return null===n},Dt.isNumber=Ze,Dt.isObject=Ve,Dt.isPlainObject=Eo,Dt.isRegExp=Ge,Dt.isString=Je,Dt.isUndefined=function(n){return typeof n=="undefined"},Dt.kebabCase=Co,Dt.last=function(n){var t=n?n.length:0;return t?n[t-1]:I},Dt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Xu(e+r,0):Hu(r||0,e-1))+1; +else if(r)return u=Tr(n,t,null,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Dt.max=function(n,t,r){r&&te(n,t,r)&&(t=null);var e=null==t,u=e&&Ao(n),o=!u&&Je(n);if(e&&!o)return Gt(u?n:fe(n));var i=eo,a=i;return t=e&&o?s:Jr(t,r,3),ir(n,function(n,r,e){r=t(n,r,e),(r>i||r===eo&&r===a)&&(i=r,a=n)}),a},Dt.min=function(n,t,r){r&&te(n,t,r)&&(t=null);var e=null==t,u=e&&Ao(n),o=!u&&Je(n);if(e&&!o)return Jt(u?n:fe(n));var i=uo,a=i;return t=e&&o?s:Jr(t,r,3),ir(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r +},Dt.template=function(n,t,r){var e=Dt.templateSettings;r&&te(n,t,r)&&(t=r=null),n=xu(null==n?"":n),t=nr(nr({},r||t),e,Qt),r=nr(nr({},t.imports),e.imports,Qt);var u,o,i=ko(r),a=Cr(r,i),f=0;r=t.interpolate||ct;var l="__p+='";r=wu((t.escape||ct).source+"|"+r.source+"|"+(r===et?ut:ct).source+"|"+(t.evaluate||ct).source+"|$","g");var c="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(gt,m),r&&(u=true,l+="'+__e("+r+")+'"),a&&(o=true,l+="';"+a+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),f=c+t.length,t +}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(Z,""):l).replace(G,"$1").replace(J,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=iu(function(){return yu(i,c+"return "+l).apply(I,a)}),t.source=l,Pe(t))throw t;return t},Dt.trim=uu,Dt.trimLeft=function(n,t,r){var e=n;return(n=null==n?"":xu(n))?(r?te(e,t,r):null==t)?n.slice(j(n)):(t=xu(t),n.slice(p(n,t))):n +},Dt.trimRight=function(n,t,r){var e=n;return(n=null==n?"":xu(n))?(r?te(e,t,r):null==t)?n.slice(0,E(n)+1):(t=xu(t),n.slice(0,h(n,t)+1)):n},Dt.trunc=function(n,t,r){r&&te(n,t,r)&&(t=null);var e=B;if(r=z,Ve(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?xu(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":xu(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(Ge(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=wu(u.source,(ot.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index; +t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n) +},Dt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Dt.sample(t,n)}):Dt.sample(this.value())},Dt.VERSION=O,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Dt[n].placeholder=Dt}),n(["filter","map","takeWhile"],function(n,t){var r=t==q;qt.prototype[n]=function(n,e){n=Jr(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==K&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While"; +qt.prototype[n]=function(e){e=null==e?1:Xu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Hu(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},qt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},qt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");qt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); +qt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?cu:hu;qt.prototype[n]=function(n){return this[r](e(n))}}),qt.prototype.dropWhile=function(n,t){n=Jr(n,t,3);var r,e,u=0>this.dir;return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},qt.prototype.reject=function(n,t){return n=Jr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},qt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n); +return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},vr(qt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Dt.prototype[t]=function(){function e(n){return n=[n],zu.apply(n,o),Dt[t].apply(Dt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,a=!!this.__actions__.length,f=u instanceof qt,l=f&&!a;return r&&!i?l?n.call(u):Dt[t](this.value()):f||Ao(u)?(u=n.apply(l?u:new qt(this),o),r||!a&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:Dt,name:"thru"}),new Mt(u,i)):this.thru(e) +}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=ju[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Dt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),qt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new qt(this.wrapped);return e.actions=n?l(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?l(t):null,e.takeCount=this.takeCount,e.views=r?l(r):null,e +},qt.prototype.reverse=function(){var n=this.filtered,t=n?new qt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t},qt.prototype.value=function(){var n=this.wrapped.value();if(!Ao(n))return Sr(n,this.actions);var t,r=this.dir,e=0>r,u=n.length;t=u;for(var o=this.views,i=0,a=-1,f=o?o.length:0;++a"'`]/g,Q=RegExp(X.source),nt=RegExp(H.source),tt=/<%-([\s\S]+?)%>/g,rt=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,ut=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ot=/\w*$/,it=/^\s*function[ \n\r\t]+\w/,at=/^0[xX]/,ft=/^\[object .+?Constructor\]$/,lt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ct=/($^)/,st=/[.*+?^${}()|[\]\/\\]/g,pt=RegExp(st.source),ht=/\bthis\b/,gt=/['\n\r\u2028\u2029\\]/g,vt=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),dt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",yt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),mt="[object Arguments]",_t="[object Array]",bt="[object Boolean]",wt="[object Date]",xt="[object Error]",At="[object Function]",jt="[object Number]",Et="[object Object]",Rt="[object RegExp]",kt="[object String]",It="[object ArrayBuffer]",Ot="[object Float32Array]",Ct="[object Float64Array]",St="[object Int8Array]",Tt="[object Int16Array]",Wt="[object Int32Array]",Nt="[object Uint8Array]",Ft="[object Uint8ClampedArray]",Ut="[object Uint16Array]",Lt="[object Uint32Array]",$t={}; +$t[mt]=$t[_t]=$t[Ot]=$t[Ct]=$t[St]=$t[Tt]=$t[Wt]=$t[Nt]=$t[Ft]=$t[Ut]=$t[Lt]=true,$t[It]=$t[bt]=$t[wt]=$t[xt]=$t[At]=$t["[object Map]"]=$t[jt]=$t[Et]=$t[Rt]=$t["[object Set]"]=$t[kt]=$t["[object WeakMap]"]=false;var Bt={};Bt[mt]=Bt[_t]=Bt[It]=Bt[bt]=Bt[wt]=Bt[Ot]=Bt[Ct]=Bt[St]=Bt[Tt]=Bt[Wt]=Bt[jt]=Bt[Et]=Bt[Rt]=Bt[kt]=Bt[Nt]=Bt[Ft]=Bt[Ut]=Bt[Lt]=true,Bt[xt]=Bt[At]=Bt["[object Map]"]=Bt["[object Set]"]=Bt["[object WeakMap]"]=false;var zt={leading:false,maxWait:0,trailing:false},Dt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Mt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Pt={"function":true,object:true},Kt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Vt=Pt[typeof window]&&window!==(this&&this.window)?window:this,Yt=Pt[typeof exports]&&exports&&!exports.nodeType&&exports,Zt=Pt[typeof module]&&module&&!module.nodeType&&module,Gt=Yt&&Zt&&typeof global=="object"&&global; +!Gt||Gt.global!==Gt&&Gt.window!==Gt&&Gt.self!==Gt||(Vt=Gt);var Jt=Zt&&Zt.exports===Yt&&Yt,Xt=k();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Vt._=Xt, define(function(){return Xt})):Yt&&Zt?Jt?(Zt.exports=Xt)._=Xt:Yt._=Xt:Vt._=Xt}).call(this); \ No newline at end of file