From e22b2f00dcd52e1c8e9a7dfe45f998677f587f80 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 3 Mar 2014 01:49:12 -0800 Subject: [PATCH] Rebuild dist files. [ci skip] --- dist/lodash.compat.js | 605 ++++++++++++++++++++++++++++++---- dist/lodash.compat.min.js | 121 +++---- dist/lodash.js | 605 ++++++++++++++++++++++++++++++---- dist/lodash.min.js | 116 +++---- dist/lodash.underscore.js | 121 ++++--- dist/lodash.underscore.min.js | 58 ++-- 6 files changed, 1297 insertions(+), 329 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index f6e7ff968..3c4ed2eb5 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -58,15 +58,28 @@ /** Used to detect hexadecimal string values */ var reHexPrefix = /^0[xX]/; + /** Used to match latin-1 supplement letters */ + var reLatin1 = /[\xC0-\xFF]/g; + /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; + /** + * Used to match RegExp special characters. + * See this [article on RegExp characters](http://www.regular-expressions.info/characters.html#special) + * for more details. + */ + var reRegExpChars =/[.*+?^${()|[\\]/g; + /** Used to detect functions containing a `this` reference */ var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; + /** Used to match words to create compound words */ + var reWords = /[a-z0-9]+/g; + /** Used to detect and test whitespace */ var whitespace = ( // whitespace @@ -115,7 +128,7 @@ cloneableClasses[numberClass] = cloneableClasses[objectClass] = cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; - /** Used as an internal `_.debounce` options object */ + /** Used as an internal `_.debounce` options object by `_.throttle` */ var debounceOptions = { 'leading': false, 'maxWait': 0, @@ -156,6 +169,31 @@ ''': "'" }; + /** + * Used to convert latin-1 supplement letters to basic latin (ASCII) letters. + * See [Wikipedia](http://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * for more details. + */ + var deburredLetters = { + '\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': ' ' + }; + /** Used to determine if values are of the language type Object */ var objectTypes = { 'function': true, @@ -339,15 +377,49 @@ return a.index - b.index; } + /** + * Creates a function that produces compound words out of the words in a + * given string. + * + * @private + * @param {Function} callback The function called to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + var index = -1, + words = string != null && String(string).replace(reLatin1, deburrLetter).match(reWords), + length = words ? words.length : 0, + result = ''; + + while (++index < length) { + result = callback(result, words[index], index, words); + } + return result; + }; + } + + /** + * Used by `createCompounder` to convert latin-1 supplement letters to basic + * latin (ASCII) letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + function deburrLetter(letter) { + return deburredLetters[letter]; + } + /** * Used by `escape` to convert characters to HTML entities. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; } /** @@ -355,11 +427,11 @@ * string literals. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeStringChar(match) { - return '\\' + stringEscapes[match]; + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; } /** @@ -482,11 +554,11 @@ * Used by `unescape` to convert HTML entities to characters. * * @private - * @param {string} match The matched character to unescape. + * @param {string} chr The matched character to unescape. * @returns {string} Returns the unescaped character. */ - function unescapeHtmlChar(match) { - return htmlUnescapes[match]; + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; } /*--------------------------------------------------------------------------*/ @@ -537,9 +609,8 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + escapeRegExp(toString) + .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Native method shortcuts */ @@ -627,7 +698,7 @@ * implicitly or explicitly included in the build. * * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `after`, `assign`, `at`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, * `compose`, `concat`, `constant`, `countBy`, `create`, `createCallback`, * `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, * `flatten`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, @@ -1819,7 +1890,7 @@ /** * Creates a function that aggregates a collection, creating an object or * array composed from the results of running each element of the collection - * through a callback. The given `setter` function sets the keys and values + * through a callback. The given setter function sets the keys and values * of the composed object or array. * * @private @@ -1868,6 +1939,29 @@ return cache; }; + /** + * Creates the pad required for `string` based on the given padding length. + * The `chars` string may be truncated if the number of padding characters + * exceeds the padding length. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ + function createPad(string, length, chars) { + var strLength = string.length; + length = +length || 0; + + if (strLength >= length) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : String(chars); + return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); + } + /** * Creates a function that, when called, either curries or invokes `func` * with an optional `this` binding and partially applied arguments. @@ -2038,10 +2132,10 @@ }; /** - * A fallback implementation of `isPlainObject` which checks if a given value - * is an object created by the `Object` constructor, assuming objects created - * by the `Object` constructor have no inherited enumerable properties and that - * there are no `Object.prototype` extensions. + * A fallback implementation of `isPlainObject` which checks if `value` is + * an object created by the `Object` constructor, assuming objects created + * by the `Object` constructor have no inherited enumerable properties and + * that there are no `Object.prototype` extensions. * * @private * @param {*} value The value to check. @@ -2388,9 +2482,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -3068,9 +3162,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -3138,7 +3232,8 @@ /** * Creates an array that is the symmetric difference of the provided arrays. - * See [Wikipedia](http://en.wikipedia.org/wiki/Symmetric_difference) for more details. + * See [Wikipedia](http://en.wikipedia.org/wiki/Symmetric_difference) for + * more details. * * @static * @memberOf _ @@ -3411,10 +3506,10 @@ * @memberOf _ * @alias include * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {*} target The value to check for. * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if the `target` element is found, else `false`. + * @returns {boolean} Returns `true` if the target element is found, else `false`. * @example * * _.contains([1, 2, 3], 1); @@ -3638,7 +3733,7 @@ * @memberOf _ * @alias detect, findWhere * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [callback=identity] The function called * per iteration. If a property name or object is provided it will be used * to create a "_.pluck" or "_.where" style callback, respectively. @@ -3696,7 +3791,7 @@ * @static * @memberOf _ * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [callback=identity] The function called * per iteration. If a property name or object is provided it will be used * to create a "_.pluck" or "_.where" style callback, respectively. @@ -3998,9 +4093,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. * @example @@ -4073,9 +4168,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. * @example @@ -4364,7 +4459,8 @@ /** * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) for more details. + * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) + * for more details. * * @static * @memberOf _ @@ -4499,9 +4595,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Array|Function|Object|string} [callback=identity] The function + * called per iteration. If a property name or object is provided it will + * be used to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -4903,7 +4999,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait) || 0; + wait = wait > 0 ? wait : 0; if (options === true) { var leading = true; trailing = false; @@ -5238,11 +5334,11 @@ if (options === false) { leading = false; } else if (isObject(options)) { - leading = 'leading' in options ? options.leading : leading; - trailing = 'trailing' in options ? options.trailing : trailing; + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; } debounceOptions.leading = leading; - debounceOptions.maxWait = wait; + debounceOptions.maxWait = +wait; debounceOptions.trailing = trailing; return debounce(func, wait, debounceOptions); @@ -5542,9 +5638,9 @@ * @memberOf _ * @category Objects * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {string|undefined} Returns the key of the found element, else `undefined`. * @example @@ -5596,9 +5692,9 @@ * @memberOf _ * @category Objects * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {string|undefined} Returns the key of the found element, else `undefined`. * @example @@ -6296,7 +6392,7 @@ } /** - * Creates an array composed of the own enumerable property names of an object. + * Creates an array composed of the own enumerable property names of `object`. * * @static * @memberOf _ @@ -6507,7 +6603,7 @@ } /** - * Creates a two dimensional array of an object's key-value pairs, + * Creates a two dimensional array of a given object's key-value pairs, * i.e. `[[key1, value1], [key2, value2]]`. * * @static @@ -6665,12 +6761,36 @@ /*--------------------------------------------------------------------------*/ /** - * Converts the first character of `string` to upper case. + * Converts `string` to camel case. + * See [Wikipedia](http://en.wikipedia.org/wiki/CamelCase) for more details. * * @static * @memberOf _ * @category Strings - * @param {string} string The string to capitalize. + * @param {string} [string=''] The string to camel case. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Hello world'); + * // => 'helloWorld' + * + * _.camelCase('hello-world'); + * // => 'helloWorld' + * + * _.camelCase('hello_world'); + * // => 'helloWorld' + */ + var camelCase = createCompounder(function(result, words, index) { + return result + words.charAt(0)[index ? 'toUpperCase' : 'toLowerCase']() + words.slice(1); + }); + + /** + * Capitalizes the first character of `string`. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to capitalize. * @returns {string} Returns the capitalized string. * @example * @@ -6685,6 +6805,37 @@ return string.charAt(0).toUpperCase() + string.slice(1); } + /** + * Checks if `string` ends with a given target string. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search from. + * @returns {boolean} Returns `true` if the given string ends with the + * target string, else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = string == null ? '' : String(string); + target = String(target); + + var length = string.length; + position = (typeof position == 'number' ? nativeMin(nativeMax(position, 0), length) : length) - target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + /** * Converts the characters "&", "<", ">", '"', and "'" in `string` to * their corresponding HTML entities. @@ -6699,7 +6850,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to escape. + * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. * @example * @@ -6710,6 +6861,234 @@ return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } + /** + * Escapes the RegExp special characters "\", "^", "$", ".", "|", "?", "*", + * "+", "(", ")", "[", and "{" in `string`. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](http://lodash.com)'); + * // => '\[lodash]\(http://lodash\.com\)' + */ + function escapeRegExp(string) { + return string == null ? '' : String(string).replace(reRegExpChars, '\\$&'); + } + + /** + * Converts `string` to kebab case (a.k.a. spinal case). + * See [Wikipedia](http://en.wikipedia.org/wiki/Letter_case#Computers) for + * more details. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to kebab case. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Hello world'); + * // => 'hello-world' + * + * _.kebabCase('helloWorld'); + * // => 'hello-world' + * + * _.kebabCase('hello_world'); + * // => 'hello-world' + */ + var kebabCase = createCompounder(function(result, words, index) { + return result + (index ? '-' : '') + words.toLowerCase(); + }); + + /** + * Pads `string` on the left and right sides if it is shorter then the given + * padding length. The `chars` string may be truncated if the number of padding + * characters can't be evenly divided by the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = string == null ? '' : String(string); + length = +length || 0; + + var strLength = string.length; + if (strLength >= length) { + return string; + } + var mid = (length - strLength) / 2, + leftLength = floor(mid), + rightLength = ceil(mid); + + chars = createPad('', rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + + /** + * Pads `string` on the left side if it is shorter then the given padding + * length. The `chars` string may be truncated if the number of padding + * characters exceeds the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padLeft('abc', 6); + * // => ' abc' + * + * _.padLeft('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padLeft('abc', 3); + * // => 'abc' + */ + function padLeft(string, length, chars) { + string = string == null ? '' : String(string); + return createPad(string, length, chars) + string; + } + + /** + * Pads `string` on the right side if it is shorter then the given padding + * length. The `chars` string may be truncated if the number of padding + * characters exceeds the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padRight('abc', 6); + * // => 'abc ' + * + * _.padRight('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padRight('abc', 3); + * // => 'abc' + */ + function padRight(string, length, chars) { + string = string == null ? '' : String(string); + return string + createPad(string, length, chars); + } + + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n) { + var result = ''; + n = +n || 0; + + if (n < 1 || string == null) { + return result; + } + string = String(string); + while (n > 0) { + if (n % 2) { + result += string; + } + n = floor(n / 2); + result += result; + } + return result; + } + + /** + * Converts `string` to snake case. + * See [Wikipedia](http://en.wikipedia.org/wiki/Snake_case) for more details. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to snake case. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Hello world'); + * // => 'hello_world' + * + * _.snakeCase('hello-world'); + * // => 'hello_world' + * + * _.snakeCase('helloWorld'); + * // => 'hello_world' + */ + var snakeCase = createCompounder(function(result, words, index) { + return result + (index ? '_' : '') + words.toLowerCase(); + }); + + /** + * Checks if `string` starts with a given target string. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if the given string starts with the + * target string, else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = string == null ? '' : String(string); + position = typeof position == 'number' ? nativeMin(nativeMax(position, 0), string.length) : 0; + return string.lastIndexOf(target, position) == position; + } + /** * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in @@ -6719,8 +7098,8 @@ * settings object is provided it will override `_.templateSettings` for the * template. * - * Note: In the development build, `_.template` utilizes sourceURLs for easier - * debugging. See [HTML5 Rocks' article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. + * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * * For more information on precompiling templates see @@ -6732,8 +7111,8 @@ * @static * @memberOf _ * @category Strings - * @param {string} text The template text. - * @param {Object} [data] The data object used to populate the text. + * @param {string} [string=''] The template string. + * @param {Object} [data] The data object used to populate the template string. * @param {Object} [options] The options object. * @param {RegExp} [options.escape] The HTML "escape" delimiter. * @param {RegExp} [options.evaluate] The "evaluate" delimiter. @@ -6799,13 +7178,13 @@ * };\ * '); */ - function template(text, data, options) { + function template(string, data, options) { // based on John Resig's `tmpl` implementation // http://ejohn.org/blog/javascript-micro-templating/ // and Laura Doktorova's doT.js // https://github.com/olado/doT var settings = lodash.templateSettings; - text = String(text || ''); + string = String(string == null ? '' : string); // avoid missing dependencies when `iteratorTemplate` is not defined options = defaults({}, options, settings); @@ -6828,11 +7207,11 @@ (options.evaluate || reNoMatch).source + '|$' , 'g'); - text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); // escape characters that cannot be included in string literals - source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar); + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); // replace delimiters with snippets if (escapeValue) { @@ -6911,7 +7290,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6935,7 +7314,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6959,7 +7338,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6977,6 +7356,85 @@ return chars == null ? nativeTrimRight.call(string) : shimTrimRight(string, chars); }; + /** + * Truncates `string` if it is longer than the given maximum string length. + * The last characters of the truncated string will be replaced with the + * omission string which defaults to "...". + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to trim. + * @param {Object|number} [options] The options object or maximum string length. + * @param {number} [options.length=30] The maximum string length. + * @param {string} [options.omission='...'] The string used to indicate text is omitted. + * @param {RegExp|string} [options.separator] The separator pattern to truncate to. + * @returns {string} Returns the truncated string. + * @example + * + * _.truncate('hi-diddly-ho there, neighborino'); + * // => 'hi-diddly-ho there, neighbo...' + * + * _.truncate('hi-diddly-ho there, neighborino', 24); + * // => 'hi-diddly-ho there, n...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * // => 'hi-diddly-ho there,...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * //=> 'hi-diddly-ho there...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * // => 'hi-diddly-ho there, neig [...]' + */ + function truncate(string, options) { + var length = 30, + omission = '...'; + + if (options && isObject(options)) { + var separator = 'separator' in options ? options.separator : separator; + length = 'length' in options ? +options.length || 0 : length; + omission = 'omission' in options ? String(options.omission) : omission; + } + else if (options != null) { + length = +options || 0; + } + string = string == null ? '' : String(string); + if (length > string.length) { + return string; + } + var end = length - omission.length; + if (end < 1) { + return omission; + } + var result = string.slice(0, end); + if (separator == null) { + return result + omission; + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, + newEnd, + substring = string.slice(0, end); + + if (!separator.global) { + separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g'); + } + separator.lastIndex = 0; + while ((match = separator.exec(substring))) { + newEnd = match.index; + } + result = result.slice(0, newEnd == null ? end : newEnd); + } + } else if (string.indexOf(separator, end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } + } + return result + omission; + } + /** * The inverse of `_.escape`; this method converts the HTML entities * `&`, `<`, `>`, `"`, and `'` in `string` to their @@ -6988,7 +7446,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to unescape. + * @param {string} [string=''] The string to unescape. * @returns {string} Returns the unescaped string. * @example * @@ -7440,7 +7898,7 @@ * @memberOf _ * @category Utilities * @param {number} n The number of times to execute the callback. - * @param {Function} callback The function called per iteration. + * @param {Function} [callback=identity] The function called per iteration. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns an array of the results of each `callback` execution. * @example @@ -7584,11 +8042,14 @@ /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining + lodash.camelCase = camelCase; lodash.capitalize = capitalize; lodash.clone = clone; lodash.cloneDeep = cloneDeep; lodash.contains = contains; + lodash.endsWith = endsWith; lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; lodash.every = every; lodash.find = find; lodash.findIndex = findIndex; @@ -7616,24 +8077,32 @@ lodash.isRegExp = isRegExp; lodash.isString = isString; lodash.isUndefined = isUndefined; + lodash.kebabCase = kebabCase; lodash.lastIndexOf = lastIndexOf; lodash.mixin = mixin; lodash.noConflict = noConflict; lodash.noop = noop; lodash.now = now; + lodash.pad = pad; + lodash.padLeft = padLeft; + lodash.padRight = padRight; lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; + lodash.repeat = repeat; lodash.result = result; lodash.runInContext = runInContext; lodash.size = size; lodash.some = some; lodash.sortedIndex = sortedIndex; + lodash.snakeCase = snakeCase; + lodash.startsWith = startsWith; lodash.template = template; lodash.trim = trim; lodash.trimLeft = trimLeft; lodash.trimRight = trimRight; + lodash.truncate = truncate; lodash.unescape = unescape; lodash.uniqueId = uniqueId; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 50bfd2bbe..18738d263 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,62 +4,65 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202a(e,l)&&f.push(l);return f}function ct(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number")for(oe.unindexedChars&&ur(e)&&(e=e.split(""));++ri(p,g)&&((u||f)&&p.push(g),c.push(s))}return c}function _t(n,t,r){for(var e=t.length,u=-1,o=Hr(r.length-e,0),a=-1,i=n.length,l=sr(o+i);++ar&&(r=0),c&&(a=[]),p&&(i=[]),s=[n,t,r,e,u,o,a,i],t==b||t==(b|x)?h(s):it(s)) -}function xt(n){n.d=U;var t=vr,r="return function("+n.a+"){",e="var r="+n.b+";if(!j(p)){return r}";oe.nonEnumArgs&&(e+="var m=p.length;if(m&&i(p)){l=-1;while(++lu;u++)e+="l='"+n.d[u]+"';if((!(k&&n[l])&&g.call(p,l))",n.e||(e+="||(!n[l]&&p[l]!==q[l])"),e+="){"+n.c+"}"; -e+="}"}return t("e,f,g,i,j,q,o,u,v,w",r+(e+"return r;")+"}")(J,xr,qr,Et,rr,Cr,ue,tt,kr,Sr)}function Ct(){var n=(n=u.indexOf)===At?t:n;return n}function kt(n){return typeof n=="function"&&Ar.test(Tr.call(n))}function Ot(n){var t,r;return!n||Sr.call(n)!=Z||!qr.call(n,"constructor")&&(t=n.constructor,tr(t)&&!(t instanceof t))||!oe.argsClass&&Et(n)||!oe.nodeClass&&c(n)?false:oe.ownLast?(le(n,function(n,t,e){return r=qr.call(e,t),false}),false!==r):(le(n,function(n,t){r=t}),typeof r=="undefined"||qr.call(n,r))}function Et(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Sr.call(n)==V||false -}function St(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,a=0;for(t=u.createCallback(t,r,3);++ee?Hr(0,u+e):e||0;else if(e)return e=Rt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function It(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,a=0;for(t=u.createCallback(t,r,3);++et?t=Hr(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Hr(u+r,0):r>u&&(r=u),u=r-t||0,r=sr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!ve(n)&&ur(n))return Kr?Kr.call(n,t,r):-1r?Hr(0,e+r):r)||0,-1a&&(a=l)}else t=null==t&&ur(n)?e:u.createCallback(t,r,3),ct(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Ut(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),ve(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),pt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Xt(n){var t=-1,r=n?n.length:0,e=sr(typeof r=="number"?r:0);return ct(n,function(n){var r=dt(0,++t);e[t]=e[r],e[r]=n}),e}function Gt(n,t,r){var e;if(t=u.createCallback(t,r,3),ve(n)){r=-1;for(var o=n.length;++rarguments.length)return jt(n,b,null,t); -if(n)var r=n[O]?n[O][2]:n.length,e=Nt(arguments,2),r=r-e.length;return jt(n,b|x,r,t,e)}function Jt(n,t,r){var e,u,o,a,i,l,f,c=0,p=false,s=true;if(!tr(n))throw new wr;if(t=Hr(0,t)||0,true===r)var g=true,s=false;else rr(r)&&(g=r.leading,p="maxWait"in r&&(Hr(t,r.maxWait)||0),s="trailing"in r?r.trailing:s);var h=function(){var r=t-(we()-a);0>=r||r>t?(u&&Nr(u),r=f,u=l=f=d,r&&(c=we(),o=n.apply(i,e),l||u||(e=i=null))):l=Br(h,r)},v=function(){l&&Nr(l),u=l=f=d,(s||p!==t)&&(c=we(),o=n.apply(i,e),l||u||(e=i=null))};return function(){if(e=arguments,a=we(),i=this,f=s&&(l||!g),false===p)var r=g&&!l; -else{u||g||(c=a);var y=p-(a-c),m=0>=y||y>p;m?(u&&(u=Nr(u)),c=a,o=n.apply(i,e)):u||(u=Br(v,y))}return m&&l?l=Nr(l):l||t===p||(l=Br(h,t)),r&&(m=true,o=n.apply(i,e)),!m||l||u||(e=i=null),o}}function Qt(n,t,r){var e=arguments,u=0,o=e.length,a=typeof r;if("number"!=a&&"string"!=a||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},u.assign=Qt,u.at=function(n,t){var r=arguments,e=-1,u=gt(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),oe.unindexedChars&&ur(n)&&(n=n.split("")),r=sr(o);++earguments.length?jt(t,b|_,null,n):jt(t,b|_|x,null,n,Nt(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(g?r(g,f):a(l,f))){for(e=u,(g||l).push(f);--e;)if(g=o[e],0>(g?r(g,f):a(n[e],f)))continue n;s.push(f)}}return s},u.invert=function(n,t){for(var r=-1,e=me(n),u=e.length,o={};++rarguments.length&&ve(n))for(;++rr?Hr(0,e+r):Jr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=fr,u.noConflict=function(){return n._=Er,this -},u.noop=cr,u.now=we,u.parseInt=je,u.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=Zr(),Jr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):dt(n,t)},u.reduce=Ut,u.reduceRight=Vt,u.result=function(n,t,r){var e=null==n?d:n[t];return typeof e=="undefined"?r:tr(e)?n[t]():e},u.runInContext=m,u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:me(n).length -},u.some=Gt,u.sortedIndex=Rt,u.template=function(n,t,r){var e=u.templateSettings;n=_r(n||""),r=Yt({},r,e);var o,a,i=Yt({},r.imports,e.imports),e=me(i),i=or(i),l=0,c=r.interpolate||D,p="__p+='",c=br((r.escape||D).source+"|"+c.source+"|"+(c===q?F:D).source+"|"+(r.evaluate||D).source+"|$","g");n.replace(c,function(t,r,e,u,i,c){return e||(e=u),p+=n.slice(l,c).replace(z,f),r&&(o=true,p+="'+__e("+r+")+'"),i&&(a=true,p+="';"+i+";\n__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l=c+t.length,t}),p+="';",(r=r.variable)||(p="with(obj){"+p+"}"),p=(a?p.replace(S,""):p).replace(A,"$1").replace(I,"$1;"),p="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(a?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; -try{var s=vr(e,"return "+p).apply(d,i)}catch(g){throw g.source=p,g}return t?s(t):(s.source=p,s)},u.trim=de,u.trimLeft=be,u.trimRight=_e,u.unescape=function(n){return null==n?"":(n=_r(n),0>n.indexOf(";")?n:n.replace(N,y))},u.uniqueId=function(n){var t=++E;return _r(null==n?"":n)+t},u.all=Lt,u.any=Gt,u.detect=Dt,u.findWhere=Dt,u.foldl=Ut,u.foldr=Vt,u.include=$t,u.inject=Ut,fr(function(){var n={};return ht(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=St,u.last=function(n,t,r){var e=n?n.length:0; -if(typeof t!="number"&&null!=t){var o=e,a=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)a++}else if(a=t,null==a||r)return n?n[e-1]:d;return a=e-a,Nt(n,0"']/g,T=/<%-([\s\S]+?)%>/g,P=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,F=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,$=/\w*$/,L=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,D=/($^)/,W=/\bthis\b/,z=/['\n\r\t\u2028\u2029\\]/g,K=" \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",M="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),U="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),V="[object Arguments]",X="[object Array]",G="[object Boolean]",H="[object Date]",J="[object Error]",Q="[object Function]",Y="[object Number]",Z="[object Object]",nt="[object RegExp]",tt="[object String]",rt={}; -rt[Q]=false,rt[V]=rt[X]=rt[G]=rt[H]=rt[Y]=rt[Z]=rt[nt]=rt[tt]=true;var et={leading:false,maxWait:0,trailing:false},ut={configurable:false,enumerable:false,value:null,writable:false},ot={"&":"&","<":"<",">":">",'"':""","'":"'"},at={"&":"&","<":"<",">":">",""":'"',"'":"'"},it={"function":true,object:true},lt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},ft=it[typeof window]&&window||this,ct=it[typeof exports]&&exports&&!exports.nodeType&&exports,it=it[typeof module]&&module&&!module.nodeType&&module,pt=ct&&it&&typeof global=="object"&&global; -!pt||pt.global!==pt&&pt.window!==pt&&pt.self!==pt||(ft=pt);var pt=it&&it.exports===ct&&ct,st=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ft._=st, define(function(){return st})):ct&&it?pt?(it.exports=st)._=st:ct._=st:ft._=st}).call(this); \ No newline at end of file +if(i)return i}return t.g-r.g}function l(n){return function(t){for(var r=-1,e=(t=null!=t&&(t+"").replace(z,f).match(X))?t.length:0,u="";++re||13e||8202r||13r||8202a(e,l)&&f.push(l);return f}function st(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number")for(se.unindexedChars&&lr(e)&&(e=e.split(""));++ri(s,g)&&((u||f)&&s.push(g),c.push(p))}return c}function xt(n,t,r){for(var e=t.length,u=-1,o=te(r.length-e,0),a=-1,i=n.length,l=dr(o+i);++ar&&(r=0),s&&(a=[]),p&&(i=[]),g=[n,t,r,e,u,o,a,i],t==w||t==(w|k)?f(g):X(g))}function Ot(n){n.d=H;var t=wr,r="return function("+n.a+"){",e="var r="+n.b+";if(!j(p)){return r}";se.nonEnumArgs&&(e+="var m=p.length;if(m&&i(p)){l=-1;while(++lu;u++)e+="l='"+n.d[u]+"';if((!(k&&n[l])&&g.call(p,l))",n.e||(e+="||(!n[l]&&p[l]!==q[l])"),e+="){"+n.c+"}";e+="}"}return t("e,f,g,i,j,q,o,u,v,w",r+(e+"return r;")+"}")(tt,Sr,Br,It,or,Ir,ce,at,Rr,Lr) +}function Et(){var n=(n=u.indexOf)===Nt?t:n;return n}function At(n){return typeof n=="function"&&Pr.test(Dr.call(n))}function St(n){var t,r;return!n||Lr.call(n)!=ut||!Br.call(n,"constructor")&&(t=n.constructor,ur(t)&&!(t instanceof t))||!se.argsClass&&It(n)||!se.nodeClass&&p(n)?false:se.ownLast?(he(n,function(n,t,e){return r=Br.call(e,t),false}),false!==r):(he(n,function(n,t){r=t}),typeof r=="undefined"||Br.call(n,r))}function It(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Lr.call(n)==J||false +}function Rt(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,a=0;for(t=u.createCallback(t,r,3);++ee?te(0,u+e):e||0;else if(e)return e=Pt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Tt(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,a=0;for(t=u.createCallback(t,r,3);++et?t=te(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=te(u+r,0):r>u&&(r=u),u=r-t||0,r=dr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!we(n)&&lr(n))return Gr?Gr.call(n,t,r):-1r?te(0,e+r):r)||0,-1a&&(a=l)}else t=null==t&&lr(n)?e:u.createCallback(t,r,3),st(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Yt(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),we(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),pt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Ht(n){var t=-1,r=n?n.length:0,e=dr(typeof r=="number"?r:0);return st(n,function(n){var r=_t(0,++t);e[t]=e[r],e[r]=n}),e}function Jt(n,t,r){var e;if(t=u.createCallback(t,r,3),we(n)){r=-1;for(var o=n.length;++rarguments.length)return kt(n,w,null,t); +if(n)var r=n[A]?n[A][2]:n.length,e=Lt(arguments,2),r=r-e.length;return kt(n,w|k,r,t,e)}function Zt(n,t,r){var e,u,o,a,i,l,f,c=0,s=false,p=true;if(!ur(n))throw new Er;if(t=0=r||r>t?(u&&qr(u),r=f,u=l=f=_,r&&(c=Ie(),o=n.apply(i,e),l||u||(e=i=null))):l=Mr(h,r)},v=function(){l&&qr(l),u=l=f=_,(p||s!==t)&&(c=Ie(),o=n.apply(i,e),l||u||(e=i=null))};return function(){if(e=arguments,a=Ie(),i=this,f=p&&(l||!g),false===s)var r=g&&!l; +else{u||g||(c=a);var y=s-(a-c),m=0>=y||y>s;m?(u&&(u=qr(u)),c=a,o=n.apply(i,e)):u||(u=Mr(v,y))}return m&&l?l=qr(l):l||t===s||(l=Mr(h,t)),r&&(m=true,o=n.apply(i,e)),!m||l||u||(e=i=null),o}}function nr(n,t,r){var e=arguments,u=0,o=e.length,a=typeof r;if("number"!=a&&"string"!=a||!e[3]||e[3][r]!==t||(o=2),3t||null==n)return r;for(n=Or(n);0--n?t.apply(this,arguments):void 0}},u.assign=nr,u.at=function(n,t){var r=arguments,e=-1,u=gt(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),se.unindexedChars&&lr(n)&&(n=n.split("")),r=dr(o);++earguments.length?kt(t,w|x,null,n):kt(t,w|x|k,null,n,Lt(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(g?r(g,f):a(l,f))){for(e=u,(g||l).push(f);--e;)if(g=o[e],0>(g?r(g,f):a(n[e],f)))continue n;p.push(f)}}return p},u.invert=function(n,t){for(var r=-1,e=Ce(n),u=e.length,o={};++rarguments.length&&we(n))for(;++rr?te(0,e+r):re(r,e-1))+1);e--;)if(n[e]===t)return e; +return-1},u.mixin=vr,u.noConflict=function(){return n._=Tr,this},u.noop=yr,u.now=Ie,u.pad=function(n,t,r){n=null==n?"":Or(n),t=+t||0;var e=n.length;return en.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(ir(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=kr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(l);)i=a.index; +r=r.slice(0,null==i?o:i)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(T,d))},u.uniqueId=function(n){var t=++S;return Or(null==n?"":n)+t},u.all=Bt,u.any=Jt,u.detect=Ut,u.findWhere=Ut,u.foldl=Yt,u.foldr=Gt,u.include=Wt,u.inject=Yt,vr(function(){var n={};return ht(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Rt,u.last=function(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,a=0; +for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)a++}else if(a=t,null==a||r)return n?n[e-1]:_;return a=e-a,Lt(n,0"']/g,P=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,W=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,z=/[\xC0-\xFF]/g,U=/($^)/,K=/[.*+?^${()|[\\]/g,M=/\bthis\b/,V=/['\n\r\t\u2028\u2029\\]/g,X=/[a-z0-9]+/g,Y=" \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",G="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),H="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),J="[object Arguments]",Q="[object Array]",Z="[object Boolean]",nt="[object Date]",tt="[object Error]",rt="[object Function]",et="[object Number]",ut="[object Object]",ot="[object RegExp]",at="[object String]",it={}; +it[rt]=false,it[J]=it[Q]=it[Z]=it[nt]=it[et]=it[ut]=it[ot]=it[at]=true;var lt={leading:false,maxWait:0,trailing:false},ft={configurable:false,enumerable:false,value:null,writable:false},ct={"&":"&","<":"<",">":">",'"':""","'":"'"},st={"&":"&","<":"<",">":">",""":'"',"'":"'"},pt={\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"AE",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss","\xd7":"","\xf7":""},gt={"function":true,object:true},ht={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},vt=gt[typeof window]&&window||this,yt=gt[typeof exports]&&exports&&!exports.nodeType&&exports,gt=gt[typeof module]&&module&&!module.nodeType&&module,mt=yt&>&&typeof global=="object"&&global; +!mt||mt.global!==mt&&mt.window!==mt&&mt.self!==mt||(vt=mt);var mt=gt&>.exports===yt&&yt,dt=b();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(vt._=dt, define(function(){return dt})):yt&>?mt?(gt.exports=dt)._=dt:yt._=dt:vt._=dt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 9daf206d9..26a6ec875 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -58,15 +58,28 @@ /** Used to detect hexadecimal string values */ var reHexPrefix = /^0[xX]/; + /** Used to match latin-1 supplement letters */ + var reLatin1 = /[\xC0-\xFF]/g; + /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; + /** + * Used to match RegExp special characters. + * See this [article on RegExp characters](http://www.regular-expressions.info/characters.html#special) + * for more details. + */ + var reRegExpChars =/[.*+?^${()|[\\]/g; + /** Used to detect functions containing a `this` reference */ var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; + /** Used to match words to create compound words */ + var reWords = /[a-z0-9]+/g; + /** Used to detect and test whitespace */ var whitespace = ( // whitespace @@ -108,7 +121,7 @@ cloneableClasses[numberClass] = cloneableClasses[objectClass] = cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; - /** Used as an internal `_.debounce` options object */ + /** Used as an internal `_.debounce` options object by `_.throttle` */ var debounceOptions = { 'leading': false, 'maxWait': 0, @@ -149,6 +162,31 @@ ''': "'" }; + /** + * Used to convert latin-1 supplement letters to basic latin (ASCII) letters. + * See [Wikipedia](http://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * for more details. + */ + var deburredLetters = { + '\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': ' ' + }; + /** Used to determine if values are of the language type Object */ var objectTypes = { 'function': true, @@ -332,15 +370,49 @@ return a.index - b.index; } + /** + * Creates a function that produces compound words out of the words in a + * given string. + * + * @private + * @param {Function} callback The function called to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + var index = -1, + words = string != null && String(string).replace(reLatin1, deburrLetter).match(reWords), + length = words ? words.length : 0, + result = ''; + + while (++index < length) { + result = callback(result, words[index], index, words); + } + return result; + }; + } + + /** + * Used by `createCompounder` to convert latin-1 supplement letters to basic + * latin (ASCII) letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + function deburrLetter(letter) { + return deburredLetters[letter]; + } + /** * Used by `escape` to convert characters to HTML entities. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; } /** @@ -348,11 +420,11 @@ * string literals. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeStringChar(match) { - return '\\' + stringEscapes[match]; + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; } /** @@ -462,11 +534,11 @@ * Used by `unescape` to convert HTML entities to characters. * * @private - * @param {string} match The matched character to unescape. + * @param {string} chr The matched character to unescape. * @returns {string} Returns the unescaped character. */ - function unescapeHtmlChar(match) { - return htmlUnescapes[match]; + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; } /*--------------------------------------------------------------------------*/ @@ -515,9 +587,8 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + escapeRegExp(toString) + .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Native method shortcuts */ @@ -585,7 +656,7 @@ * implicitly or explicitly included in the build. * * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `after`, `assign`, `at`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, * `compose`, `concat`, `constant`, `countBy`, `create`, `createCallback`, * `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, * `flatten`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, @@ -1591,7 +1662,7 @@ /** * Creates a function that aggregates a collection, creating an object or * array composed from the results of running each element of the collection - * through a callback. The given `setter` function sets the keys and values + * through a callback. The given setter function sets the keys and values * of the composed object or array. * * @private @@ -1640,6 +1711,29 @@ return cache; }; + /** + * Creates the pad required for `string` based on the given padding length. + * The `chars` string may be truncated if the number of padding characters + * exceeds the padding length. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ + function createPad(string, length, chars) { + var strLength = string.length; + length = +length || 0; + + if (strLength >= length) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : String(chars); + return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); + } + /** * Creates a function that, when called, either curries or invokes `func` * with an optional `this` binding and partially applied arguments. @@ -1782,10 +1876,10 @@ }; /** - * A fallback implementation of `isPlainObject` which checks if a given value - * is an object created by the `Object` constructor, assuming objects created - * by the `Object` constructor have no inherited enumerable properties and that - * there are no `Object.prototype` extensions. + * A fallback implementation of `isPlainObject` which checks if `value` is + * an object created by the `Object` constructor, assuming objects created + * by the `Object` constructor have no inherited enumerable properties and + * that there are no `Object.prototype` extensions. * * @private * @param {*} value The value to check. @@ -2125,9 +2219,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -2805,9 +2899,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -2875,7 +2969,8 @@ /** * Creates an array that is the symmetric difference of the provided arrays. - * See [Wikipedia](http://en.wikipedia.org/wiki/Symmetric_difference) for more details. + * See [Wikipedia](http://en.wikipedia.org/wiki/Symmetric_difference) for + * more details. * * @static * @memberOf _ @@ -3145,10 +3240,10 @@ * @memberOf _ * @alias include * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {*} target The value to check for. * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if the `target` element is found, else `false`. + * @returns {boolean} Returns `true` if the target element is found, else `false`. * @example * * _.contains([1, 2, 3], 1); @@ -3372,7 +3467,7 @@ * @memberOf _ * @alias detect, findWhere * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [callback=identity] The function called * per iteration. If a property name or object is provided it will be used * to create a "_.pluck" or "_.where" style callback, respectively. @@ -3431,7 +3526,7 @@ * @static * @memberOf _ * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [callback=identity] The function called * per iteration. If a property name or object is provided it will be used * to create a "_.pluck" or "_.where" style callback, respectively. @@ -3737,9 +3832,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. * @example @@ -3812,9 +3907,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. * @example @@ -4101,7 +4196,8 @@ /** * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) for more details. + * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) + * for more details. * * @static * @memberOf _ @@ -4236,9 +4332,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Array|Function|Object|string} [callback=identity] The function + * called per iteration. If a property name or object is provided it will + * be used to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -4638,7 +4734,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait) || 0; + wait = wait > 0 ? wait : 0; if (options === true) { var leading = true; trailing = false; @@ -4973,11 +5069,11 @@ if (options === false) { leading = false; } else if (isObject(options)) { - leading = 'leading' in options ? options.leading : leading; - trailing = 'trailing' in options ? options.trailing : trailing; + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; } debounceOptions.leading = leading; - debounceOptions.maxWait = wait; + debounceOptions.maxWait = +wait; debounceOptions.trailing = trailing; return debounce(func, wait, debounceOptions); @@ -5277,9 +5373,9 @@ * @memberOf _ * @category Objects * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {string|undefined} Returns the key of the found element, else `undefined`. * @example @@ -5331,9 +5427,9 @@ * @memberOf _ * @category Objects * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {string|undefined} Returns the key of the found element, else `undefined`. * @example @@ -6022,7 +6118,7 @@ } /** - * Creates an array composed of the own enumerable property names of an object. + * Creates an array composed of the own enumerable property names of `object`. * * @static * @memberOf _ @@ -6229,7 +6325,7 @@ } /** - * Creates a two dimensional array of an object's key-value pairs, + * Creates a two dimensional array of a given object's key-value pairs, * i.e. `[[key1, value1], [key2, value2]]`. * * @static @@ -6387,12 +6483,36 @@ /*--------------------------------------------------------------------------*/ /** - * Converts the first character of `string` to upper case. + * Converts `string` to camel case. + * See [Wikipedia](http://en.wikipedia.org/wiki/CamelCase) for more details. * * @static * @memberOf _ * @category Strings - * @param {string} string The string to capitalize. + * @param {string} [string=''] The string to camel case. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Hello world'); + * // => 'helloWorld' + * + * _.camelCase('hello-world'); + * // => 'helloWorld' + * + * _.camelCase('hello_world'); + * // => 'helloWorld' + */ + var camelCase = createCompounder(function(result, words, index) { + return result + words.charAt(0)[index ? 'toUpperCase' : 'toLowerCase']() + words.slice(1); + }); + + /** + * Capitalizes the first character of `string`. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to capitalize. * @returns {string} Returns the capitalized string. * @example * @@ -6407,6 +6527,37 @@ return string.charAt(0).toUpperCase() + string.slice(1); } + /** + * Checks if `string` ends with a given target string. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search from. + * @returns {boolean} Returns `true` if the given string ends with the + * target string, else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = string == null ? '' : String(string); + target = String(target); + + var length = string.length; + position = (typeof position == 'number' ? nativeMin(nativeMax(position, 0), length) : length) - target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + /** * Converts the characters "&", "<", ">", '"', and "'" in `string` to * their corresponding HTML entities. @@ -6421,7 +6572,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to escape. + * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. * @example * @@ -6432,6 +6583,234 @@ return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } + /** + * Escapes the RegExp special characters "\", "^", "$", ".", "|", "?", "*", + * "+", "(", ")", "[", and "{" in `string`. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](http://lodash.com)'); + * // => '\[lodash]\(http://lodash\.com\)' + */ + function escapeRegExp(string) { + return string == null ? '' : String(string).replace(reRegExpChars, '\\$&'); + } + + /** + * Converts `string` to kebab case (a.k.a. spinal case). + * See [Wikipedia](http://en.wikipedia.org/wiki/Letter_case#Computers) for + * more details. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to kebab case. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Hello world'); + * // => 'hello-world' + * + * _.kebabCase('helloWorld'); + * // => 'hello-world' + * + * _.kebabCase('hello_world'); + * // => 'hello-world' + */ + var kebabCase = createCompounder(function(result, words, index) { + return result + (index ? '-' : '') + words.toLowerCase(); + }); + + /** + * Pads `string` on the left and right sides if it is shorter then the given + * padding length. The `chars` string may be truncated if the number of padding + * characters can't be evenly divided by the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = string == null ? '' : String(string); + length = +length || 0; + + var strLength = string.length; + if (strLength >= length) { + return string; + } + var mid = (length - strLength) / 2, + leftLength = floor(mid), + rightLength = ceil(mid); + + chars = createPad('', rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + + /** + * Pads `string` on the left side if it is shorter then the given padding + * length. The `chars` string may be truncated if the number of padding + * characters exceeds the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padLeft('abc', 6); + * // => ' abc' + * + * _.padLeft('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padLeft('abc', 3); + * // => 'abc' + */ + function padLeft(string, length, chars) { + string = string == null ? '' : String(string); + return createPad(string, length, chars) + string; + } + + /** + * Pads `string` on the right side if it is shorter then the given padding + * length. The `chars` string may be truncated if the number of padding + * characters exceeds the padding length. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padRight('abc', 6); + * // => 'abc ' + * + * _.padRight('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padRight('abc', 3); + * // => 'abc' + */ + function padRight(string, length, chars) { + string = string == null ? '' : String(string); + return string + createPad(string, length, chars); + } + + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n) { + var result = ''; + n = +n || 0; + + if (n < 1 || string == null) { + return result; + } + string = String(string); + while (n > 0) { + if (n % 2) { + result += string; + } + n = floor(n / 2); + result += result; + } + return result; + } + + /** + * Converts `string` to snake case. + * See [Wikipedia](http://en.wikipedia.org/wiki/Snake_case) for more details. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to snake case. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Hello world'); + * // => 'hello_world' + * + * _.snakeCase('hello-world'); + * // => 'hello_world' + * + * _.snakeCase('helloWorld'); + * // => 'hello_world' + */ + var snakeCase = createCompounder(function(result, words, index) { + return result + (index ? '_' : '') + words.toLowerCase(); + }); + + /** + * Checks if `string` starts with a given target string. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if the given string starts with the + * target string, else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = string == null ? '' : String(string); + position = typeof position == 'number' ? nativeMin(nativeMax(position, 0), string.length) : 0; + return string.lastIndexOf(target, position) == position; + } + /** * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in @@ -6441,8 +6820,8 @@ * settings object is provided it will override `_.templateSettings` for the * template. * - * Note: In the development build, `_.template` utilizes sourceURLs for easier - * debugging. See [HTML5 Rocks' article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. + * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * * For more information on precompiling templates see @@ -6454,8 +6833,8 @@ * @static * @memberOf _ * @category Strings - * @param {string} text The template text. - * @param {Object} [data] The data object used to populate the text. + * @param {string} [string=''] The template string. + * @param {Object} [data] The data object used to populate the template string. * @param {Object} [options] The options object. * @param {RegExp} [options.escape] The HTML "escape" delimiter. * @param {RegExp} [options.evaluate] The "evaluate" delimiter. @@ -6521,13 +6900,13 @@ * };\ * '); */ - function template(text, data, options) { + function template(string, data, options) { // based on John Resig's `tmpl` implementation // http://ejohn.org/blog/javascript-micro-templating/ // and Laura Doktorova's doT.js // https://github.com/olado/doT var settings = lodash.templateSettings; - text = String(text || ''); + string = String(string == null ? '' : string); // avoid missing dependencies when `iteratorTemplate` is not defined options = defaults({}, options, settings); @@ -6550,11 +6929,11 @@ (options.evaluate || reNoMatch).source + '|$' , 'g'); - text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); // escape characters that cannot be included in string literals - source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar); + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); // replace delimiters with snippets if (escapeValue) { @@ -6633,7 +7012,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6657,7 +7036,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6681,7 +7060,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to trim. + * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. * @returns {string} Returns the trimmed string. * @example @@ -6699,6 +7078,85 @@ return chars == null ? nativeTrimRight.call(string) : shimTrimRight(string, chars); }; + /** + * Truncates `string` if it is longer than the given maximum string length. + * The last characters of the truncated string will be replaced with the + * omission string which defaults to "...". + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to trim. + * @param {Object|number} [options] The options object or maximum string length. + * @param {number} [options.length=30] The maximum string length. + * @param {string} [options.omission='...'] The string used to indicate text is omitted. + * @param {RegExp|string} [options.separator] The separator pattern to truncate to. + * @returns {string} Returns the truncated string. + * @example + * + * _.truncate('hi-diddly-ho there, neighborino'); + * // => 'hi-diddly-ho there, neighbo...' + * + * _.truncate('hi-diddly-ho there, neighborino', 24); + * // => 'hi-diddly-ho there, n...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * // => 'hi-diddly-ho there,...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * //=> 'hi-diddly-ho there...' + * + * _.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * // => 'hi-diddly-ho there, neig [...]' + */ + function truncate(string, options) { + var length = 30, + omission = '...'; + + if (options && isObject(options)) { + var separator = 'separator' in options ? options.separator : separator; + length = 'length' in options ? +options.length || 0 : length; + omission = 'omission' in options ? String(options.omission) : omission; + } + else if (options != null) { + length = +options || 0; + } + string = string == null ? '' : String(string); + if (length > string.length) { + return string; + } + var end = length - omission.length; + if (end < 1) { + return omission; + } + var result = string.slice(0, end); + if (separator == null) { + return result + omission; + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, + newEnd, + substring = string.slice(0, end); + + if (!separator.global) { + separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g'); + } + separator.lastIndex = 0; + while ((match = separator.exec(substring))) { + newEnd = match.index; + } + result = result.slice(0, newEnd == null ? end : newEnd); + } + } else if (string.indexOf(separator, end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } + } + return result + omission; + } + /** * The inverse of `_.escape`; this method converts the HTML entities * `&`, `<`, `>`, `"`, and `'` in `string` to their @@ -6710,7 +7168,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to unescape. + * @param {string} [string=''] The string to unescape. * @returns {string} Returns the unescaped string. * @example * @@ -7162,7 +7620,7 @@ * @memberOf _ * @category Utilities * @param {number} n The number of times to execute the callback. - * @param {Function} callback The function called per iteration. + * @param {Function} [callback=identity] The function called per iteration. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns an array of the results of each `callback` execution. * @example @@ -7306,11 +7764,14 @@ /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining + lodash.camelCase = camelCase; lodash.capitalize = capitalize; lodash.clone = clone; lodash.cloneDeep = cloneDeep; lodash.contains = contains; + lodash.endsWith = endsWith; lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; lodash.every = every; lodash.find = find; lodash.findIndex = findIndex; @@ -7338,24 +7799,32 @@ lodash.isRegExp = isRegExp; lodash.isString = isString; lodash.isUndefined = isUndefined; + lodash.kebabCase = kebabCase; lodash.lastIndexOf = lastIndexOf; lodash.mixin = mixin; lodash.noConflict = noConflict; lodash.noop = noop; lodash.now = now; + lodash.pad = pad; + lodash.padLeft = padLeft; + lodash.padRight = padRight; lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; + lodash.repeat = repeat; lodash.result = result; lodash.runInContext = runInContext; lodash.size = size; lodash.some = some; lodash.sortedIndex = sortedIndex; + lodash.snakeCase = snakeCase; + lodash.startsWith = startsWith; lodash.template = template; lodash.trim = trim; lodash.trimLeft = trimLeft; lodash.trimRight = trimRight; + lodash.truncate = truncate; lodash.unescape = unescape; lodash.uniqueId = uniqueId; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 4d18d99c4..4f79fa80d 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,60 +3,62 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202i(e,a)&&l.push(a);return l}function ct(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(;++rf(p,g)&&((u||l)&&p.push(g),c.push(s))}return c}function dt(n,t,r){for(var e=t.length,u=-1,o=Ur(r.length-e,0),i=-1,f=n.length,a=cr(o+f);++ir&&(r=0),c&&(i=[]),p&&(f=[]),s=[n,t,r,e,u,o,i,f],t==b||t==(b|j)?rt(s):ft(s))}function jt(){var n=(n=g.indexOf)===At?t:n;return n}function kt(n){return typeof n=="function"&&Or.test(Nr.call(n)) -}function xt(n){var t,r;return n&&Cr.call(n)==J&&(Ir.call(n,"constructor")||(t=n.constructor,!Zt(t)||t instanceof t))?(o(n,function(n,t){r=t}),typeof r=="undefined"||Ir.call(n,r)):false}function Ct(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Cr.call(n)==M||false}function Ot(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=g.createCallback(t,r,3);++ee?Ur(0,u+e):e||0;else if(e)return e=Nt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function St(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=g.createCallback(t,r,3);++et?t=Ur(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Ur(u+r,0):r>u&&(r=u),u=r-t||0,r=cr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!le(n)&&rr(n))return Wr?Wr.call(n,t,r):-1r?Ur(0,e+r):r)||0,-1o&&(o=f)}else t=null==t&&rr(n)?e:g.createCallback(t,r,3),ct(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function Kt(n,t,r,e){var u=3>arguments.length;t=g.createCallback(t,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number")for(u&&i&&(r=n[++o]);++oarguments.length;return t=g.createCallback(t,e,4),pt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Ut(n){var t=-1,r=n?n.length:0,e=cr(typeof r=="number"?r:0); -return ct(n,function(n){var r=mt(0,++t);e[t]=e[r],e[r]=n}),e}function Vt(n,t,r){var e;t=g.createCallback(t,r,3),r=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++rarguments.length)return wt(n,b,null,t);if(n)var r=n[C]?n[C][2]:n.length,e=Et(arguments,2),r=r-e.length;return wt(n,b|j,r,t,e)}function Gt(n,t,r){function e(){c&&Sr(c),i=c=p=m,(h||g!==t)&&(s=ve(),f=n.apply(l,o),c||i||(o=l=null)) -}function u(){var r=t-(ve()-a);0>=r||r>t?(i&&Sr(i),r=p,i=c=p=m,r&&(s=ve(),f=n.apply(l,o),c||i||(o=l=null))):c=$r(u,r)}var o,i,f,a,l,c,p,s=0,g=false,h=true;if(!Zt(n))throw new dr;if(t=Ur(0,t)||0,true===r)var v=true,h=false;else nr(r)&&(v=r.leading,g="maxWait"in r&&(Ur(t,r.maxWait)||0),h="trailing"in r?r.trailing:h);return function(){if(o=arguments,a=ve(),l=this,p=h&&(c||!v),false===g)var r=v&&!c;else{i||v||(s=a);var y=g-(a-s),m=0>=y||y>g;m?(i&&(i=Sr(i)),s=a,f=n.apply(l,o)):i||(i=$r(e,y))}return m&&c?c=Sr(c):c||t===g||(c=$r(u,t)),r&&(m=true,f=n.apply(l,o)),!m||c||i||(o=l=null),f -}}function Ht(n,t,r){var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},g.assign=Ht,g.at=function(n,t){var r=arguments,e=-1,u=st(r,true,false,1),o=u.length,i=typeof t;for("number"!=i&&"string"!=i||!r[2]||r[2][t]!==n||(o=1),r=cr(o);++earguments.length?wt(t,b|d,null,n):wt(t,b|d|j,null,n,Et(arguments,2))},g.chain=function(n){return n=new h(n),n.__chain__=true,n},g.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(g?r(g,l):i(a,l))){for(e=u,(g||a).push(l);--e;)if(g=o[e],0>(g?r(g,l):i(n[e],l)))continue n;s.push(l)}}return s},g.invert=function(n,t){for(var r=-1,e=pe(n),u=e.length,o={};++rarguments.length&&typeof u=="number")for(;++rr?Ur(0,e+r):Vr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},g.mixin=fr,g.noConflict=function(){return n._=xr,this},g.noop=ar,g.now=ve,g.parseInt=ye,g.random=function(n,t,r){var e=null==n,u=null==t; -return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=Hr(),Vr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):mt(n,t)},g.reduce=Kt,g.reduceRight=Mt,g.result=function(n,t,r){var e=null==n?m:n[t];return typeof e=="undefined"?r:Zt(e)?n[t]():e},g.runInContext=y,g.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pe(n).length},g.some=Vt,g.sortedIndex=Nt,g.template=function(n,t,r){var e=g.templateSettings; -n=br(n||""),r=Jt({},r,e);var u,o,i=Jt({},r.imports,e.imports),e=pe(i),i=er(i),f=0,a=r.interpolate||W,c="__p+='",a=mr((r.escape||W).source+"|"+a.source+"|"+(a===F?$:W).source+"|"+(r.evaluate||W).source+"|$","g");n.replace(a,function(t,r,e,i,a,p){return e||(e=i),c+=n.slice(f,p).replace(L,l),r&&(u=true,c+="'+__e("+r+")+'"),a&&(o=true,c+="';"+a+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),f=p+t.length,t}),c+="';",(r=r.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(A,""):c).replace(S,"$1").replace(E,"$1;"),c="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}"; -try{var p=gr(e,"return "+c).apply(m,i)}catch(s){throw s.source=c,s}return t?p(t):(p.source=c,p)},g.trim=se,g.trimLeft=ge,g.trimRight=he,g.unescape=function(n){return null==n?"":(n=br(n),0>n.indexOf(";")?n:n.replace(N,v))},g.uniqueId=function(n){var t=++O;return br(null==n?"":n)+t},g.all=Bt,g.any=Vt,g.detect=qt,g.findWhere=qt,g.foldl=Kt,g.foldr=Mt,g.include=$t,g.inject=Kt,fr(function(){var n={};return gt(g,function(t,r){g.prototype[r]||(n[r]=t)}),n}(),false),g.first=Ot,g.last=function(n,t,r){var e=n?n.length:0; -if(typeof t!="number"&&null!=t){var u=e,o=0;for(t=g.createCallback(t,r,3);u--&&t(n[u],u,n);)o++}else if(o=t,null==o||r)return n?n[e-1]:m;return o=e-o,Et(n,0"']/g,I=/<%-([\s\S]+?)%>/g,T=/<%([\s\S]+?)%>/g,F=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,B=/\w*$/,D=/^\s*function[ \n\r\t]+\w/,q=/^0[xX]/,W=/($^)/,z=/\bthis\b/,L=/['\n\r\t\u2028\u2029\\]/g,P=" \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",K="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),M="[object Arguments]",U="[object Array]",V="[object Boolean]",X="[object Date]",G="[object Function]",H="[object Number]",J="[object Object]",Q="[object RegExp]",Y="[object String]",Z={}; -Z[G]=false,Z[M]=Z[U]=Z[V]=Z[X]=Z[H]=Z[J]=Z[Q]=Z[Y]=true;var nt={leading:false,maxWait:0,trailing:false},tt={configurable:false,enumerable:false,value:null,writable:false},rt={"&":"&","<":"<",">":">",'"':""","'":"'"},et={"&":"&","<":"<",">":">",""":'"',"'":"'"},ut={"function":true,object:true},ot={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},it=ut[typeof window]&&window||this,ft=ut[typeof exports]&&exports&&!exports.nodeType&&exports,ut=ut[typeof module]&&module&&!module.nodeType&&module,at=ft&&ut&&typeof global=="object"&&global; -!at||at.global!==at&&at.window!==at&&at.self!==at||(it=at);var at=ut&&ut.exports===ft&&ft,lt=y();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(it._=lt, define(function(){return lt})):ft&&ut?at?(ut.exports=lt)._=lt:ft._=lt:it._=lt}).call(this); \ No newline at end of file +;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202i(e,f)&&l.push(f);return l}function ct(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(;++ra(p,h)&&((u||l)&&p.push(h),c.push(s))}return c}function wt(n,t,r){for(var e=t.length,u=-1,o=Jr(r.length-e,0),i=-1,a=n.length,f=yr(o+a);++ir&&(r=0),c&&(i=[]),p&&(a=[]),s=[n,t,r,e,u,o,i,a],t==_||t==(_|k)?y(s):ft(s)) +}function Ct(){var n=(n=l.indexOf)===Rt?t:n;return n}function Ot(n){return typeof n=="function"&&Sr.test(Dr.call(n))}function At(n){var t,r;return n&&Nr.call(n)==tt&&(Wr.call(n,"constructor")||(t=n.constructor,!rr(t)||t instanceof t))?(o(n,function(n,t){r=t}),typeof r=="undefined"||Wr.call(n,r)):false}function Et(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n)==G||false}function It(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=l.createCallback(t,r,3);++ee?Jr(0,u+e):e||0;else if(e)return e=Tt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Nt(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=l.createCallback(t,r,3);++et?t=Jr(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Jr(u+r,0):r>u&&(r=u),u=r-t||0,r=yr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!ve(n)&&ir(n))return Mr?Mr.call(n,t,r):-1r?Jr(0,e+r):r)||0,-1o&&(o=a)}else t=null==t&&ir(n)?e:l.createCallback(t,r,3),ct(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function Vt(n,t,r,e){var u=3>arguments.length;t=l.createCallback(t,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number")for(u&&i&&(r=n[++o]);++oarguments.length;return t=l.createCallback(t,e,4),pt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Yt(n){var t=-1,r=n?n.length:0,e=yr(typeof r=="number"?r:0);return ct(n,function(n){var r=bt(0,++t);e[t]=e[r],e[r]=n}),e}function Gt(n,t,r){var e;t=l.createCallback(t,r,3),r=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++rarguments.length)return kt(n,_,null,t); +if(n)var r=n[A]?n[A][2]:n.length,e=St(arguments,2),r=r-e.length;return kt(n,_|k,r,t,e)}function Jt(n,t,r){function e(){c&&Fr(c),i=c=p=b,(g||h!==t)&&(s=ke(),a=n.apply(l,o),c||i||(o=l=null))}function u(){var r=t-(ke()-f);0>=r||r>t?(i&&Fr(i),r=p,i=c=p=b,r&&(s=ke(),a=n.apply(l,o),c||i||(o=l=null))):c=zr(u,r)}var o,i,a,f,l,c,p,s=0,h=false,g=true;if(!rr(n))throw new Cr;if(t=0=y||y>h;m?(i&&(i=Fr(i)),s=f,a=n.apply(l,o)):i||(i=zr(e,y))}return m&&c?c=Fr(c):c||t===h||(c=zr(u,t)),r&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Qt(n,t,r){var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3t||null==n)return r;for(n=kr(n);0--n?t.apply(this,arguments):void 0 +}},l.assign=Qt,l.at=function(n,t){var r=arguments,e=-1,u=ht(r,true,false,1),o=u.length,i=typeof t;for("number"!=i&&"string"!=i||!r[2]||r[2][t]!==n||(o=1),r=yr(o);++earguments.length?kt(t,_|w,null,n):kt(t,_|w|k,null,n,St(arguments,2))},l.chain=function(n){return n=new v(n),n.__chain__=true,n +},l.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(h?r(h,l):i(f,l))){for(e=u,(h||f).push(l);--e;)if(h=o[e],0>(h?r(h,l):i(n[e],l)))continue n;s.push(l) +}}return s},l.invert=function(n,t){for(var r=-1,e=me(n),u=e.length,o={};++rarguments.length&&typeof u=="number")for(;++rr?Jr(0,e+r):Qr(r,e-1))+1);e--;)if(n[e]===t)return e; +return-1},l.mixin=hr,l.noConflict=function(){return n._=Rr,this},l.noop=gr,l.now=ke,l.pad=function(n,t,r){n=null==n?"":kr(n),t=+t||0;var e=n.length;return en.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(or(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=jr(u.source,(W.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index; +r=r.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(S,m))},l.uniqueId=function(n){var t=++E;return kr(null==n?"":n)+t},l.all=Bt,l.any=Gt,l.detect=zt,l.findWhere=zt,l.foldl=Vt,l.foldr=Xt,l.include=Wt,l.inject=Vt,hr(function(){var n={};return gt(l,function(t,r){l.prototype[r]||(n[r]=t)}),n}(),false),l.first=It,l.last=function(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var u=e,o=0; +for(t=l.createCallback(t,r,3);u--&&t(n[u],u,n);)o++}else if(o=t,null==o||r)return n?n[e-1]:b;return o=e-o,St(n,0"']/g,F=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,D=/<%=([\s\S]+?)%>/g,L=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,W=/\w*$/,B=/^\s*function[ \n\r\t]+\w/,q=/^0[xX]/,z=/[\xC0-\xFF]/g,U=/($^)/,P=/[.*+?^${()|[\\]/g,K=/\bthis\b/,M=/['\n\r\t\u2028\u2029\\]/g,V=/[a-z0-9]+/g,X=" \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",Y="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),G="[object Arguments]",H="[object Array]",J="[object Boolean]",Q="[object Date]",Z="[object Function]",nt="[object Number]",tt="[object Object]",rt="[object RegExp]",et="[object String]",ut={}; +ut[Z]=false,ut[G]=ut[H]=ut[J]=ut[Q]=ut[nt]=ut[tt]=ut[rt]=ut[et]=true;var ot={leading:false,maxWait:0,trailing:false},it={configurable:false,enumerable:false,value:null,writable:false},at={"&":"&","<":"<",">":">",'"':""","'":"'"},ft={"&":"&","<":"<",">":">",""":'"',"'":"'"},lt={\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"AE",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss","\xd7":"","\xf7":""},ct={"function":true,object:true},pt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},st=ct[typeof window]&&window||this,ht=ct[typeof exports]&&exports&&!exports.nodeType&&exports,ct=ct[typeof module]&&module&&!module.nodeType&&module,gt=ht&&ct&&typeof global=="object"&&global; +!gt||gt.global!==gt&>.window!==gt&>.self!==gt||(st=gt);var gt=ct&&ct.exports===ht&&ht,vt=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(st._=vt, define(function(){return vt})):ht&&ct?gt?(ct.exports=vt)._=vt:ht._=vt:st._=vt}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 0f60e5a4f..befdc2996 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -44,6 +44,13 @@ /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; + /** + * Used to match RegExp special characters. + * See this [article on RegExp characters](http://www.regular-expressions.info/characters.html#special) + * for more details. + */ + var reRegExpChars =/[.*+?^${()|[\\]/g; + /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; @@ -180,11 +187,11 @@ * Used by `escape` to convert characters to HTML entities. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; } /** @@ -192,22 +199,22 @@ * string literals. * * @private - * @param {string} match The matched character to escape. + * @param {string} chr The matched character to escape. * @returns {string} Returns the escaped character. */ - function escapeStringChar(match) { - return '\\' + stringEscapes[match]; + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; } /** * Used by `unescape` to convert HTML entities to characters. * * @private - * @param {string} match The matched character to unescape. + * @param {string} chr The matched character to unescape. * @returns {string} Returns the unescaped character. */ - function unescapeHtmlChar(match) { - return htmlUnescapes[match]; + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; } /*--------------------------------------------------------------------------*/ @@ -224,9 +231,8 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + escapeRegExp(toString) + .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Native method shortcuts */ @@ -263,7 +269,7 @@ * implicitly or explicitly included in the build. * * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `after`, `assign`, `at`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, * `compose`, `concat`, `constant`, `countBy`, `create`, `createCallback`, * `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, * `flatten`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, @@ -889,7 +895,7 @@ /** * Creates a function that aggregates a collection, creating an object or * array composed from the results of running each element of the collection - * through a callback. The given `setter` function sets the keys and values + * through a callback. The given setter function sets the keys and values * of the composed object or array. * * @private @@ -966,7 +972,7 @@ } /** - * Finds the indexes of all placeholder elements in a given array. + * Finds the indexes of all placeholder elements in `array`. * * @private * @param {Array} array The array to inspect. @@ -1212,9 +1218,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -1754,9 +1760,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -2006,10 +2012,10 @@ * @memberOf _ * @alias include * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {*} target The value to check for. * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if the `target` element is found, else `false`. + * @returns {boolean} Returns `true` if the target element is found, else `false`. * @example * * _.contains([1, 2, 3], 1); @@ -2219,7 +2225,7 @@ * @memberOf _ * @alias detect, findWhere * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [callback=identity] The function called * per iteration. If a property name or object is provided it will be used * to create a "_.pluck" or "_.where" style callback, respectively. @@ -2512,9 +2518,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. * @example @@ -2585,9 +2591,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|string} [callback] The function called per iteration. + * If a property name or object is provided it will be used to create a "_.pluck" + * or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. * @example @@ -2872,7 +2878,8 @@ /** * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) for more details. + * shuffle. See [Wikipedia](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle) + * for more details. * * @static * @memberOf _ @@ -3007,9 +3014,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Array|Function|Object|string} [callback=identity] The function + * called per iteration. If a property name or object is provided it will + * be used to create a "_.pluck" or "_.where" style callback, respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -3318,7 +3325,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait) || 0; + wait = wait > 0 ? wait : 0; if (options === true) { var leading = true; trailing = false; @@ -4232,7 +4239,7 @@ } /** - * Creates an array composed of the own enumerable property names of an object. + * Creates an array composed of the own enumerable property names of `object`. * * @static * @memberOf _ @@ -4303,7 +4310,7 @@ } /** - * Creates a two dimensional array of an object's key-value pairs, + * Creates a two dimensional array of a given object's key-value pairs, * i.e. `[[key1, value1], [key2, value2]]`. * * @static @@ -4412,7 +4419,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to escape. + * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. * @example * @@ -4423,6 +4430,24 @@ return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } + /** + * Escapes the RegExp special characters "\", "^", "$", ".", "|", "?", "*", + * "+", "(", ")", "[", and "{" in `string`. + * + * @static + * @memberOf _ + * @category Strings + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](http://lodash.com)'); + * // => '\[lodash]\(http://lodash\.com\)' + */ + function escapeRegExp(string) { + return string == null ? '' : String(string).replace(reRegExpChars, '\\$&'); + } + /** * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in @@ -4432,8 +4457,8 @@ * settings object is provided it will override `_.templateSettings` for the * template. * - * Note: In the development build, `_.template` utilizes sourceURLs for easier - * debugging. See [HTML5 Rocks' article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. + * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * * For more information on precompiling templates see @@ -4445,8 +4470,8 @@ * @static * @memberOf _ * @category Strings - * @param {string} text The template text. - * @param {Object} [data] The data object used to populate the text. + * @param {string} [string=''] The template string. + * @param {Object} [data] The data object used to populate the template string. * @param {Object} [options] The options object. * @param {RegExp} [options.escape] The HTML "escape" delimiter. * @param {RegExp} [options.evaluate] The "evaluate" delimiter. @@ -4512,11 +4537,11 @@ * };\ * '); */ - function template(text, data, options) { + function template(string, data, options) { var _ = lodash, settings = _.templateSettings; - text = String(text || ''); + string = String(string == null ? '' : string); options = defaults({}, options, settings); var index = 0, @@ -4529,8 +4554,8 @@ (options.evaluate || reNoMatch).source + '|$' , 'g'); - text.replace(reDelimiters, function(match, escapeValue, interpolateValue, evaluateValue, offset) { - source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar); + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, evaluateValue, offset) { + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); if (escapeValue) { source += "' +\n_.escape(" + escapeValue + ") +\n'"; } @@ -4578,7 +4603,7 @@ * @static * @memberOf _ * @category Strings - * @param {string} string The string to unescape. + * @param {string} [string=''] The string to unescape. * @returns {string} Returns the unescaped string. * @example * @@ -4942,7 +4967,7 @@ * @memberOf _ * @category Utilities * @param {number} n The number of times to execute the callback. - * @param {Function} callback The function called per iteration. + * @param {Function} [callback=identity] The function called per iteration. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns an array of the results of each `callback` execution. * @example diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index aa8ed2220..8eed2b065 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,37 +3,37 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash underscore -o ./dist/lodash.underscore.js` */ -;(function(){function n(n){var r=[];if(!H(n))return r;for(var t in n)$r.call(n,t)&&r.push(t);return r}function r(n,r){if(H(n))for(var t in n)if(r(n[t],t,n)===ur)break}function t(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined"){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function g(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(;++to(f,c)&&(t&&f.push(c),i.push(a)) -}return i}function _(n,r){return function(t,e,u){var o=r?[[],[]]:{};e=Q(e,u,3),u=-1;var i=t?t.length:0;if(typeof i=="number")for(;++ue?Vr(0,u+e):e||0;else if(e)return e=O(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function T(n,r,t){return E(n,null==r||t?1:0r?r=Vr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Vr(u+t,0):t>u&&(t=u),u=t-r||0,t=Array(u);++ee||typeof t=="undefined"){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function g(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(;++to(f,c)&&(t&&f.push(c),i.push(a)) +}return i}function _(n,r){return function(t,e,u){var o=r?[[],[]]:{};e=Q(e,u,3),u=-1;var i=t?t.length:0;if(typeof i=="number")for(;++ue?Gr(0,u+e):e||0;else if(e)return e=O(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function T(n,r,t){return E(n,null==r||t?1:0r?r=Gr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Gr(u+t,0):t>u&&(t=u),u=t-r||0,t=Array(u);++e>>1,t(n[e])u&&(u=t);else r=Q(r,t,3),g(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function I(n,r,t,e){var u=3>arguments.length;r=Q(r,e,4);var o=-1,i=n?n.length:0; -if(typeof i=="number")for(u&&i&&(t=n[++o]);++oarguments.length;return r=Q(r,e,4),h(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function D(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return g(n,function(n){var t;t=++r,t=0+Br(Jr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=Q(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++targuments.length?b(n,tr,r):b(n,tr|er,r,E(arguments,2))}function C(n,r,t){function e(){l&&clearTimeout(l),i=l=p=rr,(h||g!==r)&&(s=et(),f=n.apply(c,o),l||i||(o=c=null))}function u(){var t=r-(et()-a);0>=t||t>r?(i&&clearTimeout(i),t=p,i=l=p=rr,t&&(s=et(),f=n.apply(c,o),l||i||(o=c=null))):l=setTimeout(u,t)}var o,i,f,a,c,l,p,s=0,g=false,h=true;if(!G(n))throw new TypeError;if(r=Vr(0,r)||0,true===t)var v=true,h=false;else H(t)&&(v=t.leading,g="maxWait"in t&&(Vr(r,t.maxWait)||0),h="trailing"in t?t.trailing:h); -return function(){if(o=arguments,a=et(),c=this,p=h&&(l||!v),false===g)var t=v&&!l;else{i||v||(s=a);var y=g-(a-s),m=0>=y||y>g;m?(i&&(i=clearTimeout(i)),s=a,f=n.apply(c,o)):i||(i=setTimeout(e,y))}return m&&l?l=clearTimeout(l):l||r===g||(l=setTimeout(u,r)),t&&(m=true,f=n.apply(c,o)),!m||l||i||(o=c=null),f}}function P(n,r,t){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof t;for("number"!=i&&"string"!=i||!e[3]||e[3][t]!==r||(o=2);++u"']/g,ar=/($^)/,cr=/['\n\r\t\u2028\u2029\\]/g,lr="[object Arguments]",pr="[object Array]",sr="[object Boolean]",gr="[object Date]",hr="[object Number]",vr="[object Object]",yr="[object RegExp]",mr="[object String]",_r={"&":"&","<":"<",">":">",'"':""","'":"'"},br={"&":"&","<":"<",">":">",""":'"',"'":"'"},dr={"function":true,object:true},wr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},jr=dr[typeof window]&&window||this,xr=dr[typeof exports]&&exports&&!exports.nodeType&&exports,Ar=dr[typeof module]&&module&&!module.nodeType&&module,Tr=xr&&Ar&&typeof global=="object"&&global; -!Tr||Tr.global!==Tr&&Tr.window!==Tr&&Tr.self!==Tr||(jr=Tr);var Er=Ar&&Ar.exports===xr&&xr,Or=Array.prototype,kr=Object.prototype,Sr=jr._,Nr=kr.toString,qr=RegExp("^"+(Nr+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fr=Math.ceil,Br=Math.floor,Rr=Function.prototype.toString,$r=kr.hasOwnProperty,Ir=Or.push,Mr=kr.propertyIsEnumerable,Dr=Or.splice,Wr=w(Wr=Object.create)&&Wr,zr=w(zr=Array.isArray)&&zr,Cr=jr.isFinite,Pr=jr.isNaN,Ur=w(Ur=Object.keys)&&Ur,Vr=Math.max,Gr=Math.min,Hr=w(Hr=Date.now)&&Hr,Jr=Math.random; -a.prototype=f.prototype;var Kr={};!function(){var n={0:1,length:1};Kr.spliceObjects=(Dr.call(n,0,1),!n[0])}(1),f.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Wr||(c=function(){function n(){}return function(r){if(H(r)){n.prototype=r;var t=new n;n.prototype=null}return t||jr.Object()}}()),j(arguments)||(j=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&$r.call(n,"callee")&&!Mr.call(n,"callee")||false});var Lr=_(function(n,r,t){$r.call(n,t)?n[t]++:n[t]=1 -}),Qr=_(function(n,r,t){$r.call(n,t)?n[t].push(r):n[t]=[r]}),Xr=_(function(n,r,t){n[t]=r}),Yr=_(function(n,r,t){n[t?0:1].push(r)},true),Zr=R,nt=q,rt=zr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n)==pr||false};G(/x/)&&(G=function(n){return typeof n=="function"&&"[object Function]"==Nr.call(n)});var tt=Ur?function(n){return H(n)?Ur(n):[]}:n,et=Hr||function(){return(new Date).getTime()};f.after=function(n,r){if(!G(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0 +if(typeof i=="number")for(u&&i&&(t=n[++o]);++oarguments.length;return r=Q(r,e,4),h(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function D(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return g(n,function(n){var t;t=++r,t=0+Rr(Kr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=Q(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++targuments.length?b(n,tr,r):b(n,tr|er,r,E(arguments,2))}function C(n,r,t){function e(){l&&clearTimeout(l),i=l=p=rr,(h||g!==r)&&(s=ut(),f=n.apply(c,o),l||i||(o=c=null))}function u(){var t=r-(ut()-a);0>=t||t>r?(i&&clearTimeout(i),t=p,i=l=p=rr,t&&(s=ut(),f=n.apply(c,o),l||i||(o=c=null))):l=setTimeout(u,t)}var o,i,f,a,c,l,p,s=0,g=false,h=true;if(!G(n))throw new TypeError;if(r=0=y||y>g;m?(i&&(i=clearTimeout(i)),s=a,f=n.apply(c,o)):i||(i=setTimeout(e,y))}return m&&l?l=clearTimeout(l):l||r===g||(l=setTimeout(u,r)),t&&(m=true,f=n.apply(c,o)),!m||l||i||(o=c=null),f}}function P(n,r,t){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof t;for("number"!=i&&"string"!=i||!e[3]||e[3][t]!==r||(o=2);++u"']/g,ar=/($^)/,cr=/[.*+?^${()|[\\]/g,lr=/['\n\r\t\u2028\u2029\\]/g,pr="[object Arguments]",sr="[object Array]",gr="[object Boolean]",hr="[object Date]",vr="[object Number]",yr="[object Object]",mr="[object RegExp]",_r="[object String]",br={"&":"&","<":"<",">":">",'"':""","'":"'"},dr={"&":"&","<":"<",">":">",""":'"',"'":"'"},wr={"function":true,object:true},jr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},xr=wr[typeof window]&&window||this,Ar=wr[typeof exports]&&exports&&!exports.nodeType&&exports,Tr=wr[typeof module]&&module&&!module.nodeType&&module,Er=Ar&&Tr&&typeof global=="object"&&global; +!Er||Er.global!==Er&&Er.window!==Er&&Er.self!==Er||(xr=Er);var Or=Tr&&Tr.exports===Ar&&Ar,kr=Array.prototype,Sr=Object.prototype,Nr=xr._,qr=Sr.toString,Fr=RegExp("^"+(null==qr?"":(qr+"").replace(cr,"\\$&")).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Br=Math.ceil,Rr=Math.floor,$r=Function.prototype.toString,Ir=Sr.hasOwnProperty,Mr=kr.push,Dr=Sr.propertyIsEnumerable,Wr=kr.splice,zr=w(zr=Object.create)&&zr,Cr=w(Cr=Array.isArray)&&Cr,Pr=xr.isFinite,Ur=xr.isNaN,Vr=w(Vr=Object.keys)&&Vr,Gr=Math.max,Hr=Math.min,Jr=w(Jr=Date.now)&&Jr,Kr=Math.random; +a.prototype=f.prototype;var Lr={};!function(){var n={0:1,length:1};Lr.spliceObjects=(Wr.call(n,0,1),!n[0])}(1),f.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},zr||(c=function(){function n(){}return function(r){if(H(r)){n.prototype=r;var t=new n;n.prototype=null}return t||xr.Object()}}()),j(arguments)||(j=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ir.call(n,"callee")&&!Dr.call(n,"callee")||false});var Qr=_(function(n,r,t){Ir.call(n,t)?n[t]++:n[t]=1 +}),Xr=_(function(n,r,t){Ir.call(n,t)?n[t].push(r):n[t]=[r]}),Yr=_(function(n,r,t){n[t]=r}),Zr=_(function(n,r,t){n[t?0:1].push(r)},true),nt=R,rt=q,tt=Cr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&qr.call(n)==sr||false};G(/x/)&&(G=function(n){return typeof n=="function"&&"[object Function]"==qr.call(n)});var et=Vr?function(n){return H(n)?Vr(n):[]}:n,ut=Jr||function(){return(new Date).getTime()};f.after=function(n,r){if(!G(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0 }},f.bind=z,f.bindAll=function(n){for(var r=1i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},f.invert=function(n){for(var r=-1,t=tt(n),e=t.length,u={};++rr?0:r);++nt?Vr(0,e+t):Gr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},f.mixin=Z,f.noConflict=function(){return jr._=Sr,this},f.now=et,f.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Br(Jr()*(r-n+1)) -},f.reduce=I,f.reduceRight=M,f.result=function(n,r){if(null!=n){var t=n[r];return G(t)?n[r]():t}},f.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:tt(n).length},f.some=W,f.sortedIndex=O,f.template=function(n,r,t){var e=f,u=e.templateSettings;n=(n||"")+"",t=U({},t,u);var i=0,a="__p+='",u=t.variable;n.replace(RegExp((t.escape||ar).source+"|"+(t.interpolate||ar).source+"|"+(t.evaluate||ar).source+"|$","g"),function(r,t,e,u,f){return a+=n.slice(i,f).replace(cr,o),t&&(a+="'+_.escape("+t+")+'"),u&&(a+="';"+u+";\n__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),i=f+r.length,r +}},f.countBy=Qr,f.debounce=C,f.defaults=U,f.defer=function(n){if(!G(n))throw new TypeError;var r=E(arguments,1);return setTimeout(function(){n.apply(rr,r)},1)},f.delay=function(n,r){if(!G(n))throw new TypeError;var t=E(arguments,2);return setTimeout(function(){n.apply(rr,t)},r)},f.difference=function(n){return s(n,v(arguments,true,true,1))},f.filter=q,f.flatten=function(n,r,t){if(!n||!n.length)return[];var e=typeof r;return"number"!=e&&"string"!=e||!t||t[r]!==n||(r=false),v(n,r)},f.forEach=B,f.functions=V,f.groupBy=Xr,f.indexBy=Yr,f.initial=function(n,r,t){return r=(n?n.length:0)-(null==r||t?1:r),E(n,0,0i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},f.invert=function(n){for(var r=-1,t=et(n),e=t.length,u={};++rr?0:r);++nt?Gr(0,e+t):Hr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},f.mixin=Z,f.noConflict=function(){return xr._=Nr,this},f.now=ut,f.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Rr(Kr()*(r-n+1)) +},f.reduce=I,f.reduceRight=M,f.result=function(n,r){if(null!=n){var t=n[r];return G(t)?n[r]():t}},f.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:et(n).length},f.some=W,f.sortedIndex=O,f.template=function(n,r,t){var e=f,u=e.templateSettings;n=(null==n?"":n)+"",t=U({},t,u);var i=0,a="__p+='",u=t.variable;n.replace(RegExp((t.escape||ar).source+"|"+(t.interpolate||ar).source+"|"+(t.evaluate||ar).source+"|$","g"),function(r,t,e,u,f){return a+=n.slice(i,f).replace(lr,o),t&&(a+="'+_.escape("+t+")+'"),u&&(a+="';"+u+";\n__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),i=f+r.length,r }),a+="';",u||(a="with(obj||{}){"+a+"}"),a="function("+(u||"obj")+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var c=Function("_","return "+a)(e)}catch(l){throw l.source=a,l}return r?c(r):(c.source=a,c)},f.unescape=function(n){return null==n?"":(n+="",0>n.indexOf(";")?n:n.replace(ir,i))},f.uniqueId=function(n){var r=++or+"";return n?n+r:r},f.all=N,f.any=W,f.detect=F,f.findWhere=F,f.foldl=I,f.foldr=M,f.include=S,f.inject=I,f.first=x,f.last=function(n,r,t){var e=n?n.length:0; -return null==r||t?n?n[e-1]:rr:(r=e-r,E(n,0