From 12ad5d53c9c1d9e3e4b08da0b5370ee5289f8038 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 24 Sep 2014 11:14:32 -0700 Subject: [PATCH] Rebuild dist. --- dist/lodash.compat.js | 344 ++++++++++++++++++--------------- dist/lodash.compat.min.js | 142 +++++++------- dist/lodash.js | 346 +++++++++++++++++++--------------- dist/lodash.min.js | 133 +++++++------ dist/lodash.underscore.js | 228 ++++++++++++---------- dist/lodash.underscore.min.js | 84 ++++----- 6 files changed, 703 insertions(+), 574 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 36a0f4b03..41d710b07 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -24,6 +24,10 @@ PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64; + /** Used as default options for `_.trunc` */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; + /** Used to detect when a function becomes hot */ var HOT_COUNT = 150, HOT_SPAN = 16; @@ -81,8 +85,8 @@ /** Used to detect host constructors (Safari > 5) */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters */ - var reLatin1 = /[\xC0-\xFF]/g; + /** Used to match latin-1 supplement letters (excluding mathematical operators) */ + var reLatin1 = /[\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]/g; /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; @@ -102,11 +106,10 @@ /** Used to match words to create compound words */ var reWords = (function() { - var nums = '[0-9]', - upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]', - lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*'; + var upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]', + lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+'; - return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g'); + return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); /** Used to detect and test whitespace */ @@ -254,7 +257,7 @@ '\xDD': 'Y', '\xFD': 'y', '\xFF': 'y', '\xC6': 'Ae', '\xE6': 'ae', '\xDE': 'Th', '\xFE': 'th', - '\xDF': 'ss', '\xD7': ' ', '\xF7': ' ' + '\xDF': 'ss' }; /** Used to determine if values are of the language type `Object` */ @@ -341,7 +344,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function arrayEvery(array, predicate) { @@ -456,7 +459,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { @@ -516,7 +519,8 @@ } /** - * The base implementation of `_.indexOf` without support for binary searches. + * The base implementation of `_.indexOf` without support for `fromIndex` + * bounds checks and binary searches. * * @private * @param {Array} array The array to search. @@ -525,13 +529,14 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } var index = (fromIndex || 0) - 1, - length = array ? array.length : 0, - isReflexive = value === value; + length = array.length; while (++index < length) { - var other = array[index]; - if ((isReflexive ? other === value : other !== other)) { + if (array[index] === value) { return index; } } @@ -692,6 +697,29 @@ return '\\' + stringEscapes[chr]; } + /** + * Gets the index at which the first occurrence of `NaN` is found in `array`. + * If `fromRight` is provided elements of `array` are iterated from right to left. + * + * @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. + * @returns {number} Returns the index of the matched `NaN`, else `-1`. + */ + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, + index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + + while ((fromRight ? index-- : ++index < length)) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + /** * Checks if `value` is a host object in IE < 9. * @@ -712,6 +740,23 @@ }; }()); + /** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ + function isIterateeCall(value, index, object) { + var indexType = typeof index, + objectType = typeof object; + + return (object && (indexType == 'number' || indexType == 'string') && + (objectType == 'function' || objectType == 'object') && object[index] === value) || false; + } + /** * Used by `_.trimmedLeftIndex` and `_.trimmedRightIndex` to determine if a * character code is whitespace. @@ -1534,7 +1579,7 @@ * * @private * @param {Array} array The array to inspect. - * @param {Array} [values] The values to exclude. + * @param {Array} values The values to exclude. * @returns {Array} Returns the new array of filtered values. */ function baseDifference(array, values) { @@ -1548,7 +1593,7 @@ isLarge = prereq && createCache && values && values.length >= 200, isCommon = prereq && !isLarge, result = [], - valuesLength = values ? values.length : 0; + valuesLength = values.length; if (isLarge) { indexOf = cacheIndexOf; @@ -1623,13 +1668,13 @@ } /** - * The base implementation of `_.every` without support for callback shorthands - * or `this` binding. + * The base implementation of `_.every` without support for callback + * shorthands or `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function baseEvery(collection, predicate) { @@ -2250,7 +2295,7 @@ * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function baseSome(collection, predicate) { @@ -2518,12 +2563,10 @@ var length = arguments.length, object = arguments[0]; - if (object == null || length < 2) { + if (length < 2 || object == null) { return object; } - // enables use as a callback for functions like `_.reduce` - var type = typeof arguments[2]; - if ((type == 'number' || type == 'string') && arguments[3] && arguments[3][arguments[2]] === arguments[1]) { + if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { length = 2; } // juggle arguments @@ -3011,8 +3054,8 @@ } /** - * A specialized version of `_.pick` that picks `object` properties - * the predicate returns truthy for. + * A specialized version of `_.pick` that picks `object` properties `predicate` + * returns truthy for. * * @private * @param {Object} object The source object. @@ -3187,6 +3230,7 @@ * @category Array * @param {Array} array The array to process. * @param {numer} [size=1] The length of each chunk. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the new array containing chunks. * @example * @@ -3196,13 +3240,13 @@ * _.chunk(['a', 'b', 'c', 'd'], 3); * // => [['a', 'b', 'c'], ['d']] */ - function chunk(array, size) { + function chunk(array, size, guard) { var index = 0, length = array ? array.length : 0, resIndex = -1, result = []; - size = typeof size == 'undefined' ? 1 : nativeMax(+size || 1, 1); + size = (guard || size == null) ? 1 : nativeMax(+size || 1, 1); while (index < length) { result[++resIndex] = slice(array, index, (index += size)); } @@ -3296,7 +3340,7 @@ * // => [1, 2, 3] */ function drop(array, n, guard) { - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; return slice(array, n < 0 ? 0 : n); } @@ -3327,14 +3371,14 @@ */ function dropRight(array, n, guard) { var length = array ? array.length : 0; - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; n = length - (n || 0); return slice(array, 0, n < 0 ? 0 : n); } /** * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until the predicate returns falsey. The predicate is + * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3383,7 +3427,7 @@ /** * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until the predicate returns falsey. The predicate is + * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3432,7 +3476,7 @@ /** * This method is like `_.find` except that it returns the index of the first - * element the predicate returns truthy for, instead of the element itself. + * element `predicate` returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -3580,15 +3624,7 @@ */ function flatten(array, isDeep, guard) { var length = array ? array.length : 0; - if (!length) { - return []; - } - // enables use as a callback for functions like `_.map` - var type = typeof isDeep; - if ((type == 'number' || type == 'string') && guard && guard[isDeep] === array) { - isDeep = false; - } - return baseFlatten(array, isDeep); + return length ? baseFlatten(array, guard ? false : isDeep) : []; } /** @@ -3642,12 +3678,14 @@ */ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; - + if (!length) { + return -1; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else if (fromIndex) { var index = sortedIndex(array, value); - return (length && array[index] === value) ? index : -1; + return array[index] === value ? index : -1; } return baseIndexOf(array, value, fromIndex); } @@ -3667,7 +3705,7 @@ */ function initial(array) { var length = array ? array.length : 0; - return slice(array, 0, length ? length - 1 : 0); + return slice(array, 0, (length || 1) - 1); } /** @@ -3775,19 +3813,22 @@ * // => 3 */ function lastIndexOf(array, value, fromIndex) { - var length = array ? array.length : 0, - index = length; - + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1; + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; } else if (fromIndex) { index = sortedLastIndex(array, value) - 1; - return (length && array[index] === value) ? index : -1; + return array[index] === value ? index : -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); } - var isReflexive = value === value; while (index--) { - var other = array[index]; - if ((isReflexive ? other === value : other !== other)) { + if (array[index] === value) { return index; } } @@ -3818,8 +3859,11 @@ * // => [1, 1] */ function pull() { - var array = arguments[0], - index = 0, + var array = arguments[0]; + if (!(array && array.length)) { + return array; + } + var index = 0, indexOf = getIndexOf(), length = arguments.length; @@ -3864,7 +3908,7 @@ } /** - * Removes all elements from `array` that the predicate returns truthy for + * Removes all elements from `array` that `predicate` returns truthy for * and returns an array of the removed elements. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * @@ -3948,13 +3992,18 @@ */ function slice(array, start, end) { var index = -1, - length = array ? array.length : 0; + length = array ? array.length : 0, + endType = typeof end; + if (end && endType != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } start = start == null ? 0 : (+start || 0); if (start < 0) { start = -start > length ? 0 : (length + start); } - end = (typeof end == 'undefined' || end > length) ? length : (+end || 0); + end = (endType == 'undefined' || end > length) ? length : (+end || 0); if (end < 0) { end += length; } @@ -3975,7 +4024,7 @@ * 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 - * function is bound to `thisArg` and invoked with one argument; (value). + * 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. @@ -4072,7 +4121,7 @@ * // => [] */ function take(array, n, guard) { - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; return slice(array, 0, n < 0 ? 0 : n); } @@ -4103,14 +4152,14 @@ */ function takeRight(array, n, guard) { var length = array ? array.length : 0; - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; n = length - (n || 0); return slice(array, n < 0 ? 0 : n); } /** * Creates a slice of `array` with elements taken from the end. Elements are - * taken until the predicate returns falsey. The predicate is bound to `thisArg` + * taken until `predicate` returns falsey. The predicate is bound to `thisArg` * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4159,7 +4208,7 @@ /** * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until the predicate returns falsey. The predicate is bound to + * are taken until `predicate` returns falsey. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4281,16 +4330,10 @@ return []; } // juggle arguments - var type = typeof isSorted; - if (type != 'boolean' && isSorted != null) { + if (typeof isSorted != 'boolean' && isSorted != null) { thisArg = iteratee; - iteratee = isSorted; + iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; - - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { - iteratee = null; - } } if (iteratee != null) { iteratee = getCallback(iteratee, thisArg, 3); @@ -4670,6 +4713,9 @@ collection = values(collection); length = collection.length; } + if (!length) { + return false; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else { @@ -4719,7 +4765,7 @@ }); /** - * Checks if the predicate returns truthy for **all** elements of `collection`. + * Checks if `predicate` returns truthy for **all** elements of `collection`. * The predicate is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * @@ -4739,7 +4785,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements passed the predicate check, + * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. * @example * @@ -4769,7 +4815,7 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4815,8 +4861,8 @@ } /** - * Iterates over elements of `collection`, returning the first element that - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -5174,17 +5220,13 @@ * // => { 'user': 'fred', 'age': 40 }; */ function max(collection, iteratee, thisArg) { - var computed = -Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } - var noIteratee = iteratee == null, + var computed = -Infinity, + noIteratee = iteratee == null, isArr = noIteratee && isArray(collection), - isStr = !isArr && isString(collection); + isStr = !isArr && isString(collection), + result = computed; if (noIteratee && !isStr) { var index = -1, @@ -5257,17 +5299,13 @@ * // => { 'user': 'barney', 'age': 36 }; */ function min(collection, iteratee, thisArg) { - var computed = Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } - var noIteratee = iteratee == null, + var computed = Infinity, + noIteratee = iteratee == null, isArr = noIteratee && isArray(collection), - isStr = !isArr && isString(collection); + isStr = !isArr && isString(collection), + result = computed; if (noIteratee && !isStr) { var index = -1, @@ -5298,8 +5336,8 @@ /** * Creates an array of elements split into two groups, the first of which - * contains elements the predicate returns truthy for, while the second of which - * contains elements the predicate returns falsey for. The predicate is bound + * contains elements `predicate` returns truthy for, while the second of which + * contains elements `predicate` returns falsey for. The predicate is bound * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -5430,7 +5468,7 @@ /** * The opposite of `_.filter`; this method returns the elements of `collection` - * the predicate does **not** return truthy for. + * that `predicate` does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -5494,7 +5532,7 @@ * // => [3, 1] */ function sample(collection, n, guard) { - if (n == null || guard) { + if (guard || n == null) { collection = toIterable(collection); var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; @@ -5564,7 +5602,7 @@ } /** - * Checks if the predicate returns truthy for **any** element of `collection`. + * Checks if `predicate` returns truthy for **any** element of `collection`. * The function returns as soon as it finds a passing value and does not iterate * over the entire collection. The predicate is bound to `thisArg` and invoked * with three arguments; (value, index|key, collection). @@ -5585,7 +5623,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. * @example * @@ -5663,6 +5701,8 @@ * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ function sortBy(collection, iteratee, thisArg) { + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; + var index = -1, length = collection ? collection.length : 0, multi = iteratee && isArray(iteratee), @@ -5959,6 +5999,7 @@ * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -5975,8 +6016,8 @@ * curried(1, 2, 3); * // => [1, 2, 3] */ - function curry(func, arity) { - var result = baseCurry(func, CURRY_FLAG, arity); + function curry(func, arity, guard) { + var result = baseCurry(func, CURRY_FLAG, guard ? null : arity); result.placeholder = curry.placeholder; return result; } @@ -5992,6 +6033,7 @@ * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -6008,8 +6050,8 @@ * curried(1, 2, 3); * // => [1, 2, 3] */ - function curryRight(func, arity) { - var result = baseCurry(func, CURRY_RIGHT_FLAG, arity); + function curryRight(func, arity, guard) { + var result = baseCurry(func, CURRY_RIGHT_FLAG, guard ? null : arity); result.placeholder = curryRight.placeholder; return result; } @@ -6625,18 +6667,11 @@ * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - var type = typeof isDeep; - // juggle arguments - if (type != 'boolean' && isDeep != null) { + if (typeof isDeep != 'boolean' && isDeep != null) { thisArg = customizer; - customizer = isDeep; + customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; isDeep = false; - - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[customizer] === value) { - customizer = null; - } } customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); return baseClone(value, isDeep, customizer); @@ -6757,8 +6792,8 @@ * // => false */ function isBoolean(value) { - return (value === true || value === false || - value && typeof value == 'object' && toString.call(value) == boolClass) || false; + return (value === true || value === false || value && typeof value == 'object' && + toString.call(value) == boolClass) || false; } /** @@ -6804,8 +6839,7 @@ // fallback for environments without DOM support if (!support.dom) { isElement = function(value) { - return (value && typeof value == 'object' && value.nodeType === 1 && - !isPlainObject(value)) || false; + return (value && typeof value == 'object' && value.nodeType === 1 && !isPlainObject(value)) || false; }; } @@ -7106,8 +7140,7 @@ */ function isNumber(value) { var type = typeof value; - return type == 'number' || - (value && type == 'object' && toString.call(value) == numberClass) || false; + return type == 'number' || (value && type == 'object' && toString.call(value) == numberClass) || false; } /** @@ -7190,8 +7223,8 @@ * // => false */ function isString(value) { - return typeof value == 'string' || - (value && typeof value == 'object' && toString.call(value) == stringClass) || false; + return typeof value == 'string' || (value && typeof value == 'object' && + toString.call(value) == stringClass) || false; } /** @@ -7256,6 +7289,7 @@ * @category Object * @param {Object} prototype The object to inherit from. * @param {Object} [properties] The properties to assign to the object. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Object} Returns the new object. * @example * @@ -7277,8 +7311,9 @@ * circle instanceof Shape; * // => true */ - function create(prototype, properties) { + function create(prototype, properties, guard) { var result = baseCreate(prototype); + properties = guard ? null : properties; return properties ? baseAssign(result, properties) : result; } @@ -7312,7 +7347,7 @@ /** * This method is like `_.findIndex` except that it returns the key of the - * first element the predicate returns truthy for, instead of the element itself. + * first element `predicate` returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -7565,6 +7600,7 @@ * @category Object * @param {Object} object The object to invert. * @param {boolean} [multiValue=false] 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 * @@ -7579,7 +7615,9 @@ * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); * // => { 'fred': ['first', 'third'], 'barney': ['second'] } */ - function invert(object, multiValue) { + function invert(object, multiValue, guard) { + multiValue = guard ? null : multiValue; + var index = -1, props = keys(object), length = props.length, @@ -7807,8 +7845,8 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it is invoked for each property - * of `object` omitting the properties the predicate returns truthy for. The + * property names. If `predicate` is provided it is invoked for each property + * of `object` omitting the properties `predicate` returns truthy for. The * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * @@ -7875,8 +7913,8 @@ /** * 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 a predicate is provided it is invoked for each property - * of `object` picking the properties the predicate returns truthy for. The + * 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). * @@ -8470,8 +8508,12 @@ // and Laura Doktorova's doT.js // https://github.com/olado/doT var settings = lodash.templateSettings; - options = assign({}, otherOptions || options, settings, assignOwnDefaults); + + if (isIterateeCall(string, options, otherOptions)) { + options = otherOptions = null; + } string = String(string == null ? '' : string); + options = assign({}, otherOptions || options, settings, assignOwnDefaults); var imports = assign({}, options.imports, settings.imports, assignOwnDefaults), importsKeys = keys(imports), @@ -8574,6 +8616,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8583,12 +8626,12 @@ * _.trim('-_-fred-_-', '_-'); * // => 'fred' */ - function trim(string, chars) { + function trim(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guard || chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -8603,6 +8646,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8612,12 +8656,12 @@ * _.trimLeft('-_-fred-_-', '_-'); * // => 'fred-_-' */ - function trimLeft(string, chars) { + function trimLeft(string, chars, guards) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guards || chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -8632,6 +8676,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8641,12 +8686,12 @@ * _.trimRight('-_-fred-_-', '_-'); * // => '-_-fred' */ - function trimRight(string, chars) { + function trimRight(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guard || chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -8666,6 +8711,7 @@ * @param {number} [options.length=30] The maximum string length. * @param {string} [options.omission='...'] The string to indicate text is omitted. * @param {RegExp|string} [options.separator] The separator pattern to truncate to. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the truncated string. * @example * @@ -8684,9 +8730,11 @@ * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); * // => 'hi-diddly-ho there, neig [...]' */ - function trunc(string, options) { - var length = 30, - omission = '...'; + function trunc(string, options, guard) { + options = guard ? null : options; + + var length = DEFAULT_TRUNC_LENGTH, + omission = DEFAULT_TRUNC_OMISSION; if (isObject(options)) { var separator = 'separator' in options ? options.separator : separator; @@ -8765,6 +8813,7 @@ * @category String * @param {string} [string=''] The string to inspect. * @param {RegExp|string} [pattern] The pattern to match words. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the words of `string`. * @example * @@ -8774,8 +8823,9 @@ * _.words('fred, barney, & pebbles', /[^, ]+/g); * // => ['fred', 'barney', '&', 'pebbles'] */ - function words(string, pattern) { + function words(string, pattern, guard) { string = string != null && String(string); + pattern = guard ? null : pattern; return (string && string.match(pattern || reWords)) || []; } @@ -8821,6 +8871,7 @@ * @category Utility * @param {*} [func=identity] The value to convert to a callback. * @param {*} [thisArg] The `this` binding of the created callback. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new function. * @example * @@ -8843,8 +8894,8 @@ * _.filter(users, 'age__gt38'); * // => [{ 'user': 'fred', 'age': 40 }] */ - function callback(func, thisArg) { - return baseCallback(func, thisArg); + function callback(func, thisArg, guard) { + return baseCallback(func, guard ? undefined : thisArg); } /** @@ -9178,9 +9229,7 @@ * // => a floating-point number between 1.2 and 5.2 */ function random(min, max, floating) { - // enables use as a callback for functions like `_.map` - var type = typeof max; - if ((type == 'number' || type == 'string') && floating && floating[max] === min) { + if (floating && isIterateeCall(min, max, floating)) { max = floating = null; } var noMin = min == null, @@ -9247,13 +9296,10 @@ * // => [] */ function range(start, end, step) { - start = +start || 0; - - // enables use as a callback for functions like `_.map` - var type = typeof end; - if ((type == 'number' || type == 'string') && step && step[end] === start) { + if (step && isIterateeCall(start, end, step)) { end = step = null; } + start = +start || 0; step = step == null ? 1 : (+step || 0); if (end == null) { diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 9b4ab3224..802f0e7ca 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,74 +4,74 @@ * 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 x(n,t){for(var r=-1,e=n.length,u=-1,o=[];++ru(t,i)&&f.push(i);return f}function Vt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>q)return rr(n,t);for(var e=-1,u=$r(n);++e=r||r>q)return er(n,t);for(var e=$r(n);r--&&false!==t(e[r],r,e););return n}function Jt(n,t){var r=true;return Vt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Xt(n,t){var r=[];return Vt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Gt(n,t,r,e){var u; -return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Ht(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ec))return false}else{var g=p&&iu.call(n,"__wrapped__"),h=h&&iu.call(t,"__wrapped__");if(g||h)return or(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(l){case ht:case gt:return+n==+t;case mt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case bt:case _t:return n==He(t)}return false}if(Nu.argsClass||(c=be(n),i=be(t)),g=c?Xe:n.constructor,l=i?Xe:t.constructor,f){if(g.prototype.name!=l.prototype.name)return false -}else if(p=!c&&iu.call(n,"constructor"),h=!i&&iu.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=f?["message","name"]:Hu(n),l=f?g:Hu(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,a)for(;i&&++le(a,p)&&((t||i)&&a.push(p),f.push(c))}return f}function vr(n,t){for(var r=-1,e=t(n),u=e.length,o=ze(u);++rt)return r;var e=typeof arguments[2];if("number"!=e&&"string"!=e||!arguments[3]||arguments[3][arguments[2]]!==arguments[1]||(t=2),3r?Cu(e+r,0):r||0;else if(r)return r=Kr(n,t),e&&n[r]===t?r:-1;return l(n,t,r)}function Mr(n){return zr(n,1)}function zr(n,t,r){var e=-1,u=n?n.length:0;if(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return c(n);for(u=t>r?0:r-t,r=ze(u);++er?Cu(e+r,0):r||0:0,typeof n=="string"||!Yu(n)&&Ie(n)?ru&&(u=i);else t=o&&i?p:Cr(t,r,3),Vt(n,function(n,r,o){r=t(n,r,o),(r>e||-1/0===r&&r===u)&&(e=r,u=n)});return u}function oe(n,t){return ee(n,Me(t))}function ie(n,t,r,e){return(Yu(n)?u:sr)(n,Cr(t,e,4),r,3>arguments.length,Vt)}function fe(n,t,r,e){return(Yu(n)?o:sr)(n,Cr(t,e,4),r,3>arguments.length,Yt)}function ae(n){n=Nr(n);for(var t=-1,r=n.length,e=ze(r);++targuments.length)return Ir(n,C,null,t);var r=zr(arguments,2),e=x(r,se.placeholder);return lr(n,C|k,r,e,t)}function pe(n,t){var r=C|S;if(2=r||r>t?(f&&hu(f),r=p,f=s=p=O,r&&(h=eo(),a=n.apply(c,i),s||f||(i=c=null))):s=bu(e,r)}function u(){s&&hu(s),f=s=p=O,(v||g!==t)&&(h=eo(),a=n.apply(c,i),s||f||(i=c=null))}function o(){if(i=arguments,l=eo(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=l);var o=g-(l-h),m=0>=o||o>g;m?(f&&(f=hu(f)),h=l,a=n.apply(c,i)):f||(f=bu(u,o)) -}return m&&s?s=hu(s):s||t===g||(s=bu(e,t)),r&&(m=true,a=n.apply(c,i)),!m||s||f||(i=c=null),a}var i,f,a,l,c,s,p,h=0,g=false,v=true;if(!we(n))throw new Qe(L);if(t=0>t?0:t,true===r)var y=true,v=false;else je(r)&&(y=r.leading,g="maxWait"in r&&Cu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&hu(s),f&&hu(f),f=s=p=O},o}function ye(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,we))throw new Qe(L);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e); -return e}}function me(n){var t=zr(arguments,1),r=x(t,me.placeholder);return lr(n,k,t,r)}function de(n){var t=zr(arguments,1),r=x(t,de.placeholder);return lr(n,U,t,r)}function be(n){var t=n&&typeof n=="object"?n.length:O;return typeof t=="number"&&-1t||null==n||!Ou(t))return r; -n=He(n);do t%2&&(r+=n),t=gu(t/2),n+=n;while(t);return r}function Ue(n,t){return(n=null==n?"":He(n))?null==t?n.slice(w(n),j(n)+1):(t=He(t),n.slice(h(n,t),g(n,t)+1)):n}function Te(n,t){return(n=null!=n&&He(n))&&n.match(t||ft)||[]}function We(n){try{return n()}catch(t){return xe(t)?t:Ze(t)}}function Le(n,t){return qt(n,t)}function Ne(n){return n}function $e(n){var t=Hu(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(kr(u))return function(n){return null!=n&&u===n[e]&&iu.call(n,e)}}for(var o=r,i=ze(r),f=ze(r);o--;){var u=n[t[o]],a=kr(u); -i[o]=a,f[o]=a?u:Pt(u)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!iu.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!iu.call(n,t[o]):!or(f[o],n[t[o]],null,true))return false;return true}}function qe(n,t,r){var e=true,u=je(t),o=null==r,i=o&&u&&Hu(t),f=i&&ur(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=ur(t,Hu(t))),false===r?e=false:je(r)&&"chain"in r&&(e=r.chain),r=-1,u=we(n);for(o=f.length;++r=T)return r}else n=0;return $u(r,e)}}(),Mu=br(function(n,t,r){iu.call(n,r)?++n[r]:n[r]=1}),zu=br(function(n,t,r){iu.call(n,r)?n[r].push(t):n[r]=[t]}),Ku=br(function(n,t,r){n[r]=t}),Zu=br(function(n,t,r){n[r?0:1].push(t) -},function(){return[[],[]]}),Vu=me(ce,2);Nu.argsClass||(be=function(n){var t=n&&typeof n=="object"?n.length:O;return typeof t=="number"&&-1--n?t.apply(this,arguments):void 0}},Ut.assign=Gu,Ut.at=function(n){var t=n?n.length:0;return typeof t=="number"&&-1t?0:t)},Ut.dropRight=function(n,t,r){var e=n?n.length:0; -return t=e-((null==t||r?1:t)||0),zr(n,0,0>t?0:t)},Ut.dropRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Cr(t,r,3);e--&&t(n[e],e,n););return zr(n,0,e+1)},Ut.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Cr(t,r,3);++e(p?s(p,i):u(c,i))){for(t=r;--t;){var h=e[t];if(0>(h?s(h,i):u(n[t],i)))continue n}p&&p.push(i),c.push(i)}return c},Ut.invert=function(n,t){for(var r=-1,e=Hu(n),u=e.length,o={};++rt?0:t)},Ut.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),zr(n,0>t?0:t)},Ut.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Cr(t,r,3);e--&&t(n[e],e,n););return zr(n,e+1)},Ut.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Cr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Ut.escape=function(n){return(n=null==n?"":He(n))&&(V.lastIndex=0,V.test(n))?n.replace(V,d):n},Ut.escapeRegExp=De,Ut.every=Hr,Ut.find=ne,Ut.findIndex=qr,Ut.findKey=function(n,t,r){return t=Cr(t,r,3),Gt(n,t,rr,true) -},Ut.findLast=function(n,t,r){return t=Cr(t,r,3),Gt(n,t,Yt)},Ut.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Cr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Ut.findLastKey=function(n,t,r){return t=Cr(t,r,3),Gt(n,t,er,true)},Ut.findWhere=function(n,t){return ne(n,$e(t))},Ut.first=Pr,Ut.has=function(n,t){return n?iu.call(n,t):false},Ut.identity=Ne,Ut.indexOf=Br,Ut.isArguments=be,Ut.isArray=Yu,Ut.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&au.call(n)==ht||false},Ut.isDate=function(n){return n&&typeof n=="object"&&au.call(n)==gt||false -},Ut.isElement=_e,Ut.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?Cu(u+r,0):Su(r||0,u-1))+1;else if(r)return u=Zr(n,t)-1,e&&n[u]===t?u:-1;for(r=t===t;u--;)if(e=n[u],r?e===t:e!==e)return u;return-1},Ut.max=ue,Ut.min=function(n,t,r){var e=1/0,u=e,o=typeof t;"number"!=o&&"string"!=o||!r||r[t]!==n||(t=null);var o=null==t,i=!(o&&Yu(n))&&Ie(n);if(o&&!i)for(r=-1,n=Nr(n),o=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Ut.template=function(n,t,r){var e=Ut.templateSettings;t=Gu({},r||t,e,Lt),n=He(null==n?"":n),r=Gu({},t.imports,e.imports,Lt); -var u,o,i=Hu(r),f=Fe(r),a=0;r=t.interpolate||et;var l="__p+='";if(r=Ge((t.escape||et).source+"|"+r.source+"|"+(r===X?G:et).source+"|"+(t.evaluate||et).source+"|$","g"),n.replace(r,function(t,r,e,i,f,c){return e||(e=i),l+=n.slice(a,c).replace(it,b),r&&(u=true,l+="'+__e("+r+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(M,""):l).replace(z,"$1").replace(K,"$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=We(function(){return Ve(i,"return "+l).apply(O,f) -}),t.source=l,xe(t))throw t;return t},Ut.trim=Ue,Ut.trimLeft=function(n,t){return(n=null==n?"":He(n))?null==t?n.slice(w(n)):(t=He(t),n.slice(h(n,t))):n},Ut.trimRight=function(n,t){return(n=null==n?"":He(n))?null==t?n.slice(0,j(n)+1):(t=He(t),n.slice(0,g(n,t)+1)):n},Ut.trunc=function(n,t){var r=30,e="...";if(je(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?He(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":He(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e; -if(r=n.slice(0,o),null==u)return r+e;if(Oe(u)){if(n.slice(o).search(u)){var i,f,a=n.slice(0,o);for(u.global||(u=Ge(u.source,(H.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(a);)f=i.index;r=r.slice(0,null==f?o:f)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Ut.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Ut.sample(t,n)}):Ut.sample(this.value())},Ut.VERSION=I,Tt.prototype=Ut.prototype,Ut.prototype.chain=function(){return Xr(this)},Ut.prototype.toString=function(){return He(this.value())},Ut.prototype.toJSON=Ut.prototype.value=Ut.prototype.valueOf=function(){for(var n=-1,t=this.__queue__,r=t.length,e=this.__wrapped__;++n"'`]/g,Y=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,G=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,H=/\w*$/,Q=/^\s*function[ \n\r\t]+\w/,nt=/^0[xX]/,tt=/^\[object .+?Constructor\]$/,rt=/[\xC0-\xFF]/g,et=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ot=/\bthis\b/,it=/['\n\r\u2028\u2029\\]/g,ft=RegExp("[A-Z\\xC0-\\xD6\\xD8-\\xDE]{2,}(?=[A-Z\\xC0-\\xD6\\xD8-\\xDE][a-z\\xDF-\\xF6\\xF8-\\xFF]+[0-9]*)|[A-Z\\xC0-\\xD6\\xD8-\\xDE]?[a-z\\xDF-\\xF6\\xF8-\\xFF]+[0-9]*|[A-Z\\xC0-\\xD6\\xD8-\\xDE]+|[0-9]+","g"),at=" \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",lt="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(" "),ct="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),st="[object Arguments]",pt="[object Array]",ht="[object Boolean]",gt="[object Date]",vt="[object Error]",yt="[object Function]",mt="[object Number]",dt="[object Object]",bt="[object RegExp]",_t="[object String]",xt="[object ArrayBuffer]",wt="[object Float32Array]",jt="[object Float64Array]",At="[object Int8Array]",Et="[object Int16Array]",Ot="[object Int32Array]",It="[object Uint8Array]",Ct="[object Uint8ClampedArray]",St="[object Uint16Array]",Ft="[object Uint32Array]",Rt={}; -Rt[st]=Rt[pt]=Rt[wt]=Rt[jt]=Rt[At]=Rt[Et]=Rt[Ot]=Rt[It]=Rt[Ct]=Rt[St]=Rt[Ft]=true,Rt[xt]=Rt[ht]=Rt[gt]=Rt[vt]=Rt[yt]=Rt["[object Map]"]=Rt[mt]=Rt[dt]=Rt[bt]=Rt["[object Set]"]=Rt[_t]=Rt["[object WeakMap]"]=false;var Dt={};Dt[st]=Dt[pt]=Dt[xt]=Dt[ht]=Dt[gt]=Dt[wt]=Dt[jt]=Dt[At]=Dt[Et]=Dt[Ot]=Dt[mt]=Dt[dt]=Dt[bt]=Dt[_t]=Dt[It]=Dt[Ct]=Dt[St]=Dt[Ft]=true,Dt[vt]=Dt[yt]=Dt["[object Map]"]=Dt["[object Set]"]=Dt["[object WeakMap]"]=false;var kt={leading:false,maxWait:0,trailing:false},Ut={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Tt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Wt={"\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","\xd7":" ","\xf7":" "},Lt={"function":true,object:true},Nt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Lt[typeof window]&&window||this,qt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Lt[typeof module]&&module&&!module.nodeType&&module,Pt=qt&&Lt&&typeof global=="object"&&global; -!Pt||Pt.global!==Pt&&Pt.window!==Pt&&Pt.self!==Pt||($t=Pt);var Pt=Lt&&Lt.exports===qt&&qt,Bt=function(){try{({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Mt=E();typeof define=="function"&&typeof define.amd=="object"&&define.amd?($t._=Mt, define(function(){return Mt})):qt&&Lt?Pt?(Lt.exports=Mt)._=Mt:qt._=Mt:$t._=Mt}).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 j(n,t){for(var r=-1,e=n.length,u=-1,o=[];++ru(t,i)&&f.push(i);return f}function Gt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>z)return ir(n,t);for(var e=-1,u=Mr(n);++e=r||r>z)return fr(n,t);for(var e=Mr(n);r--&&false!==t(e[r],r,e););return n +}function Qt(n,t){var r=true;return Gt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function nr(n,t){var r=[];return Gt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function tr(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function rr(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ec))return false}else{var g=p&&cu.call(n,"__wrapped__"),h=h&&cu.call(t,"__wrapped__");if(g||h)return lr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(l){case dt:case mt:return+n==+t;case xt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t; +case jt:case At:return n==ru(t)}return false}if(Bu.argsClass||(c=je(n),i=je(t)),g=c?nu:n.constructor,l=i?nu:t.constructor,f){if(g.prototype.name!=l.prototype.name)return false}else if(p=!c&&cu.call(n,"constructor"),h=!i&&cu.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=f?["message","name"]:ro(n),l=f?g:ro(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,a)for(;i&&++le(a,p)&&((t||i)&&a.push(p),f.push(c))}return f}function br(n,t){for(var r=-1,e=t(n),u=e.length,o=Ye(u);++rt||null==r)return r;if(3r?Ru(e+r,0):r||0;else if(r)return r=Jr(n,t),n[r]===t?r:-1;return l(n,t,r)}function Vr(n){return Yr(n,1)}function Yr(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&x(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 c(n);for(u=t>r?0:r-t,r=Ye(u);++er?Ru(e+r,0):r||0:0,typeof n=="string"||!Hu(n)&&De(n)?ri&&(i=o);else t=u&&o?p:Rr(t,r,3),Gt(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===i)&&(e=r,i=n) +});return i}function le(n,t){return fe(n,Ve(t))}function ce(n,t,r,e){return(Hu(n)?u:vr)(n,Rr(t,e,4),r,3>arguments.length,Gt)}function se(n,t,r,e){return(Hu(n)?o:vr)(n,Rr(t,e,4),r,3>arguments.length,Ht)}function pe(n){n=Br(n);for(var t=-1,r=n.length,e=Ye(r);++targuments.length)return Dr(n,S,null,t);var r=Yr(arguments,2),e=j(r,ve.placeholder);return hr(n,S|T,r,e,t)}function ye(n,t){var r=S|D;if(2=r||r>t?(f&&du(f),r=p,f=s=p=C,r&&(h=fo(),a=n.apply(c,i),s||f||(i=c=null))):s=ju(e,r)}function u(){s&&du(s),f=s=p=C,(v||g!==t)&&(h=fo(),a=n.apply(c,i),s||f||(i=c=null))}function o(){if(i=arguments,l=fo(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=l);var o=g-(l-h),d=0>=o||o>g;d?(f&&(f=du(f)),h=l,a=n.apply(c,i)):f||(f=ju(u,o))}return d&&s?s=du(s):s||t===g||(s=ju(e,t)),r&&(d=true,a=n.apply(c,i)),!d||s||f||(i=c=null),a}var i,f,a,l,c,s,p,h=0,g=false,v=true;if(!Oe(n))throw new eu(P);if(t=0>t?0:t,true===r)var y=true,v=false; +else Ie(r)&&(y=r.leading,g="maxWait"in r&&Ru(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&du(s),f&&du(f),f=s=p=C},o}function _e(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Oe))throw new eu(P);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function xe(n){var t=Yr(arguments,1),r=j(t,xe.placeholder);return hr(n,T,t,r)}function we(n){var t=Yr(arguments,1),r=j(t,we.placeholder);return hr(n,W,t,r)}function je(n){var t=n&&typeof n=="object"?n.length:C; +return typeof t=="number"&&-1t||null==n||!Su(t))return r; +n=ru(n);do t%2&&(r+=n),t=mu(t/2),n+=n;while(t);return r}function Ne(n,t,r){return(n=null==n?"":ru(n))?r||null==t?n.slice(A(n),E(n)+1):(t=ru(t),n.slice(h(n,t),g(n,t)+1)):n}function $e(n,t,r){return(n=null!=n&&ru(n))&&n.match((r?null:t)||st)||[]}function qe(n){try{return n()}catch(t){return Ee(t)?t:Xe(t)}}function Pe(n,t,r){return zt(n,r?C:t)}function Be(n){return n}function Me(n){var t=ro(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Lr(u))return function(n){return null!=n&&u===n[e]&&cu.call(n,e)}}for(var o=r,i=Ye(r),f=Ye(r);o--;){var u=n[t[o]],a=Lr(u); +i[o]=a,f[o]=a?u:Kt(u)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!cu.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!cu.call(n,t[o]):!lr(f[o],n[t[o]],null,true))return false;return true}}function ze(n,t,r){var e=true,u=Ie(t),o=null==r,i=o&&u&&ro(t),f=i&&ar(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=ar(t,ro(t))),false===r?e=false:Ie(r)&&"chain"in r&&(e=r.chain),r=-1,u=Oe(n);for(o=f.length;++r=$)return r}else n=0;return Mu(r,e)}}(),Vu=jr(function(n,t,r){cu.call(n,r)?++n[r]:n[r]=1}),Yu=jr(function(n,t,r){cu.call(n,r)?n[r].push(t):n[r]=[t]}),Ju=jr(function(n,t,r){n[r]=t}),Xu=jr(function(n,t,r){n[r?0:1].push(t) +},function(){return[[],[]]}),Gu=xe(ge,2);Bu.argsClass||(je=function(n){var t=n&&typeof n=="object"?n.length:C;return typeof t=="number"&&-1--n?t.apply(this,arguments):void 0}},Nt.assign=to,Nt.at=function(n){var t=n?n.length:0;return typeof t=="number"&&-1t?0:t)},Nt.dropRight=function(n,t,r){var e=n?n.length:0; +return t=e-((r||null==t?1:t)||0),Yr(n,0,0>t?0:t)},Nt.dropRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Rr(t,r,3);e--&&t(n[e],e,n););return Yr(n,0,e+1)},Nt.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Rr(t,r,3);++e(p?s(p,i):u(c,i))){for(t=r;--t;){var h=e[t];if(0>(h?s(h,i):u(n[t],i)))continue n}p&&p.push(i),c.push(i)}return c},Nt.invert=function(n,t,r){t=r?null:t,r=-1;for(var e=ro(n),u=e.length,o={};++rt?0:t) +},Nt.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),Yr(n,0>t?0:t)},Nt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Rr(t,r,3);e--&&t(n[e],e,n););return Yr(n,e+1)},Nt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Rr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Nt.escape=function(n){return(n=null==n?"":ru(n))&&(G.lastIndex=0,G.test(n))?n.replace(G,m):n},Nt.escapeRegExp=We,Nt.every=re,Nt.find=ue,Nt.findIndex=zr,Nt.findKey=function(n,t,r){return t=Rr(t,r,3),tr(n,t,ir,true)},Nt.findLast=function(n,t,r){return t=Rr(t,r,3),tr(n,t,Ht)},Nt.findLastIndex=function(n,t,r){var e=n?n.length:0; +for(t=Rr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Nt.findLastKey=function(n,t,r){return t=Rr(t,r,3),tr(n,t,fr,true)},Nt.findWhere=function(n,t){return ue(n,Me(t))},Nt.first=Kr,Nt.has=function(n,t){return n?cu.call(n,t):false},Nt.identity=Be,Nt.indexOf=Zr,Nt.isArguments=je,Nt.isArray=Hu,Nt.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&pu.call(n)==dt||false},Nt.isDate=function(n){return n&&typeof n=="object"&&pu.call(n)==mt||false},Nt.isElement=Ae,Nt.isEmpty=function(n){if(null==n)return true; +var t=n.length;return typeof t=="number"&&-1r?Ru(e+r,0):ku(r||0,e-1))+1;else if(r)return u=Xr(n,t)-1,n[u]===t?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nt.max=ae,Nt.min=function(n,t,r){t=x(n,t,r)?null:t;var e=1/0,u=null==t,o=!(u&&Hu(n))&&De(n),i=e;if(u&&!o)for(r=-1,n=Br(n),u=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nt.template=function(n,t,r){var e=Nt.templateSettings;x(n,t,r)&&(t=r=null),n=ru(null==n?"":n),t=to({},r||t,e,Pt),r=to({},t.imports,e.imports,Pt); +var u,o,i=ro(r),f=Ue(r),a=0;r=t.interpolate||ft;var l="__p+='";if(r=tu((t.escape||ft).source+"|"+r.source+"|"+(r===nt?tt:ft).source+"|"+(t.evaluate||ft).source+"|$","g"),n.replace(r,function(t,r,e,i,f,c){return e||(e=i),l+=n.slice(a,c).replace(ct,b),r&&(u=true,l+="'+__e("+r+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(V,""):l).replace(Y,"$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=qe(function(){return Ge(i,"return "+l).apply(C,f) +}),t.source=l,Ee(t))throw t;return t},Nt.trim=Ne,Nt.trimLeft=function(n,t,r){return(n=null==n?"":ru(n))?r||null==t?n.slice(A(n)):(t=ru(t),n.slice(h(n,t))):n},Nt.trimRight=function(n,t,r){return(n=null==n?"":ru(n))?r||null==t?n.slice(0,E(n)+1):(t=ru(t),n.slice(0,g(n,t)+1)):n},Nt.trunc=function(n,t,r){t=r?null:t;var e=L;if(r=N,Ie(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?ru(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":ru(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(Se(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=tu(u.source,(rt.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)},Nt.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Nt.sample(t,n)}):Nt.sample(this.value())},Nt.VERSION=F,$t.prototype=Nt.prototype,Nt.prototype.chain=function(){return ne(this)},Nt.prototype.toString=function(){return ru(this.value())},Nt.prototype.toJSON=Nt.prototype.value=Nt.prototype.valueOf=function(){for(var n=-1,t=this.__queue__,r=t.length,e=this.__wrapped__;++n"'`]/g,H=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,nt=/<%=([\s\S]+?)%>/g,tt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,et=/^\s*function[ \n\r\t]+\w/,ut=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,it=/[\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]/g,ft=/($^)/,at=/[.*+?^${}()|[\]\/\\]/g,lt=/\bthis\b/,ct=/['\n\r\u2028\u2029\\]/g,st=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"),pt=" \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",ht="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(" "),gt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),vt="[object Arguments]",yt="[object Array]",dt="[object Boolean]",mt="[object Date]",bt="[object Error]",_t="[object Function]",xt="[object Number]",wt="[object Object]",jt="[object RegExp]",At="[object String]",Et="[object ArrayBuffer]",Ot="[object Float32Array]",It="[object Float64Array]",Ct="[object Int8Array]",Ft="[object Int16Array]",St="[object Int32Array]",Dt="[object Uint8Array]",Rt="[object Uint8ClampedArray]",kt="[object Uint16Array]",Ut="[object Uint32Array]",Tt={}; +Tt[vt]=Tt[yt]=Tt[Ot]=Tt[It]=Tt[Ct]=Tt[Ft]=Tt[St]=Tt[Dt]=Tt[Rt]=Tt[kt]=Tt[Ut]=true,Tt[Et]=Tt[dt]=Tt[mt]=Tt[bt]=Tt[_t]=Tt["[object Map]"]=Tt[xt]=Tt[wt]=Tt[jt]=Tt["[object Set]"]=Tt[At]=Tt["[object WeakMap]"]=false;var Wt={};Wt[vt]=Wt[yt]=Wt[Et]=Wt[dt]=Wt[mt]=Wt[Ot]=Wt[It]=Wt[Ct]=Wt[Ft]=Wt[St]=Wt[xt]=Wt[wt]=Wt[jt]=Wt[At]=Wt[Dt]=Wt[Rt]=Wt[kt]=Wt[Ut]=true,Wt[bt]=Wt[_t]=Wt["[object Map]"]=Wt["[object Set]"]=Wt["[object WeakMap]"]=false;var Lt={leading:false,maxWait:0,trailing:false},Nt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},$t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},qt={"\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"},Pt={"function":true,object:true},Bt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mt=Pt[typeof window]&&window||this,zt=Pt[typeof exports]&&exports&&!exports.nodeType&&exports,Kt=Pt[typeof module]&&module&&!module.nodeType&&module,Zt=zt&&Kt&&typeof global=="object"&&global; +!Zt||Zt.global!==Zt&&Zt.window!==Zt&&Zt.self!==Zt||(Mt=Zt);var Vt=Kt&&Kt.exports===zt&&zt,Yt=function(){try{({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Jt=I();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Mt._=Jt, define(function(){return Jt})):zt&&Kt?Vt?(Kt.exports=Jt)._=Jt:zt._=Jt:Mt._=Jt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 6bae84a0b..047ea0f70 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -24,6 +24,10 @@ PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64; + /** Used as default options for `_.trunc` */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; + /** Used to detect when a function becomes hot */ var HOT_COUNT = 150, HOT_SPAN = 16; @@ -81,8 +85,8 @@ /** Used to detect host constructors (Safari > 5) */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters */ - var reLatin1 = /[\xC0-\xFF]/g; + /** Used to match latin-1 supplement letters (excluding mathematical operators) */ + var reLatin1 = /[\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]/g; /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; @@ -102,11 +106,10 @@ /** Used to match words to create compound words */ var reWords = (function() { - var nums = '[0-9]', - upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]', - lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*'; + var upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]', + lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+'; - return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g'); + return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); /** Used to detect and test whitespace */ @@ -248,7 +251,7 @@ '\xDD': 'Y', '\xFD': 'y', '\xFF': 'y', '\xC6': 'Ae', '\xE6': 'ae', '\xDE': 'Th', '\xFE': 'th', - '\xDF': 'ss', '\xD7': ' ', '\xF7': ' ' + '\xDF': 'ss' }; /** Used to determine if values are of the language type `Object` */ @@ -335,7 +338,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function arrayEvery(array, predicate) { @@ -450,7 +453,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { @@ -510,7 +513,8 @@ } /** - * The base implementation of `_.indexOf` without support for binary searches. + * The base implementation of `_.indexOf` without support for `fromIndex` + * bounds checks and binary searches. * * @private * @param {Array} array The array to search. @@ -519,13 +523,14 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } var index = (fromIndex || 0) - 1, - length = array ? array.length : 0, - isReflexive = value === value; + length = array.length; while (++index < length) { - var other = array[index]; - if ((isReflexive ? other === value : other !== other)) { + if (array[index] === value) { return index; } } @@ -686,6 +691,46 @@ return '\\' + stringEscapes[chr]; } + /** + * Gets the index at which the first occurrence of `NaN` is found in `array`. + * If `fromRight` is provided elements of `array` are iterated from right to left. + * + * @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. + * @returns {number} Returns the index of the matched `NaN`, else `-1`. + */ + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, + index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + + while ((fromRight ? index-- : ++index < length)) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + + /** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ + function isIterateeCall(value, index, object) { + var indexType = typeof index, + objectType = typeof object; + + return (object && (indexType == 'number' || indexType == 'string') && + (objectType == 'function' || objectType == 'object') && object[index] === value) || false; + } + /** * Used by `_.trimmedLeftIndex` and `_.trimmedRightIndex` to determine if a * character code is whitespace. @@ -1375,7 +1420,7 @@ * * @private * @param {Array} array The array to inspect. - * @param {Array} [values] The values to exclude. + * @param {Array} values The values to exclude. * @returns {Array} Returns the new array of filtered values. */ function baseDifference(array, values) { @@ -1389,7 +1434,7 @@ isLarge = prereq && createCache && values && values.length >= 200, isCommon = prereq && !isLarge, result = [], - valuesLength = values ? values.length : 0; + valuesLength = values.length; if (isLarge) { indexOf = cacheIndexOf; @@ -1464,13 +1509,13 @@ } /** - * The base implementation of `_.every` without support for callback shorthands - * or `this` binding. + * The base implementation of `_.every` without support for callback + * shorthands or `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function baseEvery(collection, predicate) { @@ -2087,7 +2132,7 @@ * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function baseSome(collection, predicate) { @@ -2355,12 +2400,10 @@ var length = arguments.length, object = arguments[0]; - if (object == null || length < 2) { + if (length < 2 || object == null) { return object; } - // enables use as a callback for functions like `_.reduce` - var type = typeof arguments[2]; - if ((type == 'number' || type == 'string') && arguments[3] && arguments[3][arguments[2]] === arguments[1]) { + if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { length = 2; } // juggle arguments @@ -2844,8 +2887,8 @@ } /** - * A specialized version of `_.pick` that picks `object` properties - * the predicate returns truthy for. + * A specialized version of `_.pick` that picks `object` properties `predicate` + * returns truthy for. * * @private * @param {Object} object The source object. @@ -2995,6 +3038,7 @@ * @category Array * @param {Array} array The array to process. * @param {numer} [size=1] The length of each chunk. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the new array containing chunks. * @example * @@ -3004,13 +3048,13 @@ * _.chunk(['a', 'b', 'c', 'd'], 3); * // => [['a', 'b', 'c'], ['d']] */ - function chunk(array, size) { + function chunk(array, size, guard) { var index = 0, length = array ? array.length : 0, resIndex = -1, result = []; - size = typeof size == 'undefined' ? 1 : nativeMax(+size || 1, 1); + size = (guard || size == null) ? 1 : nativeMax(+size || 1, 1); while (index < length) { result[++resIndex] = slice(array, index, (index += size)); } @@ -3104,7 +3148,7 @@ * // => [1, 2, 3] */ function drop(array, n, guard) { - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; return slice(array, n < 0 ? 0 : n); } @@ -3135,14 +3179,14 @@ */ function dropRight(array, n, guard) { var length = array ? array.length : 0; - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; n = length - (n || 0); return slice(array, 0, n < 0 ? 0 : n); } /** * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until the predicate returns falsey. The predicate is + * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3191,7 +3235,7 @@ /** * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until the predicate returns falsey. The predicate is + * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3240,7 +3284,7 @@ /** * This method is like `_.find` except that it returns the index of the first - * element the predicate returns truthy for, instead of the element itself. + * element `predicate` returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -3388,15 +3432,7 @@ */ function flatten(array, isDeep, guard) { var length = array ? array.length : 0; - if (!length) { - return []; - } - // enables use as a callback for functions like `_.map` - var type = typeof isDeep; - if ((type == 'number' || type == 'string') && guard && guard[isDeep] === array) { - isDeep = false; - } - return baseFlatten(array, isDeep); + return length ? baseFlatten(array, guard ? false : isDeep) : []; } /** @@ -3450,12 +3486,14 @@ */ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; - + if (!length) { + return -1; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else if (fromIndex) { var index = sortedIndex(array, value); - return (length && array[index] === value) ? index : -1; + return array[index] === value ? index : -1; } return baseIndexOf(array, value, fromIndex); } @@ -3475,7 +3513,7 @@ */ function initial(array) { var length = array ? array.length : 0; - return slice(array, 0, length ? length - 1 : 0); + return slice(array, 0, (length || 1) - 1); } /** @@ -3583,19 +3621,22 @@ * // => 3 */ function lastIndexOf(array, value, fromIndex) { - var length = array ? array.length : 0, - index = length; - + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1; + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; } else if (fromIndex) { index = sortedLastIndex(array, value) - 1; - return (length && array[index] === value) ? index : -1; + return array[index] === value ? index : -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); } - var isReflexive = value === value; while (index--) { - var other = array[index]; - if ((isReflexive ? other === value : other !== other)) { + if (array[index] === value) { return index; } } @@ -3626,8 +3667,11 @@ * // => [1, 1] */ function pull() { - var array = arguments[0], - index = 0, + var array = arguments[0]; + if (!(array && array.length)) { + return array; + } + var index = 0, indexOf = getIndexOf(), length = arguments.length; @@ -3672,7 +3716,7 @@ } /** - * Removes all elements from `array` that the predicate returns truthy for + * Removes all elements from `array` that `predicate` returns truthy for * and returns an array of the removed elements. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * @@ -3756,13 +3800,18 @@ */ function slice(array, start, end) { var index = -1, - length = array ? array.length : 0; + length = array ? array.length : 0, + endType = typeof end; + if (end && endType != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } start = start == null ? 0 : (+start || 0); if (start < 0) { start = -start > length ? 0 : (length + start); } - end = (typeof end == 'undefined' || end > length) ? length : (+end || 0); + end = (endType == 'undefined' || end > length) ? length : (+end || 0); if (end < 0) { end += length; } @@ -3783,7 +3832,7 @@ * 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 - * function is bound to `thisArg` and invoked with one argument; (value). + * 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. @@ -3880,7 +3929,7 @@ * // => [] */ function take(array, n, guard) { - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; return slice(array, 0, n < 0 ? 0 : n); } @@ -3911,14 +3960,14 @@ */ function takeRight(array, n, guard) { var length = array ? array.length : 0; - n = (n == null || guard) ? 1 : n; + n = (guard || n == null) ? 1 : n; n = length - (n || 0); return slice(array, n < 0 ? 0 : n); } /** * Creates a slice of `array` with elements taken from the end. Elements are - * taken until the predicate returns falsey. The predicate is bound to `thisArg` + * taken until `predicate` returns falsey. The predicate is bound to `thisArg` * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3967,7 +4016,7 @@ /** * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until the predicate returns falsey. The predicate is bound to + * are taken until `predicate` returns falsey. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4089,16 +4138,10 @@ return []; } // juggle arguments - var type = typeof isSorted; - if (type != 'boolean' && isSorted != null) { + if (typeof isSorted != 'boolean' && isSorted != null) { thisArg = iteratee; - iteratee = isSorted; + iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; - - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { - iteratee = null; - } } if (iteratee != null) { iteratee = getCallback(iteratee, thisArg, 3); @@ -4478,6 +4521,9 @@ collection = values(collection); length = collection.length; } + if (!length) { + return false; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else { @@ -4527,7 +4573,7 @@ }); /** - * Checks if the predicate returns truthy for **all** elements of `collection`. + * Checks if `predicate` returns truthy for **all** elements of `collection`. * The predicate is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * @@ -4547,7 +4593,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements passed the predicate check, + * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. * @example * @@ -4577,7 +4623,7 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4623,8 +4669,8 @@ } /** - * Iterates over elements of `collection`, returning the first element that - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -4982,17 +5028,13 @@ * // => { 'user': 'fred', 'age': 40 }; */ function max(collection, iteratee, thisArg) { - var computed = -Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } - var noIteratee = iteratee == null, + var computed = -Infinity, + noIteratee = iteratee == null, isArr = noIteratee && isArray(collection), - isStr = !isArr && isString(collection); + isStr = !isArr && isString(collection), + result = computed; if (noIteratee && !isStr) { var index = -1, @@ -5065,17 +5107,13 @@ * // => { 'user': 'barney', 'age': 36 }; */ function min(collection, iteratee, thisArg) { - var computed = Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } - var noIteratee = iteratee == null, + var computed = Infinity, + noIteratee = iteratee == null, isArr = noIteratee && isArray(collection), - isStr = !isArr && isString(collection); + isStr = !isArr && isString(collection), + result = computed; if (noIteratee && !isStr) { var index = -1, @@ -5106,8 +5144,8 @@ /** * Creates an array of elements split into two groups, the first of which - * contains elements the predicate returns truthy for, while the second of which - * contains elements the predicate returns falsey for. The predicate is bound + * contains elements `predicate` returns truthy for, while the second of which + * contains elements `predicate` returns falsey for. The predicate is bound * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -5238,7 +5276,7 @@ /** * The opposite of `_.filter`; this method returns the elements of `collection` - * the predicate does **not** return truthy for. + * that `predicate` does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -5302,7 +5340,7 @@ * // => [3, 1] */ function sample(collection, n, guard) { - if (n == null || guard) { + if (guard || n == null) { collection = toIterable(collection); var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; @@ -5372,7 +5410,7 @@ } /** - * Checks if the predicate returns truthy for **any** element of `collection`. + * Checks if `predicate` returns truthy for **any** element of `collection`. * The function returns as soon as it finds a passing value and does not iterate * over the entire collection. The predicate is bound to `thisArg` and invoked * with three arguments; (value, index|key, collection). @@ -5393,7 +5431,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. * @example * @@ -5471,6 +5509,8 @@ * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ function sortBy(collection, iteratee, thisArg) { + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; + var index = -1, length = collection ? collection.length : 0, multi = iteratee && isArray(iteratee), @@ -5765,6 +5805,7 @@ * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -5781,8 +5822,8 @@ * curried(1, 2, 3); * // => [1, 2, 3] */ - function curry(func, arity) { - var result = baseCurry(func, CURRY_FLAG, arity); + function curry(func, arity, guard) { + var result = baseCurry(func, CURRY_FLAG, guard ? null : arity); result.placeholder = curry.placeholder; return result; } @@ -5798,6 +5839,7 @@ * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -5814,8 +5856,8 @@ * curried(1, 2, 3); * // => [1, 2, 3] */ - function curryRight(func, arity) { - var result = baseCurry(func, CURRY_RIGHT_FLAG, arity); + function curryRight(func, arity, guard) { + var result = baseCurry(func, CURRY_RIGHT_FLAG, guard ? null : arity); result.placeholder = curryRight.placeholder; return result; } @@ -6431,18 +6473,11 @@ * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - var type = typeof isDeep; - // juggle arguments - if (type != 'boolean' && isDeep != null) { + if (typeof isDeep != 'boolean' && isDeep != null) { thisArg = customizer; - customizer = isDeep; + customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; isDeep = false; - - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[customizer] === value) { - customizer = null; - } } customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1); return baseClone(value, isDeep, customizer); @@ -6555,8 +6590,8 @@ * // => false */ function isBoolean(value) { - return (value === true || value === false || - value && typeof value == 'object' && toString.call(value) == boolClass) || false; + return (value === true || value === false || value && typeof value == 'object' && + toString.call(value) == boolClass) || false; } /** @@ -6602,8 +6637,7 @@ // fallback for environments without DOM support if (!support.dom) { isElement = function(value) { - return (value && typeof value == 'object' && value.nodeType === 1 && - !isPlainObject(value)) || false; + return (value && typeof value == 'object' && value.nodeType === 1 && !isPlainObject(value)) || false; }; } @@ -6897,8 +6931,7 @@ */ function isNumber(value) { var type = typeof value; - return type == 'number' || - (value && type == 'object' && toString.call(value) == numberClass) || false; + return type == 'number' || (value && type == 'object' && toString.call(value) == numberClass) || false; } /** @@ -6981,8 +7014,8 @@ * // => false */ function isString(value) { - return typeof value == 'string' || - (value && typeof value == 'object' && toString.call(value) == stringClass) || false; + return typeof value == 'string' || (value && typeof value == 'object' && + toString.call(value) == stringClass) || false; } /** @@ -7047,6 +7080,7 @@ * @category Object * @param {Object} prototype The object to inherit from. * @param {Object} [properties] The properties to assign to the object. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Object} Returns the new object. * @example * @@ -7068,8 +7102,9 @@ * circle instanceof Shape; * // => true */ - function create(prototype, properties) { + function create(prototype, properties, guard) { var result = baseCreate(prototype); + properties = guard ? null : properties; return properties ? baseAssign(result, properties) : result; } @@ -7103,7 +7138,7 @@ /** * This method is like `_.findIndex` except that it returns the key of the - * first element the predicate returns truthy for, instead of the element itself. + * first element `predicate` returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -7356,6 +7391,7 @@ * @category Object * @param {Object} object The object to invert. * @param {boolean} [multiValue=false] 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 * @@ -7370,7 +7406,9 @@ * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); * // => { 'fred': ['first', 'third'], 'barney': ['second'] } */ - function invert(object, multiValue) { + function invert(object, multiValue, guard) { + multiValue = guard ? null : multiValue; + var index = -1, props = keys(object), length = props.length, @@ -7455,7 +7493,7 @@ } var length = object.length; length = (typeof length == 'number' && length > 0 && - (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) >>> 0; + (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0; var keyIndex, Ctor = object.constructor, @@ -7573,8 +7611,8 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it is invoked for each property - * of `object` omitting the properties the predicate returns truthy for. The + * property names. If `predicate` is provided it is invoked for each property + * of `object` omitting the properties `predicate` returns truthy for. The * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * @@ -7641,8 +7679,8 @@ /** * 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 a predicate is provided it is invoked for each property - * of `object` picking the properties the predicate returns truthy for. The + * 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). * @@ -8236,8 +8274,12 @@ // and Laura Doktorova's doT.js // https://github.com/olado/doT var settings = lodash.templateSettings; - options = assign({}, otherOptions || options, settings, assignOwnDefaults); + + if (isIterateeCall(string, options, otherOptions)) { + options = otherOptions = null; + } string = String(string == null ? '' : string); + options = assign({}, otherOptions || options, settings, assignOwnDefaults); var imports = assign({}, options.imports, settings.imports, assignOwnDefaults), importsKeys = keys(imports), @@ -8340,6 +8382,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8349,12 +8392,12 @@ * _.trim('-_-fred-_-', '_-'); * // => 'fred' */ - function trim(string, chars) { + function trim(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guard || chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -8369,6 +8412,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8378,12 +8422,12 @@ * _.trimLeft('-_-fred-_-', '_-'); * // => 'fred-_-' */ - function trimLeft(string, chars) { + function trimLeft(string, chars, guards) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guards || chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -8398,6 +8442,7 @@ * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -8407,12 +8452,12 @@ * _.trimRight('-_-fred-_-', '_-'); * // => '-_-fred' */ - function trimRight(string, chars) { + function trimRight(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (chars == null) { + if (guard || chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -8432,6 +8477,7 @@ * @param {number} [options.length=30] The maximum string length. * @param {string} [options.omission='...'] The string to indicate text is omitted. * @param {RegExp|string} [options.separator] The separator pattern to truncate to. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {string} Returns the truncated string. * @example * @@ -8450,9 +8496,11 @@ * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); * // => 'hi-diddly-ho there, neig [...]' */ - function trunc(string, options) { - var length = 30, - omission = '...'; + function trunc(string, options, guard) { + options = guard ? null : options; + + var length = DEFAULT_TRUNC_LENGTH, + omission = DEFAULT_TRUNC_OMISSION; if (isObject(options)) { var separator = 'separator' in options ? options.separator : separator; @@ -8531,6 +8579,7 @@ * @category String * @param {string} [string=''] The string to inspect. * @param {RegExp|string} [pattern] The pattern to match words. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Array} Returns the words of `string`. * @example * @@ -8540,8 +8589,9 @@ * _.words('fred, barney, & pebbles', /[^, ]+/g); * // => ['fred', 'barney', '&', 'pebbles'] */ - function words(string, pattern) { + function words(string, pattern, guard) { string = string != null && String(string); + pattern = guard ? null : pattern; return (string && string.match(pattern || reWords)) || []; } @@ -8587,6 +8637,7 @@ * @category Utility * @param {*} [func=identity] The value to convert to a callback. * @param {*} [thisArg] The `this` binding of the created callback. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new function. * @example * @@ -8609,8 +8660,8 @@ * _.filter(users, 'age__gt38'); * // => [{ 'user': 'fred', 'age': 40 }] */ - function callback(func, thisArg) { - return baseCallback(func, thisArg); + function callback(func, thisArg, guard) { + return baseCallback(func, guard ? undefined : thisArg); } /** @@ -8944,9 +8995,7 @@ * // => a floating-point number between 1.2 and 5.2 */ function random(min, max, floating) { - // enables use as a callback for functions like `_.map` - var type = typeof max; - if ((type == 'number' || type == 'string') && floating && floating[max] === min) { + if (floating && isIterateeCall(min, max, floating)) { max = floating = null; } var noMin = min == null, @@ -9013,13 +9062,10 @@ * // => [] */ function range(start, end, step) { - start = +start || 0; - - // enables use as a callback for functions like `_.map` - var type = typeof end; - if ((type == 'number' || type == 'string') && step && step[end] === start) { + if (step && isIterateeCall(start, end, step)) { end = step = null; } + start = +start || 0; step = step == null ? 1 : (+step || 0); if (end == null) { diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 1a746ef90..f4ef31fe9 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,70 +4,69 @@ * 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 w(n,t){for(var r=-1,e=n.length,u=-1,o=[];++ru(t,i)&&f.push(i);return f}function Kt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>L)return Qt(n,t);for(var e=-1,u=Wr(n);++e=r||r>L)return nr(n,t);for(var e=Wr(n);r--&&false!==t(e[r],r,e););return n}function Zt(n,t){var r=true;return Kt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Vt(n,t){var r=[];return Kt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Yt(n,t,r,e){var u; -return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Jt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++el))return false}else{var g=p&&tu.call(n,"__wrapped__"),h=h&&tu.call(t,"__wrapped__");if(g||h)return rr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(c){case pt:case ht:return+n==+t;case vt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case mt:case dt:return n==Je(t)}return false}if(g=l?Ve:n.constructor,c=i?Ve:t.constructor,f){if(g.prototype.name!=c.prototype.name)return false}else if(p=!l&&tu.call(n,"constructor"),h=!i&&tu.call(t,"constructor"),p!=h||!p&&g!=c&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof c=="function"&&c instanceof c))return false; -if(g=f?["message","name"]:Pu(n),c=f?g:Pu(t),l&&g.push("length"),i&&c.push("length"),l=g.length,p=c.length,l!=p&&!e)return false}for(u||(u=[]),o||(o=[]),c=u.length;c--;)if(u[c]==n)return o[c]==t;if(u.push(n),o.push(t),i=true,a)for(;i&&++ce(a,p)&&((t||i)&&a.push(p),f.push(l))}return f}function pr(n,t){for(var r=-1,e=t(n),u=e.length,o=Be(u);++rt)return r; -var e=typeof arguments[2];if("number"!=e&&"string"!=e||!arguments[3]||arguments[3][arguments[2]]!==arguments[1]||(t=2),3r?ju(e+r,0):r||0;else if(r)return r=Mr(n,t),e&&n[r]===t?r:-1;return c(n,t,r)}function Lr(n){return Br(n,1)}function Br(n,t,r){var e=-1,u=n?n.length:0;if(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=Be(u);++er?ju(e+r,0):r||0:0,typeof n=="string"||!Bu(n)&&Ae(n)?ru&&(u=i);else t=o&&i?p:Er(t,r,3),Kt(n,function(n,r,o){r=t(n,r,o),(r>e||-1/0===r&&r===u)&&(e=r,u=n) -});return u}function re(n,t){return ne(n,Le(t))}function ee(n,t,r,e){return(Bu(n)?u:ar)(n,Er(t,e,4),r,3>arguments.length,Kt)}function ue(n,t,r,e){return(Bu(n)?o:ar)(n,Er(t,e,4),r,3>arguments.length,Pt)}function oe(n){n=Ur(n);for(var t=-1,r=n.length,e=Be(r);++targuments.length)return Ar(n,F,null,t);var r=Br(arguments,2),e=w(r,ae.placeholder);return ir(n,F|S,r,e,t)}function ce(n,t){var r=F|R;if(2=r||r>t?(f&&au(f),r=p,f=s=p=I,r&&(h=Xu(),a=n.apply(l,i),s||f||(i=l=null))):s=gu(e,r)}function u(){s&&au(s),f=s=p=I,(v||g!==t)&&(h=Xu(),a=n.apply(l,i),s||f||(i=l=null))}function o(){if(i=arguments,c=Xu(),l=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=c);var o=g-(c-h),m=0>=o||o>g;m?(f&&(f=au(f)),h=c,a=n.apply(l,i)):f||(f=gu(u,o))}return m&&s?s=au(s):s||t===g||(s=gu(e,t)),r&&(m=true,a=n.apply(l,i)),!m||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,g=false,v=true;if(!be(n))throw new Xe(N);if(t=0>t?0:t,true===r)var y=true,v=false; -else _e(r)&&(y=r.leading,g="maxWait"in r&&ju(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&au(s),f&&au(f),f=s=p=I},o}function he(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,be))throw new Xe(N);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function ge(n){var t=Br(arguments,1),r=w(t,ge.placeholder);return ir(n,S,t,r)}function ve(n){var t=Br(arguments,1),r=w(t,ve.placeholder);return ir(n,T,t,r)}function ye(n){var t=n&&typeof n=="object"?n.length:I; -return typeof t=="number"&&-1>>0,e=n.constructor,u=-1,e=typeof e=="function"&&e.prototype==n,o=r-1,i=Be(r),f=0t||null==n||!wu(t))return r;n=Je(n);do t%2&&(r+=n),t=cu(t/2),n+=n;while(t);return r}function ke(n,t){return(n=null==n?"":Je(n))?null==t?n.slice(x(n),j(n)+1):(t=Je(t),n.slice(h(n,t),g(n,t)+1)):n}function Ce(n,t){return(n=null!=n&&Je(n))&&n.match(t||ft)||[]}function Se(n){try{return n() -}catch(t){return de(t)?t:ze(t)}}function Te(n,t){return $t(n,t)}function Ue(n){return n}function We(n){var t=Pu(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Dr(u))return function(n){return null!=n&&u===n[e]&&tu.call(n,e)}}for(var o=r,i=Be(r),f=Be(r);o--;){var u=n[t[o]],a=Dr(u);i[o]=a,f[o]=a?u:qt(u)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!tu.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!tu.call(n,t[o]):!rr(f[o],n[t[o]],null,true))return false;return true}}function Ne(n,t,r){var e=true,u=_e(t),o=null==r,i=o&&u&&Pu(t),f=i&&tr(t,i); -(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=tr(t,Pu(t))),false===r?e=false:_e(r)&&"chain"in r&&(e=r.chain),r=-1,u=be(n);for(o=f.length;++r=U)return r -}else n=0;return Cu(r,e)}}(),Wu=yr(function(n,t,r){tu.call(n,r)?++n[r]:n[r]=1}),Nu=yr(function(n,t,r){tu.call(n,r)?n[r].push(t):n[r]=[t]}),$u=yr(function(n,t,r){n[r]=t}),qu=yr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Lu=ge(fe,2),Bu=_u||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&eu.call(n)==st||false};ku.dom||(me=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!zu(n)||false});var Mu=Iu||function(n){return typeof n=="number"&&wu(n)},zu=lu?function(n){if(!n||eu.call(n)!=yt)return false; -var t=n.valueOf,r=we(t)&&(r=lu(t))&&lu(r);return r?n==r||lu(n)==r:Sr(n)}:Sr,Ku=mr(Wt),Pu=xu?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}},Ct.assign=Ku,Ct.at=function(n){var t=n?n.length:0;return typeof t=="number"&&-1t?0:t)},Ct.dropRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),Br(n,0,0>t?0:t)},Ct.dropRightWhile=function(n,t,r){var e=n?n.length:0; -for(t=Er(t,r,3);e--&&t(n[e],e,n););return Br(n,0,e+1)},Ct.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Er(t,r,3);++e(p?s(p,i):u(l,i))){for(t=r;--t;){var h=e[t];if(0>(h?s(h,i):u(n[t],i)))continue n}p&&p.push(i),l.push(i)}return l},Ct.invert=function(n,t){for(var r=-1,e=Pu(n),u=e.length,o={};++rt?0:t) -},Ct.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),Br(n,0>t?0:t)},Ct.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Er(t,r,3);e--&&t(n[e],e,n););return Br(n,e+1)},Ct.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Er(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Ct.escape=function(n){return(n=null==n?"":Je(n))&&(V.lastIndex=0,V.test(n))?n.replace(V,d):n -},Ct.escapeRegExp=Re,Ct.every=Jr,Ct.find=Gr,Ct.findIndex=Nr,Ct.findKey=function(n,t,r){return t=Er(t,r,3),Yt(n,t,Qt,true)},Ct.findLast=function(n,t,r){return t=Er(t,r,3),Yt(n,t,Pt)},Ct.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Er(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Ct.findLastKey=function(n,t,r){return t=Er(t,r,3),Yt(n,t,nr,true)},Ct.findWhere=function(n,t){return Gr(n,We(t))},Ct.first=$r,Ct.has=function(n,t){return n?tu.call(n,t):false},Ct.identity=Ue,Ct.indexOf=qr,Ct.isArguments=ye,Ct.isArray=Bu,Ct.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&eu.call(n)==pt||false -},Ct.isDate=function(n){return n&&typeof n=="object"&&eu.call(n)==ht||false},Ct.isElement=me,Ct.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?ju(u+r,0):Au(r||0,u-1))+1;else if(r)return u=zr(n,t)-1,e&&n[u]===t?u:-1;for(r=t===t;u--;)if(e=n[u],r?e===t:e!==e)return u;return-1},Ct.max=te,Ct.min=function(n,t,r){var e=1/0,u=e,o=typeof t;"number"!=o&&"string"!=o||!r||r[t]!==n||(t=null); -var o=null==t,i=!(o&&Bu(n))&&Ae(n);if(o&&!i)for(r=-1,n=Ur(n),o=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Ct.template=function(n,t,r){var e=Ct.templateSettings;t=Ku({},r||t,e,Ut),n=Je(null==n?"":n),r=Ku({},t.imports,e.imports,Ut);var u,o,i=Pu(r),f=Oe(r),a=0;r=t.interpolate||et;var c="__p+='";if(r=Ye((t.escape||et).source+"|"+r.source+"|"+(r===X?G:et).source+"|"+(t.evaluate||et).source+"|$","g"),n.replace(r,function(t,r,e,i,f,l){return e||(e=i),c+=n.slice(a,l).replace(it,b),r&&(u=true,c+="'+__e("+r+")+'"),f&&(o=true,c+="';"+f+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t -}),c+="';",(t=t.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(z,""):c).replace(K,"$1").replace(P,"$1;"),c="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}",t=Se(function(){return Ke(i,"return "+c).apply(I,f)}),t.source=c,de(t))throw t;return t},Ct.trim=ke,Ct.trimLeft=function(n,t){return(n=null==n?"":Je(n))?null==t?n.slice(x(n)):(t=Je(t),n.slice(h(n,t))):n -},Ct.trimRight=function(n,t){return(n=null==n?"":Je(n))?null==t?n.slice(0,j(n)+1):(t=Je(t),n.slice(0,g(n,t)+1)):n},Ct.trunc=function(n,t){var r=30,e="...";if(_e(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Je(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Je(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(je(u)){if(n.slice(o).search(u)){var i,f,a=n.slice(0,o);for(u.global||(u=Ye(u.source,(H.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(a);)f=i.index; -r=r.slice(0,null==f?o:f)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n) -},Ct.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Ct.sample(t,n)}):Ct.sample(this.value())},Ct.VERSION=O,St.prototype=Ct.prototype,Ct.prototype.chain=function(){return Vr(this)},Ct.prototype.toString=function(){return Je(this.value())},Ct.prototype.toJSON=Ct.prototype.value=Ct.prototype.valueOf=function(){for(var n=-1,t=this.__queue__,r=t.length,e=this.__wrapped__;++n"'`]/g,Y=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,G=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,H=/\w*$/,Q=/^\s*function[ \n\r\t]+\w/,nt=/^0[xX]/,tt=/^\[object .+?Constructor\]$/,rt=/[\xC0-\xFF]/g,et=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ot=/\bthis\b/,it=/['\n\r\u2028\u2029\\]/g,ft=RegExp("[A-Z\\xC0-\\xD6\\xD8-\\xDE]{2,}(?=[A-Z\\xC0-\\xD6\\xD8-\\xDE][a-z\\xDF-\\xF6\\xF8-\\xFF]+[0-9]*)|[A-Z\\xC0-\\xD6\\xD8-\\xDE]?[a-z\\xDF-\\xF6\\xF8-\\xFF]+[0-9]*|[A-Z\\xC0-\\xD6\\xD8-\\xDE]+|[0-9]+","g"),at=" \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",ct="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(" "),lt="[object Arguments]",st="[object Array]",pt="[object Boolean]",ht="[object Date]",gt="[object Error]",vt="[object Number]",yt="[object Object]",mt="[object RegExp]",dt="[object String]",bt="[object ArrayBuffer]",_t="[object Float32Array]",wt="[object Float64Array]",xt="[object Int8Array]",jt="[object Int16Array]",At="[object Int32Array]",Et="[object Uint8Array]",It="[object Uint8ClampedArray]",Ot="[object Uint16Array]",Ft="[object Uint32Array]",Rt={}; -Rt[lt]=Rt[st]=Rt[_t]=Rt[wt]=Rt[xt]=Rt[jt]=Rt[At]=Rt[Et]=Rt[It]=Rt[Ot]=Rt[Ft]=true,Rt[bt]=Rt[pt]=Rt[ht]=Rt[gt]=Rt["[object Function]"]=Rt["[object Map]"]=Rt[vt]=Rt[yt]=Rt[mt]=Rt["[object Set]"]=Rt[dt]=Rt["[object WeakMap]"]=false;var Dt={};Dt[lt]=Dt[st]=Dt[bt]=Dt[pt]=Dt[ht]=Dt[_t]=Dt[wt]=Dt[xt]=Dt[jt]=Dt[At]=Dt[vt]=Dt[yt]=Dt[mt]=Dt[dt]=Dt[Et]=Dt[It]=Dt[Ot]=Dt[Ft]=true,Dt[gt]=Dt["[object Function]"]=Dt["[object Map]"]=Dt["[object Set]"]=Dt["[object WeakMap]"]=false;var kt={leading:false,maxWait:0,trailing:false},Ct={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},St={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Tt={"\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","\xd7":" ","\xf7":" "},Ut={"function":true,object:true},Wt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Nt=Ut[typeof window]&&window||this,$t=Ut[typeof exports]&&exports&&!exports.nodeType&&exports,Ut=Ut[typeof module]&&module&&!module.nodeType&&module,qt=$t&&Ut&&typeof global=="object"&&global; -!qt||qt.global!==qt&&qt.window!==qt&&qt.self!==qt||(Nt=qt);var qt=Ut&&Ut.exports===$t&&$t,Lt=E();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Nt._=Lt, define(function(){return Lt})):$t&&Ut?qt?(Ut.exports=Lt)._=Lt:$t._=Lt:Nt._=Lt}).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 j(n,t){for(var r=-1,e=n.length,u=-1,o=[];++ru(t,i)&&f.push(i);return f}function Yt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>K)return er(n,t);for(var e=-1,u=Lr(n);++e=r||r>K)return ur(n,t);for(var e=Lr(n);r--&&false!==t(e[r],r,e););return n +}function Xt(n,t){var r=true;return Yt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Gt(n,t){var r=[];return Yt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Ht(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Qt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ec))return false}else{var g=p&&ou.call(n,"__wrapped__"),h=h&&ou.call(t,"__wrapped__");if(g||h)return ir(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(l){case yt:case dt:return+n==+t;case bt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t; +case xt:case wt:return n==Qe(t)}return false}if(g=c?Ge:n.constructor,l=i?Ge:t.constructor,f){if(g.prototype.name!=l.prototype.name)return false}else if(p=!c&&ou.call(n,"constructor"),h=!i&&ou.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=f?["message","name"]:Ju(n),l=f?g:Ju(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,a)for(;i&&++le(a,p)&&((t||i)&&a.push(p),f.push(c))}return f}function yr(n,t){for(var r=-1,e=t(n),u=e.length,o=Pe(u);++rt||null==r)return r;if(3r?Ou(e+r,0):r||0;else if(r)return r=Zr(n,t),n[r]===t?r:-1;return l(n,t,r)}function Kr(n){return Pr(n,1)}function Pr(n,t,r){var e=-1,u=n?n.length:0,o=typeof r; +if(r&&"number"!=o&&x(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 c(n);for(u=t>r?0:r-t,r=Pe(u);++er?Ou(e+r,0):r||0:0,typeof n=="string"||!Pu(n)&&Fe(n)?ri&&(i=o);else t=u&&o?p:Dr(t,r,3),Yt(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===i)&&(e=r,i=n)});return i}function ie(n,t){return ue(n,Ke(t))}function fe(n,t,r,e){return(Pu(n)?u:pr)(n,Dr(t,e,4),r,3>arguments.length,Yt)}function ae(n,t,r,e){return(Pu(n)?o:pr)(n,Dr(t,e,4),r,3>arguments.length,Jt)}function le(n){n=qr(n);for(var t=-1,r=n.length,e=Pe(r);++targuments.length)return Fr(n,R,null,t);var r=Pr(arguments,2),e=j(r,pe.placeholder);return cr(n,R|U,r,e,t)}function he(n,t){var r=R|k;if(2=r||r>t?(f&&pu(f),r=p,f=s=p=F,r&&(h=no(),a=n.apply(c,i),s||f||(i=c=null))):s=mu(e,r)}function u(){s&&pu(s),f=s=p=F,(v||g!==t)&&(h=no(),a=n.apply(c,i),s||f||(i=c=null))}function o(){if(i=arguments,l=no(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=l); +var o=g-(l-h),d=0>=o||o>g;d?(f&&(f=pu(f)),h=l,a=n.apply(c,i)):f||(f=mu(u,o))}return d&&s?s=pu(s):s||t===g||(s=mu(e,t)),r&&(d=true,a=n.apply(c,i)),!d||s||f||(i=c=null),a}var i,f,a,l,c,s,p,h=0,g=false,v=true;if(!je(n))throw new nu(B);if(t=0>t?0:t,true===r)var y=true,v=false;else Ae(r)&&(y=r.leading,g="maxWait"in r&&Ou(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&pu(s),f&&pu(f),f=s=p=F},o}function de(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,je))throw new nu(B); +return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function me(n){var t=Pr(arguments,1),r=j(t,me.placeholder);return cr(n,U,t,r)}function be(n){var t=Pr(arguments,1),r=j(t,be.placeholder);return cr(n,W,t,r)}function _e(n){var t=n&&typeof n=="object"?n.length:F;return typeof t=="number"&&-1t||null==n||!Eu(t))return r; +n=Qe(n);do t%2&&(r+=n),t=hu(t/2),n+=n;while(t);return r}function Ue(n,t,r){return(n=null==n?"":Qe(n))?r||null==t?n.slice(A(n),E(n)+1):(t=Qe(t),n.slice(h(n,t),g(n,t)+1)):n}function We(n,t,r){return(n=null!=n&&Qe(n))&&n.match((r?null:t)||st)||[]}function Ne(n){try{return n()}catch(t){return we(t)?t:Ve(t)}}function $e(n,t,r){return Mt(n,r?F:t)}function qe(n){return n}function Le(n){var t=Ju(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Tr(u))return function(n){return null!=n&&u===n[e]&&ou.call(n,e)}}for(var o=r,i=Pe(r),f=Pe(r);o--;){var u=n[t[o]],a=Tr(u); +i[o]=a,f[o]=a?u:zt(u)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!ou.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!ou.call(n,t[o]):!ir(f[o],n[t[o]],null,true))return false;return true}}function Be(n,t,r){var e=true,u=Ae(t),o=null==r,i=o&&u&&Ju(t),f=i&&or(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=or(t,Ju(t))),false===r?e=false:Ae(r)&&"chain"in r&&(e=r.chain),r=-1,u=je(n);for(o=f.length;++r=q)return r +}else n=0;return Wu(r,e)}}(),Lu=_r(function(n,t,r){ou.call(n,r)?++n[r]:n[r]=1}),Bu=_r(function(n,t,r){ou.call(n,r)?n[r].push(t):n[r]=[t]}),Mu=_r(function(n,t,r){n[r]=t}),zu=_r(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Ku=me(se,2),Pu=Au||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&fu.call(n)==vt||false};Uu.dom||(xe=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!Vu(n)||false});var Zu=Ru||function(n){return typeof n=="number"&&Eu(n)},Vu=gu?function(n){if(!n||fu.call(n)!=_t)return false; +var t=n.valueOf,r=Ee(t)&&(r=gu(t))&&gu(r);return r?n==r||gu(n)==r:Nr(n)}:Nr,Yu=xr(Lt),Ju=Iu?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}},Wt.assign=Yu,Wt.at=function(n){var t=n?n.length:0;return typeof t=="number"&&-1t?0:t)},Wt.dropRight=function(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),Pr(n,0,0>t?0:t)},Wt.dropRightWhile=function(n,t,r){var e=n?n.length:0; +for(t=Dr(t,r,3);e--&&t(n[e],e,n););return Pr(n,0,e+1)},Wt.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Dr(t,r,3);++e(p?s(p,i):u(c,i))){for(t=r;--t;){var h=e[t];if(0>(h?s(h,i):u(n[t],i)))continue n}p&&p.push(i),c.push(i)}return c},Wt.invert=function(n,t,r){t=r?null:t,r=-1;for(var e=Ju(n),u=e.length,o={};++rt?0:t) +},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),Pr(n,0>t?0:t)},Wt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Dr(t,r,3);e--&&t(n[e],e,n););return Pr(n,e+1)},Wt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Dr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Wt.escape=function(n){return(n=null==n?"":Qe(n))&&(G.lastIndex=0,G.test(n))?n.replace(G,m):n},Wt.escapeRegExp=Se,Wt.every=Qr,Wt.find=te,Wt.findIndex=Br,Wt.findKey=function(n,t,r){return t=Dr(t,r,3),Ht(n,t,er,true) +},Wt.findLast=function(n,t,r){return t=Dr(t,r,3),Ht(n,t,Jt)},Wt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Dr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Wt.findLastKey=function(n,t,r){return t=Dr(t,r,3),Ht(n,t,ur,true)},Wt.findWhere=function(n,t){return te(n,Le(t))},Wt.first=Mr,Wt.has=function(n,t){return n?ou.call(n,t):false},Wt.identity=qe,Wt.indexOf=zr,Wt.isArguments=_e,Wt.isArray=Pu,Wt.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&fu.call(n)==yt||false},Wt.isDate=function(n){return n&&typeof n=="object"&&fu.call(n)==dt||false +},Wt.isElement=xe,Wt.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?Ou(e+r,0):Fu(r||0,e-1))+1;else if(r)return u=Vr(n,t)-1,n[u]===t?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=oe,Wt.min=function(n,t,r){t=x(n,t,r)?null:t;var e=1/0,u=null==t,o=!(u&&Pu(n))&&Fe(n),i=e;if(u&&!o)for(r=-1,n=qr(n),u=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Wt.template=function(n,t,r){var e=Wt.templateSettings;x(n,t,r)&&(t=r=null),n=Qe(null==n?"":n),t=Yu({},r||t,e,qt),r=Yu({},t.imports,e.imports,qt); +var u,o,i=Ju(r),f=ke(r),a=0;r=t.interpolate||ft;var l="__p+='";if(r=He((t.escape||ft).source+"|"+r.source+"|"+(r===nt?tt:ft).source+"|"+(t.evaluate||ft).source+"|$","g"),n.replace(r,function(t,r,e,i,f,c){return e||(e=i),l+=n.slice(a,c).replace(ct,b),r&&(u=true,l+="'+__e("+r+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(V,""):l).replace(Y,"$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=Ne(function(){return Ye(i,"return "+l).apply(F,f) +}),t.source=l,we(t))throw t;return t},Wt.trim=Ue,Wt.trimLeft=function(n,t,r){return(n=null==n?"":Qe(n))?r||null==t?n.slice(A(n)):(t=Qe(t),n.slice(h(n,t))):n},Wt.trimRight=function(n,t,r){return(n=null==n?"":Qe(n))?r||null==t?n.slice(0,E(n)+1):(t=Qe(t),n.slice(0,g(n,t)+1)):n},Wt.trunc=function(n,t,r){t=r?null:t;var e=N;if(r=$,Ae(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?Qe(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":Qe(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(Oe(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=He(u.source,(rt.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)},Wt.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Wt.sample(t,n)}):Wt.sample(this.value())},Wt.VERSION=D,Nt.prototype=Wt.prototype,Wt.prototype.chain=function(){return Gr(this)},Wt.prototype.toString=function(){return Qe(this.value())},Wt.prototype.toJSON=Wt.prototype.value=Wt.prototype.valueOf=function(){for(var n=-1,t=this.__queue__,r=t.length,e=this.__wrapped__;++n"'`]/g,H=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,nt=/<%=([\s\S]+?)%>/g,tt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,et=/^\s*function[ \n\r\t]+\w/,ut=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,it=/[\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]/g,ft=/($^)/,at=/[.*+?^${}()|[\]\/\\]/g,lt=/\bthis\b/,ct=/['\n\r\u2028\u2029\\]/g,st=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"),pt=" \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",ht="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(" "),gt="[object Arguments]",vt="[object Array]",yt="[object Boolean]",dt="[object Date]",mt="[object Error]",bt="[object Number]",_t="[object Object]",xt="[object RegExp]",wt="[object String]",jt="[object ArrayBuffer]",At="[object Float32Array]",Et="[object Float64Array]",It="[object Int8Array]",Ot="[object Int16Array]",Ft="[object Int32Array]",Dt="[object Uint8Array]",Rt="[object Uint8ClampedArray]",kt="[object Uint16Array]",Ct="[object Uint32Array]",St={}; +St[gt]=St[vt]=St[At]=St[Et]=St[It]=St[Ot]=St[Ft]=St[Dt]=St[Rt]=St[kt]=St[Ct]=true,St[jt]=St[yt]=St[dt]=St[mt]=St["[object Function]"]=St["[object Map]"]=St[bt]=St[_t]=St[xt]=St["[object Set]"]=St[wt]=St["[object WeakMap]"]=false;var Tt={};Tt[gt]=Tt[vt]=Tt[jt]=Tt[yt]=Tt[dt]=Tt[At]=Tt[Et]=Tt[It]=Tt[Ot]=Tt[Ft]=Tt[bt]=Tt[_t]=Tt[xt]=Tt[wt]=Tt[Dt]=Tt[Rt]=Tt[kt]=Tt[Ct]=true,Tt[mt]=Tt["[object Function]"]=Tt["[object Map]"]=Tt["[object Set]"]=Tt["[object WeakMap]"]=false;var Ut={leading:false,maxWait:0,trailing:false},Wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Nt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},$t={"\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"},qt={"function":true,object:true},Lt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=qt[typeof window]&&window||this,Mt=qt[typeof exports]&&exports&&!exports.nodeType&&exports,zt=qt[typeof module]&&module&&!module.nodeType&&module,Kt=Mt&&zt&&typeof global=="object"&&global; +!Kt||Kt.global!==Kt&&Kt.window!==Kt&&Kt.self!==Kt||(Bt=Kt);var Pt=zt&&zt.exports===Mt&&Mt,Zt=O();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Zt, define(function(){return Zt})):Mt&&zt?Pt?(zt.exports=Zt)._=Zt:Mt._=Zt:Bt._=Zt}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index dfc1a1b4d..6f98fc92e 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -209,7 +209,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function arrayEvery(array, predicate) { @@ -324,7 +324,7 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { @@ -364,7 +364,8 @@ } /** - * The base implementation of `_.indexOf` without support for binary searches. + * The base implementation of `_.indexOf` without support for `fromIndex` + * bounds checks and binary searches. * * @private * @param {Array} array The array to search. @@ -373,12 +374,14 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } var index = (fromIndex || 0) - 1, - length = array ? array.length : 0; + length = array.length; while (++index < length) { - var other = array[index]; - if (other === value) { + if (array[index] === value) { return index; } } @@ -440,6 +443,46 @@ return '\\' + stringEscapes[chr]; } + /** + * Gets the index at which the first occurrence of `NaN` is found in `array`. + * If `fromRight` is provided elements of `array` are iterated from right to left. + * + * @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. + * @returns {number} Returns the index of the matched `NaN`, else `-1`. + */ + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, + index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + + while ((fromRight ? index-- : ++index < length)) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + + /** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ + function isIterateeCall(value, index, object) { + var indexType = typeof index, + objectType = typeof object; + + return (object && (indexType == 'number' || indexType == 'string') && + (objectType == 'function' || objectType == 'object') && object[index] === value) || false; + } + /** * Replaces all `placeholder` elements in `array` with an internal placeholder * and returns an array of their indexes. @@ -827,7 +870,7 @@ * * @private * @param {Array} array The array to inspect. - * @param {Array} [values] The values to exclude. + * @param {Array} values The values to exclude. * @returns {Array} Returns the new array of filtered values. */ function baseDifference(array, values) { @@ -897,13 +940,13 @@ } /** - * The base implementation of `_.every` without support for callback shorthands - * or `this` binding. + * The base implementation of `_.every` without support for callback + * shorthands or `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns `true` if all elements passed the predicate check, + * @returns {Array} Returns `true` if all elements pass the predicate check, * else `false` */ function baseEvery(collection, predicate) { @@ -1344,7 +1387,7 @@ * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function baseSome(collection, predicate) { @@ -1719,8 +1762,8 @@ } /** - * A specialized version of `_.pick` that picks `object` properties - * the predicate returns truthy for. + * A specialized version of `_.pick` that picks `object` properties `predicate` + * returns truthy for. * * @private * @param {Object} object The source object. @@ -1882,7 +1925,7 @@ /** * This method is like `_.find` except that it returns the index of the first - * element the predicate returns truthy for, instead of the element itself. + * element `predicate` returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -1980,15 +2023,7 @@ */ function flatten(array, isDeep, guard) { var length = array ? array.length : 0; - if (!length) { - return []; - } - // enables use as a callback for functions like `_.map` - var type = typeof isDeep; - if ((type == 'number' || type == 'string') && guard && guard[isDeep] === array) { - isDeep = false; - } - return baseFlatten(array, !isDeep); + return length ? baseFlatten(array, guard ? true : !isDeep) : []; } /** @@ -2024,12 +2059,14 @@ */ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; - + if (!length) { + return -1; + } if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); } else if (fromIndex) { var index = sortedIndex(array, value); - return (length && array[index] === value) ? index : -1; + return array[index] === value ? index : -1; } return baseIndexOf(array, value, fromIndex); } @@ -2156,15 +2193,19 @@ * // => 3 */ function lastIndexOf(array, value, fromIndex) { - var length = array ? array.length : 0, - index = length; - + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1; + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } + if (value !== value) { + return indexOfNaN(array, index, true); } while (index--) { - var other = array[index]; - if (other === value) { + if (array[index] === value) { return index; } } @@ -2210,13 +2251,18 @@ */ function slice(array, start, end) { var index = -1, - length = array ? array.length : 0; + length = array ? array.length : 0, + endType = typeof end; + if (end && endType != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } start = start == null ? 0 : (+start || 0); if (start < 0) { start = -start > length ? 0 : (length + start); } - end = (typeof end == 'undefined' || end > length) ? length : (+end || 0); + end = (endType == 'undefined' || end > length) ? length : (+end || 0); if (end < 0) { end += length; } @@ -2237,7 +2283,7 @@ * 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 - * function is bound to `thisArg` and invoked with one argument; (value). + * 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. @@ -2384,16 +2430,10 @@ return []; } // juggle arguments - var type = typeof isSorted; - if (type != 'boolean' && isSorted != null) { + if (typeof isSorted != 'boolean' && isSorted != null) { thisArg = iteratee; - iteratee = isSorted; + iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; - - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { - iteratee = null; - } } if (iteratee != null) { iteratee = baseCallback(iteratee, thisArg, 3); @@ -2658,8 +2698,9 @@ if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { collection = values(collection); + length = collection.length; } - return getIndexOf(collection, target) > -1; + return length ? (getIndexOf(collection, target) > -1) : false; } /** @@ -2701,7 +2742,7 @@ }); /** - * Checks if the predicate returns truthy for **all** elements of `collection`. + * Checks if `predicate` returns truthy for **all** elements of `collection`. * The predicate is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * @@ -2721,7 +2762,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements passed the predicate check, + * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. * @example * @@ -2751,7 +2792,7 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -2797,8 +2838,8 @@ } /** - * Iterates over elements of `collection`, returning the first element that - * the predicate returns truthy for. The predicate is bound to `thisArg` and + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3110,14 +3151,10 @@ * // => { 'user': 'fred', 'age': 40 }; */ function max(collection, iteratee, thisArg) { - var computed = -Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } + var computed = -Infinity, + result = computed; if (iteratee == null) { var index = -1, @@ -3188,14 +3225,10 @@ * // => { 'user': 'barney', 'age': 36 }; */ function min(collection, iteratee, thisArg) { - var computed = Infinity, - result = computed, - type = typeof iteratee; + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; - // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { - iteratee = null; - } + var computed = Infinity, + result = computed; if (iteratee == null) { var index = -1, @@ -3224,8 +3257,8 @@ /** * Creates an array of elements split into two groups, the first of which - * contains elements the predicate returns truthy for, while the second of which - * contains elements the predicate returns falsey for. The predicate is bound + * contains elements `predicate` returns truthy for, while the second of which + * contains elements `predicate` returns falsey for. The predicate is bound * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style @@ -3356,7 +3389,7 @@ /** * The opposite of `_.filter`; this method returns the elements of `collection` - * the predicate does **not** return truthy for. + * that `predicate` does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style * callback returns the property value of the given element. @@ -3420,7 +3453,7 @@ * // => [3, 1] */ function sample(collection, n, guard) { - if (n == null || guard) { + if (guard || n == null) { collection = toIterable(collection); var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; @@ -3490,7 +3523,7 @@ } /** - * Checks if the predicate returns truthy for **any** element of `collection`. + * Checks if `predicate` returns truthy for **any** element of `collection`. * The function returns as soon as it finds a passing value and does not iterate * over the entire collection. The predicate is bound to `thisArg` and invoked * with three arguments; (value, index|key, collection). @@ -3511,7 +3544,7 @@ * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if any element passed the predicate check, + * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. * @example * @@ -3589,10 +3622,15 @@ * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ function sortBy(collection, iteratee, thisArg) { - var index = -1, - length = collection && collection.length, - result = Array(length < 0 ? 0 : length >>> 0); + iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee; + var index = -1, + length = collection ? collection.length : 0, + result = []; + + if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { + result.length = length; + } iteratee = baseCallback(iteratee, thisArg, 3); baseEach(collection, function(value, key, collection) { result[++index] = { @@ -4409,8 +4447,8 @@ * // => false */ function isBoolean(value) { - return (value === true || value === false || - value && typeof value == 'object' && toString.call(value) == boolClass) || false; + return (value === true || value === false || value && typeof value == 'object' && + toString.call(value) == boolClass) || false; } /** @@ -4746,8 +4784,7 @@ */ function isNumber(value) { var type = typeof value; - return type == 'number' || - (value && type == 'object' && toString.call(value) == numberClass) || false; + return type == 'number' || (value && type == 'object' && toString.call(value) == numberClass) || false; } /** @@ -4787,8 +4824,8 @@ * // => false */ function isString(value) { - return typeof value == 'string' || - (value && typeof value == 'object' && toString.call(value) == stringClass) || false; + return typeof value == 'string' || (value && typeof value == 'object' && + toString.call(value) == stringClass) || false; } /** @@ -4847,10 +4884,9 @@ } var args = arguments, index = 0, - length = args.length, - type = typeof args[2]; + length = args.length; - if ((type == 'number' || type == 'string') && args[3] && args[3][args[2]] === args[1]) { + if (isIterateeCall(args[1], args[2], args[3])) { length = 2; } while (++index < length) { @@ -4884,10 +4920,9 @@ } var args = arguments, index = 0, - length = args.length, - type = typeof args[2]; + length = args.length; - if ((type == 'number' || type == 'string') && args[3] && args[3][args[2]] === args[1]) { + if (isIterateeCall(args[1], args[2], args[3])) { length = 2; } while (++index < length) { @@ -4950,6 +4985,7 @@ * @category Object * @param {Object} object The object to invert. * @param {boolean} [multiValue=false] 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 * @@ -5035,8 +5071,8 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it is invoked for each property - * of `object` omitting the properties the predicate returns truthy for. The + * property names. If `predicate` is provided it is invoked for each property + * of `object` omitting the properties `predicate` returns truthy for. The * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * @@ -5103,8 +5139,8 @@ /** * 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 a predicate is provided it is invoked for each property - * of `object` picking the properties the predicate returns truthy for. The + * 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). * @@ -5312,6 +5348,9 @@ var _ = lodash, settings = _.templateSettings; + if (isIterateeCall(string, options, otherOptions)) { + options = otherOptions = null; + } string = String(string == null ? '' : string); options = defaults({}, otherOptions || options, settings); @@ -5428,6 +5467,7 @@ * @category Utility * @param {*} [func=identity] The value to convert to a callback. * @param {*} [thisArg] The `this` binding of the created callback. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. * @returns {Function} Returns the new function. * @example * @@ -5450,8 +5490,8 @@ * _.filter(users, 'age__gt38'); * // => [{ 'user': 'fred', 'age': 40 }] */ - function callback(func, thisArg) { - return baseCallback(func, thisArg); + function callback(func, thisArg, guard) { + return baseCallback(func, guard ? undefined : thisArg); } /** @@ -5702,7 +5742,8 @@ * _.random(1.2, 5.2); * // => a floating-point number between 1.2 and 5.2 */ - function random(min, max) { + function random(min, max, guard) { + max = guard ? null : max; if (min == null && max == null) { max = 1; } @@ -5749,13 +5790,10 @@ * // => [] */ function range(start, end, step) { - start = +start || 0; - - // enables use as a callback for functions like `_.map` - var type = typeof end; - if ((type == 'number' || type == 'string') && step && step[end] === start) { + if (step && isIterateeCall(start, end, step)) { end = step = null; } + start = +start || 0; step = +step || 1; if (end == null) { diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 20d4c3883..7f368f0cf 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,45 +3,45 @@ * Lo-Dash 3.0.0-pre (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE * Build: `lodash underscore -o ./dist/lodash.underscore.js` */ -;(function(){function n(n,r){for(var t=-1,e=n.length;++te||!u||typeof t=="undefined"&&o){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function b(n,r){var t=n?n.length:0;if(typeof t!="number"||-1>=t||t>Dr)return x(n,r,Ct);for(var e=-1,u=G(n);++e=t||t>Dr){for(var t=G(n),e=Ct(n),u=e.length;u--;){var o=e[u];if(r(t[o],o,t)===$r)break}return n}for(e=G(n);t--&&r(e[t],t,e)!==$r;);return n -}function _(n,r){var t=true;return b(n,function(n,e,u){return(t=!!r(n,e,u))||$r}),t}function j(n,r){var t=[];return b(n,function(n,e,u){r(n,e,u)&&t.push(n)}),t}function w(n,r,t){var e;return t(n,function(n,t,u){return r(n,t,u)?(e=n,$r):void 0}),e}function A(n,r,t,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ee(i,a)&&(r&&i.push(a),o.push(f))}return o}function q(n,r){return function(t,e,u){e=v(e,u,3);var o=r?r():{};if(zt(t)){u=-1;for(var i=t.length;++ur?0:r)}function J(n,r,t){var e=n?n.length:0;if(typeof t=="number")t=0>t?St(e+t,0):t||0;else if(t)return t=Q(n,r),e&&n[t]===r?t:-1;return f(n,r,t)}function K(n,r,t){return L(n,null==r||t?1:0>r?0:r)}function L(n,r,t){var e=-1,u=n?n.length:0;if(r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),t=typeof t=="undefined"||t>u?u:+t||0,0>t&&(t+=u),t&&t==u&&!r)return a(n); -for(u=r>t?0:t-r,t=Array(u);++eu&&(u=i)}else r=v(r,t,3),b(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function ir(n,r){return ur(n,Fr(r))}function fr(n,r,t,e){return(zt(n)?u:F)(n,v(r,e,4),t,3>arguments.length,b) -}function ar(n,r,t,e){return(zt(n)?o:F)(n,v(r,e,4),t,3>arguments.length,d)}function cr(n){n=V(n);for(var r=-1,t=n.length,e=Array(t);++r=t||t>r?(f&&clearTimeout(f),t=s,f=p=s=Mr,t&&(g=Pt(),a=n.apply(l,i),p||f||(i=l=null))):p=setTimeout(e,t) -}function u(){p&&clearTimeout(p),f=p=s=Mr,(v||h!==r)&&(g=Pt(),a=n.apply(l,i),p||f||(i=l=null))}function o(){if(i=arguments,c=Pt(),l=this,s=v&&(p||!y),false===h)var t=y&&!p;else{f||y||(g=c);var o=h-(c-g),m=0>=o||o>h;m?(f&&(f=clearTimeout(f)),g=c,a=n.apply(l,i)):f||(f=setTimeout(u,o))}return m&&p?p=clearTimeout(p):p||r===h||(p=setTimeout(e,r)),t&&(m=true,a=n.apply(l,i)),!m||p||f||(i=l=null),a}var i,f,a,c,l,p,s,g=0,h=false,v=true;if(!yr(n))throw new TypeError(Rr);if(r=0>r?0:r,true===t)var y=true,v=false;else mr(t)&&(y=t.leading,h="maxWait"in t&&St(+t.maxWait||0,r),v="trailing"in t?t.trailing:v); -return o.cancel=function(){p&&clearTimeout(p),f&&clearTimeout(f),f=p=s=Mr},o}function gr(n){for(var r=L(arguments,1),t=r,e=gr.placeholder,u=-1,o=t.length,i=-1,f=[];++u"'`]/g,Gr=/^\[object .+?Constructor\]$/,Hr=/($^)/,Jr=/[.*+?^${}()|[\]\/\\]/g,Kr=/['\n\r\u2028\u2029\\]/g,Lr="[object Arguments]",Qr="[object Boolean]",Xr="[object Date]",Yr="[object Error]",Zr="[object Number]",nt="[object Object]",rt="[object RegExp]",tt="[object String]",et={}; -et[Lr]=et["[object Array]"]=et["[object Float32Array]"]=et["[object Float64Array]"]=et["[object Int8Array]"]=et["[object Int16Array]"]=et["[object Int32Array]"]=et["[object Uint8Array]"]=et["[object Uint8ClampedArray]"]=et["[object Uint16Array]"]=et["[object Uint32Array]"]=true,et["[object ArrayBuffer]"]=et[Qr]=et[Xr]=et[Yr]=et["[object Function]"]=et["[object Map]"]=et[Zr]=et[nt]=et[rt]=et["[object Set]"]=et[tt]=et["[object WeakMap]"]=false;var ut={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},ot={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},it={"function":true,object:true},ft={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=it[typeof window]&&window||this,ct=it[typeof exports]&&exports&&!exports.nodeType&&exports,lt=it[typeof module]&&module&&!module.nodeType&&module,pt=ct&<&&typeof global=="object"&&global; -!pt||pt.global!==pt&&pt.window!==pt&&pt.self!==pt||(at=pt);var st=lt&<.exports===ct&&ct,gt=Array.prototype,ht=Object.prototype,vt=Function.prototype.toString,yt=ht.hasOwnProperty,mt=at._,bt=ht.toString,dt=RegExp("^"+function(n){return(n=null==n?"":n+"")&&(Jr.lastIndex=0,Jr.test(n))?n.replace(Jr,"\\$&"):n}(bt).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_t=Math.ceil,jt=Math.floor,wt=gt.push,At=ht.propertyIsEnumerable,xt=gt.splice,Tt=br(Tt=Object.create)&&Tt,Et=br(Et=Array.isArray)&&Et,Ot=at.isFinite,kt=br(kt=Object.keys)&&kt,St=Math.max,It=Math.min,Ft=br(Ft=Date.now)&&Ft,Mt=Math.random,$t={}; -!function(){var n={0:1,length:1};$t.spliceObjects=(xt.call(n,0,1),!n[0])}(0,0),g.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Tt||(y=function(){function n(){}return function(r){if(mr(r)){n.prototype=r;var t=new n;n.prototype=null}return t||at.Object()}}());var qt=K,Bt=H,Nt=q(function(n,r,t){yt.call(n,t)?++n[t]:n[t]=1}),Rt=q(function(n,r,t){yt.call(n,t)?n[t].push(r):n[t]=[r]}),Ut=q(function(n,r,t){n[t]=r}),Wt=q(function(n,r,t){n[t?0:1].push(r) -},function(){return[[],[]]}),Dt=gr(pr,2);hr(arguments)||(hr=function(n){var r=n&&typeof n=="object"?n.length:Mr;return typeof r=="number"&&-1--n?r.apply(this,arguments):void 0}},g.before=pr,g.bind=function(n,r){return 3>arguments.length?W(n,qr,r):S(n,qr|Nr,L(arguments,2),[],r)},g.bindAll=function(n){for(var r=n,t=1r?0:r)},g.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},g.invert=function(n){for(var r=-1,t=Ct(n),e=t.length,u={};++ru?0:u>>>0);for(r=v(r,t,3),b(n,function(n,t,u){o[++e]={a:r(n,t,u),b:e,c:n}}),u=o.length,o.sort(c);u--;)o[u]=o[u].c;return o},g.take=Bt,g.tap=function(n,r){return r(n),n},g.throttle=function(n,r,t){var e=true,u=true;if(!yr(n))throw new TypeError(funcErrorText);return false===t?e=false:mr(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),sr(n,r,{leading:e,maxWait:r,trailing:u}) -},g.times=function(n,r,t){n=Ot(n=+n)&&-1t)return function(){};if(!r(n,yr))throw new TypeError(Rr);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},g.each=er,g.extend=jr,g.iteratee=function(n,r){return v(n,r)},g.methods=Ar,g.object=function(n,r){var t=-1,e=n?n.length:0,u={};for(r||!e||zt(n[0])||(r=[]);++tr?0:r))},g.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?St(e+t,0):It(t||0,e-1))+1);e--;)if(n[e]===r)return e;return-1},g.max=or,g.min=function(n,r,t){var e=1/0,u=e,o=typeof r;if("number"!=o&&"string"!=o||!t||t[r]!==n||(r=null),null==r)for(t=-1,n=V(n),o=n.length;++tr?0:+r||0,n.length),n)},Ir(jr({},g)),g.VERSION="3.0.0-pre",h.prototype=g.prototype,g.prototype.chain=function(){return Y(this) -},g.prototype.value=function(){return this.__wrapped__},gr.placeholder=g,n("concat join pop push reverse shift sort splice unshift".split(" "),function(n){var r=gt[n],t=!/^(?:concat|join|slice)$/.test(n),e=!$t.spliceObjects&&/^(?:pop|shift|splice)$/.test(n);g.prototype[n]=function(){var n=this.__wrapped__,u=r.apply(n,arguments);return e&&0===n.length&&delete n[0],t&&(u=n),this.__chain__?new h(u,true):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(at._=g, define("underscore",function(){return g -})):ct&<?st?(lt.exports=g)._=g:ct._=g:at._=g}).call(this); \ No newline at end of file +;(function(){function n(n,r){for(var t=-1,e=n.length;++te||!u||typeof t=="undefined"&&o){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function _(n,r){var t=n?n.length:0;if(typeof t!="number"||-1>=t||t>Cr)return E(n,r,Vt); +for(var e=-1,u=J(n);++e=t||t>Cr){for(var t=J(n),e=Vt(n),u=e.length;u--;){var o=e[u];if(r(t[o],o,t)===Br)break}return n}for(e=J(n);t--&&r(e[t],t,e)!==Br;);return n}function w(n,r){var t=true;return _(n,function(n,e,u){return(t=!!r(n,e,u))||Br}),t}function A(n,r){var t=[];return _(n,function(n,e,u){r(n,e,u)&&t.push(n)}),t}function x(n,r,t){var e;return t(n,function(n,t,u){return r(n,t,u)?(e=n,Br):void 0}),e}function T(n,r,t,e){e=(e||0)-1; +for(var u=n.length,o=-1,i=[];++ee(i,a)&&(r&&i.push(a),o.push(f))}return o}function N(n,r){return function(t,e,u){e=m(e,u,3);var o=r?r():{};if(Pt(t)){u=-1; +for(var i=t.length;++ur?0:r) +}function L(n,r,t){var e=n?n.length:0;if(!e)return-1;if(typeof t=="number")t=0>t?Ft(e+t,0):t||0;else if(t)return t=Y(n,r),n[t]===r?t:-1;return f(n,r,t)}function Q(n,r,t){return X(n,null==r||t?1:0>r?0:r)}function X(n,r,t){var e=-1,u=n?n.length:0,o=typeof t;if(t&&"number"!=o&&h(n,r,t)&&(r=0,t=u),r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),t="undefined"==o||t>u?u:+t||0,0>t&&(t+=u),t&&t==u&&!r)return a(n);for(u=r>t?0:t-r,t=Array(u);++eu&&(u=i)}}else r=m(r,t,3),_(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function ar(n,r){return ir(n,$r(r))}function cr(n,r,t,e){return(Pt(n)?u:$)(n,m(r,e,4),t,3>arguments.length,_)}function lr(n,r,t,e){return(Pt(n)?o:$)(n,m(r,e,4),t,3>arguments.length,j)}function pr(n){n=H(n);for(var r=-1,t=n.length,e=Array(t);++r=t||t>r?(f&&clearTimeout(f),t=s,f=p=s=qr,t&&(h=Gt(),a=n.apply(l,i),p||f||(i=l=null))):p=setTimeout(e,t)}function u(){p&&clearTimeout(p),f=p=s=qr,(v||g!==r)&&(h=Gt(),a=n.apply(l,i),p||f||(i=l=null)) +}function o(){if(i=arguments,c=Gt(),l=this,s=v&&(p||!y),false===g)var t=y&&!p;else{f||y||(h=c);var o=g-(c-h),m=0>=o||o>g;m?(f&&(f=clearTimeout(f)),h=c,a=n.apply(l,i)):f||(f=setTimeout(u,o))}return m&&p?p=clearTimeout(p):p||r===g||(p=setTimeout(e,r)),t&&(m=true,a=n.apply(l,i)),!m||p||f||(i=l=null),a}var i,f,a,c,l,p,s,h=0,g=false,v=true;if(!br(n))throw new TypeError(Wr);if(r=0>r?0:r,true===t)var y=true,v=false;else dr(t)&&(y=t.leading,g="maxWait"in t&&Ft(+t.maxWait||0,r),v="trailing"in t?t.trailing:v);return o.cancel=function(){p&&clearTimeout(p),f&&clearTimeout(f),f=p=s=qr +},o}function vr(n){for(var r=X(arguments,1),t=r,e=vr.placeholder,u=-1,o=t.length,i=-1,f=[];++u"'`]/g,Jr=/^\[object .+?Constructor\]$/,Kr=/($^)/,Lr=/[.*+?^${}()|[\]\/\\]/g,Qr=/['\n\r\u2028\u2029\\]/g,Xr="[object Arguments]",Yr="[object Boolean]",Zr="[object Date]",nt="[object Error]",rt="[object Number]",tt="[object Object]",et="[object RegExp]",ut="[object String]",ot={}; +ot[Xr]=ot["[object Array]"]=ot["[object Float32Array]"]=ot["[object Float64Array]"]=ot["[object Int8Array]"]=ot["[object Int16Array]"]=ot["[object Int32Array]"]=ot["[object Uint8Array]"]=ot["[object Uint8ClampedArray]"]=ot["[object Uint16Array]"]=ot["[object Uint32Array]"]=true,ot["[object ArrayBuffer]"]=ot[Yr]=ot[Zr]=ot[nt]=ot["[object Function]"]=ot["[object Map]"]=ot[rt]=ot[tt]=ot[et]=ot["[object Set]"]=ot[ut]=ot["[object WeakMap]"]=false;var it={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},ft={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},at={"function":true,object:true},ct={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lt=at[typeof window]&&window||this,pt=at[typeof exports]&&exports&&!exports.nodeType&&exports,st=at[typeof module]&&module&&!module.nodeType&&module,ht=pt&&st&&typeof global=="object"&&global; +!ht||ht.global!==ht&&ht.window!==ht&&ht.self!==ht||(lt=ht);var gt=st&&st.exports===pt&&pt,vt=Array.prototype,yt=Object.prototype,mt=Function.prototype.toString,bt=yt.hasOwnProperty,dt=lt._,_t=yt.toString,jt=RegExp("^"+function(n){return(n=null==n?"":n+"")&&(Lr.lastIndex=0,Lr.test(n))?n.replace(Lr,"\\$&"):n}(_t).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wt=Math.ceil,At=Math.floor,xt=vt.push,Tt=yt.propertyIsEnumerable,Et=vt.splice,Ot=_r(Ot=Object.create)&&Ot,kt=_r(kt=Array.isArray)&&kt,St=lt.isFinite,It=_r(It=Object.keys)&&It,Ft=Math.max,Mt=Math.min,$t=_r($t=Date.now)&&$t,qt=Math.random,Bt={}; +!function(){var n={0:1,length:1};Bt.spliceObjects=(Et.call(n,0,1),!n[0])}(0,0),v.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Ot||(b=function(){function n(){}return function(r){if(dr(r)){n.prototype=r;var t=new n;n.prototype=null}return t||lt.Object()}}());var Nt=Q,Rt=K,Ut=N(function(n,r,t){bt.call(n,t)?++n[t]:n[t]=1}),Wt=N(function(n,r,t){bt.call(n,t)?n[t].push(r):n[t]=[r]}),Dt=N(function(n,r,t){n[t]=r}),zt=N(function(n,r,t){n[t?0:1].push(r) +},function(){return[[],[]]}),Ct=vr(hr,2);yr(arguments)||(yr=function(n){var r=n&&typeof n=="object"?n.length:qr;return typeof r=="number"&&-1--n?r.apply(this,arguments):void 0}},v.before=hr,v.bind=function(n,r){return 3>arguments.length?z(n,Nr,r):F(n,Nr|Ur,X(arguments,2),[],r)},v.bindAll=function(n){for(var r=n,t=1r?0:r)},v.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},v.invert=function(n){for(var r=-1,t=Vt(n),e=t.length,u={};++rt)return function(){};if(!r(n,br))throw new TypeError(Wr);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},v.each=or,v.extend=Ar,v.iteratee=function(n,r,t){return m(n,t?qr:r)},v.methods=Tr,v.object=function(n,r){var t=-1,e=n?n.length:0,u={};for(r||!e||Pt(n[0])||(r=[]);++tr?0:r))},v.lastIndexOf=function(n,r,t){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof t=="number"&&(u=(0>t?Ft(e+t,0):Mt(t||0,e-1))+1),r!==r)return s(n,u,true);for(;u--;)if(n[u]===r)return u;return-1},v.max=fr,v.min=function(n,r,t){r=h(n,r,t)?null:r;var e=1/0,u=e;if(null==r){t=-1,n=H(n);for(var o=n.length;++tr?0:+r||0,n.length),n)},Mr(Ar({},v)),v.VERSION="3.0.0-pre",y.prototype=v.prototype,v.prototype.chain=function(){return nr(this) +},v.prototype.value=function(){return this.__wrapped__},vr.placeholder=v,n("concat join pop push reverse shift sort splice unshift".split(" "),function(n){var r=vt[n],t=!/^(?:concat|join|slice)$/.test(n),e=!Bt.spliceObjects&&/^(?:pop|shift|splice)$/.test(n);v.prototype[n]=function(){var n=this.__wrapped__,u=r.apply(n,arguments);return e&&0===n.length&&delete n[0],t&&(u=n),this.__chain__?new y(u,true):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(lt._=v, define("underscore",function(){return v +})):pt&&st?gt?(st.exports=v)._=v:pt._=v:lt._=v}).call(this); \ No newline at end of file