From 681d3e09ba34d1ff78fb48b4bf53b3fe1542a1a1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 4 Jun 2014 08:57:01 -0700 Subject: [PATCH] Rebuild dist. --- dist/lodash.compat.js | 867 +++++++++++++++++++--------------- dist/lodash.compat.min.js | 133 +++--- dist/lodash.js | 850 ++++++++++++++++++--------------- dist/lodash.min.js | 127 ++--- dist/lodash.underscore.js | 532 ++++++++++++--------- dist/lodash.underscore.min.js | 76 +-- 6 files changed, 1439 insertions(+), 1146 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 77e17cb8c..dcc866ee4 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) + * Lo-Dash 2.5.0-pre (Custom Build) * Build: `lodash -o ./dist/lodash.compat.js` * Copyright 2012-2014 The Dojo Foundation * Based on Underscore.js 1.6.0 @@ -21,7 +21,7 @@ PARTIAL_RIGHT_FLAG = 32; /** Used as the semantic version number */ - var version = '2.4.1'; + var version = '2.5.0-pre'; /** Used as the property name for wrapper metadata */ var expando = '__lodash@' + version + '__'; @@ -41,8 +41,8 @@ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; /** Used to match HTML entities and HTML characters */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, - reUnescapedHtml = /[&<>"']/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, + reUnescapedHtml = /[&<>"'`]/g; /** Used to match template delimiters */ var reEscape = /<%-([\s\S]+?)%>/g, @@ -65,6 +65,9 @@ /** Used to detect hexadecimal string values */ var reHexPrefix = /^0[xX]/; + /** Used to detect host constructors (Safari > 5) */ + var reHostCtor = /^\[object .+?Constructor\]$/; + /** Used to match latin-1 supplement letters */ var reLatin1 = /[\xC0-\xFF]/g; @@ -101,9 +104,10 @@ /** Used to assign default `context` object properties */ var contextProps = [ - 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', - 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'isNaN', - 'parseInt', 'setTimeout', 'TypeError', 'window', 'WinRTError' + 'Array', 'ArrayBuffer', 'Boolean', 'Date', 'Error', 'Float64Array', 'Function', + 'Math', 'Number', 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', + 'document', 'isFinite', 'isNaN','parseInt', 'setTimeout', 'TypeError', + 'Uint8Array', 'window', 'WinRTError' ]; /** Used to fix the JScript `[[DontEnum]]` bug */ @@ -122,18 +126,54 @@ dateClass = '[object Date]', errorClass = '[object Error]', funcClass = '[object Function]', + mapClass = '[object Map]', numberClass = '[object Number]', objectClass = '[object Object]', regexpClass = '[object RegExp]', - stringClass = '[object String]'; + setClass = '[object Set]', + stringClass = '[object String]', + weakMapClass = '[object WeakMap]'; + + var arrayBufferClass = '[object ArrayBuffer]', + float32Class = '[object Float32Array]', + float64Class = '[object Float64Array]', + int8Class = '[object Int8Array]', + int16Class = '[object Int16Array]', + int32Class = '[object Int32Array]', + uint8Class = '[object Uint8Array]', + uint8ClampedClass = '[object Uint8ClampedArray]', + uint16Class = '[object Uint16Array]', + uint32Class = '[object Uint32Array]'; + + /** Used to identify object classifications that are treated like arrays */ + var arrayLikeClasses = {}; + arrayLikeClasses[argsClass] = + arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = + arrayLikeClasses[float64Class] = arrayLikeClasses[int8Class] = + arrayLikeClasses[int16Class] = arrayLikeClasses[int32Class] = + arrayLikeClasses[uint8Class] = arrayLikeClasses[uint8ClampedClass] = + arrayLikeClasses[uint16Class] = arrayLikeClasses[uint32Class] = true; + arrayLikeClasses[arrayBufferClass] = arrayLikeClasses[boolClass] = + arrayLikeClasses[dateClass] = arrayLikeClasses[errorClass] = + arrayLikeClasses[funcClass] = arrayLikeClasses[mapClass] = + arrayLikeClasses[numberClass] = arrayLikeClasses[objectClass] = + arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = + arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; /** Used to identify object classifications that `_.clone` supports */ var cloneableClasses = {}; - cloneableClasses[funcClass] = false; - cloneableClasses[argsClass] = cloneableClasses[arrayClass] = + cloneableClasses[argsClass] = + cloneableClasses[arrayClass] = cloneableClasses[arrayBufferClass] = cloneableClasses[boolClass] = cloneableClasses[dateClass] = + cloneableClasses[errorClass] = cloneableClasses[float32Class] = + cloneableClasses[float64Class] = cloneableClasses[int8Class] = + cloneableClasses[int16Class] = cloneableClasses[int32Class] = cloneableClasses[numberClass] = cloneableClasses[objectClass] = - cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; + cloneableClasses[regexpClass] = cloneableClasses[stringClass] = + cloneableClasses[uint8Class] = cloneableClasses[uint8ClampedClass] = + cloneableClasses[uint16Class] = cloneableClasses[uint32Class] = true; + cloneableClasses[funcClass] = cloneableClasses[mapClass] = + cloneableClasses[setClass] = cloneableClasses[weakMapClass] = false; /** Used as an internal `_.debounce` options object by `_.throttle` */ var debounceOptions = { @@ -154,17 +194,23 @@ * Used to convert characters to HTML entities. * * Note: Though the ">" character is escaped for symmetry, characters like - * ">", "`", and "/" don't require escaping in HTML and have no special meaning + * ">" and "/" don't require escaping in HTML and have no special meaning * unless they're part of a tag or unquoted attribute value. * See [Mathias' article](http://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can be used to + * break out of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. */ var htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', - "'": ''' + "'": ''', + '`': '`' }; /** Used to convert HTML entities to characters */ @@ -173,7 +219,8 @@ '<': '<', '>': '>', '"': '"', - ''': "'" + ''': "'", + '`': '`' }; /** @@ -565,12 +612,10 @@ /** Native constructor references */ var Array = context.Array, - Boolean = context.Boolean, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, - Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, @@ -585,8 +630,8 @@ /** Used to detect DOM support */ var document = (document = context.window) && document.document; - /** Used to restore the original `_` reference in `_.noConflict` */ - var oldDash = context._; + /** Used to resolve the decompiled source of functions */ + var fnToString = Function.prototype.toString; /** * Used as the maximum length of an array-like object. @@ -595,6 +640,9 @@ */ var maxSafeInteger = Math.pow(2, 53) - 1; + /** Used to restore the original `_` reference in `_.noConflict` */ + var oldDash = context._; + /** Used to resolve the internal `[[Class]]` of values */ var toString = objectProto.toString; @@ -605,10 +653,12 @@ ); /** Native method shortcuts */ - var ceil = Math.ceil, + var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, + bufferSlice = isNative(bufferSlice = ArrayBuffer && (new ArrayBuffer).slice) && bufferSlice, + ceil = Math.ceil, clearTimeout = context.clearTimeout, + Float64Array = isNative(Float64Array = context.Float64Array) && Float64Array, floor = Math.floor, - fnToString = Function.prototype.toString, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, @@ -616,6 +666,7 @@ Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, + Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, unshift = arrayProto.unshift; /** Used to set metadata on functions */ @@ -642,17 +693,6 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used to lookup built-in constructors by `[[Class]]` */ - var ctorByClass = {}; - ctorByClass[arrayClass] = Array; - ctorByClass[boolClass] = Boolean; - ctorByClass[dateClass] = Date; - ctorByClass[funcClass] = Function; - ctorByClass[objectClass] = Object; - ctorByClass[numberClass] = Number; - ctorByClass[regexpClass] = RegExp; - ctorByClass[stringClass] = String; - /** Used to avoid iterating over non-enumerable properties in IE < 9 */ var nonEnumProps = {}; nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }; @@ -725,15 +765,11 @@ * var wrapped = _([1, 2, 3]); * * // returns an unwrapped value - * wrapped.reduce(function(sum, num) { - * return sum + num; - * }); + * wrapped.reduce(function(sum, n) { return sum + n; }); * // => 6 * * // returns a wrapped value - * var squares = wrapped.map(function(num) { - * return num * num; - * }); + * var squares = wrapped.map(function(n) { return n * n; }); * * _.isArray(squares); * // => false @@ -773,12 +809,12 @@ var support = lodash.support = {}; (function(x) { - var ctor = function() { this.x = 1; }, + var Ctor = function() { this.x = 1; }, object = { '0': 1, 'length': 1 }, props = []; - ctor.prototype = { 'valueOf': 1, 'y': 1 }; - for (var key in new ctor) { props.push(key); } + Ctor.prototype = { 'valueOf': 1, 'y': 1 }; + for (var key in new Ctor) { props.push(key); } for (var argsKey in arguments) { } for (var strKey in 'x') { } @@ -821,7 +857,7 @@ * @memberOf _.support * @type boolean */ - support.enumPrototypes = propertyIsEnumerable.call(ctor, 'prototype'); + support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype'); /** * Detect if functions can be decompiled by `Function#toString` @@ -1109,9 +1145,6 @@ * @returns {Object} Returns the destination object. */ function baseAssign(object, source, callback) { - if (!object) { - return object; - } var index = -1, props = keys(source), length = props.length; @@ -1189,18 +1222,32 @@ if (!cloneableClasses[className] || (!support.nodeClass && isNode(value))) { return value; } - var ctor = ctorByClass[className]; + var Ctor = value.constructor; + if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { + Ctor = Object; + } switch (className) { + case arrayBufferClass: + return cloneBuffer(value); + case boolClass: case dateClass: - return new ctor(+value); + return new Ctor(+value); + + case errorClass: + return new Ctor(value.message); + + case float32Class: case float64Class: + case int8Class: case int16Class: case int32Class: + case uint8Class: case uint8ClampedClass: case uint16Class: case uint32Class: + return value.subarray(0); case numberClass: case stringClass: - return new ctor(value); + return new Ctor(value); case regexpClass: - result = ctor(value.source, reFlags.exec(value)); + result = Ctor(value.source, reFlags.exec(value)); result.lastIndex = value.lastIndex; return result; } @@ -1219,7 +1266,7 @@ return stackB[length]; } } - result = isArr ? ctor(value.length) : {}; + result = isArr ? Ctor(value.length) : Ctor(); } else { result = isArr ? slice(value) : baseAssign({}, value); @@ -1323,15 +1370,15 @@ case 1: return function(value) { return func.call(thisArg, value); }; - case 2: return function(value, other) { - return func.call(thisArg, value, other); - }; case 3: return function(value, index, collection) { return func.call(thisArg, value, index, collection); }; case 4: return function(accumulator, value, index, collection) { return func.call(thisArg, accumulator, value, index, collection); }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; } return bind(func, thisArg); } @@ -1691,7 +1738,7 @@ * @param {*} value The value to compare to `other`. * @param {*} other The value to compare to `value`. * @param {Function} [callback] The function to customize comparing values. - * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. + * @param {boolean} [isWhere=false] A flag to indicate performing partial comparisons. * @param {Array} [stackA=[]] Tracks traversed `value` objects. * @param {Array} [stackB=[]] Tracks traversed `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. @@ -1742,13 +1789,15 @@ // but treat `-0` vs. `+0` as not equal : (value == 0 ? (1 / value == 1 / other) : value == +other); + case errorClass: case regexpClass: case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) + // coerce errors (http://es5.github.io/#x15.11.4.4) + // and regexes (http://es5.github.io/#x15.10.6.4) to strings // treat string primitives and their corresponding object instances as equal return value == String(other); } - var isArr = valClass == arrayClass; + var isArr = arrayLikeClasses[valClass]; if (!isArr) { // exit for functions and DOM nodes if (valClass != objectClass || (!support.nodeClass && (isNode(value) || isNode(other)))) { @@ -1914,11 +1963,9 @@ * @returns {Object} Returns the destination object. */ function baseMerge(object, source, callback, stackA, stackB) { - if (!object) { - return object; - } - (isArray(source) ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { - var isArr = srcValue && isArray(srcValue), + var isSrcArr = isArrayLike(source); + (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { + var isArr = srcValue && isArrayLike(srcValue), isObj = srcValue && isPlainObject(srcValue), value = object[key]; @@ -1927,10 +1974,9 @@ if (typeof result == 'undefined') { result = srcValue; } - if (typeof result != 'undefined') { - value = result; + if (isSrcArr || typeof result != 'undefined') { + object[key] = result; } - object[key] = value; return; } // avoid merging previously merged cyclic sources @@ -1947,22 +1993,21 @@ var result = callback ? callback(value, srcValue, key, object, source) : undefined, isShallow = typeof result != 'undefined'; - if (isShallow) { - value = result; - } else { - value = isArr + if (!isShallow) { + result = isArr ? (isArray(value) ? value : []) : (isPlainObject(value) ? value : {}); } - // add `source` and associated `value` to the stack of traversed objects + // add the source value to the stack of traversed objects + // and associate it with its merged value stackA.push(srcValue); - stackB.push(value); + stackB.push(result); // recursively merge objects and arrays (susceptible to call stack limits) if (!isShallow) { - baseMerge(value, srcValue, callback, stackA, stackB); + baseMerge(result, srcValue, callback, stackA, stackB); } - object[key] = value; + object[key] = result; }); return object; @@ -2125,7 +2170,7 @@ /** * Compiles a function from `source` using the `varNames` and `varValues` * pairs to import free variables into the compiled function. If `sourceURL` - * is provided it will be used as the sourceURL for the compiled function. + * is provided it is used as the sourceURL for the compiled function. * * @private * @param {string} source The source to compile. @@ -2214,7 +2259,7 @@ * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection * through a callback. The given setter function sets the keys and values of - * the accumulator object. If `initializer` is provided it will be used to + * the accumulator object. If `initializer` is provided it is used to * initialize the accumulator object. * * @private @@ -2267,7 +2312,7 @@ } // juggle arguments if (length > 3 && typeof args[length - 2] == 'function') { - var callback = baseCreateCallback(args[--length - 1], args[length--], 2); + var callback = baseCreateCallback(args[--length - 1], args[length--], 5); } else if (length > 2 && typeof args[length - 1] == 'function') { callback = args[--length]; } @@ -2456,6 +2501,18 @@ return result === indexOf ? baseIndexOf : result; } + /** + * Checks if `value` is an array-like object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + */ + function isArrayLike(value) { + return (value && typeof value == 'object' && typeof value.length == 'number' && + arrayLikeClasses[toString.call(value)]) || false; + } + /** * Checks if `value` is a native function. * @@ -2464,7 +2521,40 @@ * @returns {boolean} Returns `true` if `value` is a native function, else `false`. */ function isNative(value) { - return typeof value == 'function' && reNative.test(fnToString.call(value)); + var type = typeof value; + return type == 'function' + ? reNative.test(fnToString.call(value)) + : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; + } + + /** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneBuffer(buffer) { + return bufferSlice.call(buffer, 0); + } + if (!bufferSlice) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` + cloneBuffer = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + var byteLength = buffer.byteLength, + floatLength = Float64Array ? floor(byteLength / 8) : 0, + offset = floatLength * 8, + result = new ArrayBuffer(byteLength); + + if (floatLength) { + var view = new Float64Array(result, 0, floatLength); + view.set(new Float64Array(buffer, 0, floatLength)); + } + if (byteLength != offset) { + view = new Uint8Array(result, offset); + view.set(new Uint8Array(buffer, offset)); + } + return result; + }; } /** @@ -2490,13 +2580,13 @@ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. */ function shimIsPlainObject(value) { - var ctor, + var Ctor, result; // avoid non `Object` objects, `arguments` objects, and DOM elements if (!(value && toString.call(value) == objectClass) || (!hasOwnProperty.call(value, 'constructor') && - (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor))) || + (Ctor = value.constructor, isFunction(Ctor) && !(Ctor instanceof Ctor))) || (!support.argsClass && isArguments(value)) || (!support.nodeClass && isNode(value))) { return false; @@ -2664,14 +2754,14 @@ /** * Creates a slice of `array` excluding elements dropped from the end. - * Elements will be dropped until the predicate returns falsey. The predicate - * is bound to `thisArg` and invoked with three arguments; (value, index, array). + * Elements are dropped until the predicate returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2684,9 +2774,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropRightWhile([1, 2, 3], function(num) { - * return num > 1; - * }); + * _.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); * // => [1] * * var characters = [ @@ -2707,14 +2795,14 @@ /** * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements will be dropped until the predicate returns falsey. The predicate - * is bound to `thisArg` and invoked with three arguments; (value, index, array). + * Elements are dropped until the predicate returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2727,9 +2815,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropWhile([1, 2, 3], function(num) { - * return num < 3; - * }); + * _.dropWhile([1, 2, 3], function(n) { return n < 3; }); * // => [3] * * var characters = [ @@ -2753,10 +2839,10 @@ * element the predicate returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2764,8 +2850,8 @@ * @category Arrays * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -2807,10 +2893,10 @@ * of a collection from right to left. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2818,8 +2904,8 @@ * @category Arrays * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -2896,16 +2982,16 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` - * is truthy, the array will only be flattened a single level. If a callback - * is provided each element of the array is passed through the callback before + * is truthy, the array is only flattened a single level. If a callback is + * provided each element of the array is passed through the callback before * flattening. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2914,7 +3000,7 @@ * @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] The function called per iteration. - * If a property name or object is provided it will be used to create a "_.pluck" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new flattened array. @@ -2962,7 +3048,7 @@ /** * Gets the index at which the first occurrence of `value` is found using * strict equality for comparisons, i.e. `===`. If the array is already sorted - * providing `true` for `fromIndex` will run a faster binary search. + * providing `true` for `fromIndex` performs a faster binary search. * * @static * @memberOf _ @@ -3231,10 +3317,10 @@ * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * Note: Unlike `_.filter`, this method mutates `array`. @@ -3244,14 +3330,14 @@ * @category Arrays * @param {Array} array The array to modify. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new array of removed elements. * @example * * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(num) { return num % 2 == 0; }); + * var evens = _.remove(array, function(n) { return n % 2 == 0; }); * * console.log(array); * // => [1, 3] @@ -3353,15 +3439,15 @@ /** * Uses a binary search to determine the smallest index at which a value * should be inserted into a given sorted array in order to maintain the sort - * order of the array. If a callback is provided it will be executed for - * `value` and each element of `array` to compute their sort ranking. The - * callback is bound to `thisArg` and invoked with one argument; (value). + * order of the array. If a callback is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The callback + * is bound to `thisArg` and invoked with one argument; (value). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3370,8 +3456,8 @@ * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. @@ -3470,15 +3556,15 @@ var takeRight = last; /** - * Creates a slice of `array` with elements taken from the end. Elements will - * be taken until the predicate returns falsey. The predicate is bound to - * `thisArg` and invoked with three arguments; (value, index, array). + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until the predicate returns falsey. The predicate is bound to `thisArg` + * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3491,9 +3577,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeRightWhile([1, 2, 3], function(num) { - * return num > 1; - * }); + * _.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); * // => [2, 3] * * var characters = [ @@ -3514,14 +3598,14 @@ /** * Creates a slice of `array` with elements taken from the beginning. Elements - * will be taken until the predicate returns falsey. The predicate is bound - * to `thisArg` and invoked with three arguments; (value, index, array). + * are taken until the predicate returns falsey. The predicate is bound to + * `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3534,9 +3618,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeWhile([1, 2, 3], function(num) { - * return num < 3; - * }); + * _.takeWhile([1, 2, 3], function(n) { return n < 3; }); * // => [1, 2] * * var characters = [ @@ -3575,17 +3657,17 @@ /** * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. If the array is sorted, providing `true` for - * `isSorted` will use a faster algorithm. If a callback is provided it will - * be executed for each value in the array to generate the criterion by which - * uniqueness is computed. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index, array). + * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a + * faster search algorithm for sorted arrays. If a callback is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3595,26 +3677,26 @@ * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new duplicate-value-free array. * @example * - * _.uniq([1, 2, 1, 3, 1]); - * // => [1, 2, 3] + * _.uniq([1, 2, 1]); + * // => [1, 2] * * // using `isSorted` - * _.uniq([1, 1, 2, 2, 3], true); - * // => [1, 2, 3] + * _.uniq([1, 1, 2], true); + * // => [1, 2] * * // using `callback` - * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); - * // => ['A', 'b', 'C'] + * _.uniq(['A', 'b', 'a', 'B'], function(chr) { return chr.toLowerCase(); }); + * // => ['A', 'b'] * * // using `callback` with `thisArg` - * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2.5, 3] + * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); + * // => [1, 2.5] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); @@ -3699,7 +3781,7 @@ * Creates an array of grouped elements, the first of which contains the first * elements of the given arrays, the second of which contains the second elements * of the given arrays, and so on. If a zipped value is provided its corresponding - * unzipped value will be returned. + * unzipped value is returned. * * @static * @memberOf _ @@ -3969,10 +4051,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3980,16 +4062,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': 1, '6': 2 } * - * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': 1, '6': 2 } * * _.countBy(['one', 'two', 'three'], 'length'); @@ -4005,10 +4087,10 @@ * (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4017,8 +4099,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if all elements passed the predicate check, * else `false`. @@ -4070,10 +4152,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4082,13 +4164,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var evens = _.filter([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [2, 4] * * var characters = [ @@ -4134,10 +4216,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4146,8 +4228,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -4189,15 +4271,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.findLast([1, 2, 3, 4], function(num) { - * return num % 2 == 1; - * }); + * _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); * // => 3 */ function findLast(collection, predicate, thisArg) { @@ -4253,10 +4333,10 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * _([1, 2, 3]).forEach(function(n) { console.log(n); }).join(','); * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { console.log(n); }); * // => logs each number and returns the object (property order is not guaranteed across environments) */ function forEach(collection, callback, thisArg) { @@ -4279,7 +4359,7 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); * // => logs each number from right to left and returns '3,2,1' */ function forEachRight(collection, callback, thisArg) { @@ -4296,10 +4376,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4307,16 +4387,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * * // using "_.pluck" callback shorthand @@ -4339,10 +4419,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4350,8 +4430,8 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -4377,8 +4457,8 @@ /** * Invokes the method named by `methodName` on each element in the collection * returning an array of the results of each invoked method. Additional arguments - * will be provided to each invoked method. If `methodName` is a function it - * will be invoked for, and `this` bound to, each element in the collection. + * is provided to each invoked method. If `methodName` is a function it is + * invoked for, and `this` bound to, each element in the collection. * * @static * @memberOf _ @@ -4406,10 +4486,10 @@ * three arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4418,16 +4498,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new mapped array. * @example * - * _.map([1, 2, 3], function(num) { return num * 3; }); + * _.map([1, 2, 3], function(n) { return n * 3; }); * // => [3, 6, 9] * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); + * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); * // => [3, 6, 9] (property order is not guaranteed across environments) * * var characters = [ @@ -4455,17 +4535,17 @@ } /** - * Retrieves the maximum value of a collection. If the collection is empty or - * falsey `-Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the maximum value of a collection. If the collection is empty + * or falsey `-Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4473,7 +4553,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. @@ -4533,17 +4613,17 @@ } /** - * Retrieves the minimum value of a collection. If the collection is empty or - * falsey `Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the minimum value of a collection. If the collection is empty + * or falsey `Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4551,7 +4631,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. @@ -4617,10 +4697,10 @@ * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4628,16 +4708,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the array of grouped elements. * @example * - * _.partition([1, 2, 3], function(num) { return num % 2; }); + * _.partition([1, 2, 3], function(n) { return n % 2; }); * // => [[1, 3], [2]] * - * _.partition([1.2, 2.3, 3.4], function(num) { return this.floor(num) % 2; }, Math); + * _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); * // => [[1, 3], [2]] * * var characters = [ @@ -4685,9 +4765,9 @@ * Reduces a collection to a value which is the accumulated result of running * each element in the collection through the callback, where each successive * callback execution consumes the return value of the previous execution. If - * `accumulator` is not provided the first element of the collection will be - * used as the initial `accumulator` value. The callback is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, index|key, collection). + * `accumulator` is not provided the first element of the collection is used + * as the initial `accumulator` value. The callback is bound to `thisArg` and + * invoked with four arguments; (accumulator, value, index|key, collection). * * @static * @memberOf _ @@ -4700,13 +4780,11 @@ * @returns {*} Returns the accumulated value. * @example * - * var sum = _.reduce([1, 2, 3], function(sum, num) { - * return sum + num; - * }); + * var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); * // => 6 * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; + * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; * return result; * }, {}); * // => { 'a': 3, 'b': 6, 'c': 9 } @@ -4771,10 +4849,10 @@ * the predicate does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4782,13 +4860,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var odds = _.reject([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [1, 3] * * var characters = [ @@ -4904,10 +4982,10 @@ * with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4916,8 +4994,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if any element passed the predicate check, * else `false`. @@ -4966,18 +5044,18 @@ /** * Creates an array of elements, sorted in ascending order by the results of * running each element in a collection through the callback. This method - * performs a stable sort, that is, it will preserve the original sort order - * of equal elements. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an array of property names is provided for `callback` the collection - * will be sorted by each property value. + * is sorted by each property value. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4985,16 +5063,16 @@ * @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. + * called per iteration. If a property name or object is provided it is + * used to create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new sorted array. * @example * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); + * _.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); * // => [3, 1, 2] * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + * _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); * // => [3, 1, 2] * * var characters = [ @@ -5177,7 +5255,7 @@ * Binds methods of an object to the object itself, overwriting the existing * method. Method names may be specified as individual arguments or as arrays * of method names. If no method names are provided all enumerable function - * properties, own and inherited, of `object` will be bound. + * properties, own and inherited, of `object` are bound. * * Note: This method does not set the `length` property of bound functions. * @@ -5229,7 +5307,7 @@ * Creates a function that invokes the method at `object[key]` and prepends * any additional `bindKey` arguments to those provided to the bound function. * This method differs from `_.bind` by allowing bound functions to reference - * methods that will be redefined or don't yet exist. + * methods that may be redefined or don't yet exist. * See [Peter Michaux's article](http://michaux.ca/articles/lazy-function-definition-pattern) * for more details. * @@ -5355,14 +5433,15 @@ } /** - * Creates a function that will delay the execution of `func` until after - * `wait` milliseconds have elapsed since the last time it was invoked. - * Provide an options object to indicate that `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. Subsequent calls - * to the debounced function will return the result of the last `func` call. + * Creates a function that delays the execution of `func` until after `wait` + * milliseconds have elapsed since the last time it was invoked. The created + * function comes with a `cancel` method to cancel delayed calls. Provide an + * options object to indicate that `func` should be invoked on the leading + * and/or trailing edge of the `wait` timeout. Subsequent calls to the + * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the debounced function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -5378,8 +5457,7 @@ * @example * * // avoid costly calculations while the window size is in flux - * var lazyLayout = _.debounce(calculateLayout, 150); - * jQuery(window).on('resize', lazyLayout); + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * * // execute `sendMail` when the click event is fired, debouncing subsequent calls * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { @@ -5389,9 +5467,26 @@ * * // ensure `batchLog` is executed once after 1 second of debounced calls * var source = new EventSource('/stream'); - * source.addEventListener('message', _.debounce(batchLog, 250, { + * jQuery(source).on('message', _.debounce(batchLog, 250, { * 'maxWait': 1000 * }, false); + * + * // cancel a debounced call + * var todoChanges = _.debounce(batchLog, 1000); + * Object.observe(models.todo, todoChanges); + * + * Object.observe(models, function(changes) { + * if (_.find(changes, { 'name': 'todo', 'type': 'delete'})) { + * todoChanges.cancel(); + * } + * }, ['delete']); + * + * // ...at some point `models.todo` is changed + * models.todo.completed = true; + * + * // ...before 1 second has passed `models.todo` is deleted + * // which cancels the debounced `todoChanges` call + * delete models.todo; */ function debounce(func, wait, options) { var args, @@ -5417,7 +5512,18 @@ maxWait = 'maxWait' in options && nativeMax(wait, +options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } - var delayed = function() { + + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + } + + function delayed() { var remaining = wait - (now() - stamp); if (remaining <= 0 || remaining > wait) { if (maxTimeoutId) { @@ -5435,9 +5541,9 @@ } else { timeoutId = setTimeout(delayed, remaining); } - }; + } - var maxDelayed = function() { + function maxDelayed() { if (timeoutId) { clearTimeout(timeoutId); } @@ -5449,9 +5555,9 @@ args = thisArg = null; } } - }; + } - return function() { + function debounced() { args = arguments; stamp = now(); thisArg = this; @@ -5491,12 +5597,14 @@ args = thisArg = null; } return result; - }; + } + debounced.cancel = cancel; + return debounced; } /** - * Defers executing the `func` function until the current call stack has cleared. - * Additional arguments will be provided to `func` when it is invoked. + * Defers executing the `func` function until the current call stack has + * cleared. Additional arguments are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -5519,7 +5627,7 @@ /** * Executes the `func` function after `wait` milliseconds. Additional arguments - * will be provided to `func` when it is invoked. + * are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -5543,11 +5651,11 @@ /** * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it will be used to determine the cache key for storing the result - * based on the arguments provided to the memoized function. By default, the - * first argument provided to the memoized function is used as the cache key. - * The `func` is executed with the `this` binding of the memoized function. - * The result cache is exposed as the `cache` property on the memoized function. + * provided it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the cache key. The `func` is + * executed with the `this` binding of the memoized function. The result cache + * is exposed as the `cache` property on the memoized function. * * @static * @memberOf _ @@ -5606,8 +5714,8 @@ * @returns {Function} Returns the new function. * @example * - * function isEven(num) { - * return num % 2 == 0; + * function isEven(n) { + * return n % 2 == 0; * } * * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); @@ -5623,8 +5731,8 @@ } /** - * Creates a function that is restricted to execute `func` once. Repeat calls to - * the function will return the value of the first call. The `func` is executed + * Creates a function that is restricted to execute `func` once. Repeat calls + * to the function return the value of the first call. The `func` is executed * with the `this` binding of the created function. * * @static @@ -5726,14 +5834,15 @@ } /** - * Creates a function that, when executed, will only call the `func` function - * at most once per every `wait` milliseconds. Provide an options object to - * indicate that `func` should be invoked on the leading and/or trailing edge - * of the `wait` timeout. Subsequent calls to the throttled function will - * return the result of the last `func` call. + * Creates a function that only calls the `func` function at most once per + * every `wait` milliseconds. The created function comes with a `cancel` method + * to cancel delayed calls. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the throttled function return the result of the last + * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * * @static @@ -5748,13 +5857,14 @@ * @example * * // avoid excessively updating the position while scrolling - * var throttled = _.throttle(updatePosition, 100); - * jQuery(window).on('scroll', throttled); + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) + * jQuery('.interactive').on('click', throttled); + * + * // cancel a trailing throttled call + * jQuery(window).on('popstate', throttled.cancel); */ function throttle(func, wait, options) { var leading = true, @@ -5805,10 +5915,10 @@ /** * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources will overwrite property assignments of previous - * sources. If a callback is provided it will be executed to produce the - * assigned values. The callback is bound to `thisArg` and invoked with - * five arguments; (objectValue, sourceValue, key, object, source). + * object. Subsequent sources overwrite property assignments of previous + * sources. If a callback is provided it is executed to produce the assigned + * values. The callback is bound to `thisArg` and invoked with five arguments; + * (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -5821,24 +5931,24 @@ * @returns {Object} Returns the destination object. * @example * - * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); - * // => { 'name': 'fred', 'employer': 'slate' } + * _.assign({ 'name': 'fred' }, { 'age': 40 }, { 'employer': 'slate' }); + * // => { 'name': 'fred', 'age': 40, 'employer': 'slate' } * * var defaults = _.partialRight(_.assign, function(value, other) { * return typeof value == 'undefined' ? other : value; * }); * - * defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ var assign = createAssigner(baseAssign); /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects will also - * be cloned, otherwise they will be assigned by reference. If a callback - * is provided it will be executed to produce the cloned values. If the - * callback returns `undefined` cloning will be handled by the method instead. - * The callback is bound to `thisArg` and invoked with two argument; (value, index|key). + * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, + * otherwise they are assigned by reference. If a callback is provided it is + * executed to produce the cloned values. If the callback returns `undefined` + * cloning is handled by the method instead. The callback is bound to `thisArg` + * and invoked with two argument; (value, index|key). * * Note: This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and @@ -5898,10 +6008,10 @@ } /** - * Creates a deep clone of `value`. If a callback is provided it will be - * executed to produce the cloned values. If the callback returns `undefined` - * cloning will be handled by the method instead. The callback is bound to - * `thisArg` and invoked with two argument; (value, index|key). + * Creates a deep clone of `value`. If a callback is provided it is executed + * to produce the cloned values. If the callback returns `undefined` cloning + * is handled by the method instead. The callback is bound to `thisArg` and + * invoked with two argument; (value, index|key). * * Note: This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and @@ -5983,7 +6093,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property will be ignored. + * property is set, additional defaults of the same property are ignored. * * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. @@ -5997,8 +6107,8 @@ * @returns {Object} Returns the destination object. * @example * - * _.defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * _.defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ function defaults(object) { if (!object) { @@ -6014,10 +6124,10 @@ * first element the predicate returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -6025,8 +6135,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -6060,10 +6170,10 @@ * a collection in the opposite order. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -6071,8 +6181,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -6180,7 +6290,7 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) @@ -6205,7 +6315,7 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' @@ -6256,7 +6366,7 @@ /** * Creates an object composed of the inverted keys and values of the given * object. If the given object contains duplicate values, subsequent values - * will overwrite property assignments of previous values unless `multiValue` + * overwrite property assignments of previous values unless `multiValue` * is `true`. * * @static @@ -6467,10 +6577,10 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent. If a callback is provided it will be executed to compare - * values. If the callback returns `undefined` comparisons will be handled - * by the method instead. The callback is bound to `thisArg` and invoked - * with three arguments; (value, other, key). + * equivalent. If a callback is provided it is executed to compare values. + * If the callback returns `undefined` comparisons are handled by the method + * instead. The callback is bound to `thisArg` and invoked with three arguments; + * (value, other, key). * * Note: This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes @@ -6505,7 +6615,7 @@ * // => true */ function isEqual(value, other, callback, thisArg) { - callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2); + callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 3); if (!callback) { // exit early for identical values @@ -6549,7 +6659,7 @@ /** * Checks if `value` is, or can be coerced to, a finite number. * - * Note: This method is not the same as native `isFinite` which will return + * Note: This method is not the same as native `isFinite` which returns * `true` for booleans and empty strings. See the [ES5 spec](http://es5.github.io/#x15.1.2.5) * for more details. * @@ -6639,7 +6749,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which will return `true` + * Note: This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -6841,11 +6951,12 @@ * // => ['x', 'y'] (property order is not guaranteed across environments) */ var keys = !nativeKeys ? shimKeys : function(object) { - var ctor = object && object.constructor, + var Ctor = object && object.constructor, length = object ? object.length : 0; - if ((typeof length == 'number' && length > 0) || - (ctor && object === ctor.prototype)) { + if ((Ctor && object === Ctor.prototype) || + (typeof length == 'number' && length > 0) || + (support.enumPrototypes && typeof object == 'function')) { return shimKeys(object); } return isObject(object) ? nativeKeys(object) : []; @@ -6881,9 +6992,9 @@ (support.nonEnumArgs && isArguments(object))) && length) >>> 0; var keyIndex, - ctor = object.constructor, + Ctor = object.constructor, index = -1, - isProto = ctor && object === ctor.prototype, + isProto = Ctor && object === Ctor.prototype, maxIndex = length - 1, result = Array(length), skipIndexes = length > 0, @@ -6893,6 +7004,10 @@ while (++index < length) { result[index] = String(index); } + // Lo-Dash skips the `constructor` property when it infers it's iterating + // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]` + // attribute of an existing property and the `constructor` property of a + // prototype defaults to non-enumerable. for (var key in object) { if (!(isProto && key == 'constructor') && !(skipProto && key == 'prototype') && @@ -6901,10 +7016,6 @@ result.push(key); } } - // Lo-Dash skips the `constructor` property when it infers it's iterating - // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]` - // attribute of an existing property and the `constructor` property of a - // prototype defaults to non-enumerable. if (support.nonEnumShadows && object !== objectProto) { index = -1; length = shadowedProps.length; @@ -6930,10 +7041,10 @@ * (value, key, object). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -6941,13 +7052,13 @@ * @category Objects * @param {Object} object The object 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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the new mapped object. * @example * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; }); + * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; }); * // => { 'a': 3, 'b': 6, 'c': 9 } * * var characters = { @@ -6972,11 +7083,11 @@ /** * Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined` into the destination object. Subsequent sources - * will overwrite property assignments of previous sources. If a callback is - * provided it will be executed to produce the merged values of the destination - * and source properties. If the callback returns `undefined` merging will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with five arguments; (objectValue, sourceValue, key, object, source). + * overwrite property assignments of previous sources. If a callback is provided + * it is executed to produce the merged values of the destination and source + * properties. If the callback returns `undefined` merging is handled by the + * method instead. The callback is bound to `thisArg` and invoked with five + * arguments; (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -7025,9 +7136,9 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` omitting the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` omitting the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -7095,9 +7206,9 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` picking the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` picking the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -7146,28 +7257,28 @@ * @returns {*} Returns the accumulated value. * @example * - * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8], function(result, num) { - * num *= num; - * if (num % 2) { - * return result.push(num) < 3; + * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { + * n *= n; + * if (n % 2) { + * return result.push(n) < 3; * } * }); * // => [1, 9, 25] * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; + * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; * }); * // => { 'a': 3, 'b': 6, 'c': 9 } */ function transform(object, callback, accumulator, thisArg) { - var isArr = isArray(object); + var isArr = isArrayLike(object); if (accumulator == null) { if (isArr) { accumulator = []; } else { if (isObject(object)) { - var ctor = object.constructor, - proto = ctor && ctor.prototype; + var Ctor = object.constructor, + proto = Ctor && Ctor.prototype; } accumulator = baseCreate(proto); } @@ -7568,9 +7679,9 @@ * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. If - * a data object is provided the interpolated template string will be returned. + * a data object is provided the interpolated template string is returned. * Data properties may be accessed as free variables in the template. If a - * settings object is provided it will override `_.templateSettings` for the + * settings object is provided it overrides `_.templateSettings` for the * template. * * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. @@ -7834,8 +7945,8 @@ /** * 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 "...". + * The last characters of the truncated string are replaced with the omission + * string which defaults to "...". * * @static * @memberOf _ @@ -7848,22 +7959,22 @@ * @returns {string} Returns the truncated string. * @example * - * _.truncate('hi-diddly-ho there, neighborino'); + * _.trunc('hi-diddly-ho there, neighborino'); * // => 'hi-diddly-ho there, neighbo...' * - * _.truncate('hi-diddly-ho there, neighborino', 24); + * _.trunc('hi-diddly-ho there, neighborino', 24); * // => 'hi-diddly-ho there, n...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); * // => 'hi-diddly-ho there,...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); * //=> 'hi-diddly-ho there...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); * // => 'hi-diddly-ho there, neig [...]' */ - function truncate(string, options) { + function trunc(string, options) { var length = 30, omission = '...'; @@ -7962,9 +8073,9 @@ /** * Creates a function bound to an optional `thisArg`. If `func` is a property - * name the created callback will return the property value for a given element. - * If `func` is an object the created callback will return `true` for elements - * that contain the equivalent object properties, otherwise it will return `false`. + * name the created callback returns the property value for a given element. + * If `func` is an object the created callback returns `true` for elements + * that contain the equivalent object properties, otherwise it returns `false`. * * @static * @memberOf _ @@ -8085,7 +8196,7 @@ /** * Adds all own enumerable function properties of a source object to the - * destination object. If `object` is a function methods will be added to + * destination object. If `object` is a function then methods are added to * its prototype as well. * * @static @@ -8275,9 +8386,9 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number will be - * returned. If `floating` is truthy or either `min` or `max` are floats a - * floating-point number will be returned instead of an integer. + * argument is provided a number between `0` and the given number is returned. + * If `floating` is truthy, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. * * @static * @memberOf _ @@ -8389,10 +8500,10 @@ /** * Resolves the value of property `key` on `object`. If `key` is a function - * it will be invoked with the `this` binding of `object` and its result - * returned, else the property value is returned. If `object` is `null` or - * `undefined` then `undefined` is returned. If a default value is provided - * it will be returned if the property value resolves to `undefined`. + * it is invoked with the `this` binding of `object` and its result returned, + * else the property value is returned. If `object` is `null` or `undefined` + * then `undefined` is returned. If a default value is provided it is returned + * if the property value resolves to `undefined`. * * @static * @memberOf _ @@ -8465,7 +8576,7 @@ } /** - * Generates a unique ID. If `prefix` is provided the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided the ID is appended to it. * * @static * @memberOf _ @@ -8651,7 +8762,7 @@ lodash.trim = trim; lodash.trimLeft = trimLeft; lodash.trimRight = trimRight; - lodash.truncate = truncate; + lodash.trunc = trunc; lodash.unescape = unescape; lodash.uniqueId = uniqueId; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index faeb5016e..b743d3c0c 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -1,70 +1,71 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE + * Lo-Dash 2.5.0-pre (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202>>0:0,u=Zr(e);++ri(t,l)&&f.push(l);return f}function Ct(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number"&&-1o?0:o>>>0); -return Ct(n,function(n){var o=u?t:null!=n&&n[t];i[++e]=o?o.apply(n,r):m}),i}function Ft(n,t,r,e,u){return n?((Ze(t)?ct:It)(t,function(t,o,i){var a=t&&Ze(t),l=t&&Ke(t),f=n[o];if(a||l){for(e||(e=[]),u||(u=[]),l=e.length;l--;)if(e[l]==t)return void(n[o]=u[l]);i=r?r(f,t,o,n,i):m,f=(l=typeof i!="undefined")?i:a?Ze(f)?f:[]:Ke(f)?f:{},e.push(t),u.push(f),l||Ft(f,t,r,e,u)}else i=r?r(f,t,o,n,i):m,typeof i=="undefined"&&(i=t),typeof i!="undefined"&&(f=i);n[o]=f}),n):n}function Wt(n,t){var r={};if(typeof t=="function")return St(n,function(n,e,u){t(n,e,u)&&(r[e]=n) -}),r;for(var e=-1,u=t.length;++ea(s,g)&&((u||f)&&s.push(g),c.push(p))}return c}function Dt(n,t){for(var r=-1,e=t(n),u=e.length,o=Zr(u);++re)return t;var u=typeof r[2];if("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2),3o?0:o)}function Qt(n,t,e){var u=n?n.length:0;if(typeof e=="number")e=0>e?Se(u+e,0):e||0;else if(e)return e=ur(n,t),u&&n[e]===t?e:-1;return r(n,t,e) -}function nr(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var u=e,o=0;for(t=U.createCallback(t,r,3);u--&&t(n[u],u,n);)o++}else o=null==t||r?1:t;return o=e-(o||0),er(n,0,0>o?0:o)}function tr(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var u=e,o=0;for(t=U.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||0),er(n,0>o?0:o)}function rr(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=U.createCallback(t,r,3);++et?0:t;return er(n,o)}function er(n,t,r){var e=-1,u=n?n.length:0;for(t=null==t?0:+t||0,0>t?t=Se(u+t,0):t>u&&(t=u),r=typeof r=="undefined"?u:+r||0,0>r?r=Se(u+r,0):r>u&&(r=u),u=t>r?0:r-t,r=Zr(u);++e>>1,r(n[e])r?0:r);++tr?Se(e+r,0):r||0:0,typeof n=="string"||!Ze(n)&&Nr(n)?ro&&(o=a)}else t=null==t&&Nr(n)?u:U.createCallback(t,r,3),Ct(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===o)&&(e=r,o=n)});return o}function dr(n,t){return vr(n,qr(t))}function mr(n,t,r,e){var u=3>arguments.length;if(t=U.createCallback(t,e,4),Ze(n)){var o=-1,i=n.length;for(u&&i&&(r=n[++o]);++oarguments.length;return t=U.createCallback(t,e,4),jt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o) -}),r}function _r(n){var t=-1,r=n&&n.length,e=Zr(0>r?0:r>>>0);return Ct(n,function(n){var r=$t(0,++t);e[t]=e[r],e[r]=n}),e}function wr(n,t,r){var e;if((typeof t!="function"||typeof r!="undefined")&&(t=U.createCallback(t,r,3)),Ze(n)){r=-1;for(var u=n.length;++rarguments.length)return Kt(n,b,null,t);if(n)var r=n[O]?n[O][2]:n.length,e=er(arguments,2),r=r-e.length;return Kt(n,b|C,r,t,e)}function Cr(n,t,r){var e,u,o,i,a,l,f,c=0,s=false,p=true; -if(!Ar(n))throw new ne(E);if(t=0>t?0:t,true===r)var g=true,p=false;else Sr(r)&&(g=r.leading,s="maxWait"in r&&Se(t,+r.maxWait||0),p="trailing"in r?r.trailing:p);var h=function(){var r=t-(Ge()-i);0>=r||r>t?(u&&se(u),r=f,u=l=f=m,r&&(c=Ge(),o=n.apply(a,e),l||u||(e=a=null))):l=be(h,r)},v=function(){l&&se(l),u=l=f=m,(p||s!==t)&&(c=Ge(),o=n.apply(a,e),l||u||(e=a=null))};return function(){if(e=arguments,i=Ge(),a=this,f=p&&(l||!g),false===s)var r=g&&!l;else{u||g||(c=i);var y=s-(i-c),d=0>=y||y>s;d?(u&&(u=se(u)),c=i,o=n.apply(a,e)):u||(u=be(v,y)) -}return d&&l?l=se(l):l||t===s||(l=be(h,t)),r&&(d=true,o=n.apply(a,e)),!d||l||u||(e=a=null),o}}function jr(n){if(!Ar(n))throw new ne(E);return function(){return!n.apply(this,arguments)}}function kr(n){return Nt(n,Tr)}function Or(n){return n&&typeof n=="object"&&typeof n.length=="number"&&le.call(n)==G||false}function Er(n){return n&&typeof n=="object"&&1===n.nodeType&&(We.nodeClass?-1>>0,e=n.constructor,u=-1,o=e&&n===e.prototype,i=r-1,e=Zr(r),a=0t||null==n||!Oe(t))return r;n=Qr(n);do t%2&&(r+=n),t=pe(t/2),n+=n;while(t);return r}function $r(n,t){return(n=null==n?"":Qr(n))?null==t?n.slice(h(n),v(n)+1):(t=Qr(t),n.slice(o(n,t),i(n,t)+1)):n -}function Pr(n,t,r){var e=typeof n,u="function"==e;return!u||typeof t!="undefined"&&"prototype"in n?u||null==n?_t(n,t,r):"object"==e?zr(n):qr(n):n}function Dr(n){return n}function zr(n){var t=Me(n),r=t.length,e=t[0],u=r&&n[e];return 1!=r||u!==u||Sr(u)?function(e){var u=r;if(u&&!e)return false;for(;u--;){var o=t[u];if(!ve.call(e,o)||!Tt(e[o],n[o],null,true))return false}return true}:function(n){return n&&ve.call(n,e)?(n=n[e],u===n&&(0!==u||1/u==1/n)):false}}function Br(n,t,r){var e=true,u=t&&Nt(t,Me);t&&(r||u.length)||(null==r&&(r=t),t=n,n=this,u=Nt(t,Me)),false===r?e=false:Sr(r)&&"chain"in r&&(e=r.chain),r=-1; -for(var o=Ar(n),i=u?u.length:0;++r--n?t.apply(this,arguments):void 0}},U.assign=qe,U.at=function(t){return We.unindexedChars&&Nr(t)&&(t=t.split("")),n(t,Ot(arguments,true,false,1))},U.bind=xr,U.bindAll=function(n){for(var t=n,r=1arguments.length?Kt(t,b|_,null,n):Kt(t,b|_|C,null,n,er(arguments,2))},U.chain=function(n){return new V(n,true)},U.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(p?e(p,l):i(s,l))){for(t=u;--t;){var g=o[t]; -if(0>(g?e(g,l):i(n[t],l)))continue n}p&&p.push(l),s.push(l)}return s},U.invert=function(n,t){for(var r=-1,e=Me(n),u=e.length,o={};++ru?0:u>>>0);for(o||(t=U.createCallback(t,r,3)),Ct(n,function(n,r,u){if(o)for(r=t.length,u=Zr(r);r--;)u[r]=n[t[r]]; -else u=t(n,r,u);i[++e]={a:u,b:e,c:n}}),u=i.length,i.sort(o?l:a);u--;)i[u]=i[u].c;return i},U.tap=function(n,t,r){return t.call(r,n),n},U.throttle=function(n,t,r){var e=true,u=true;if(!Ar(n))throw new ne(E);return false===r?e=false:Sr(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),lt.leading=e,lt.maxWait=+t,lt.trailing=u,Cr(n,t,lt)},U.times=function(n,t,r){n=0>n?0:n>>>0,t=_t(t,r,1),r=-1;for(var e=Zr(n);++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},U.escape=function(n){return null==n?"":Qr(n).replace(L,s)},U.escapeRegExp=Fr,U.every=cr,U.find=pr,U.findIndex=Gt,U.findKey=function(n,t,r){return t=U.createCallback(t,r,3),kt(n,t,It,true)},U.findLast=function(n,t,r){return t=U.createCallback(t,r,3),kt(n,t,jt) -},U.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=U.createCallback(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},U.findLastKey=function(n,t,r){return t=U.createCallback(t,r,3),kt(n,t,Rt,true)},U.findWhere=function(n,t){return pr(n,zr(t))},U.has=function(n,t){return n?ve.call(n,t):false},U.identity=Dr,U.indexOf=Qt,U.isArguments=Or,U.isArray=Ze,U.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&le.call(n)==Q||false},U.isDate=function(n){return n&&typeof n=="object"&&le.call(n)==nt||false -},U.isElement=Er,U.isEmpty=function(n){var t=true;if(!n)return t;var r=n.length;return-1r?Se(e+r,0):Ie(r||0,e-1))+1);e--;)if(n[e]===t)return e;return-1},U.noConflict=function(){return c._=ie,this},U.noop=Ur,U.now=Ge,U.pad=function(n,t,r){n=null==n?"":Qr(n),t=+t;var e=n.length; -return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},U.template=function(n,t,r){var e=U.templateSettings;r=qe({},r,e,gt),n=Qr(null==n?"":n);var u,o,i=qe({},r.imports,e.imports,gt),e=Me(i),i=Lr(i),a=0,l=r.interpolate||q,f="__p+='",l=Hr((r.escape||q).source+"|"+l.source+"|"+(l===$?P:q).source+"|"+(r.evaluate||q).source+"|$","g"); -return n.replace(l,function(t,r,e,i,l,c){return e||(e=i),f+=n.slice(a,c).replace(M,p),r&&(u=true,f+="'+__e("+r+")+'"),l&&(o=true,f+="';"+l+";\n__p+='"),e&&(f+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),f+="';",(r=r.variable)||(f="with(obj){"+f+"}"),f=(o?f.replace(I,""):f).replace(R,"$1").replace(N,"$1;"),f="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}",r=zt(f,e,i,void 0),t?r(t):r -},U.trim=$r,U.trimLeft=function(n,t){return(n=null==n?"":Qr(n))?null==t?n.slice(h(n)):(t=Qr(t),n.slice(o(n,t))):n},U.trimRight=function(n,t){return(n=null==n?"":Qr(n))?null==t?n.slice(0,v(n)+1):(t=Qr(t),n.slice(0,i(n,t)+1)):n},U.truncate=function(n,t){var r=30,e="...";if(t&&Sr(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Qr(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Qr(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e; -if(Rr(u)){if(n.slice(o).search(u)){var i,a,l=n.slice(0,o);for(u.global||(u=Hr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(l);)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(T,y))},U.uniqueId=function(n){var t=++A;return Qr(null==n?"":n)+t},U.all=cr,U.any=wr,U.detect=pr,U.foldl=mr,U.foldr=br,U.include=fr,U.inject=mr,Br(U,function(){var n={};return It(U,function(t,r){U.prototype[r]||(n[r]=t) -}),n}(),false),U.first=Ht,U.last=tr,U.sample=function(n,t,r){return n&&typeof n.length!="number"?n=Lr(n):We.unindexedChars&&Nr(n)&&(n=n.split("")),null==t||r?(t=n?n.length:0,0t?0:+t||0,n.length),n)},U.take=Ht,U.takeRight=tr,U.takeRightWhile=tr,U.takeWhile=Ht,U.head=Ht,It(U,function(n,t){var r="sample"!=t;U.prototype[t]||(U.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new V(o,u):o}) -}),U.VERSION=k,U.prototype.chain=function(){return this.__chain__=true,this},U.prototype.toJSON=lr,U.prototype.toString=function(){return Qr(this.__wrapped__)},U.prototype.value=lr,U.prototype.valueOf=lr,ct(["join","pop","shift"],function(n){var t=te[n];U.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new V(r,n):r}}),ct(["push","reverse","sort","unshift"],function(n){var t=te[n];U.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ct(["concat","splice"],function(n){var t=te[n]; -U.prototype[n]=function(){return new V(t.apply(this.__wrapped__,arguments),this.__chain__)}}),We.spliceObjects||ct(["pop","shift","splice"],function(n){var t=te[n],r="splice"==n;U.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new V(u,n):u}}),U}var m,b=1,_=2,w=4,x=8,C=16,j=32,k="2.4.1",O="__lodash@"+k+"__",E="Expected a function",A=0,S=/^[A-Z]+$/,I=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,T=/&(?:amp|lt|gt|quot|#39);/g,L=/[&<>"']/g,F=/<%-([\s\S]+?)%>/g,W=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,P=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,U=/[\xC0-\xFF]/g,q=/($^)/,Z=/[.*+?^${}()|[\]\/\\]/g,K=/\bthis\b/,M=/['\n\r\u2028\u2029\\]/g,V=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,J=" \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",X="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),Y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),G="[object Arguments]",H="[object Array]",Q="[object Boolean]",nt="[object Date]",tt="[object Error]",rt="[object Function]",et="[object Number]",ut="[object Object]",ot="[object RegExp]",it="[object String]",at={}; -at[rt]=false,at[G]=at[H]=at[Q]=at[nt]=at[et]=at[ut]=at[ot]=at[it]=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","\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,dt=yt&>&&typeof global=="object"&&global; -!dt||dt.global!==dt&&dt.window!==dt&&dt.self!==dt||(vt=dt);var dt=gt&>.exports===yt&&yt,mt=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(vt._=mt, define(function(){return mt})):yt&>?dt?(gt.exports=mt)._=mt:yt._=mt:vt._=mt}).call(this); \ No newline at end of file +;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202>>0:0,u=ue(e);++ra(t,l)&&f.push(l);return f}function Tt(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number"&&-1o?0:o>>>0);return Tt(n,function(n){var o=u?t:null!=n&&n[t];a[++e]=o?o.apply(n,r):m}),a}function Vt(n,t,r,e,u){var o=ar(t);return(o?jt:zt)(t,function(t,a,i){var l=t&&ar(t),f=t&&au(t),c=n[a];if(l||f){for(e||(e=[]),u||(u=[]),f=e.length;f--;)if(e[f]==t)return void(n[a]=u[f]);i=r?r(c,t,a,n,i):m,(f=typeof i!="undefined")||(i=l?ou(c)?c:[]:au(c)?c:{}),e.push(t),u.push(i),f||Vt(i,t,r,e,u),n[a]=i}else i=r?r(c,t,a,n,i):m,typeof i=="undefined"&&(i=t),(o||typeof i!="undefined")&&(n[a]=i) +}),n}function Jt(n,t){var r={};if(typeof t=="function")return Dt(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r;for(var e=-1,u=t.length;++ei(s,g)&&((u||f)&&s.push(g),c.push(p)) +}return c}function Gt(n,t){for(var r=-1,e=t(n),u=e.length,o=ue(u);++re)return t;var u=typeof r[2];if("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2),3o?0:o)}function gr(n,t,e){var u=n?n.length:0;if(typeof e=="number")e=0>e?Ze(u+e,0):e||0;else if(e)return e=mr(n,t),u&&n[e]===t?e:-1;return r(n,t,e)}function hr(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var u=e,o=0;for(t=q.createCallback(t,r,3);u--&&t(n[u],u,n);)o++}else o=null==t||r?1:t;return o=e-(o||0),dr(n,0,0>o?0:o)}function vr(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var u=e,o=0; +for(t=q.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||0),dr(n,0>o?0:o)}function yr(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,u=n?n.length:0,o=0;for(t=q.createCallback(t,r,3);++et?0:t;return dr(n,o)}function dr(n,t,r){var e=-1,u=n?n.length:0;for(t=null==t?0:+t||0,0>t?t=Ze(u+t,0):t>u&&(t=u),r=typeof r=="undefined"?u:+r||0,0>r?r=Ze(u+r,0):r>u&&(r=u),u=t>r?0:r-t,r=ue(u);++e>>1,r(n[e])r?0:r);++tr?Ze(e+r,0):r||0:0,typeof n=="string"||!ou(n)&&Kr(n)?ro&&(o=i)}else t=null==t&&Kr(n)?u:q.createCallback(t,r,3),Tt(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===o)&&(e=r,o=n)});return o}function Rr(n,t){return Sr(n,ee(t))}function Fr(n,t,r,e){var u=3>arguments.length; +if(t=q.createCallback(t,e,4),ou(n)){var o=-1,a=n.length;for(u&&a&&(r=n[++o]);++oarguments.length;return t=q.createCallback(t,e,4),Wt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Lr(n){var t=-1,r=n&&n.length,e=ue(0>r?0:r>>>0);return Tt(n,function(n){var r=Xt(0,++t);e[t]=e[r],e[r]=n}),e}function Tr(n,t,r){var e;if((typeof t!="function"||typeof r!="undefined")&&(t=q.createCallback(t,r,3)),ou(n)){r=-1; +for(var u=n.length;++rarguments.length)return er(n,b,null,t);if(n)var r=n[A]?n[A][2]:n.length,e=dr(arguments,2),r=r-e.length;return er(n,b|x,r,t,e)}function Ur(n,t,r){function e(){var r=t-(pu()-f);0>=r||r>t?(i&&Ae(i),r=p,i=s=p=m,r&&(g=pu(),l=n.apply(c,a),s||i||(a=c=null))):s=Le(e,r)}function u(){s&&Ae(s),i=s=p=m,(v||h!==t)&&(g=pu(),l=n.apply(c,a),s||i||(a=c=null))}function o(){if(a=arguments,f=pu(),c=this,p=v&&(s||!y),false===h)var r=y&&!s; +else{i||y||(g=f);var o=h-(f-g),d=0>=o||o>h;d?(i&&(i=Ae(i)),g=f,l=n.apply(c,a)):i||(i=Le(u,o))}return d&&s?s=Ae(s):s||t===h||(s=Le(e,t)),r&&(d=true,l=n.apply(c,a)),!d||s||i||(a=c=null),l}var a,i,l,f,c,s,p,g=0,h=false,v=true;if(!zr(n))throw new pe(O);if(t=0>t?0:t,true===r)var y=true,v=false;else qr(r)&&(y=r.leading,h="maxWait"in r&&Ze(t,+r.maxWait||0),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Ae(s),i&&Ae(i),i=s=p=m},o}function $r(n){if(!zr(n))throw new pe(O);return function(){return!n.apply(this,arguments) +}}function Pr(n){return Mt(n,Vr)}function Br(n){return n&&typeof n=="object"&&typeof n.length=="number"&&we.call(n)==H||false}function Dr(n){return n&&typeof n=="object"&&1===n.nodeType&&(Ge.nodeClass?-1>>0,e=n.constructor,u=-1,o=e&&n===e.prototype,a=r-1,e=ue(r),i=0t||null==n||!ze(t))return r;n=se(n);do t%2&&(r+=n),t=Ee(t/2),n+=n;while(t);return r}function Gr(n,t){return(n=null==n?"":se(n))?null==t?n.slice(h(n),v(n)+1):(t=se(t),n.slice(o(n,t),a(n,t)+1)):n}function Hr(n,t,r){var e=typeof n,u="function"==e;return!u||typeof t!="undefined"&&"prototype"in n?u||null==n?Ft(n,t,r):"object"==e?ne(n):ee(n):n +}function Qr(n){return n}function ne(n){var t=iu(n),r=t.length,e=t[0],u=r&&n[e];return 1!=r||u!==u||qr(u)?function(e){var u=r;if(u&&!e)return false;for(;u--;){var o=t[u];if(!Ie.call(e,o)||!Zt(e[o],n[o],null,true))return false}return true}:function(n){return n&&Ie.call(n,e)?(n=n[e],u===n&&(0!==u||1/u==1/n)):false}}function te(n,t,r){var e=true,u=t&&Mt(t,iu);t&&(r||u.length)||(null==r&&(r=t),t=n,n=this,u=Mt(t,iu)),false===r?e=false:qr(r)&&"chain"in r&&(e=r.chain),r=-1;for(var o=zr(n),a=u?u.length:0;++r--n?t.apply(this,arguments):void 0}},q.assign=uu,q.at=function(t){return Ge.unindexedChars&&Kr(t)&&(t=t.split("")),n(t,$t(arguments,true,false,1))},q.bind=Wr,q.bindAll=function(n){for(var t=n,r=1arguments.length?er(t,b|_,null,n):er(t,b|_|x,null,n,dr(arguments,2)) +},q.chain=function(n){return new J(n,true)},q.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(p?e(p,l):a(s,l))){for(t=u;--t;){var g=o[t];if(0>(g?e(g,l):a(n[t],l)))continue n}p&&p.push(l),s.push(l)}return s},q.invert=function(n,t){for(var r=-1,e=iu(n),u=e.length,o={};++ru?0:u>>>0);for(o||(t=q.createCallback(t,r,3)),Tt(n,function(n,r,u){if(o)for(r=t.length,u=ue(r);r--;)u[r]=n[t[r]];else u=t(n,r,u);a[++e]={a:u,b:e,c:n}}),u=a.length,a.sort(o?l:i);u--;)a[u]=a[u].c;return a},q.tap=function(n,t,r){return t.call(r,n),n},q.throttle=function(n,t,r){var e=true,u=true;if(!zr(n))throw new pe(O);return false===r?e=false:qr(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),_t.leading=e,_t.maxWait=+t,_t.trailing=u,Ur(n,t,_t) +},q.times=function(n,t,r){n=0>n?0:n>>>0,t=Ft(t,r,1),r=-1;for(var e=ue(n);++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},q.escape=function(n){return null==n?"":se(n).replace(L,s)},q.escapeRegExp=Xr,q.every=Cr,q.find=Ar,q.findIndex=sr,q.findKey=function(n,t,r){return t=q.createCallback(t,r,3),Ut(n,t,zt,true) +},q.findLast=function(n,t,r){return t=q.createCallback(t,r,3),Ut(n,t,Wt)},q.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=q.createCallback(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},q.findLastKey=function(n,t,r){return t=q.createCallback(t,r,3),Ut(n,t,qt,true)},q.findWhere=function(n,t){return Ar(n,ne(t))},q.has=function(n,t){return n?Ie.call(n,t):false},q.identity=Qr,q.indexOf=gr,q.isArguments=Br,q.isArray=ou,q.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&we.call(n)==nt||false +},q.isDate=function(n){return n&&typeof n=="object"&&we.call(n)==tt||false},q.isElement=Dr,q.isEmpty=function(n){var t=true;if(!n)return t;var r=n.length;return-1r?Ze(e+r,0):Ke(r||0,e-1))+1);e--;)if(n[e]===t)return e;return-1},q.noConflict=function(){return c._=_e,this},q.noop=re,q.now=pu,q.pad=function(n,t,r){n=null==n?"":se(n),t=+t; +var e=n.length;return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},q.template=function(n,t,r){var e=q.templateSettings;r=uu({},r,e,kt),n=se(null==n?"":n);var u,o,a=uu({},r.imports,e.imports,kt),e=iu(a),a=Jr(a),i=0,l=r.interpolate||M,f="__p+='",l=ce((r.escape||M).source+"|"+l.source+"|"+(l===U?$:M).source+"|"+(r.evaluate||M).source+"|$","g"); +return n.replace(l,function(t,r,e,a,l,c){return e||(e=a),f+=n.slice(i,c).replace(V,p),r&&(u=true,f+="'+__e("+r+")+'"),l&&(o=true,f+="';"+l+";\n__p+='"),e&&(f+="'+((__t=("+e+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';",(r=r.variable)||(f="with(obj){"+f+"}"),f=(o?f.replace(I,""):f).replace(R,"$1").replace(F,"$1;"),f="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}",r=Ht(f,e,a),t?r(t):r +},q.trim=Gr,q.trimLeft=function(n,t){return(n=null==n?"":se(n))?null==t?n.slice(h(n)):(t=se(t),n.slice(o(n,t))):n},q.trimRight=function(n,t){return(n=null==n?"":se(n))?null==t?n.slice(0,v(n)+1):(t=se(t),n.slice(0,a(n,t)+1)):n},q.trunc=function(n,t){var r=30,e="...";if(t&&qr(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?se(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":se(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e; +if(Zr(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=ce(u.source,(P.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(N,y))},q.uniqueId=function(n){var t=++E;return se(null==n?"":n)+t},q.all=Cr,q.any=Tr,q.detect=Ar,q.foldl=Fr,q.foldr=Nr,q.include=xr,q.inject=Fr,te(q,function(){var n={};return zt(q,function(t,r){q.prototype[r]||(n[r]=t) +}),n}(),false),q.first=pr,q.last=vr,q.sample=function(n,t,r){return n&&typeof n.length!="number"?n=Jr(n):Ge.unindexedChars&&Kr(n)&&(n=n.split("")),null==t||r?(t=n?n.length:0,0t?0:+t||0,n.length),n)},q.take=pr,q.takeRight=vr,q.takeRightWhile=vr,q.takeWhile=pr,q.head=pr,zt(q,function(n,t){var r="sample"!=t;q.prototype[t]||(q.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new J(o,u):o}) +}),q.VERSION=k,q.prototype.chain=function(){return this.__chain__=true,this},q.prototype.toJSON=jr,q.prototype.toString=function(){return se(this.__wrapped__)},q.prototype.value=jr,q.prototype.valueOf=jr,jt(["join","pop","shift"],function(n){var t=ge[n];q.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new J(r,n):r}}),jt(["push","reverse","sort","unshift"],function(n){var t=ge[n];q.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),jt(["concat","splice"],function(n){var t=ge[n]; +q.prototype[n]=function(){return new J(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Ge.spliceObjects||jt(["pop","shift","splice"],function(n){var t=ge[n],r="splice"==n;q.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new J(u,n):u}}),q}var m,b=1,_=2,w=4,j=8,x=16,C=32,k="2.5.0-pre",A="__lodash@"+k+"__",O="Expected a function",E=0,S=/^[A-Z]+$/,I=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,F=/(__e\(.*?\)|\b__t\))\+'';/g,N=/&(?:amp|lt|gt|quot|#39|#96);/g,L=/[&<>"'`]/g,T=/<%-([\s\S]+?)%>/g,W=/<%([\s\S]+?)%>/g,U=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,P=/\w*$/,B=/^\s*function[ \n\r\t]+\w/,D=/^0[xX]/,z=/^\[object .+?Constructor\]$/,q=/[\xC0-\xFF]/g,M=/($^)/,Z=/[.*+?^${}()|[\]\/\\]/g,K=/\bthis\b/,V=/['\n\r\u2028\u2029\\]/g,J=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-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 ArrayBuffer Boolean Date Error Float64Array Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError Uint8Array window WinRTError".split(" "),G="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),H="[object Arguments]",Q="[object Array]",nt="[object Boolean]",tt="[object Date]",rt="[object Error]",et="[object Function]",ut="[object Number]",ot="[object Object]",at="[object RegExp]",it="[object String]",lt="[object ArrayBuffer]",ft="[object Float32Array]",ct="[object Float64Array]",st="[object Int8Array]",pt="[object Int16Array]",gt="[object Int32Array]",ht="[object Uint8Array]",vt="[object Uint8ClampedArray]",yt="[object Uint16Array]",dt="[object Uint32Array]",mt={}; +mt[H]=mt[Q]=mt[ft]=mt[ct]=mt[st]=mt[pt]=mt[gt]=mt[ht]=mt[vt]=mt[yt]=mt[dt]=true,mt[lt]=mt[nt]=mt[tt]=mt[rt]=mt[et]=mt["[object Map]"]=mt[ut]=mt[ot]=mt[at]=mt["[object Set]"]=mt[it]=mt["[object WeakMap]"]=false;var bt={};bt[H]=bt[Q]=bt[lt]=bt[nt]=bt[tt]=bt[rt]=bt[ft]=bt[ct]=bt[st]=bt[pt]=bt[gt]=bt[ut]=bt[ot]=bt[at]=bt[it]=bt[ht]=bt[vt]=bt[yt]=bt[dt]=true,bt[et]=bt["[object Map]"]=bt["[object Set]"]=bt["[object WeakMap]"]=false;var _t={leading:false,maxWait:0,trailing:false},wt={configurable:false,enumerable:false,value:null,writable:false},jt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},xt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ct={\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":" "},kt={"function":true,object:true},At={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ot=kt[typeof window]&&window||this,Et=kt[typeof exports]&&exports&&!exports.nodeType&&exports,kt=kt[typeof module]&&module&&!module.nodeType&&module,St=Et&&kt&&typeof global=="object"&&global; +!St||St.global!==St&&St.window!==St&&St.self!==St||(Ot=St);var St=kt&&kt.exports===Et&&Et,It=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Ot._=It, define(function(){return It})):Et&&kt?St?(kt.exports=It)._=It:Et._=It:Ot._=It}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 7611f17dd..034294890 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) + * Lo-Dash 2.5.0-pre (Custom Build) * Build: `lodash modern -o ./dist/lodash.js` * Copyright 2012-2014 The Dojo Foundation * Based on Underscore.js 1.6.0 @@ -21,7 +21,7 @@ PARTIAL_RIGHT_FLAG = 32; /** Used as the semantic version number */ - var version = '2.4.1'; + var version = '2.5.0-pre'; /** Used as the property name for wrapper metadata */ var expando = '__lodash@' + version + '__'; @@ -41,8 +41,8 @@ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; /** Used to match HTML entities and HTML characters */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, - reUnescapedHtml = /[&<>"']/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, + reUnescapedHtml = /[&<>"'`]/g; /** Used to match template delimiters */ var reEscape = /<%-([\s\S]+?)%>/g, @@ -65,6 +65,9 @@ /** Used to detect hexadecimal string values */ var reHexPrefix = /^0[xX]/; + /** Used to detect host constructors (Safari > 5) */ + var reHostCtor = /^\[object .+?Constructor\]$/; + /** Used to match latin-1 supplement letters */ var reLatin1 = /[\xC0-\xFF]/g; @@ -101,9 +104,10 @@ /** Used to assign default `context` object properties */ var contextProps = [ - 'Array', 'Boolean', 'Date', 'Function', 'Math', 'Number', 'Object', - 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'isNaN', - 'parseInt', 'setTimeout', 'TypeError', 'window', 'WinRTError' + 'Array', 'ArrayBuffer', 'Boolean', 'Date', 'Float64Array', 'Function', + 'Math', 'Number', 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', + 'document', 'isFinite', 'isNaN','parseInt', 'setTimeout', 'TypeError', + 'Uint8Array', 'window', 'WinRTError' ]; /** Used to make template sourceURLs easier to identify */ @@ -116,18 +120,54 @@ dateClass = '[object Date]', errorClass = '[object Error]', funcClass = '[object Function]', + mapClass = '[object Map]', numberClass = '[object Number]', objectClass = '[object Object]', regexpClass = '[object RegExp]', - stringClass = '[object String]'; + setClass = '[object Set]', + stringClass = '[object String]', + weakMapClass = '[object WeakMap]'; + + var arrayBufferClass = '[object ArrayBuffer]', + float32Class = '[object Float32Array]', + float64Class = '[object Float64Array]', + int8Class = '[object Int8Array]', + int16Class = '[object Int16Array]', + int32Class = '[object Int32Array]', + uint8Class = '[object Uint8Array]', + uint8ClampedClass = '[object Uint8ClampedArray]', + uint16Class = '[object Uint16Array]', + uint32Class = '[object Uint32Array]'; + + /** Used to identify object classifications that are treated like arrays */ + var arrayLikeClasses = {}; + arrayLikeClasses[argsClass] = + arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = + arrayLikeClasses[float64Class] = arrayLikeClasses[int8Class] = + arrayLikeClasses[int16Class] = arrayLikeClasses[int32Class] = + arrayLikeClasses[uint8Class] = arrayLikeClasses[uint8ClampedClass] = + arrayLikeClasses[uint16Class] = arrayLikeClasses[uint32Class] = true; + arrayLikeClasses[arrayBufferClass] = arrayLikeClasses[boolClass] = + arrayLikeClasses[dateClass] = arrayLikeClasses[errorClass] = + arrayLikeClasses[funcClass] = arrayLikeClasses[mapClass] = + arrayLikeClasses[numberClass] = arrayLikeClasses[objectClass] = + arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = + arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; /** Used to identify object classifications that `_.clone` supports */ var cloneableClasses = {}; - cloneableClasses[funcClass] = false; - cloneableClasses[argsClass] = cloneableClasses[arrayClass] = + cloneableClasses[argsClass] = + cloneableClasses[arrayClass] = cloneableClasses[arrayBufferClass] = cloneableClasses[boolClass] = cloneableClasses[dateClass] = + cloneableClasses[errorClass] = cloneableClasses[float32Class] = + cloneableClasses[float64Class] = cloneableClasses[int8Class] = + cloneableClasses[int16Class] = cloneableClasses[int32Class] = cloneableClasses[numberClass] = cloneableClasses[objectClass] = - cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; + cloneableClasses[regexpClass] = cloneableClasses[stringClass] = + cloneableClasses[uint8Class] = cloneableClasses[uint8ClampedClass] = + cloneableClasses[uint16Class] = cloneableClasses[uint32Class] = true; + cloneableClasses[funcClass] = cloneableClasses[mapClass] = + cloneableClasses[setClass] = cloneableClasses[weakMapClass] = false; /** Used as an internal `_.debounce` options object by `_.throttle` */ var debounceOptions = { @@ -148,17 +188,23 @@ * Used to convert characters to HTML entities. * * Note: Though the ">" character is escaped for symmetry, characters like - * ">", "`", and "/" don't require escaping in HTML and have no special meaning + * ">" and "/" don't require escaping in HTML and have no special meaning * unless they're part of a tag or unquoted attribute value. * See [Mathias' article](http://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can be used to + * break out of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. */ var htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', - "'": ''' + "'": ''', + '`': '`' }; /** Used to convert HTML entities to characters */ @@ -167,7 +213,8 @@ '<': '<', '>': '>', '"': '"', - ''': "'" + ''': "'", + '`': '`' }; /** @@ -546,11 +593,9 @@ /** Native constructor references */ var Array = context.Array, - Boolean = context.Boolean, Date = context.Date, Function = context.Function, Math = context.Math, - Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, @@ -564,8 +609,8 @@ /** Used to detect DOM support */ var document = (document = context.window) && document.document; - /** Used to restore the original `_` reference in `_.noConflict` */ - var oldDash = context._; + /** Used to resolve the decompiled source of functions */ + var fnToString = Function.prototype.toString; /** * Used as the maximum length of an array-like object. @@ -574,6 +619,9 @@ */ var maxSafeInteger = Math.pow(2, 53) - 1; + /** Used to restore the original `_` reference in `_.noConflict` */ + var oldDash = context._; + /** Used to resolve the internal `[[Class]]` of values */ var toString = objectProto.toString; @@ -584,10 +632,12 @@ ); /** Native method shortcuts */ - var ceil = Math.ceil, + var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, + bufferSlice = isNative(bufferSlice = ArrayBuffer && (new ArrayBuffer).slice) && bufferSlice, + ceil = Math.ceil, clearTimeout = context.clearTimeout, + Float64Array = isNative(Float64Array = context.Float64Array) && Float64Array, floor = Math.floor, - fnToString = Function.prototype.toString, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, @@ -595,6 +645,7 @@ Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, + Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, unshift = arrayProto.unshift; /** Used to set metadata on functions */ @@ -621,17 +672,6 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used to lookup built-in constructors by `[[Class]]` */ - var ctorByClass = {}; - ctorByClass[arrayClass] = Array; - ctorByClass[boolClass] = Boolean; - ctorByClass[dateClass] = Date; - ctorByClass[funcClass] = Function; - ctorByClass[objectClass] = Object; - ctorByClass[numberClass] = Number; - ctorByClass[regexpClass] = RegExp; - ctorByClass[stringClass] = String; - /*--------------------------------------------------------------------------*/ /** @@ -685,15 +725,11 @@ * var wrapped = _([1, 2, 3]); * * // returns an unwrapped value - * wrapped.reduce(function(sum, num) { - * return sum + num; - * }); + * wrapped.reduce(function(sum, n) { return sum + n; }); * // => 6 * * // returns a wrapped value - * var squares = wrapped.map(function(num) { - * return num * num; - * }); + * var squares = wrapped.map(function(n) { return n * n; }); * * _.isArray(squares); * // => false @@ -951,9 +987,6 @@ * @returns {Object} Returns the destination object. */ function baseAssign(object, source, callback) { - if (!object) { - return object; - } var index = -1, props = keys(source), length = props.length; @@ -1031,18 +1064,32 @@ if (!cloneableClasses[className]) { return value; } - var ctor = ctorByClass[className]; + var Ctor = value.constructor; + if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { + Ctor = Object; + } switch (className) { + case arrayBufferClass: + return cloneBuffer(value); + case boolClass: case dateClass: - return new ctor(+value); + return new Ctor(+value); + + case errorClass: + return new Ctor(value.message); + + case float32Class: case float64Class: + case int8Class: case int16Class: case int32Class: + case uint8Class: case uint8ClampedClass: case uint16Class: case uint32Class: + return value.subarray(0); case numberClass: case stringClass: - return new ctor(value); + return new Ctor(value); case regexpClass: - result = ctor(value.source, reFlags.exec(value)); + result = Ctor(value.source, reFlags.exec(value)); result.lastIndex = value.lastIndex; return result; } @@ -1061,7 +1108,7 @@ return stackB[length]; } } - result = isArr ? ctor(value.length) : {}; + result = isArr ? Ctor(value.length) : Ctor(); } else { result = isArr ? slice(value) : baseAssign({}, value); @@ -1165,15 +1212,15 @@ case 1: return function(value) { return func.call(thisArg, value); }; - case 2: return function(value, other) { - return func.call(thisArg, value, other); - }; case 3: return function(value, index, collection) { return func.call(thisArg, value, index, collection); }; case 4: return function(accumulator, value, index, collection) { return func.call(thisArg, accumulator, value, index, collection); }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; } return bind(func, thisArg); } @@ -1527,7 +1574,7 @@ * @param {*} value The value to compare to `other`. * @param {*} other The value to compare to `value`. * @param {Function} [callback] The function to customize comparing values. - * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. + * @param {boolean} [isWhere=false] A flag to indicate performing partial comparisons. * @param {Array} [stackA=[]] Tracks traversed `value` objects. * @param {Array} [stackB=[]] Tracks traversed `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. @@ -1578,13 +1625,15 @@ // but treat `-0` vs. `+0` as not equal : (value == 0 ? (1 / value == 1 / other) : value == +other); + case errorClass: case regexpClass: case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) + // coerce errors (http://es5.github.io/#x15.11.4.4) + // and regexes (http://es5.github.io/#x15.10.6.4) to strings // treat string primitives and their corresponding object instances as equal return value == String(other); } - var isArr = valClass == arrayClass; + var isArr = arrayLikeClasses[valClass]; if (!isArr) { // exit for functions and DOM nodes if (valClass != objectClass) { @@ -1746,11 +1795,9 @@ * @returns {Object} Returns the destination object. */ function baseMerge(object, source, callback, stackA, stackB) { - if (!object) { - return object; - } - (isArray(source) ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { - var isArr = srcValue && isArray(srcValue), + var isSrcArr = isArrayLike(source); + (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { + var isArr = srcValue && isArrayLike(srcValue), isObj = srcValue && isPlainObject(srcValue), value = object[key]; @@ -1759,10 +1806,9 @@ if (typeof result == 'undefined') { result = srcValue; } - if (typeof result != 'undefined') { - value = result; + if (isSrcArr || typeof result != 'undefined') { + object[key] = result; } - object[key] = value; return; } // avoid merging previously merged cyclic sources @@ -1779,22 +1825,21 @@ var result = callback ? callback(value, srcValue, key, object, source) : undefined, isShallow = typeof result != 'undefined'; - if (isShallow) { - value = result; - } else { - value = isArr + if (!isShallow) { + result = isArr ? (isArray(value) ? value : []) : (isPlainObject(value) ? value : {}); } - // add `source` and associated `value` to the stack of traversed objects + // add the source value to the stack of traversed objects + // and associate it with its merged value stackA.push(srcValue); - stackB.push(value); + stackB.push(result); // recursively merge objects and arrays (susceptible to call stack limits) if (!isShallow) { - baseMerge(value, srcValue, callback, stackA, stackB); + baseMerge(result, srcValue, callback, stackA, stackB); } - object[key] = value; + object[key] = result; }); return object; @@ -1957,7 +2002,7 @@ /** * Compiles a function from `source` using the `varNames` and `varValues` * pairs to import free variables into the compiled function. If `sourceURL` - * is provided it will be used as the sourceURL for the compiled function. + * is provided it is used as the sourceURL for the compiled function. * * @private * @param {string} source The source to compile. @@ -2046,7 +2091,7 @@ * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection * through a callback. The given setter function sets the keys and values of - * the accumulator object. If `initializer` is provided it will be used to + * the accumulator object. If `initializer` is provided it is used to * initialize the accumulator object. * * @private @@ -2099,7 +2144,7 @@ } // juggle arguments if (length > 3 && typeof args[length - 2] == 'function') { - var callback = baseCreateCallback(args[--length - 1], args[length--], 2); + var callback = baseCreateCallback(args[--length - 1], args[length--], 5); } else if (length > 2 && typeof args[length - 1] == 'function') { callback = args[--length]; } @@ -2288,6 +2333,18 @@ return result === indexOf ? baseIndexOf : result; } + /** + * Checks if `value` is an array-like object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + */ + function isArrayLike(value) { + return (value && typeof value == 'object' && typeof value.length == 'number' && + arrayLikeClasses[toString.call(value)]) || false; + } + /** * Checks if `value` is a native function. * @@ -2296,7 +2353,40 @@ * @returns {boolean} Returns `true` if `value` is a native function, else `false`. */ function isNative(value) { - return typeof value == 'function' && reNative.test(fnToString.call(value)); + var type = typeof value; + return type == 'function' + ? reNative.test(fnToString.call(value)) + : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; + } + + /** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneBuffer(buffer) { + return bufferSlice.call(buffer, 0); + } + if (!bufferSlice) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` + cloneBuffer = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + var byteLength = buffer.byteLength, + floatLength = Float64Array ? floor(byteLength / 8) : 0, + offset = floatLength * 8, + result = new ArrayBuffer(byteLength); + + if (floatLength) { + var view = new Float64Array(result, 0, floatLength); + view.set(new Float64Array(buffer, 0, floatLength)); + } + if (byteLength != offset) { + view = new Uint8Array(result, offset); + view.set(new Uint8Array(buffer, offset)); + } + return result; + }; } /** @@ -2322,13 +2412,13 @@ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. */ function shimIsPlainObject(value) { - var ctor, + var Ctor, result; // avoid non `Object` objects, `arguments` objects, and DOM elements if (!(value && toString.call(value) == objectClass) || (!hasOwnProperty.call(value, 'constructor') && - (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor)))) { + (Ctor = value.constructor, isFunction(Ctor) && !(Ctor instanceof Ctor)))) { return false; } // In most environments an object's own properties are iterated before @@ -2483,14 +2573,14 @@ /** * Creates a slice of `array` excluding elements dropped from the end. - * Elements will be dropped until the predicate returns falsey. The predicate - * is bound to `thisArg` and invoked with three arguments; (value, index, array). + * Elements are dropped until the predicate returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2503,9 +2593,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropRightWhile([1, 2, 3], function(num) { - * return num > 1; - * }); + * _.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); * // => [1] * * var characters = [ @@ -2526,14 +2614,14 @@ /** * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements will be dropped until the predicate returns falsey. The predicate - * is bound to `thisArg` and invoked with three arguments; (value, index, array). + * Elements are dropped until the predicate returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2546,9 +2634,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropWhile([1, 2, 3], function(num) { - * return num < 3; - * }); + * _.dropWhile([1, 2, 3], function(n) { return n < 3; }); * // => [3] * * var characters = [ @@ -2572,10 +2658,10 @@ * element the predicate returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2583,8 +2669,8 @@ * @category Arrays * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -2626,10 +2712,10 @@ * of a collection from right to left. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2637,8 +2723,8 @@ * @category Arrays * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -2715,16 +2801,16 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` - * is truthy, the array will only be flattened a single level. If a callback - * is provided each element of the array is passed through the callback before + * is truthy, the array is only flattened a single level. If a callback is + * provided each element of the array is passed through the callback before * flattening. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2733,7 +2819,7 @@ * @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] The function called per iteration. - * If a property name or object is provided it will be used to create a "_.pluck" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new flattened array. @@ -2781,7 +2867,7 @@ /** * Gets the index at which the first occurrence of `value` is found using * strict equality for comparisons, i.e. `===`. If the array is already sorted - * providing `true` for `fromIndex` will run a faster binary search. + * providing `true` for `fromIndex` performs a faster binary search. * * @static * @memberOf _ @@ -3050,10 +3136,10 @@ * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * Note: Unlike `_.filter`, this method mutates `array`. @@ -3063,14 +3149,14 @@ * @category Arrays * @param {Array} array The array to modify. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new array of removed elements. * @example * * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(num) { return num % 2 == 0; }); + * var evens = _.remove(array, function(n) { return n % 2 == 0; }); * * console.log(array); * // => [1, 3] @@ -3172,15 +3258,15 @@ /** * Uses a binary search to determine the smallest index at which a value * should be inserted into a given sorted array in order to maintain the sort - * order of the array. If a callback is provided it will be executed for - * `value` and each element of `array` to compute their sort ranking. The - * callback is bound to `thisArg` and invoked with one argument; (value). + * order of the array. If a callback is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The callback + * is bound to `thisArg` and invoked with one argument; (value). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3189,8 +3275,8 @@ * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. @@ -3289,15 +3375,15 @@ var takeRight = last; /** - * Creates a slice of `array` with elements taken from the end. Elements will - * be taken until the predicate returns falsey. The predicate is bound to - * `thisArg` and invoked with three arguments; (value, index, array). + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until the predicate returns falsey. The predicate is bound to `thisArg` + * and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3310,9 +3396,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeRightWhile([1, 2, 3], function(num) { - * return num > 1; - * }); + * _.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); * // => [2, 3] * * var characters = [ @@ -3333,14 +3417,14 @@ /** * Creates a slice of `array` with elements taken from the beginning. Elements - * will be taken until the predicate returns falsey. The predicate is bound - * to `thisArg` and invoked with three arguments; (value, index, array). + * are taken until the predicate returns falsey. The predicate is bound to + * `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3353,9 +3437,7 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeWhile([1, 2, 3], function(num) { - * return num < 3; - * }); + * _.takeWhile([1, 2, 3], function(n) { return n < 3; }); * // => [1, 2] * * var characters = [ @@ -3394,17 +3476,17 @@ /** * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. If the array is sorted, providing `true` for - * `isSorted` will use a faster algorithm. If a callback is provided it will - * be executed for each value in the array to generate the criterion by which - * uniqueness is computed. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index, array). + * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a + * faster search algorithm for sorted arrays. If a callback is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3414,26 +3496,26 @@ * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new duplicate-value-free array. * @example * - * _.uniq([1, 2, 1, 3, 1]); - * // => [1, 2, 3] + * _.uniq([1, 2, 1]); + * // => [1, 2] * * // using `isSorted` - * _.uniq([1, 1, 2, 2, 3], true); - * // => [1, 2, 3] + * _.uniq([1, 1, 2], true); + * // => [1, 2] * * // using `callback` - * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); - * // => ['A', 'b', 'C'] + * _.uniq(['A', 'b', 'a', 'B'], function(chr) { return chr.toLowerCase(); }); + * // => ['A', 'b'] * * // using `callback` with `thisArg` - * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2.5, 3] + * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); + * // => [1, 2.5] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); @@ -3518,7 +3600,7 @@ * Creates an array of grouped elements, the first of which contains the first * elements of the given arrays, the second of which contains the second elements * of the given arrays, and so on. If a zipped value is provided its corresponding - * unzipped value will be returned. + * unzipped value is returned. * * @static * @memberOf _ @@ -3785,10 +3867,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3796,16 +3878,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': 1, '6': 2 } * - * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': 1, '6': 2 } * * _.countBy(['one', 'two', 'three'], 'length'); @@ -3821,10 +3903,10 @@ * (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3833,8 +3915,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if all elements passed the predicate check, * else `false`. @@ -3886,10 +3968,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3898,13 +3980,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var evens = _.filter([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [2, 4] * * var characters = [ @@ -3950,10 +4032,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3962,8 +4044,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -4007,15 +4089,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.findLast([1, 2, 3, 4], function(num) { - * return num % 2 == 1; - * }); + * _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); * // => 3 */ function findLast(collection, predicate, thisArg) { @@ -4071,10 +4151,10 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * _([1, 2, 3]).forEach(function(n) { console.log(n); }).join(','); * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { console.log(n); }); * // => logs each number and returns the object (property order is not guaranteed across environments) */ function forEach(collection, callback, thisArg) { @@ -4102,7 +4182,7 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); * // => logs each number from right to left and returns '3,2,1' */ function forEachRight(collection, callback, thisArg) { @@ -4124,10 +4204,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4135,16 +4215,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * * // using "_.pluck" callback shorthand @@ -4167,10 +4247,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4178,8 +4258,8 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -4205,8 +4285,8 @@ /** * Invokes the method named by `methodName` on each element in the collection * returning an array of the results of each invoked method. Additional arguments - * will be provided to each invoked method. If `methodName` is a function it - * will be invoked for, and `this` bound to, each element in the collection. + * is provided to each invoked method. If `methodName` is a function it is + * invoked for, and `this` bound to, each element in the collection. * * @static * @memberOf _ @@ -4234,10 +4314,10 @@ * three arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4246,16 +4326,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new mapped array. * @example * - * _.map([1, 2, 3], function(num) { return num * 3; }); + * _.map([1, 2, 3], function(n) { return n * 3; }); * // => [3, 6, 9] * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); + * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); * // => [3, 6, 9] (property order is not guaranteed across environments) * * var characters = [ @@ -4284,17 +4364,17 @@ } /** - * Retrieves the maximum value of a collection. If the collection is empty or - * falsey `-Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the maximum value of a collection. If the collection is empty + * or falsey `-Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4302,7 +4382,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. @@ -4362,17 +4442,17 @@ } /** - * Retrieves the minimum value of a collection. If the collection is empty or - * falsey `Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the minimum value of a collection. If the collection is empty + * or falsey `Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4380,7 +4460,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. @@ -4446,10 +4526,10 @@ * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4457,16 +4537,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the array of grouped elements. * @example * - * _.partition([1, 2, 3], function(num) { return num % 2; }); + * _.partition([1, 2, 3], function(n) { return n % 2; }); * // => [[1, 3], [2]] * - * _.partition([1.2, 2.3, 3.4], function(num) { return this.floor(num) % 2; }, Math); + * _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); * // => [[1, 3], [2]] * * var characters = [ @@ -4514,9 +4594,9 @@ * Reduces a collection to a value which is the accumulated result of running * each element in the collection through the callback, where each successive * callback execution consumes the return value of the previous execution. If - * `accumulator` is not provided the first element of the collection will be - * used as the initial `accumulator` value. The callback is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, index|key, collection). + * `accumulator` is not provided the first element of the collection is used + * as the initial `accumulator` value. The callback is bound to `thisArg` and + * invoked with four arguments; (accumulator, value, index|key, collection). * * @static * @memberOf _ @@ -4529,13 +4609,11 @@ * @returns {*} Returns the accumulated value. * @example * - * var sum = _.reduce([1, 2, 3], function(sum, num) { - * return sum + num; - * }); + * var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); * // => 6 * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; + * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; * return result; * }, {}); * // => { 'a': 3, 'b': 6, 'c': 9 } @@ -4600,10 +4678,10 @@ * the predicate does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4611,13 +4689,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var odds = _.reject([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [1, 3] * * var characters = [ @@ -4731,10 +4809,10 @@ * with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4743,8 +4821,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if any element passed the predicate check, * else `false`. @@ -4793,18 +4871,18 @@ /** * Creates an array of elements, sorted in ascending order by the results of * running each element in a collection through the callback. This method - * performs a stable sort, that is, it will preserve the original sort order - * of equal elements. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an array of property names is provided for `callback` the collection - * will be sorted by each property value. + * is sorted by each property value. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -4812,16 +4890,16 @@ * @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. + * called per iteration. If a property name or object is provided it is + * used to create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new sorted array. * @example * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); + * _.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); * // => [3, 1, 2] * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + * _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); * // => [3, 1, 2] * * var characters = [ @@ -5002,7 +5080,7 @@ * Binds methods of an object to the object itself, overwriting the existing * method. Method names may be specified as individual arguments or as arrays * of method names. If no method names are provided all enumerable function - * properties, own and inherited, of `object` will be bound. + * properties, own and inherited, of `object` are bound. * * Note: This method does not set the `length` property of bound functions. * @@ -5054,7 +5132,7 @@ * Creates a function that invokes the method at `object[key]` and prepends * any additional `bindKey` arguments to those provided to the bound function. * This method differs from `_.bind` by allowing bound functions to reference - * methods that will be redefined or don't yet exist. + * methods that may be redefined or don't yet exist. * See [Peter Michaux's article](http://michaux.ca/articles/lazy-function-definition-pattern) * for more details. * @@ -5180,14 +5258,15 @@ } /** - * Creates a function that will delay the execution of `func` until after - * `wait` milliseconds have elapsed since the last time it was invoked. - * Provide an options object to indicate that `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. Subsequent calls - * to the debounced function will return the result of the last `func` call. + * Creates a function that delays the execution of `func` until after `wait` + * milliseconds have elapsed since the last time it was invoked. The created + * function comes with a `cancel` method to cancel delayed calls. Provide an + * options object to indicate that `func` should be invoked on the leading + * and/or trailing edge of the `wait` timeout. Subsequent calls to the + * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the debounced function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -5203,8 +5282,7 @@ * @example * * // avoid costly calculations while the window size is in flux - * var lazyLayout = _.debounce(calculateLayout, 150); - * jQuery(window).on('resize', lazyLayout); + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * * // execute `sendMail` when the click event is fired, debouncing subsequent calls * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { @@ -5214,9 +5292,26 @@ * * // ensure `batchLog` is executed once after 1 second of debounced calls * var source = new EventSource('/stream'); - * source.addEventListener('message', _.debounce(batchLog, 250, { + * jQuery(source).on('message', _.debounce(batchLog, 250, { * 'maxWait': 1000 * }, false); + * + * // cancel a debounced call + * var todoChanges = _.debounce(batchLog, 1000); + * Object.observe(models.todo, todoChanges); + * + * Object.observe(models, function(changes) { + * if (_.find(changes, { 'name': 'todo', 'type': 'delete'})) { + * todoChanges.cancel(); + * } + * }, ['delete']); + * + * // ...at some point `models.todo` is changed + * models.todo.completed = true; + * + * // ...before 1 second has passed `models.todo` is deleted + * // which cancels the debounced `todoChanges` call + * delete models.todo; */ function debounce(func, wait, options) { var args, @@ -5242,7 +5337,18 @@ maxWait = 'maxWait' in options && nativeMax(wait, +options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } - var delayed = function() { + + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + } + + function delayed() { var remaining = wait - (now() - stamp); if (remaining <= 0 || remaining > wait) { if (maxTimeoutId) { @@ -5260,9 +5366,9 @@ } else { timeoutId = setTimeout(delayed, remaining); } - }; + } - var maxDelayed = function() { + function maxDelayed() { if (timeoutId) { clearTimeout(timeoutId); } @@ -5274,9 +5380,9 @@ args = thisArg = null; } } - }; + } - return function() { + function debounced() { args = arguments; stamp = now(); thisArg = this; @@ -5316,12 +5422,14 @@ args = thisArg = null; } return result; - }; + } + debounced.cancel = cancel; + return debounced; } /** - * Defers executing the `func` function until the current call stack has cleared. - * Additional arguments will be provided to `func` when it is invoked. + * Defers executing the `func` function until the current call stack has + * cleared. Additional arguments are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -5344,7 +5452,7 @@ /** * Executes the `func` function after `wait` milliseconds. Additional arguments - * will be provided to `func` when it is invoked. + * are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -5368,11 +5476,11 @@ /** * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it will be used to determine the cache key for storing the result - * based on the arguments provided to the memoized function. By default, the - * first argument provided to the memoized function is used as the cache key. - * The `func` is executed with the `this` binding of the memoized function. - * The result cache is exposed as the `cache` property on the memoized function. + * provided it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the cache key. The `func` is + * executed with the `this` binding of the memoized function. The result cache + * is exposed as the `cache` property on the memoized function. * * @static * @memberOf _ @@ -5431,8 +5539,8 @@ * @returns {Function} Returns the new function. * @example * - * function isEven(num) { - * return num % 2 == 0; + * function isEven(n) { + * return n % 2 == 0; * } * * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); @@ -5448,8 +5556,8 @@ } /** - * Creates a function that is restricted to execute `func` once. Repeat calls to - * the function will return the value of the first call. The `func` is executed + * Creates a function that is restricted to execute `func` once. Repeat calls + * to the function return the value of the first call. The `func` is executed * with the `this` binding of the created function. * * @static @@ -5551,14 +5659,15 @@ } /** - * Creates a function that, when executed, will only call the `func` function - * at most once per every `wait` milliseconds. Provide an options object to - * indicate that `func` should be invoked on the leading and/or trailing edge - * of the `wait` timeout. Subsequent calls to the throttled function will - * return the result of the last `func` call. + * Creates a function that only calls the `func` function at most once per + * every `wait` milliseconds. The created function comes with a `cancel` method + * to cancel delayed calls. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the throttled function return the result of the last + * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * * @static @@ -5573,13 +5682,14 @@ * @example * * // avoid excessively updating the position while scrolling - * var throttled = _.throttle(updatePosition, 100); - * jQuery(window).on('scroll', throttled); + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) + * jQuery('.interactive').on('click', throttled); + * + * // cancel a trailing throttled call + * jQuery(window).on('popstate', throttled.cancel); */ function throttle(func, wait, options) { var leading = true, @@ -5630,10 +5740,10 @@ /** * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources will overwrite property assignments of previous - * sources. If a callback is provided it will be executed to produce the - * assigned values. The callback is bound to `thisArg` and invoked with - * five arguments; (objectValue, sourceValue, key, object, source). + * object. Subsequent sources overwrite property assignments of previous + * sources. If a callback is provided it is executed to produce the assigned + * values. The callback is bound to `thisArg` and invoked with five arguments; + * (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -5646,24 +5756,24 @@ * @returns {Object} Returns the destination object. * @example * - * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); - * // => { 'name': 'fred', 'employer': 'slate' } + * _.assign({ 'name': 'fred' }, { 'age': 40 }, { 'employer': 'slate' }); + * // => { 'name': 'fred', 'age': 40, 'employer': 'slate' } * * var defaults = _.partialRight(_.assign, function(value, other) { * return typeof value == 'undefined' ? other : value; * }); * - * defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ var assign = createAssigner(baseAssign); /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects will also - * be cloned, otherwise they will be assigned by reference. If a callback - * is provided it will be executed to produce the cloned values. If the - * callback returns `undefined` cloning will be handled by the method instead. - * The callback is bound to `thisArg` and invoked with two argument; (value, index|key). + * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, + * otherwise they are assigned by reference. If a callback is provided it is + * executed to produce the cloned values. If the callback returns `undefined` + * cloning is handled by the method instead. The callback is bound to `thisArg` + * and invoked with two argument; (value, index|key). * * Note: This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and @@ -5723,10 +5833,10 @@ } /** - * Creates a deep clone of `value`. If a callback is provided it will be - * executed to produce the cloned values. If the callback returns `undefined` - * cloning will be handled by the method instead. The callback is bound to - * `thisArg` and invoked with two argument; (value, index|key). + * Creates a deep clone of `value`. If a callback is provided it is executed + * to produce the cloned values. If the callback returns `undefined` cloning + * is handled by the method instead. The callback is bound to `thisArg` and + * invoked with two argument; (value, index|key). * * Note: This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and @@ -5808,7 +5918,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property will be ignored. + * property is set, additional defaults of the same property are ignored. * * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. @@ -5822,8 +5932,8 @@ * @returns {Object} Returns the destination object. * @example * - * _.defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * _.defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ function defaults(object) { if (!object) { @@ -5839,10 +5949,10 @@ * first element the predicate returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -5850,8 +5960,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -5885,10 +5995,10 @@ * a collection in the opposite order. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -5896,8 +6006,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -6005,7 +6115,7 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) @@ -6030,7 +6140,7 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' @@ -6081,7 +6191,7 @@ /** * Creates an object composed of the inverted keys and values of the given * object. If the given object contains duplicate values, subsequent values - * will overwrite property assignments of previous values unless `multiValue` + * overwrite property assignments of previous values unless `multiValue` * is `true`. * * @static @@ -6285,10 +6395,10 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent. If a callback is provided it will be executed to compare - * values. If the callback returns `undefined` comparisons will be handled - * by the method instead. The callback is bound to `thisArg` and invoked - * with three arguments; (value, other, key). + * equivalent. If a callback is provided it is executed to compare values. + * If the callback returns `undefined` comparisons are handled by the method + * instead. The callback is bound to `thisArg` and invoked with three arguments; + * (value, other, key). * * Note: This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes @@ -6323,7 +6433,7 @@ * // => true */ function isEqual(value, other, callback, thisArg) { - callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2); + callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 3); if (!callback) { // exit early for identical values @@ -6367,7 +6477,7 @@ /** * Checks if `value` is, or can be coerced to, a finite number. * - * Note: This method is not the same as native `isFinite` which will return + * Note: This method is not the same as native `isFinite` which returns * `true` for booleans and empty strings. See the [ES5 spec](http://es5.github.io/#x15.1.2.5) * for more details. * @@ -6451,7 +6561,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which will return `true` + * Note: This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -6653,11 +6763,11 @@ * // => ['x', 'y'] (property order is not guaranteed across environments) */ var keys = !nativeKeys ? shimKeys : function(object) { - var ctor = object && object.constructor, + var Ctor = object && object.constructor, length = object ? object.length : 0; - if ((typeof length == 'number' && length > 0) || - (ctor && object === ctor.prototype)) { + if ((Ctor && object === Ctor.prototype) || + (typeof length == 'number' && length > 0)) { return shimKeys(object); } return isObject(object) ? nativeKeys(object) : []; @@ -6692,9 +6802,9 @@ (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) >>> 0; var keyIndex, - ctor = object.constructor, + Ctor = object.constructor, index = -1, - isProto = ctor && object === ctor.prototype, + isProto = Ctor && object === Ctor.prototype, maxIndex = length - 1, result = Array(length), skipIndexes = length > 0; @@ -6718,10 +6828,10 @@ * (value, key, object). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -6729,13 +6839,13 @@ * @category Objects * @param {Object} object The object 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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the new mapped object. * @example * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; }); + * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; }); * // => { 'a': 3, 'b': 6, 'c': 9 } * * var characters = { @@ -6760,11 +6870,11 @@ /** * Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined` into the destination object. Subsequent sources - * will overwrite property assignments of previous sources. If a callback is - * provided it will be executed to produce the merged values of the destination - * and source properties. If the callback returns `undefined` merging will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with five arguments; (objectValue, sourceValue, key, object, source). + * overwrite property assignments of previous sources. If a callback is provided + * it is executed to produce the merged values of the destination and source + * properties. If the callback returns `undefined` merging is handled by the + * method instead. The callback is bound to `thisArg` and invoked with five + * arguments; (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -6813,9 +6923,9 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` omitting the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` omitting the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -6883,9 +6993,9 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` picking the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` picking the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -6934,28 +7044,28 @@ * @returns {*} Returns the accumulated value. * @example * - * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8], function(result, num) { - * num *= num; - * if (num % 2) { - * return result.push(num) < 3; + * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { + * n *= n; + * if (n % 2) { + * return result.push(n) < 3; * } * }); * // => [1, 9, 25] * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; + * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; * }); * // => { 'a': 3, 'b': 6, 'c': 9 } */ function transform(object, callback, accumulator, thisArg) { - var isArr = isArray(object); + var isArr = isArrayLike(object); if (accumulator == null) { if (isArr) { accumulator = []; } else { if (isObject(object)) { - var ctor = object.constructor, - proto = ctor && ctor.prototype; + var Ctor = object.constructor, + proto = Ctor && Ctor.prototype; } accumulator = baseCreate(proto); } @@ -7356,9 +7466,9 @@ * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. If - * a data object is provided the interpolated template string will be returned. + * a data object is provided the interpolated template string is returned. * Data properties may be accessed as free variables in the template. If a - * settings object is provided it will override `_.templateSettings` for the + * settings object is provided it overrides `_.templateSettings` for the * template. * * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. @@ -7622,8 +7732,8 @@ /** * 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 "...". + * The last characters of the truncated string are replaced with the omission + * string which defaults to "...". * * @static * @memberOf _ @@ -7636,22 +7746,22 @@ * @returns {string} Returns the truncated string. * @example * - * _.truncate('hi-diddly-ho there, neighborino'); + * _.trunc('hi-diddly-ho there, neighborino'); * // => 'hi-diddly-ho there, neighbo...' * - * _.truncate('hi-diddly-ho there, neighborino', 24); + * _.trunc('hi-diddly-ho there, neighborino', 24); * // => 'hi-diddly-ho there, n...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); * // => 'hi-diddly-ho there,...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); * //=> 'hi-diddly-ho there...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); * // => 'hi-diddly-ho there, neig [...]' */ - function truncate(string, options) { + function trunc(string, options) { var length = 30, omission = '...'; @@ -7750,9 +7860,9 @@ /** * Creates a function bound to an optional `thisArg`. If `func` is a property - * name the created callback will return the property value for a given element. - * If `func` is an object the created callback will return `true` for elements - * that contain the equivalent object properties, otherwise it will return `false`. + * name the created callback returns the property value for a given element. + * If `func` is an object the created callback returns `true` for elements + * that contain the equivalent object properties, otherwise it returns `false`. * * @static * @memberOf _ @@ -7873,7 +7983,7 @@ /** * Adds all own enumerable function properties of a source object to the - * destination object. If `object` is a function methods will be added to + * destination object. If `object` is a function then methods are added to * its prototype as well. * * @static @@ -8063,9 +8173,9 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number will be - * returned. If `floating` is truthy or either `min` or `max` are floats a - * floating-point number will be returned instead of an integer. + * argument is provided a number between `0` and the given number is returned. + * If `floating` is truthy, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. * * @static * @memberOf _ @@ -8177,10 +8287,10 @@ /** * Resolves the value of property `key` on `object`. If `key` is a function - * it will be invoked with the `this` binding of `object` and its result - * returned, else the property value is returned. If `object` is `null` or - * `undefined` then `undefined` is returned. If a default value is provided - * it will be returned if the property value resolves to `undefined`. + * it is invoked with the `this` binding of `object` and its result returned, + * else the property value is returned. If `object` is `null` or `undefined` + * then `undefined` is returned. If a default value is provided it is returned + * if the property value resolves to `undefined`. * * @static * @memberOf _ @@ -8253,7 +8363,7 @@ } /** - * Generates a unique ID. If `prefix` is provided the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided the ID is appended to it. * * @static * @memberOf _ @@ -8439,7 +8549,7 @@ lodash.trim = trim; lodash.trimLeft = trimLeft; lodash.trimRight = trimRight; - lodash.truncate = truncate; + lodash.trunc = trunc; lodash.unescape = unescape; lodash.uniqueId = uniqueId; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index e2ba8d833..3b44b85bb 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,67 +1,68 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE + * Lo-Dash 2.5.0-pre (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){for(var e=-1,r=t.length,u=Array(r);++et||typeof n=="undefined")return 1;if(nr||13r||8202e||13e||8202>>0:0,u=qe(r);++ei(t,f)&&l.push(f);return l}function wt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number"&&-1o?0:o>>>0);return wt(n,function(n){var o=u?t:null!=n&&n[t];i[++r]=o?o.apply(n,e):m}),i}function Tt(n,t,e,r,u){return n?((zr(t)?ft:Et)(t,function(t,o,i){var a=t&&zr(t),f=t&&Br(t),l=n[o];if(a||f){for(r||(r=[]),u||(u=[]),f=r.length;f--;)if(r[f]==t)return void(n[o]=u[f]);i=e?e(l,t,o,n,i):m,l=(f=typeof i!="undefined")?i:a?zr(l)?l:[]:Br(l)?l:{},r.push(t),u.push(l),f||Tt(l,t,e,r,u)}else i=e?e(l,t,o,n,i):m,typeof i=="undefined"&&(i=t),typeof i!="undefined"&&(l=i); -n[o]=l}),n):n}function Ft(n,t){var e={};if(typeof t=="function")return Ot(n,function(n,r,u){t(n,r,u)&&(e[r]=n)}),e;for(var r=-1,u=t.length;++ra(p,h)&&((u||l)&&p.push(h),c.push(s)) -}return c}function Lt(n,t){for(var e=-1,r=t(n),u=r.length,o=qe(u);++er)return t;var u=typeof e[2];if("number"!=u&&"string"!=u||!e[3]||e[3][e[2]]!==e[1]||(r=2),3o?0:o)}function Gt(n,t,r){var u=n?n.length:0;if(typeof r=="number")r=0>r?Cr(u+r,0):r||0;else if(r)return r=ee(n,t),u&&n[r]===t?r:-1;return e(n,t,r) -}function Ht(n,t,e){var r=n?n.length:0;if(typeof t!="number"&&null!=t){var u=r,o=0;for(t=U.createCallback(t,e,3);u--&&t(n[u],u,n);)o++}else o=null==t||e?1:t;return o=r-(o||0),te(n,0,0>o?0:o)}function Qt(n,t,e){var r=n?n.length:0;if(typeof t!="number"&&null!=t){var u=r,o=0;for(t=U.createCallback(t,e,3);u--&&t(n[u],u,n);)o++}else if(o=t,null==o||e)return n?n[r-1]:m;return o=r-(o||0),te(n,0>o?0:o)}function ne(n,t,e){if(typeof t!="number"&&null!=t){var r=-1,u=n?n.length:0,o=0;for(t=U.createCallback(t,e,3);++rt?0:t;return te(n,o)}function te(n,t,e){var r=-1,u=n?n.length:0;for(t=null==t?0:+t||0,0>t?t=Cr(u+t,0):t>u&&(t=u),e=typeof e=="undefined"?u:+e||0,0>e?e=Cr(u+e,0):e>u&&(e=u),u=t>e?0:e-t,e=qe(u);++r>>1,e(n[r])e?0:e);++te?Cr(r+e,0):e||0:0,typeof n=="string"||!zr(n)&&Re(n)?eo&&(o=a)}else t=null==t&&Re(n)?u:U.createCallback(t,e,3),wt(n,function(n,e,u){e=t(n,e,u),(e>r||-1/0===e&&e===o)&&(r=e,o=n)});return o}function ve(n,t){return he(n,Ue(t))}function ye(n,t,e,r){var u=3>arguments.length;t=U.createCallback(t,r,4);var o=-1,i=n?n.length:0;if(typeof i=="number"&&-1arguments.length;return t=U.createCallback(t,r,4),jt(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)}),e}function de(n){var t=-1,e=n&&n.length,r=qe(0>e?0:e>>>0);return wt(n,function(n){var e=Wt(0,++t);r[t]=r[e],r[e]=n}),r}function be(n,t,e){var r;(typeof t!="function"||typeof e!="undefined")&&(t=U.createCallback(t,e,3)),e=-1;var u=n?n.length:0;if(typeof u=="number"&&-1arguments.length)return Zt(n,d,null,t);if(n)var e=n[C]?n[C][2]:n.length,r=te(arguments,2),e=e-r.length;return Zt(n,d|j,e,t,r)}function we(n,t,e){var r,u,o,i,a,f,l,c=0,p=false,s=true;if(!Ae(n))throw new Ge(A);if(t=0>t?0:t,true===e)var h=true,s=false;else Oe(e)&&(h=e.leading,p="maxWait"in e&&Cr(t,+e.maxWait||0),s="trailing"in e?e.trailing:s);var g=function(){var e=t-(Mr()-i);0>=e||e>t?(u&&ar(u),e=l,u=f=l=m,e&&(c=Mr(),o=n.apply(a,r),f||u||(r=a=null))):f=vr(g,e) -},v=function(){f&&ar(f),u=f=l=m,(s||p!==t)&&(c=Mr(),o=n.apply(a,r),f||u||(r=a=null))};return function(){if(r=arguments,i=Mr(),a=this,l=s&&(f||!h),false===p)var e=h&&!f;else{u||h||(c=i);var y=p-(i-c),m=0>=y||y>p;m?(u&&(u=ar(u)),c=i,o=n.apply(a,r)):u||(u=vr(v,y))}return m&&f?f=ar(f):f||t===p||(f=vr(g,t)),e&&(m=true,o=n.apply(a,r)),!m||f||u||(r=a=null),o}}function je(n){if(!Ae(n))throw new Ge(A);return function(){return!n.apply(this,arguments)}}function xe(n){return Rt(n,Ne)}function ke(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ur.call(n)==X||false -}function Ce(n){return n&&typeof n=="object"&&1===n.nodeType&&-1>>0,r=n.constructor,u=-1,r=r&&n===r.prototype,o=e-1,i=qe(e),a=0t||null==n||!jr(t))return e;n=Ye(n);do t%2&&(e+=n),t=fr(t/2),n+=n;while(t);return e}function We(n,t){return(n=null==n?"":Ye(n))?null==t?n.slice(h(n),g(n)+1):(t=Ye(t),n.slice(o(n,t),i(n,t)+1)):n}function $e(n,t,e){var r=typeof n,u="function"==r;return!u||typeof t!="undefined"&&"prototype"in n?u||null==n?dt(n,t,e):"object"==r?De(n):Ue(n):n -}function Le(n){return n}function De(n){var t=Ur(n),e=t.length,r=t[0],u=e&&n[r];return 1!=e||u!==u||Oe(u)?function(r){var u=e;if(u&&!r)return false;for(;u--;){var o=t[u];if(!pr.call(r,o)||!Nt(r[o],n[o],null,true))return false}return true}:function(n){return n&&pr.call(n,r)?(n=n[r],u===n&&(0!==u||1/u==1/n)):false}}function ze(n,t,e){var r=true,u=t&&Rt(t,Ur);t&&(e||u.length)||(null==e&&(e=t),t=n,n=this,u=Rt(t,Ur)),false===e?r=false:Oe(e)&&"chain"in e&&(r=e.chain),e=-1;for(var o=Ae(n),i=u?u.length:0;++e--n?t.apply(this,arguments):void 0}},U.assign=Dr,U.at=function(t){return n(t,kt(arguments,true,false,1))},U.bind=_e,U.bindAll=function(n){for(var t=n,e=1arguments.length?Zt(t,d|b,null,n):Zt(t,d|b|j,null,n,te(arguments,2))},U.chain=function(n){return new M(n,true)},U.compact=function(n){for(var t=-1,e=n?n.length:0,r=0,u=[];++t(s?r(s,f):i(p,f))){for(t=u;--t;){var h=o[t];if(0>(h?r(h,f):i(n[t],f)))continue n}s&&s.push(f),p.push(f)}return p},U.invert=function(n,t){for(var e=-1,r=Ur(n),u=r.length,o={};++eu?0:u>>>0);for(o||(t=U.createCallback(t,e,3)),wt(n,function(n,e,u){if(o)for(e=t.length,u=qe(e);e--;)u[e]=n[t[e]];else u=t(n,e,u);i[++r]={a:u,b:r,c:n}}),u=i.length,i.sort(o?f:a);u--;)i[u]=i[u].c;return i},U.tap=function(n,t,e){return t.call(e,n),n},U.throttle=function(n,t,e){var r=true,u=true;if(!Ae(n))throw new Ge(A);return false===e?r=false:Oe(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),it.leading=r,it.maxWait=+t,it.trailing=u,we(n,t,it) -},U.times=function(n,t,e){n=0>n?0:n>>>0,t=dt(t,e,1),e=-1;for(var r=qe(n);++ee?0:+e||0,r))-t.length,0<=e&&n.indexOf(t,e)==e},U.escape=function(n){return null==n?"":Ye(n).replace(T,p)},U.escapeRegExp=Te,U.every=fe,U.find=ce,U.findIndex=Xt,U.findKey=function(n,t,e){return t=U.createCallback(t,e,3),xt(n,t,Et,true) -},U.findLast=function(n,t,e){return t=U.createCallback(t,e,3),xt(n,t,jt)},U.findLastIndex=function(n,t,e){var r=n?n.length:0;for(t=U.createCallback(t,e,3);r--;)if(t(n[r],r,n))return r;return-1},U.findLastKey=function(n,t,e){return t=U.createCallback(t,e,3),xt(n,t,It,true)},U.findWhere=function(n,t){return ce(n,De(t))},U.has=function(n,t){return n?pr.call(n,t):false},U.identity=Le,U.indexOf=Gt,U.isArguments=ke,U.isArray=zr,U.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&ur.call(n)==G||false -},U.isDate=function(n){return n&&typeof n=="object"&&ur.call(n)==H||false},U.isElement=Ce,U.isEmpty=function(n){var t=true;if(!n)return t;var e=n.length;return-1e?Cr(r+e,0):Ar(e||0,r-1))+1);r--;)if(n[r]===t)return r;return-1},U.noConflict=function(){return c._=er,this},U.noop=Be,U.now=Mr,U.pad=function(n,t,e){n=null==n?"":Ye(n),t=+t; -var r=n.length;return re?0:+e||0,n.length),n.lastIndexOf(t,e)==e},U.template=function(n,t,e){var r=U.templateSettings;e=Dr({},e,r,pt),n=Ye(null==n?"":n);var u,o,i=Dr({},e.imports,r.imports,pt),r=Ur(i),i=Se(i),a=0,f=e.interpolate||q,l="__p+='",f=Xe((e.escape||q).source+"|"+f.source+"|"+(f===$?L:q).source+"|"+(e.evaluate||q).source+"|$","g"); -return n.replace(f,function(t,e,r,i,f,c){return r||(r=i),l+=n.slice(a,c).replace(K,s),e&&(u=true,l+="'+__e("+e+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(e=e.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(I,""):l).replace(R,"$1").replace(N,"$1;"),l="function("+(e||"obj")+"){"+(e?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",e=Dt(l,r,i,void 0),t?e(t):e -},U.trim=We,U.trimLeft=function(n,t){return(n=null==n?"":Ye(n))?null==t?n.slice(h(n)):(t=Ye(t),n.slice(o(n,t))):n},U.trimRight=function(n,t){return(n=null==n?"":Ye(n))?null==t?n.slice(0,g(n)+1):(t=Ye(t),n.slice(0,i(n,t)+1)):n},U.truncate=function(n,t){var e=30,r="...";if(t&&Oe(t))var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e,r="omission"in t?Ye(t.omission):r;else null!=t&&(e=+t||0);if(n=null==n?"":Ye(n),e>=n.length)return n;var o=e-r.length;if(1>o)return r;if(e=n.slice(0,o),null==u)return e+r; -if(Ie(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=Xe(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index;e=e.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=e.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(S,v))},U.uniqueId=function(n){var t=++O;return Ye(null==n?"":n)+t},U.all=fe,U.any=be,U.detect=ce,U.foldl=ye,U.foldr=me,U.include=ae,U.inject=ye,ze(U,function(){var n={};return Et(U,function(t,e){U.prototype[e]||(n[e]=t) -}),n}(),false),U.first=Yt,U.last=Qt,U.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Se(n)),null==t||e?(t=n?n.length:0,0t?0:+t||0,n.length),n)},U.take=Yt,U.takeRight=Qt,U.takeRightWhile=Qt,U.takeWhile=Yt,U.head=Yt,Et(U,function(n,t){var e="sample"!=t;U.prototype[t]||(U.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new M(o,u):o})}),U.VERSION=k,U.prototype.chain=function(){return this.__chain__=true,this -},U.prototype.toJSON=ie,U.prototype.toString=function(){return Ye(this.__wrapped__)},U.prototype.value=ie,U.prototype.valueOf=ie,ft(["join","pop","shift"],function(n){var t=He[n];U.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new M(e,n):e}}),ft(["push","reverse","sort","unshift"],function(n){var t=He[n];U.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ft(["concat","splice"],function(n){var t=He[n];U.prototype[n]=function(){return new M(t.apply(this.__wrapped__,arguments),this.__chain__) -}}),U}var m,d=1,b=2,_=4,w=8,j=16,x=32,k="2.4.1",C="__lodash@"+k+"__",A="Expected a function",O=0,E=/^[A-Z]+$/,I=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,S=/&(?:amp|lt|gt|quot|#39);/g,T=/[&<>"']/g,F=/<%-([\s\S]+?)%>/g,W=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,L=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,U=/[\xC0-\xFF]/g,q=/($^)/,Z=/[.*+?^${}()|[\]\/\\]/g,P=/\bthis\b/,K=/['\n\r\u2028\u2029\\]/g,M=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,V=" \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",J="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),X="[object Arguments]",Y="[object Array]",G="[object Boolean]",H="[object Date]",Q="[object Error]",nt="[object Function]",tt="[object Number]",et="[object Object]",rt="[object RegExp]",ut="[object String]",ot={}; -ot[nt]=false,ot[X]=ot[Y]=ot[G]=ot[H]=ot[tt]=ot[et]=ot[rt]=ot[ut]=true;var it={leading:false,maxWait:0,trailing:false},at={configurable:false,enumerable:false,value:null,writable:false},ft={"&":"&","<":"<",">":">",'"':""","'":"'"},lt={"&":"&","<":"<",">":">",""":'"',"'":"'"},ct={\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":" "},pt={"function":true,object:true},st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ht=pt[typeof window]&&window||this,gt=pt[typeof exports]&&exports&&!exports.nodeType&&exports,pt=pt[typeof module]&&module&&!module.nodeType&&module,vt=gt&&pt&&typeof global=="object"&&global; -!vt||vt.global!==vt&&vt.window!==vt&&vt.self!==vt||(ht=vt);var vt=pt&&pt.exports===gt&>,yt=y();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ht._=yt, define(function(){return yt})):gt&&pt?vt?(pt.exports=yt)._=yt:gt._=yt:ht._=yt}).call(this); \ No newline at end of file +;(function(){function n(n,t){for(var e=-1,r=t.length,u=Array(r);++et||typeof n=="undefined")return 1;if(nr||13r||8202e||13e||8202>>0:0,u=tr(r);++ea(t,f)&&l.push(f);return l}function Ft(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number"&&-1o?0:o>>>0);return Ft(n,function(n){var o=u?t:null!=n&&n[t];a[++r]=o?o.apply(n,e):m}),a}function Zt(n,t,e,r,u){var o=re(t);return(o?bt:Bt)(t,function(t,a,i){var f=t&&re(t),l=t&&nu(t),c=n[a]; +if(f||l){for(r||(r=[]),u||(u=[]),l=r.length;l--;)if(r[l]==t)return void(n[a]=u[l]);i=e?e(c,t,a,n,i):m,(l=typeof i!="undefined")||(i=f?Qr(c)?c:[]:nu(c)?c:{}),r.push(t),u.push(i),l||Zt(i,t,e,r,u),n[a]=i}else i=e?e(c,t,a,n,i):m,typeof i=="undefined"&&(i=t),(o||typeof i!="undefined")&&(n[a]=i)}),n}function Pt(n,t){var e={};if(typeof t=="function")return Lt(n,function(n,r,u){t(n,r,u)&&(e[r]=n)}),e;for(var r=-1,u=t.length;++ri(p,h)&&((u||l)&&p.push(h),c.push(s))}return c}function Jt(n,t){for(var e=-1,r=t(n),u=r.length,o=tr(u);++er)return t;var u=typeof e[2];if("number"!=u&&"string"!=u||!e[3]||e[3][e[2]]!==e[1]||(r=2),3o?0:o)}function ce(n,t,r){var u=n?n.length:0;if(typeof r=="number")r=0>r?Dr(u+r,0):r||0;else if(r)return r=ve(n,t),u&&n[r]===t?r:-1;return e(n,t,r)}function pe(n,t,e){var r=n?n.length:0;if(typeof t!="number"&&null!=t){var u=r,o=0; +for(t=q.createCallback(t,e,3);u--&&t(n[u],u,n);)o++}else o=null==t||e?1:t;return o=r-(o||0),ge(n,0,0>o?0:o)}function se(n,t,e){var r=n?n.length:0;if(typeof t!="number"&&null!=t){var u=r,o=0;for(t=q.createCallback(t,e,3);u--&&t(n[u],u,n);)o++}else if(o=t,null==o||e)return n?n[r-1]:m;return o=r-(o||0),ge(n,0>o?0:o)}function he(n,t,e){if(typeof t!="number"&&null!=t){var r=-1,u=n?n.length:0,o=0;for(t=q.createCallback(t,e,3);++rt?0:t;return ge(n,o)}function ge(n,t,e){var r=-1,u=n?n.length:0; +for(t=null==t?0:+t||0,0>t?t=Dr(u+t,0):t>u&&(t=u),e=typeof e=="undefined"?u:+e||0,0>e?e=Dr(u+e,0):e>u&&(e=u),u=t>e?0:e-t,e=tr(u);++r>>1,e(n[r])e?0:e);++te?Dr(r+e,0):e||0:0,typeof n=="string"||!Qr(n)&&Me(n)?eo&&(o=i)}else t=null==t&&Me(n)?u:q.createCallback(t,e,3),Ft(n,function(n,e,u){e=t(n,e,u),(e>r||-1/0===e&&e===o)&&(r=e,o=n)});return o}function Ee(n,t){return Ce(n,nr(t))}function Ie(n,t,e,r){var u=3>arguments.length;t=q.createCallback(t,r,4);var o=-1,a=n?n.length:0;if(typeof a=="number"&&-1arguments.length;return t=q.createCallback(t,r,4),Nt(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)}),e}function Se(n){var t=-1,e=n&&n.length,r=tr(0>e?0:e>>>0);return Ft(n,function(n){var e=Kt(0,++t);r[t]=r[e],r[e]=n}),r}function Fe(n,t,e){var r;(typeof t!="function"||typeof e!="undefined")&&(t=q.createCallback(t,e,3)),e=-1;var u=n?n.length:0;if(typeof u=="number"&&-1arguments.length)return ne(n,d,null,t);if(n)var e=n[A]?n[A][2]:n.length,r=ge(arguments,2),e=e-r.length;return ne(n,d|j,e,t,r)}function Te(n,t,e){function r(){var e=t-(au()-l);0>=e||e>t?(i&&wr(i),e=s,i=p=s=m,e&&(h=au(),f=n.apply(c,a),p||i||(a=c=null))):p=Ir(r,e)}function u(){p&&wr(p),i=p=s=m,(v||g!==t)&&(h=au(),f=n.apply(c,a),p||i||(a=c=null))}function o(){if(a=arguments,l=au(),c=this,s=v&&(p||!y),false===g)var e=y&&!p; +else{i||y||(h=l);var o=g-(l-h),m=0>=o||o>g;m?(i&&(i=wr(i)),h=l,f=n.apply(c,a)):i||(i=Ir(u,o))}return m&&p?p=wr(p):p||t===g||(p=Ir(r,t)),e&&(m=true,f=n.apply(c,a)),!m||p||i||(a=c=null),f}var a,i,f,l,c,p,s,h=0,g=false,v=true;if(!Be(n))throw new fr(C);if(t=0>t?0:t,true===e)var y=true,v=false;else De(e)&&(y=e.leading,g="maxWait"in e&&Dr(t,+e.maxWait||0),v="trailing"in e?e.trailing:v);return o.cancel=function(){p&&wr(p),i&&wr(i),i=p=s=m},o}function We(n){if(!Be(n))throw new fr(C);return function(){return!n.apply(this,arguments) +}}function Ue(n){return zt(n,Ze)}function $e(n){return n&&typeof n=="object"&&typeof n.length=="number"&&yr.call(n)==Y||false}function Le(n){return n&&typeof n=="object"&&1===n.nodeType&&-1>>0,r=n.constructor,u=-1,r=r&&n===r.prototype,o=e-1,a=tr(e),i=0t||null==n||!$r(t))return e;n=ir(n);do t%2&&(e+=n),t=kr(t/2),n+=n;while(t);return e}function Je(n,t){return(n=null==n?"":ir(n))?null==t?n.slice(h(n),g(n)+1):(t=ir(t),n.slice(o(n,t),a(n,t)+1)):n +}function Xe(n,t,e){var r=typeof n,u="function"==r;return!u||typeof t!="undefined"&&"prototype"in n?u||null==n?It(n,t,e):"object"==r?Ge(n):nr(n):n}function Ye(n){return n}function Ge(n){var t=tu(n),e=t.length,r=t[0],u=e&&n[r];return 1!=e||u!==u||De(u)?function(r){var u=e;if(u&&!r)return false;for(;u--;){var o=t[u];if(!Ar.call(r,o)||!qt(r[o],n[o],null,true))return false}return true}:function(n){return n&&Ar.call(n,r)?(n=n[r],u===n&&(0!==u||1/u==1/n)):false}}function He(n,t,e){var r=true,u=t&&zt(t,tu);t&&(e||u.length)||(null==e&&(e=t),t=n,n=this,u=zt(t,tu)),false===e?r=false:De(e)&&"chain"in e&&(r=e.chain),e=-1; +for(var o=Be(n),a=u?u.length:0;++e--n?t.apply(this,arguments):void 0}},q.assign=Hr,q.at=function(t){return n(t,Wt(arguments,true,false,1))},q.bind=Ne,q.bindAll=function(n){for(var t=n,e=1arguments.length?ne(t,d|b,null,n):ne(t,d|b|j,null,n,ge(arguments,2))},q.chain=function(n){return new V(n,true) +},q.compact=function(n){for(var t=-1,e=n?n.length:0,r=0,u=[];++t(s?r(s,f):a(p,f))){for(t=u;--t;){var h=o[t];if(0>(h?r(h,f):a(n[t],f)))continue n}s&&s.push(f),p.push(f)}return p},q.invert=function(n,t){for(var e=-1,r=tu(n),u=r.length,o={};++eu?0:u>>>0);for(o||(t=q.createCallback(t,e,3)),Ft(n,function(n,e,u){if(o)for(e=t.length,u=tr(e);e--;)u[e]=n[t[e]];else u=t(n,e,u);a[++r]={a:u,b:r,c:n}}),u=a.length,a.sort(o?f:i);u--;)a[u]=a[u].c;return a},q.tap=function(n,t,e){return t.call(e,n),n},q.throttle=function(n,t,e){var r=true,u=true;if(!Be(n))throw new fr(C);return false===e?r=false:De(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),mt.leading=r,mt.maxWait=+t,mt.trailing=u,Te(n,t,mt) +},q.times=function(n,t,e){n=0>n?0:n>>>0,t=It(t,e,1),e=-1;for(var r=tr(n);++ee?0:+e||0,r))-t.length,0<=e&&n.indexOf(t,e)==e},q.escape=function(n){return null==n?"":ir(n).replace(N,p)},q.escapeRegExp=Ke,q.every=we,q.find=ke,q.findIndex=fe,q.findKey=function(n,t,e){return t=q.createCallback(t,e,3),Tt(n,t,Bt,true) +},q.findLast=function(n,t,e){return t=q.createCallback(t,e,3),Tt(n,t,Nt)},q.findLastIndex=function(n,t,e){var r=n?n.length:0;for(t=q.createCallback(t,e,3);r--;)if(t(n[r],r,n))return r;return-1},q.findLastKey=function(n,t,e){return t=q.createCallback(t,e,3),Tt(n,t,Dt,true)},q.findWhere=function(n,t){return ke(n,Ge(t))},q.has=function(n,t){return n?Ar.call(n,t):false},q.identity=Ye,q.indexOf=ce,q.isArguments=$e,q.isArray=Qr,q.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&yr.call(n)==H||false +},q.isDate=function(n){return n&&typeof n=="object"&&yr.call(n)==Q||false},q.isElement=Le,q.isEmpty=function(n){var t=true;if(!n)return t;var e=n.length;return-1e?Dr(r+e,0):zr(e||0,r-1))+1);r--;)if(n[r]===t)return r;return-1},q.noConflict=function(){return c._=vr,this},q.noop=Qe,q.now=au,q.pad=function(n,t,e){n=null==n?"":ir(n),t=+t; +var r=n.length;return re?0:+e||0,n.length),n.lastIndexOf(t,e)==e},q.template=function(n,t,e){var r=q.templateSettings;e=Hr({},e,r,jt),n=ir(null==n?"":n);var u,o,a=Hr({},e.imports,r.imports,jt),r=tu(a),a=Pe(a),i=0,f=e.interpolate||M,l="__p+='",f=ar((e.escape||M).source+"|"+f.source+"|"+(f===U?$:M).source+"|"+(e.evaluate||M).source+"|$","g"); +return n.replace(f,function(t,e,r,a,f,c){return r||(r=a),l+=n.slice(i,c).replace(K,s),e&&(u=true,l+="'+__e("+e+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),l+="';",(e=e.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(I,""):l).replace(R,"$1").replace(S,"$1;"),l="function("+(e||"obj")+"){"+(e?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",e=Xt(l,r,a,void 0),t?e(t):e +},q.trim=Je,q.trimLeft=function(n,t){return(n=null==n?"":ir(n))?null==t?n.slice(h(n)):(t=ir(t),n.slice(o(n,t))):n},q.trimRight=function(n,t){return(n=null==n?"":ir(n))?null==t?n.slice(0,g(n)+1):(t=ir(t),n.slice(0,a(n,t)+1)):n},q.trunc=function(n,t){var e=30,r="...";if(t&&De(t))var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e,r="omission"in t?ir(t.omission):r;else null!=t&&(e=+t||0);if(n=null==n?"":ir(n),e>=n.length)return n;var o=e-r.length;if(1>o)return r;if(e=n.slice(0,o),null==u)return e+r; +if(qe(u)){if(n.slice(o).search(u)){var a,i,f=n.slice(0,o);for(u.global||(u=ar(u.source,(L.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(f);)i=a.index;e=e.slice(0,null==i?o:i)}}else n.indexOf(u,o)!=o&&(u=e.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(F,v))},q.uniqueId=function(n){var t=++O;return ir(null==n?"":n)+t},q.all=we,q.any=Fe,q.detect=ke,q.foldl=Ie,q.foldr=Re,q.include=_e,q.inject=Ie,He(q,function(){var n={};return Bt(q,function(t,e){q.prototype[e]||(n[e]=t) +}),n}(),false),q.first=le,q.last=se,q.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Pe(n)),null==t||e?(t=n?n.length:0,0t?0:+t||0,n.length),n)},q.take=le,q.takeRight=se,q.takeRightWhile=se,q.takeWhile=le,q.head=le,Bt(q,function(n,t){var e="sample"!=t;q.prototype[t]||(q.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new V(o,u):o})}),q.VERSION=x,q.prototype.chain=function(){return this.__chain__=true,this +},q.prototype.toJSON=be,q.prototype.toString=function(){return ir(this.__wrapped__)},q.prototype.value=be,q.prototype.valueOf=be,bt(["join","pop","shift"],function(n){var t=lr[n];q.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new V(e,n):e}}),bt(["push","reverse","sort","unshift"],function(n){var t=lr[n];q.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),bt(["concat","splice"],function(n){var t=lr[n];q.prototype[n]=function(){return new V(t.apply(this.__wrapped__,arguments),this.__chain__) +}}),q}var m,d=1,b=2,_=4,w=8,j=16,k=32,x="2.5.0-pre",A="__lodash@"+x+"__",C="Expected a function",O=0,E=/^[A-Z]+$/,I=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,S=/(__e\(.*?\)|\b__t\))\+'';/g,F=/&(?:amp|lt|gt|quot|#39|#96);/g,N=/[&<>"'`]/g,T=/<%-([\s\S]+?)%>/g,W=/<%([\s\S]+?)%>/g,U=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,L=/\w*$/,B=/^\s*function[ \n\r\t]+\w/,D=/^0[xX]/,z=/^\[object .+?Constructor\]$/,q=/[\xC0-\xFF]/g,M=/($^)/,Z=/[.*+?^${}()|[\]\/\\]/g,P=/\bthis\b/,K=/['\n\r\u2028\u2029\\]/g,V=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,J=" \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",X="Array ArrayBuffer Boolean Date Float64Array Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError Uint8Array window WinRTError".split(" "),Y="[object Arguments]",G="[object Array]",H="[object Boolean]",Q="[object Date]",nt="[object Error]",tt="[object Number]",et="[object Object]",rt="[object RegExp]",ut="[object String]",ot="[object ArrayBuffer]",at="[object Float32Array]",it="[object Float64Array]",ft="[object Int8Array]",lt="[object Int16Array]",ct="[object Int32Array]",pt="[object Uint8Array]",st="[object Uint8ClampedArray]",ht="[object Uint16Array]",gt="[object Uint32Array]",vt={}; +vt[Y]=vt[G]=vt[at]=vt[it]=vt[ft]=vt[lt]=vt[ct]=vt[pt]=vt[st]=vt[ht]=vt[gt]=true,vt[ot]=vt[H]=vt[Q]=vt[nt]=vt["[object Function]"]=vt["[object Map]"]=vt[tt]=vt[et]=vt[rt]=vt["[object Set]"]=vt[ut]=vt["[object WeakMap]"]=false;var yt={};yt[Y]=yt[G]=yt[ot]=yt[H]=yt[Q]=yt[nt]=yt[at]=yt[it]=yt[ft]=yt[lt]=yt[ct]=yt[tt]=yt[et]=yt[rt]=yt[ut]=yt[pt]=yt[st]=yt[ht]=yt[gt]=true,yt["[object Function]"]=yt["[object Map]"]=yt["[object Set]"]=yt["[object WeakMap]"]=false;var mt={leading:false,maxWait:0,trailing:false},dt={configurable:false,enumerable:false,value:null,writable:false},bt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},wt={\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":" "},jt={"function":true,object:true},kt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xt=jt[typeof window]&&window||this,At=jt[typeof exports]&&exports&&!exports.nodeType&&exports,jt=jt[typeof module]&&module&&!module.nodeType&&module,Ct=At&&jt&&typeof global=="object"&&global; +!Ct||Ct.global!==Ct&&Ct.window!==Ct&&Ct.self!==Ct||(xt=Ct);var Ct=jt&&jt.exports===At&&At,Ot=y();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(xt._=Ot, define(function(){return Ot})):At&&jt?Ct?(jt.exports=Ot)._=Ot:At._=Ot:xt._=Ot}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index bdc0aa335..b52fd841e 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) + * Lo-Dash 2.5.0-pre (Custom Build) * Build: `lodash underscore -o ./dist/lodash.underscore.js` * Copyright 2012-2014 The Dojo Foundation * Based on Underscore.js 1.6.0 @@ -21,7 +21,7 @@ PARTIAL_RIGHT_FLAG = 32; /** Used as the semantic version number */ - var version = '2.4.1'; + var version = '2.5.0-pre'; /** Used as the property name for wrapper metadata */ var expando = '__lodash@' + version + '__'; @@ -36,14 +36,17 @@ var idCounter = 0; /** Used to match HTML entities and HTML characters */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g, - reUnescapedHtml = /[&<>"']/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27|#96);/g, + reUnescapedHtml = /[&<>"'`]/g; /** Used to match template delimiters */ var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; + /** Used to detect host constructors (Safari > 5) */ + var reHostCtor = /^\[object .+?Constructor\]$/; + /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; @@ -62,27 +65,63 @@ arrayClass = '[object Array]', boolClass = '[object Boolean]', dateClass = '[object Date]', + errorClass = '[object Error]', funcClass = '[object Function]', + mapClass = '[object Map]', numberClass = '[object Number]', objectClass = '[object Object]', regexpClass = '[object RegExp]', - stringClass = '[object String]'; + setClass = '[object Set]', + stringClass = '[object String]', + weakMapClass = '[object WeakMap]'; + + var arrayBufferClass = '[object ArrayBuffer]', + float32Class = '[object Float32Array]', + float64Class = '[object Float64Array]', + int8Class = '[object Int8Array]', + int16Class = '[object Int16Array]', + int32Class = '[object Int32Array]', + uint8Class = '[object Uint8Array]', + uint8ClampedClass = '[object Uint8ClampedArray]', + uint16Class = '[object Uint16Array]', + uint32Class = '[object Uint32Array]'; + + /** Used to identify object classifications that are treated like arrays */ + var arrayLikeClasses = {}; + arrayLikeClasses[argsClass] = + arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = + arrayLikeClasses[float64Class] = arrayLikeClasses[int8Class] = + arrayLikeClasses[int16Class] = arrayLikeClasses[int32Class] = + arrayLikeClasses[uint8Class] = arrayLikeClasses[uint8ClampedClass] = + arrayLikeClasses[uint16Class] = arrayLikeClasses[uint32Class] = true; + arrayLikeClasses[arrayBufferClass] = arrayLikeClasses[boolClass] = + arrayLikeClasses[dateClass] = arrayLikeClasses[errorClass] = + arrayLikeClasses[funcClass] = arrayLikeClasses[mapClass] = + arrayLikeClasses[numberClass] = arrayLikeClasses[objectClass] = + arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = + arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; /** * Used to convert characters to HTML entities. * * Note: Though the ">" character is escaped for symmetry, characters like - * ">", "`", and "/" don't require escaping in HTML and have no special meaning + * ">" and "/" don't require escaping in HTML and have no special meaning * unless they're part of a tag or unquoted attribute value. * See [Mathias' article](http://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can be used to + * break out of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. */ var htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', - "'": ''' + "'": ''', + '`': '`' }; /** Used to convert HTML entities to characters */ @@ -91,7 +130,8 @@ '<': '<', '>': '>', '"': '"', - ''': "'" + ''': "'", + '`': '`' }; /** Used to determine if values are of the language type `Object` */ @@ -225,8 +265,8 @@ var arrayProto = Array.prototype, objectProto = Object.prototype; - /** Used to restore the original `_` reference in `_.noConflict` */ - var oldDash = root._; + /** Used to resolve the decompiled source of functions */ + var fnToString = Function.prototype.toString; /** * Used as the maximum length of an array-like object. @@ -235,6 +275,9 @@ */ var maxSafeInteger = Math.pow(2, 53) - 1; + /** Used to restore the original `_` reference in `_.noConflict` */ + var oldDash = root._; + /** Used to resolve the internal `[[Class]]` of values */ var toString = objectProto.toString; @@ -247,7 +290,6 @@ /** Native method shortcuts */ var ceil = Math.ceil, floor = Math.floor, - fnToString = Function.prototype.toString, hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, propertyIsEnumerable = objectProto.propertyIsEnumerable, @@ -317,15 +359,11 @@ * var wrapped = _([1, 2, 3]); * * // returns an unwrapped value - * wrapped.reduce(function(sum, num) { - * return sum + num; - * }); + * wrapped.reduce(function(sum, n) { return sum + n; }); * // => 6 * * // returns a wrapped value - * var squares = wrapped.map(function(num) { - * return num * num; - * }); + * var squares = wrapped.map(function(n) { return n * n; }); * * _.isArray(squares); * // => false @@ -481,9 +519,6 @@ * @returns {Object} Returns the destination object. */ function baseAssign(object, source, callback) { - if (!object) { - return object; - } var index = -1, props = keys(source), length = props.length; @@ -543,15 +578,15 @@ case 1: return function(value) { return func.call(thisArg, value); }; - case 2: return function(value, other) { - return func.call(thisArg, value, other); - }; case 3: return function(value, index, collection) { return func.call(thisArg, value, index, collection); }; case 4: return function(accumulator, value, index, collection) { return func.call(thisArg, accumulator, value, index, collection); }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; } return bind(func, thisArg); } @@ -864,7 +899,7 @@ * @param {*} value The value to compare to `other`. * @param {*} other The value to compare to `value`. * @param {Function} [callback] The function to customize comparing values. - * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. + * @param {boolean} [isWhere=false] A flag to indicate performing partial comparisons. * @param {Array} [stackA=[]] Tracks traversed `value` objects. * @param {Array} [stackB=[]] Tracks traversed `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. @@ -900,7 +935,7 @@ case stringClass: return value == String(other); } - var isArr = valClass == arrayClass; + var isArr = arrayLikeClasses[valClass]; if (!isArr) { if (valClass != objectClass) { return false; @@ -1116,7 +1151,7 @@ /** * Compiles a function from `source` using the `varNames` and `varValues` * pairs to import free variables into the compiled function. If `sourceURL` - * is provided it will be used as the sourceURL for the compiled function. + * is provided it is used as the sourceURL for the compiled function. * * @private * @param {string} source The source to compile. @@ -1173,7 +1208,7 @@ * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection * through a callback. The given setter function sets the keys and values of - * the accumulator object. If `initializer` is provided it will be used to + * the accumulator object. If `initializer` is provided it is used to * initialize the accumulator object. * * @private @@ -1292,7 +1327,10 @@ * @returns {boolean} Returns `true` if `value` is a native function, else `false`. */ function isNative(value) { - return typeof value == 'function' && reNative.test(fnToString.call(value)); + var type = typeof value; + return type == 'function' + ? reNative.test(fnToString.call(value)) + : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; } /** @@ -1408,10 +1446,10 @@ * element the predicate returns truthy for, instead of the element itself. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -1419,8 +1457,8 @@ * @category Arrays * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -1486,16 +1524,16 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` - * is truthy, the array will only be flattened a single level. If a callback - * is provided each element of the array is passed through the callback before + * is truthy, the array is only flattened a single level. If a callback is + * provided each element of the array is passed through the callback before * flattening. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -1504,7 +1542,7 @@ * @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] The function called per iteration. - * If a property name or object is provided it will be used to create a "_.pluck" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new flattened array. @@ -1541,7 +1579,7 @@ /** * Gets the index at which the first occurrence of `value` is found using * strict equality for comparisons, i.e. `===`. If the array is already sorted - * providing `true` for `fromIndex` will run a faster binary search. + * providing `true` for `fromIndex` performs a faster binary search. * * @static * @memberOf _ @@ -1775,15 +1813,15 @@ /** * Uses a binary search to determine the smallest index at which a value * should be inserted into a given sorted array in order to maintain the sort - * order of the array. If a callback is provided it will be executed for - * `value` and each element of `array` to compute their sort ranking. The - * callback is bound to `thisArg` and invoked with one argument; (value). + * order of the array. If a callback is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The callback + * is bound to `thisArg` and invoked with one argument; (value). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -1792,8 +1830,8 @@ * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. @@ -1885,17 +1923,17 @@ /** * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. If the array is sorted, providing `true` for - * `isSorted` will use a faster algorithm. If a callback is provided it will - * be executed for each value in the array to generate the criterion by which - * uniqueness is computed. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index, array). + * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a + * faster search algorithm for sorted arrays. If a callback is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -1905,26 +1943,26 @@ * @param {Array} array The array to process. * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new duplicate-value-free array. * @example * - * _.uniq([1, 2, 1, 3, 1]); - * // => [1, 2, 3] + * _.uniq([1, 2, 1]); + * // => [1, 2] * * // using `isSorted` - * _.uniq([1, 1, 2, 2, 3], true); - * // => [1, 2, 3] + * _.uniq([1, 1, 2], true); + * // => [1, 2] * * // using `callback` - * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); - * // => ['A', 'b', 'C'] + * _.uniq(['A', 'b', 'a', 'B'], function(chr) { return chr.toLowerCase(); }); + * // => ['A', 'b'] * * // using `callback` with `thisArg` - * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2.5, 3] + * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); + * // => [1, 2.5] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); @@ -1976,7 +2014,7 @@ * Creates an array of grouped elements, the first of which contains the first * elements of the given arrays, the second of which contains the second elements * of the given arrays, and so on. If a zipped value is provided its corresponding - * unzipped value will be returned. + * unzipped value is returned. * * @static * @memberOf _ @@ -2189,10 +2227,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2200,16 +2238,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': 1, '6': 2 } * - * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': 1, '6': 2 } * * _.countBy(['one', 'two', 'three'], 'length'); @@ -2225,10 +2263,10 @@ * (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2237,8 +2275,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if all elements passed the predicate check, * else `false`. @@ -2290,10 +2328,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2302,13 +2340,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var evens = _.filter([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [2, 4] * * var characters = [ @@ -2354,10 +2392,10 @@ * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2366,8 +2404,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -2450,10 +2488,10 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * _([1, 2, 3]).forEach(function(n) { console.log(n); }).join(','); * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { console.log(n); }); * // => logs each number and returns the object (property order is not guaranteed across environments) */ function forEach(collection, callback, thisArg) { @@ -2475,10 +2513,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2486,16 +2524,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * * // using "_.pluck" callback shorthand @@ -2518,10 +2556,10 @@ * (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2529,8 +2567,8 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -2556,8 +2594,8 @@ /** * Invokes the method named by `methodName` on each element in the collection * returning an array of the results of each invoked method. Additional arguments - * will be provided to each invoked method. If `methodName` is a function it - * will be invoked for, and `this` bound to, each element in the collection. + * is provided to each invoked method. If `methodName` is a function it is + * invoked for, and `this` bound to, each element in the collection. * * @static * @memberOf _ @@ -2585,10 +2623,10 @@ * three arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2597,16 +2635,16 @@ * @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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new mapped array. * @example * - * _.map([1, 2, 3], function(num) { return num * 3; }); + * _.map([1, 2, 3], function(n) { return n * 3; }); * // => [3, 6, 9] * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); + * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); * // => [3, 6, 9] (property order is not guaranteed across environments) * * var characters = [ @@ -2635,17 +2673,17 @@ } /** - * Retrieves the maximum value of a collection. If the collection is empty or - * falsey `-Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the maximum value of a collection. If the collection is empty + * or falsey `-Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2653,7 +2691,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the maximum value. @@ -2711,17 +2749,17 @@ } /** - * Retrieves the minimum value of a collection. If the collection is empty or - * falsey `Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three + * Retrieves the minimum value of a collection. If the collection is empty + * or falsey `Infinity` is returned. If a callback is provided it is executed + * for each value in the collection to generate the criterion by which the + * value is ranked. The callback is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2729,7 +2767,7 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @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" + * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the minimum value. @@ -2793,10 +2831,10 @@ * to `thisArg` and invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2804,16 +2842,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the array of grouped elements. * @example * - * _.partition([1, 2, 3], function(num) { return num % 2; }); + * _.partition([1, 2, 3], function(n) { return n % 2; }); * // => [[1, 3], [2]] * - * _.partition([1.2, 2.3, 3.4], function(num) { return this.floor(num) % 2; }, Math); + * _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); * // => [[1, 3], [2]] * * var characters = [ @@ -2861,9 +2899,9 @@ * Reduces a collection to a value which is the accumulated result of running * each element in the collection through the callback, where each successive * callback execution consumes the return value of the previous execution. If - * `accumulator` is not provided the first element of the collection will be - * used as the initial `accumulator` value. The callback is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, index|key, collection). + * `accumulator` is not provided the first element of the collection is used + * as the initial `accumulator` value. The callback is bound to `thisArg` and + * invoked with four arguments; (accumulator, value, index|key, collection). * * @static * @memberOf _ @@ -2876,13 +2914,11 @@ * @returns {*} Returns the accumulated value. * @example * - * var sum = _.reduce([1, 2, 3], function(sum, num) { - * return sum + num; - * }); + * var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); * // => 6 * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; + * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; * return result; * }, {}); * // => { 'a': 3, 'b': 6, 'c': 9 } @@ -2947,10 +2983,10 @@ * the predicate does **not** return truthy for. * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -2958,13 +2994,13 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example * - * var odds = _.reject([1, 2, 3, 4], function(num) { return num % 2 == 0; }); + * var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); * // => [1, 3] * * var characters = [ @@ -3078,10 +3114,10 @@ * with three arguments; (value, index|key, collection). * * If a property name is provided for `predicate` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an object is provided for `predicate` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3090,8 +3126,8 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=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. + * per iteration. If a property name or object is provided it is used to + * create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if any element passed the predicate check, * else `false`. @@ -3140,18 +3176,18 @@ /** * Creates an array of elements, sorted in ascending order by the results of * running each element in a collection through the callback. This method - * performs a stable sort, that is, it will preserve the original sort order - * of equal elements. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. + * callback returns the property value of the given element. * * If an array of property names is provided for `callback` the collection - * will be sorted by each property value. + * is sorted by each property value. * * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, + * returns `true` for elements that have the properties of the given object, * else `false`. * * @static @@ -3159,16 +3195,16 @@ * @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. + * called per iteration. If a property name or object is provided it is + * used to create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns the new sorted array. * @example * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); + * _.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); * // => [3, 1, 2] * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + * _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); * // => [3, 1, 2] * * var characters = [ @@ -3335,7 +3371,7 @@ * Binds methods of an object to the object itself, overwriting the existing * method. Method names may be specified as individual arguments or as arrays * of method names. If no method names are provided all enumerable function - * properties, own and inherited, of `object` will be bound. + * properties, own and inherited, of `object` are bound. * * Note: This method does not set the `length` property of bound functions. * @@ -3435,14 +3471,15 @@ } /** - * Creates a function that will delay the execution of `func` until after - * `wait` milliseconds have elapsed since the last time it was invoked. - * Provide an options object to indicate that `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. Subsequent calls - * to the debounced function will return the result of the last `func` call. + * Creates a function that delays the execution of `func` until after `wait` + * milliseconds have elapsed since the last time it was invoked. The created + * function comes with a `cancel` method to cancel delayed calls. Provide an + * options object to indicate that `func` should be invoked on the leading + * and/or trailing edge of the `wait` timeout. Subsequent calls to the + * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the debounced function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -3458,8 +3495,7 @@ * @example * * // avoid costly calculations while the window size is in flux - * var lazyLayout = _.debounce(calculateLayout, 150); - * jQuery(window).on('resize', lazyLayout); + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * * // execute `sendMail` when the click event is fired, debouncing subsequent calls * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { @@ -3469,9 +3505,26 @@ * * // ensure `batchLog` is executed once after 1 second of debounced calls * var source = new EventSource('/stream'); - * source.addEventListener('message', _.debounce(batchLog, 250, { + * jQuery(source).on('message', _.debounce(batchLog, 250, { * 'maxWait': 1000 * }, false); + * + * // cancel a debounced call + * var todoChanges = _.debounce(batchLog, 1000); + * Object.observe(models.todo, todoChanges); + * + * Object.observe(models, function(changes) { + * if (_.find(changes, { 'name': 'todo', 'type': 'delete'})) { + * todoChanges.cancel(); + * } + * }, ['delete']); + * + * // ...at some point `models.todo` is changed + * models.todo.completed = true; + * + * // ...before 1 second has passed `models.todo` is deleted + * // which cancels the debounced `todoChanges` call + * delete models.todo; */ function debounce(func, wait, options) { var args, @@ -3497,7 +3550,18 @@ maxWait = 'maxWait' in options && nativeMax(wait, +options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } - var delayed = function() { + + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + } + + function delayed() { var remaining = wait - (now() - stamp); if (remaining <= 0 || remaining > wait) { if (maxTimeoutId) { @@ -3515,9 +3579,9 @@ } else { timeoutId = setTimeout(delayed, remaining); } - }; + } - var maxDelayed = function() { + function maxDelayed() { if (timeoutId) { clearTimeout(timeoutId); } @@ -3529,9 +3593,9 @@ args = thisArg = null; } } - }; + } - return function() { + function debounced() { args = arguments; stamp = now(); thisArg = this; @@ -3571,12 +3635,14 @@ args = thisArg = null; } return result; - }; + } + debounced.cancel = cancel; + return debounced; } /** - * Defers executing the `func` function until the current call stack has cleared. - * Additional arguments will be provided to `func` when it is invoked. + * Defers executing the `func` function until the current call stack has + * cleared. Additional arguments are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -3599,7 +3665,7 @@ /** * Executes the `func` function after `wait` milliseconds. Additional arguments - * will be provided to `func` when it is invoked. + * are provided to `func` when it is invoked. * * @static * @memberOf _ @@ -3623,11 +3689,11 @@ /** * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it will be used to determine the cache key for storing the result - * based on the arguments provided to the memoized function. By default, the - * first argument provided to the memoized function is used as the cache key. - * The `func` is executed with the `this` binding of the memoized function. - * The result cache is exposed as the `cache` property on the memoized function. + * provided it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the cache key. The `func` is + * executed with the `this` binding of the memoized function. The result cache + * is exposed as the `cache` property on the memoized function. * * @static * @memberOf _ @@ -3684,8 +3750,8 @@ * @returns {Function} Returns the new function. * @example * - * function isEven(num) { - * return num % 2 == 0; + * function isEven(n) { + * return n % 2 == 0; * } * * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); @@ -3701,8 +3767,8 @@ } /** - * Creates a function that is restricted to execute `func` once. Repeat calls to - * the function will return the value of the first call. The `func` is executed + * Creates a function that is restricted to execute `func` once. Repeat calls + * to the function return the value of the first call. The `func` is executed * with the `this` binding of the created function. * * @static @@ -3763,14 +3829,15 @@ } /** - * Creates a function that, when executed, will only call the `func` function - * at most once per every `wait` milliseconds. Provide an options object to - * indicate that `func` should be invoked on the leading and/or trailing edge - * of the `wait` timeout. Subsequent calls to the throttled function will - * return the result of the last `func` call. + * Creates a function that only calls the `func` function at most once per + * every `wait` milliseconds. The created function comes with a `cancel` method + * to cancel delayed calls. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the throttled function return the result of the last + * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * Note: If `leading` and `trailing` options are `true`, `func` is called on + * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * * @static @@ -3785,13 +3852,14 @@ * @example * * // avoid excessively updating the position while scrolling - * var throttled = _.throttle(updatePosition, 100); - * jQuery(window).on('scroll', throttled); + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) + * jQuery('.interactive').on('click', throttled); + * + * // cancel a trailing throttled call + * jQuery(window).on('popstate', throttled.cancel); */ function throttle(func, wait, options) { var leading = true, @@ -3842,10 +3910,10 @@ /** * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources will overwrite property assignments of previous - * sources. If a callback is provided it will be executed to produce the - * assigned values. The callback is bound to `thisArg` and invoked with - * five arguments; (objectValue, sourceValue, key, object, source). + * object. Subsequent sources overwrite property assignments of previous + * sources. If a callback is provided it is executed to produce the assigned + * values. The callback is bound to `thisArg` and invoked with five arguments; + * (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -3858,15 +3926,15 @@ * @returns {Object} Returns the destination object. * @example * - * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); - * // => { 'name': 'fred', 'employer': 'slate' } + * _.assign({ 'name': 'fred' }, { 'age': 40 }, { 'employer': 'slate' }); + * // => { 'name': 'fred', 'age': 40, 'employer': 'slate' } * * var defaults = _.partialRight(_.assign, function(value, other) { * return typeof value == 'undefined' ? other : value; * }); * - * defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ function assign(object) { if (!object) { @@ -3890,11 +3958,11 @@ } /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects will also - * be cloned, otherwise they will be assigned by reference. If a callback - * is provided it will be executed to produce the cloned values. If the - * callback returns `undefined` cloning will be handled by the method instead. - * The callback is bound to `thisArg` and invoked with two argument; (value, index|key). + * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, + * otherwise they are assigned by reference. If a callback is provided it is + * executed to produce the cloned values. If the callback returns `undefined` + * cloning is handled by the method instead. The callback is bound to `thisArg` + * and invoked with two argument; (value, index|key). * * Note: This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and @@ -3944,7 +4012,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property will be ignored. + * property is set, additional defaults of the same property are ignored. * * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. @@ -3958,8 +4026,8 @@ * @returns {Object} Returns the destination object. * @example * - * _.defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } + * _.defaults({ 'name': 'barney' }, { 'age': 36 }, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'age': 36, 'employer': 'slate' } */ function defaults(object) { if (!object) { @@ -4025,7 +4093,7 @@ /** * Creates an object composed of the inverted keys and values of the given * object. If the given object contains duplicate values, subsequent values - * will overwrite property assignments of previous values unless `multiValue` + * overwrite property assignments of previous values unless `multiValue` * is `true`. * * @static @@ -4216,10 +4284,10 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent. If a callback is provided it will be executed to compare - * values. If the callback returns `undefined` comparisons will be handled - * by the method instead. The callback is bound to `thisArg` and invoked - * with three arguments; (value, other, key). + * equivalent. If a callback is provided it is executed to compare values. + * If the callback returns `undefined` comparisons are handled by the method + * instead. The callback is bound to `thisArg` and invoked with three arguments; + * (value, other, key). * * Note: This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes @@ -4260,7 +4328,7 @@ /** * Checks if `value` is, or can be coerced to, a finite number. * - * Note: This method is not the same as native `isFinite` which will return + * Note: This method is not the same as native `isFinite` which returns * `true` for booleans and empty strings. See the [ES5 spec](http://es5.github.io/#x15.1.2.5) * for more details. * @@ -4350,7 +4418,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which will return `true` + * Note: This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -4546,9 +4614,9 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` omitting the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` omitting the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -4613,9 +4681,9 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a predicate is provided it will be executed for each - * property of `object` picking the properties the predicate returns truthy - * for. The predicate is bound to `thisArg` and invoked with three arguments; + * property names. If a predicate is provided it is executed for each property + * of `object` picking the properties the predicate returns truthy for. The + * predicate is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static @@ -4716,9 +4784,9 @@ * Creates a compiled template function that can interpolate data properties * in "interpolate" delimiters, HTML-escaped interpolated data properties in * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. If - * a data object is provided the interpolated template string will be returned. + * a data object is provided the interpolated template string is returned. * Data properties may be accessed as free variables in the template. If a - * settings object is provided it will override `_.templateSettings` for the + * settings object is provided it overrides `_.templateSettings` for the * template. * * Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. @@ -4898,9 +4966,9 @@ /** * Creates a function bound to an optional `thisArg`. If `func` is a property - * name the created callback will return the property value for a given element. - * If `func` is an object the created callback will return `true` for elements - * that contain the equivalent object properties, otherwise it will return `false`. + * name the created callback returns the property value for a given element. + * If `func` is an object the created callback returns `true` for elements + * that contain the equivalent object properties, otherwise it returns `false`. * * @static * @memberOf _ @@ -5006,7 +5074,7 @@ /** * Adds all own enumerable function properties of a source object to the - * destination object. If `object` is a function methods will be added to + * destination object. If `object` is a function then methods are added to * its prototype as well. * * @static @@ -5125,9 +5193,9 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number will be - * returned. If `floating` is truthy or either `min` or `max` are floats a - * floating-point number will be returned instead of an integer. + * argument is provided a number between `0` and the given number is returned. + * If `floating` is truthy, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. * * @static * @memberOf _ @@ -5221,10 +5289,10 @@ /** * Resolves the value of property `key` on `object`. If `key` is a function - * it will be invoked with the `this` binding of `object` and its result - * returned, else the property value is returned. If `object` is `null` or - * `undefined` then `undefined` is returned. If a default value is provided - * it will be returned if the property value resolves to `undefined`. + * it is invoked with the `this` binding of `object` and its result returned, + * else the property value is returned. If `object` is `null` or `undefined` + * then `undefined` is returned. If a default value is provided it is returned + * if the property value resolves to `undefined`. * * @static * @memberOf _ @@ -5296,7 +5364,7 @@ } /** - * Generates a unique ID. If `prefix` is provided the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided the ID is appended to it. * * @static * @memberOf _ diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index a94de725e..a1d307cae 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -1,41 +1,43 @@ /** * @license - * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE + * Lo-Dash 2.5.0-pre (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,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined"){t=1;break n}if(t>>0:0,u=Array(e);++tu(r,i)&&o.push(i)}return o}function g(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number"&&-1o?0:o>>>0);return g(n,function(n){var o=u?r:null!=n&&n[r];i[++e]=o?o.apply(n,t):sr}),i}function w(n,r){var t={};if(typeof r=="function")return d(n,function(n,e,u){r(n,e,u)&&(t[e]=n)}),t;for(var e=-1,u=r.length;++eo(f,c)&&(t&&f.push(c),i.push(a))}return i}function T(n,r,t,e){try{var u=Function(r,"return "+n+(e?"\n/*\n//# sourceURL="+e+"\n*/":"")).apply(sr,t);u.source=n}catch(o){throw o.source=n,o}return u}function A(n,r){return function(t,e,u){var o=r?r():{};e=fr(e,u,3),u=-1;var i=t?t.length:0;if(typeof i=="number"&&-1r?0:r) -}function q(r,t,e){var u=r?r.length:0;if(typeof e=="number")e=0>e?ot(u+e,0):e||0;else if(e)return e=B(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function F(n,r,t){return R(n,null==r||t?1:0>r?0:r)}function R(n,r,t){var e=-1,u=n?n.length:0;for(r=null==r?0:+r||0,0>r?r=ot(u+r,0):r>u&&(r=u),t=typeof t=="undefined"?u:+t||0,0>t?t=ot(u+t,0):t>u&&(t=u),u=r>t?0:t-r,t=Array(u);++e>>1,t(n[e])u&&(u=t);else r=fr(r,t,3),g(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function L(n,r){return U(n,pr(r))}function P(n,r,t,e){var u=3>arguments.length; -r=fr(r,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number"&&-1arguments.length;return r=fr(r,e,4),h(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function G(n){var r=-1,t=n&&n.length,e=Array(0>t?0:t>>>0);return g(n,function(n){var t=j(0,++r);e[r]=e[t],e[t]=n}),e}function H(n,r,t){var e;(typeof r!="function"||typeof t!="undefined")&&(r=fr(r,t,3)),t=-1;var u=n?n.length:0; -if(typeof u=="number"&&-1arguments.length?E(n,gr,null,r):E(n,gr|vr,null,r,R(arguments,2))}function K(n,r,t){var e,u,o,i,f,a,c,l=0,p=false,s=true;if(!rr(n))throw new TypeError(mr);if(r=0>r?0:r,true===t)var g=true,s=false;else tr(t)&&(g=t.leading,p="maxWait"in t&&ot(r,+t.maxWait||0),s="trailing"in t?t.trailing:s);var h=function(){var t=r-(dt()-i);0>=t||t>r?(u&&clearTimeout(u),t=c,u=a=c=sr,t&&(l=dt(),o=n.apply(f,e),a||u||(e=f=null))):a=setTimeout(h,t) -},v=function(){a&&clearTimeout(a),u=a=c=sr,(s||p!==r)&&(l=dt(),o=n.apply(f,e),a||u||(e=f=null))};return function(){if(e=arguments,i=dt(),f=this,c=s&&(a||!g),false===p)var t=g&&!a;else{u||g||(l=i);var y=p-(i-l),m=0>=y||y>p;m?(u&&(u=clearTimeout(u)),l=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o}}function Q(n){if(!rr(n))throw new TypeError(mr);return function(){return!n.apply(this,arguments)}}function X(n){if(!n)return n; -var r=arguments,t=0,e=r.length,u=typeof r[2];for("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2);++t"']/g,wr=/($^)/,jr=/[.*+?^${}()|[\]\/\\]/g,xr=/['\n\r\u2028\u2029\\]/g,Tr="[object Arguments]",Ar="[object Array]",Er="[object Boolean]",Or="[object Date]",kr="[object Number]",Sr="[object Object]",Nr="[object RegExp]",qr="[object String]",Fr={"&":"&","<":"<",">":">",'"':""","'":"'"},Rr={"&":"&","<":"<",">":">",""":'"',"'":"'"},Br={"function":true,object:true},Mr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$r=Br[typeof window]&&window||this,Ir=Br[typeof exports]&&exports&&!exports.nodeType&&exports,Dr=Br[typeof module]&&module&&!module.nodeType&&module,Wr=Ir&&Dr&&typeof global=="object"&&global; -!Wr||Wr.global!==Wr&&Wr.window!==Wr&&Wr.self!==Wr||($r=Wr);var zr=Dr&&Dr.exports===Ir&&Ir,Ur=Array.prototype,Cr=Object.prototype,Lr=$r._,Pr=Math.pow(2,53)-1,Vr=Cr.toString,Gr=RegExp("^"+(null==Vr?"":(Vr+"").replace(jr,"\\$&")).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hr=Math.ceil,Jr=Math.floor,Kr=Function.prototype.toString,Qr=Cr.hasOwnProperty,Xr=Ur.push,Yr=Cr.propertyIsEnumerable,Zr=Ur.splice,nt=k(nt=Object.create)&&nt,rt=k(rt=Array.isArray)&&rt,tt=$r.isFinite,et=$r.isNaN,ut=k(ut=Object.keys)&&ut,ot=Math.max,it=Math.min,ft=k(ft=Date.now)&&ft,at=Math.random; -i.prototype=o.prototype;var ct={};!function(n){n={0:1,length:1},ct.spliceObjects=(Zr.call(n,0,1),!n[0])}(0,0),o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},nt||(c=function(){function n(){}return function(r){if(tr(r)){n.prototype=r;var t=new n;n.prototype=null}return t||$r.Object()}}());var lt=F,pt=N,st=A(function(n,r,t){Qr.call(n,t)?n[t]++:n[t]=1}),gt=A(function(n,r,t){Qr.call(n,t)?n[t].push(r):n[t]=[r]}),ht=A(function(n,r,t){n[t]=r -}),vt=A(function(n,r,t){n[t?0:1].push(r)},function(){return[[],[]]});nr(arguments)||(nr=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Qr.call(n,"callee")&&!Yr.call(n,"callee")||false});var yt=rt||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Vr.call(n)==Ar||false};rr(/x/)&&(rr=function(n){return typeof n=="function"&&"[object Function]"==Vr.call(n)});var mt=ut?function(n){return tr(n)?ut(n):[]}:S,dt=ft||function(){return(new Date).getTime()};o.after=function(n,r){if(!rr(r))throw new TypeError(mr); -return n=tt(n=+n)?n:0,function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=J,o.bindAll=function(n){for(var r=n,t=1r?0:r)},o.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},o.invert=function(n){for(var r=-1,t=mt(n),e=t.length,u={};++ro?0:o>>>0);for(t=fr(t,e,3),g(n,function(n,r,e){i[++u]={a:t(n,r,e),b:u,c:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].c;return i -},o.tap=function(n,r){return r(n),n},o.throttle=function(n,r,t){var e=true,u=true;if(!rr(n))throw new TypeError(mr);return false===t?e=false:tr(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),K(n,r,{leading:e,maxWait:r,trailing:u})},o.times=function(n,r,t){n=0>n?0:n>>>0,r=l(r,t,1),t=-1;for(var e=Array(n);++tr?0:r);++nt?ot(e+t,0):it(t||0,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.noConflict=function(){return $r._=Lr,this -},o.now=dt,o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Jr(at()*(r-n+1))},o.reduce=P,o.reduceRight=V,o.result=function(n,r){if(null!=n){var t=n[r];return rr(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"&&-1n.indexOf(";")?n:n.replace(br,u))},o.uniqueId=function(n){var r=++dr+"";return n?n+r:r},o.all=I,o.any=H,o.detect=W,o.foldl=P,o.foldr=V,o.include=$,o.inject=P,o.first=N,o.last=function(n,r,t){var e=n?n.length:0;return null==r||t?n?n[e-1]:sr:(r=e-(r||0),R(n,0>r?0:r)) -},o.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=ir(n)),null==r||t?(r=n?n.length:0,0r?0:+r||0,n.length),n)},o.take=pt,o.head=N,lr(function(n,r,t){if(!n)return n;for(var e=-1,u=mt(r),o=u.length;++ee||typeof t=="undefined"){t=1;break n}if(t>>0:0,u=Array(e);++tu(r,i)&&o.push(i)}return o}function g(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number"&&-1o?0:o>>>0);return g(n,function(n){var o=u?r:null!=n&&n[r];i[++e]=o?o.apply(n,t):sr}),i}function j(n,r){var t={};if(typeof r=="function")return b(n,function(n,e,u){r(n,e,u)&&(t[e]=n)}),t;for(var e=-1,u=r.length;++eo(f,c)&&(t&&f.push(c),i.push(a))}return i}function x(n,r){var t,e=["_"];try{var u=Function(e,"return "+n+(t?"\n/*\n//# sourceURL="+t+"\n*/":"")).apply(sr,r);u.source=n}catch(o){throw o.source=n,o}return u}function T(n,r){return function(t,e,u){var o=r?r():{};e=fr(e,u,3),u=-1;var i=t?t.length:0;if(typeof i=="number"&&-1r?0:r)}function I(r,t,e){var u=r?r.length:0;if(typeof e=="number")e=0>e?it(u+e,0):e||0;else if(e)return e=q(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function M(n,r,t){return N(n,null==r||t?1:0>r?0:r)}function N(n,r,t){var e=-1,u=n?n.length:0;for(r=null==r?0:+r||0,0>r?r=it(u+r,0):r>u&&(r=u),t=typeof t=="undefined"?u:+t||0,0>t?t=it(u+t,0):t>u&&(t=u),u=r>t?0:t-r,t=Array(u);++e>>1,t(n[e])u&&(u=t);else r=fr(r,t,3),g(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function L(n,r){return z(n,pr(r))}function P(n,r,t,e){var u=3>arguments.length; +r=fr(r,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number"&&-1arguments.length;return r=fr(r,e,4),h(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function G(n){var r=-1,t=n&&n.length,e=Array(0>t?0:t>>>0);return g(n,function(n){var t=w(++r);e[r]=e[t],e[t]=n}),e}function H(n,r,t){var e;(typeof r!="function"||typeof t!="undefined")&&(r=fr(r,t,3)),t=-1;var u=n?n.length:0; +if(typeof u=="number"&&-1arguments.length?E(n,gr,r):E(n,gr|vr,r,N(arguments,2))}function K(n,r,t){function e(){var t=r-(dt()-c);0>=t||t>r?(f&&clearTimeout(f),t=s,f=p=s=sr,t&&(g=dt(),a=n.apply(l,i),p||f||(i=l=null))):p=setTimeout(e,t)}function u(){p&&clearTimeout(p),f=p=s=sr,(v||h!==r)&&(g=dt(),a=n.apply(l,i),p||f||(i=l=null))}function o(){if(i=arguments,c=dt(),l=this,s=v&&(p||!y),false===h)var t=y&&!p; +else{f||y||(g=c);var o=h-(c-g),m=0>=o||o>h;m?(f&&(f=clearTimeout(f)),g=c,a=n.apply(l,i)):f||(f=setTimeout(u,o))}return m&&p?p=clearTimeout(p):p||r===h||(p=setTimeout(e,r)),t&&(m=true,a=n.apply(l,i)),!m||p||f||(i=l=null),a}var i,f,a,c,l,p,s,g=0,h=false,v=true;if(!rr(n))throw new TypeError(mr);if(r=0>r?0:r,true===t)var y=true,v=false;else tr(t)&&(y=t.leading,h="maxWait"in t&&it(r,+t.maxWait||0),v="trailing"in t?t.trailing:v);return o.cancel=function(){p&&clearTimeout(p),f&&clearTimeout(f),f=p=s=sr},o}function Q(n){if(!rr(n))throw new TypeError(mr); +return function(){return!n.apply(this,arguments)}}function X(n){if(!n)return n;var r=arguments,t=0,e=r.length,u=typeof r[2];for("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2);++t"'`]/g,jr=/^\[object .+?Constructor\]$/,wr=/($^)/,Ar=/[.*+?^${}()|[\]\/\\]/g,xr=/['\n\r\u2028\u2029\\]/g,Tr="[object Arguments]",Er="[object Boolean]",kr="[object Date]",Or="[object Number]",Sr="[object Object]",Fr="[object RegExp]",Ir="[object String]",Mr={};Mr[Tr]=Mr["[object Array]"]=Mr["[object Float32Array]"]=Mr["[object Float64Array]"]=Mr["[object Int8Array]"]=Mr["[object Int16Array]"]=Mr["[object Int32Array]"]=Mr["[object Uint8Array]"]=Mr["[object Uint8ClampedArray]"]=Mr["[object Uint16Array]"]=Mr["[object Uint32Array]"]=true,Mr["[object ArrayBuffer]"]=Mr[Er]=Mr[kr]=Mr["[object Error]"]=Mr["[object Function]"]=Mr["[object Map]"]=Mr[Or]=Mr[Sr]=Mr[Fr]=Mr["[object Set]"]=Mr[Ir]=Mr["[object WeakMap]"]=false; +var Nr={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qr={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Br={"function":true,object:true},Rr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$r=Br[typeof window]&&window||this,Ur=Br[typeof exports]&&exports&&!exports.nodeType&&exports,Wr=Br[typeof module]&&module&&!module.nodeType&&module,Dr=Ur&&Wr&&typeof global=="object"&&global;!Dr||Dr.global!==Dr&&Dr.window!==Dr&&Dr.self!==Dr||($r=Dr); +var zr=Wr&&Wr.exports===Ur&&Ur,Cr=Array.prototype,Lr=Object.prototype,Pr=Function.prototype.toString,Vr=Math.pow(2,53)-1,Gr=$r._,Hr=Lr.toString,Jr=RegExp("^"+(null==Hr?"":(Hr+"").replace(Ar,"\\$&")).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Kr=Math.ceil,Qr=Math.floor,Xr=Lr.hasOwnProperty,Yr=Cr.push,Zr=Lr.propertyIsEnumerable,nt=Cr.splice,rt=O(rt=Object.create)&&rt,tt=O(tt=Array.isArray)&&tt,et=$r.isFinite,ut=$r.isNaN,ot=O(ot=Object.keys)&&ot,it=Math.max,ft=Math.min,at=O(at=Date.now)&&at,ct=Math.random; +i.prototype=o.prototype;var lt={};!function(){var n={0:1,length:1};lt.spliceObjects=(nt.call(n,0,1),!n[0])}(0,0),o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},rt||(c=function(){function n(){}return function(r){if(tr(r)){n.prototype=r;var t=new n;n.prototype=null}return t||$r.Object()}}());var pt=M,st=F,gt=T(function(n,r,t){Xr.call(n,t)?n[t]++:n[t]=1}),ht=T(function(n,r,t){Xr.call(n,t)?n[t].push(r):n[t]=[r]}),vt=T(function(n,r,t){n[t]=r +}),yt=T(function(n,r,t){n[t?0:1].push(r)},function(){return[[],[]]});nr(arguments)||(nr=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Xr.call(n,"callee")&&!Zr.call(n,"callee")||false});var mt=tt||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&"[object Array]"==Hr.call(n)||false};rr(/x/)&&(rr=function(n){return typeof n=="function"&&"[object Function]"==Hr.call(n)});var bt=ot?function(n){return tr(n)?ot(n):[]}:S,dt=at||function(){return(new Date).getTime()};o.after=function(n,r){if(!rr(r))throw new TypeError(mr); +return n=et(n=+n)?n:0,function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=J,o.bindAll=function(n){for(var r=n,t=1r?0:r)},o.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},o.invert=function(n){for(var r=-1,t=bt(n),e=t.length,u={};++ro?0:o>>>0);for(t=fr(t,e,3),g(n,function(n,r,e){i[++u]={a:t(n,r,e),b:u,c:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].c;return i +},o.tap=function(n,r){return r(n),n},o.throttle=function(n,r,t){var e=true,u=true;if(!rr(n))throw new TypeError(mr);return false===t?e=false:tr(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),K(n,r,{leading:e,maxWait:r,trailing:u})},o.times=function(n,r,t){n=0>n?0:n>>>0,r=l(r,t,1),t=-1;for(var e=Array(n);++tr?0:r);++nt?it(e+t,0):ft(t||0,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.noConflict=function(){return $r._=Gr,this +},o.now=dt,o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Qr(ct()*(r-n+1))},o.reduce=P,o.reduceRight=V,o.result=function(n,r){if(null!=n){var t=n[r];return rr(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"&&-1n.indexOf(";")?n:n.replace(dr,u))},o.uniqueId=function(n){var r=++br+"";return n?n+r:r},o.all=$,o.any=H,o.detect=W,o.foldl=P,o.foldr=V,o.include=R,o.inject=P,o.first=F,o.last=function(n,r,t){var e=n?n.length:0;return null==r||t?n?n[e-1]:sr:(r=e-(r||0),N(n,0>r?0:r)) +},o.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=ir(n)),null==r||t?(r=n?n.length:0,0r?0:+r||0,n.length),n)},o.take=st,o.head=F,lr(function(n,r,t){for(var e=-1,u=bt(r),o=u.length;++e