From 6c8893a55078f836e43190449f46cc9156515308 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 01:08:55 -0800 Subject: [PATCH 001/176] Add a benchmark for `_.some` with `thisArg` and avoid corrupting the aggregate score if a single benchmark errors. [ci skip] Former-commit-id: 10dae73eb07e610a7752fc3f9035e71e696ce93d --- perf/perf.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/perf/perf.js b/perf/perf.js index d8dda55b30..625e9ee9e3 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -78,7 +78,8 @@ * @returns {Number} Returns the adjusted Hz. */ function getHz(bench) { - return 1 / (bench.stats.mean + bench.stats.moe); + var result = 1 / (bench.stats.mean + bench.stats.moe); + return isFinite(result) ? result : 0; } /** @@ -1419,6 +1420,20 @@ ) ); + suites.push( + Benchmark.Suite('`_.some` with `thisArg` iterating an array (slow path)') + .add(buildName, '\ + lodash.some(objects, function(value, index) {\ + return this["key" + index] == 19;\ + }, object)' + ) + .add(otherName, '\ + _.some(objects, function(value, index) {\ + return this["key" + index] == 19;\ + }, object)' + ) + ); + suites.push( Benchmark.Suite('`_.some` iterating an object') .add(buildName, '\ From 3bee212876ebac3e6e53c10abf4e4256f7c32580 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 01:49:50 -0800 Subject: [PATCH 002/176] Update Chrome extension sandboxing link in README.md. [ci skip] Former-commit-id: c093d1d8356b5ef4129e91b820478c25c5224798 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d6c4893b8..19924c1c7c 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ lodash backbone ``` * CSP builds, supporting default [Content Security Policy](http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html) restrictions, may be created using the `csp` modifier argument. - The `csp` modifier is an alais of the `mobile` modifier. Chrome extensions will require [sandboxing](http://developer.chrome.com/trunk/extensions/sandboxingEval.html) or the use of either the `csp`, `mobile`, or `underscore` build. + The `csp` modifier is an alais of the `mobile` modifier. Chrome extensions will require [sandboxing](http://developer.chrome.com/extensions/sandboxingEval.html) or the use of either the `csp`, `mobile`, or `underscore` build. ```bash lodash csp ``` From 2f20781e162253bbf8f978e162b8ad1f33098be9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 02:45:56 -0800 Subject: [PATCH 003/176] Optimize `_.invert`, `_.pairs`, and `_.values`. Former-commit-id: 7df68977c0a99b48e8989101228432c3db55c460 --- build.js | 6 ++--- lodash.js | 78 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/build.js b/build.js index 899d190a8b..0f42a66cfd 100755 --- a/build.js +++ b/build.js @@ -97,7 +97,7 @@ 'indexOf': ['sortedIndex'], 'initial': [], 'intersection': ['indexOf'], - 'invert': ['forOwn'], + 'invert': ['keys'], 'invoke': ['forEach'], 'isArguments': [], 'isArray': [], @@ -129,7 +129,7 @@ 'object': [], 'omit': ['forIn', 'indexOf'], 'once': [], - 'pairs': ['forOwn'], + 'pairs': ['keys'], 'partial': ['isFunction', 'isObject'], 'pick': ['forIn'], 'pluck': ['map'], @@ -155,7 +155,7 @@ 'uniq': ['identity', 'indexOf'], 'uniqueId': [], 'value': ['mixin'], - 'values': ['forOwn'], + 'values': ['keys'], 'where': ['filter', 'keys'], 'without': ['indexOf'], 'wrap': [], diff --git a/lodash.js b/lodash.js index f4a8bb12db..7e659648c2 100644 --- a/lodash.js +++ b/lodash.js @@ -892,6 +892,26 @@ */ var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + /** + * Creates an array composed of the own enumerable property names of `object`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns a new array of property names. + * @example + * + * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); + * // => ['one', 'two', 'three'] (order is not guaranteed) + */ + var keys = !nativeKeys ? shimKeys : function(object) { + // avoid iterating over the `prototype` property + return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype') + ? shimKeys(object) + : (isObject(object) ? nativeKeys(object) : []); + }; + /** * A fallback implementation of `isPlainObject` that checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -1179,10 +1199,15 @@ * // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) */ function invert(object) { - var result = {}; - forOwn(object, function(value, key) { - result[value] = key; - }); + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + result[object[key]] = key; + } return result; } @@ -1684,26 +1709,6 @@ return typeof value == 'undefined'; } - /** - * Creates an array composed of the own enumerable property names of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (order is not guaranteed) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - // avoid iterating over the `prototype` property - return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype') - ? shimKeys(object) - : (isObject(object) ? nativeKeys(object) : []); - }; - /** * Merges enumerable properties of the source object(s) into the `destination` * object. Subsequent sources will overwrite propery assignments of previous @@ -1844,10 +1849,15 @@ * // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) */ function pairs(object) { - var result = []; - forOwn(object, function(value, key) { - result.push([key, value]); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } return result; } @@ -1914,10 +1924,14 @@ * // => [1, 2, 3] */ function values(object) { - var result = []; - forOwn(object, function(value) { - result.push(value); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } return result; } From bba18cd56b1477e5a622a865c2bb781e0b2982c1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 07:41:34 -0800 Subject: [PATCH 004/176] Update vendors, builds, and docs. Former-commit-id: 488762bd908dca5538767e4b4210ca0079560520 --- doc/README.md | 186 ++++++++++++++--------------- lodash.min.js | 69 +++++------ lodash.underscore.js | 72 ++++++----- lodash.underscore.min.js | 55 ++++----- vendor/backbone/backbone.js | 50 ++++---- vendor/backbone/test/collection.js | 49 ++++++-- vendor/backbone/test/events.js | 24 ++++ 7 files changed, 286 insertions(+), 219 deletions(-) diff --git a/doc/README.md b/doc/README.md index 1341019713..faef8e4ecc 100644 --- a/doc/README.md +++ b/doc/README.md @@ -186,7 +186,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2728 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -210,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -235,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -263,7 +263,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -291,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2862 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -323,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -348,7 +348,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -372,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2974 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -397,7 +397,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3001 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -426,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3017 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -451,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3076 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -489,7 +489,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -517,7 +517,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3159 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -561,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3177 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3191 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -585,7 +585,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -624,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -649,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3315 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -706,7 +706,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4182 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -736,7 +736,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4199 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -757,7 +757,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4216 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -788,7 +788,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1967 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -826,7 +826,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -858,7 +858,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2044 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -887,7 +887,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2069 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2083 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +916,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +945,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -977,7 +977,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2204 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1009,7 +1009,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2237 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1038,7 +1038,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1070,7 +1070,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1102,7 +1102,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2357 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1128,7 +1128,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2406 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1159,7 +1159,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2430 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1189,7 +1189,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2472 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1220,7 +1220,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2510 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1246,7 +1246,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2531 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1270,7 +1270,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1300,7 +1300,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2588 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1329,7 +1329,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1361,7 +1361,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2667 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1385,7 +1385,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2698 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1423,7 +1423,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3348 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1451,7 +1451,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3381 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1482,7 +1482,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3397 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3411 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1513,7 +1513,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3443 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1554,7 +1554,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3480 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1581,7 +1581,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1607,7 +1607,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3577 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1632,7 +1632,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1659,7 +1659,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1685,7 +1685,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3628 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3685 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1763,7 +1763,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1827,7 +1827,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1023 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1863,7 +1863,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1118 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1896,7 +1896,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1140 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1986,7 +1986,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1139 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1159 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2013,7 +2013,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1184 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2038,7 +2038,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1181 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2089,7 +2089,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1230 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2116,7 +2116,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1224 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1249 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2140,7 +2140,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2164,7 +2164,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2188,7 +2188,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2218,7 +2218,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2249,7 +2249,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2287,7 +2287,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2311,7 +2311,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2346,7 +2346,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2373,7 +2373,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1596 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2397,7 +2397,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1549 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2427,7 +2427,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2462,7 +2462,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2486,7 +2486,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1666 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1691 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2510,7 +2510,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1683 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1708 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2534,7 +2534,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L908 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2558,7 +2558,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2593,7 +2593,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1812 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2624,7 +2624,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2648,7 +2648,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2679,7 +2679,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2710,7 +2710,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3762 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2734,7 +2734,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3766 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3780 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2759,7 +2759,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3806 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2789,7 +2789,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2809,7 +2809,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3855 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2837,7 +2837,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2872,7 +2872,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3978 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2950,7 +2950,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4109 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2982,7 +2982,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4135 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3006,7 +3006,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4155 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3040,7 +3040,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.min.js b/lodash.min.js index 40126c4a5d..8a28924d99 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -6,37 +6,38 @@ ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" -,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s} -function A(e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o= -e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g -,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt= -p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype= -{valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0, -number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e) -}:m,gn=At?function(e){return typeof e=="function"&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D, -n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if(typeof t!="function")for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0; -return typeof t=="number"?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'" -),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source= -l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]|| -(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice" -],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file +,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return pn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e +,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A(e,t,n){var r=!0,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments +.length,t=u(t,r,et);if(mn(e)){var s=-1,o=e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=hn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/ +,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable +,Tt=Y.toString,Nt=lt.test(Nt=p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e() +{this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean" +:!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},dn=w(pn),vn=a(sn,{g:"if(t[i]==null)"+sn.g}),mn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var gn=wt?function(e){if(!e||typeof +e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=hn +,n.map=D,n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!mn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=hn(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t= +e?e.length:0;return typeof t=="number"?t:hn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+ +r+"))==null?'':__t)+'"),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n) +}catch(p){throw p.source=l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function( +e,t){n.prototype[t]||(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an +(["concat","slice","splice"],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports= +n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index a68dd807b9..dc9ac65590 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -715,6 +715,23 @@ return result }; + /** + * Creates an array composed of the own enumerable property names of `object`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns a new array of property names. + * @example + * + * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); + * // => ['one', 'two', 'three'] (order is not guaranteed) + */ + var keys = !nativeKeys ? shimKeys : function(object) { + return (isObject(object) ? nativeKeys(object) : []); + }; + /** * A fallback implementation of `isPlainObject` that checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -912,10 +929,15 @@ * // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) */ function invert(object) { - var result = {}; - forOwn(object, function(value, key) { - result[value] = key; - }); + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + result[object[key]] = key; + } return result; } @@ -1371,23 +1393,6 @@ return typeof value == 'undefined'; } - /** - * Creates an array composed of the own enumerable property names of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (order is not guaranteed) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - return (isObject(object) ? nativeKeys(object) : []); - }; - /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of @@ -1440,10 +1445,15 @@ * // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) */ function pairs(object) { - var result = []; - forOwn(object, function(value, key) { - result.push([key, value]); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } return result; } @@ -1501,10 +1511,14 @@ * // => [1, 2, 3] */ function values(object) { - var result = []; - forOwn(object, function(value) { - result.push(value); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } return result; } diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index daba5025c4..03ad89b12a 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,31 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||typeof e=="undefined")return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1 -,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft= -K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029" -:"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1> -e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert= -v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r; -return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+ -(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function( -e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" -.split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file +(e,t,n){return e?typeof e!="function"?function(t){return t[e]}:typeof t!="undefined"?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)}:e:q}function o(e){return"\\"+Tt[e]}function u(e){return At[e]}function a(){}function f(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n, +r){var i=3>arguments.length,t=s(t,r,V);if(Mt(e)){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Lt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Mt(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st= +f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt= +{"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},Ot=v(At),Mt=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"== +it.call(e)}),n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t +[u],o))continue e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Mt(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=Lt(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Lt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings +),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch( +f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype +.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._= +n})(this); \ No newline at end of file diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index 38cc991290..f4cfabd26b 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -190,25 +190,27 @@ // An inversion-of-control version of `on`. Tell *this* object to listen to // an event in another object ... keeping track of what it's listening to. - listenTo: function(object, events, callback) { + listenTo: function(object, events, callback, context) { + context = context || this; var listeners = this._listeners || (this._listeners = {}); var id = object._listenerId || (object._listenerId = _.uniqueId('l')); listeners[id] = object; - object.on(events, callback || this, this); + object.on(events, callback || context, context); return this; }, // Tell this object to stop listening to either specific events ... or // to every object it's currently listening to. - stopListening: function(object, events, callback) { + stopListening: function(object, events, callback, context) { + context = context || this; var listeners = this._listeners; if (!listeners) return; if (object) { - object.off(events, callback, this); + object.off(events, callback, context); if (!events && !callback) delete listeners[object._listenerId]; } else { for (var id in listeners) { - listeners[id].off(null, null, this); + listeners[id].off(null, null, context); } this._listeners = {}; } @@ -237,7 +239,7 @@ this.attributes = {}; this._changes = []; if (options && options.collection) this.collection = options.collection; - if (options && options.parse) attrs = this.parse(attrs); + if (options && options.parse) attrs = this.parse(attrs, options); if (defaults = _.result(this, 'defaults')) _.defaults(attrs, defaults); this.set(attrs, {silent: true}); this._currentAttributes = _.clone(this.attributes); @@ -352,7 +354,7 @@ var model = this; var success = options.success; options.success = function(resp, status, xhr) { - if (!model.set(model.parse(resp), options)) return false; + if (!model.set(model.parse(resp, options), options)) return false; if (success) success(model, resp, options); }; return this.sync('read', this, options); @@ -394,7 +396,7 @@ var success = options.success; options.success = function(resp, status, xhr) { done = true; - var serverAttrs = model.parse(resp); + var serverAttrs = model.parse(resp, options); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); if (!model.set(serverAttrs, options)) return false; if (success) success(model, resp, options); @@ -453,7 +455,7 @@ // **parse** converts a response into the hash of attributes to be `set` on // the model. The default implementation is just to pass the response along. - parse: function(resp) { + parse: function(resp, options) { return resp; }, @@ -567,8 +569,8 @@ }, // Run validation against the next complete set of model attributes, - // returning `true` if all is well. If a specific `error` callback has - // been passed, call that instead of firing the general `"error"` event. + // returning `true` if all is well. Otherwise, fire a general + // `"error"` event and call the error callback, if specified. _validate: function(attrs, options) { if (!this.validate) return true; attrs = _.extend({}, this.attributes, attrs); @@ -636,11 +638,10 @@ } models[i] = model; - existing = model.id != null && this._byId[model.id]; // If a duplicate is found, prevent it from being added and // optionally merge it into the existing model. - if (existing || this._byCid[model.cid]) { - if (options && options.merge && existing) { + if (existing = this.get(model)) { + if (options && options.merge) { existing.set(model.attributes, options); needsSort = sort; } @@ -651,7 +652,7 @@ // Listen to added models' events, and index models for lookup by // `id` and by `cid`. model.on('all', this._onModelEvent, this); - this._byCid[model.cid] = model; + this._byId[model.cid] = model; if (model.id != null) this._byId[model.id] = model; } @@ -685,7 +686,7 @@ model = this.get(models[i]); if (!model) continue; delete this._byId[model.id]; - delete this._byCid[model.cid]; + delete this._byId[model.cid]; index = this.indexOf(model); this.models.splice(index, 1); this.length--; @@ -734,7 +735,8 @@ // Get a model from the set by id. get: function(obj) { if (obj == null) return void 0; - return this._byId[obj.id != null ? obj.id : obj] || this._byCid[obj.cid || obj]; + this._idAttr || (this._idAttr = this.model.prototype.idAttribute); + return this._byId[obj.id || obj.cid || obj[this._idAttr] || obj]; }, // Get the model at the given index. @@ -781,9 +783,8 @@ update: function(models, options) { var model, i, l, existing; var add = [], remove = [], modelMap = {}; - var idAttr = this.model.prototype.idAttribute; options = _.extend({add: true, merge: true, remove: true}, options); - if (options.parse) models = this.parse(models); + if (options.parse) models = this.parse(models, options); // Allow a single model (or no argument) to be passed. if (!_.isArray(models)) models = models ? [models] : []; @@ -794,7 +795,7 @@ // Determine which models to add and merge, and which to remove. for (i = 0, l = models.length; i < l; i++) { model = models[i]; - existing = this.get(model.id || model.cid || model[idAttr]); + existing = this.get(model); if (options.remove && existing) modelMap[existing.cid] = true; if ((options.add && !existing) || (options.merge && existing)) { add.push(model); @@ -818,7 +819,7 @@ // any `add` or `remove` events. Fires `reset` when finished. reset: function(models, options) { options || (options = {}); - if (options.parse) models = this.parse(models); + if (options.parse) models = this.parse(models, options); for (var i = 0, l = this.models.length; i < l; i++) { this._removeReference(this.models[i]); } @@ -865,7 +866,7 @@ // **parse** converts a response into a list of models to be added to the // collection. The default implementation is just to pass it through. - parse: function(resp) { + parse: function(resp, options) { return resp; }, @@ -886,7 +887,6 @@ this.length = 0; this.models = []; this._byId = {}; - this._byCid = {}; }, // Prepare a model or hash of attributes to be added to this collection. @@ -1473,7 +1473,7 @@ }; // Make the request, allowing the user to override any Ajax options. - var xhr = Backbone.ajax(_.extend(params, options)); + var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); model.trigger('request', model, xhr, options); return xhr; }; @@ -1499,7 +1499,7 @@ if (protoProps && _.has(protoProps, 'constructor')) { child = protoProps.constructor; } else { - child = function(){ parent.apply(this, arguments); }; + child = function(){ return parent.apply(this, arguments); }; } // Add static properties to the constructor function, if supplied. diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index 339a50e8b2..28b857a444 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -62,13 +62,15 @@ $(document).ready(function() { strictEqual(collection.last().get('a'), 4); }); - test("get", 3, function() { + test("get", 5, function() { equal(col.get(0), d); equal(col.get(2), b); + equal(col.get({id: 1}), c); + equal(col.get(c.clone()), c); equal(col.get(col.first().cid), col.first()); }); - test("get with non-default ids", 2, function() { + test("get with non-default ids", 4, function() { var col = new Backbone.Collection(); var MongoModel = Backbone.Model.extend({ idAttribute: '_id' @@ -78,6 +80,12 @@ $(document).ready(function() { equal(col.get(100), model); model.set({_id: 101}); equal(col.get(101), model); + + var Col2 = Backbone.Collection.extend({ model: MongoModel }); + col2 = new Col2(); + col2.push(model); + equal(col2.get({_id: 101}), model); + equal(col2.get(model.clone()), model); }); test("update index when id changes", 3, function() { @@ -882,14 +890,14 @@ $(document).ready(function() { new Collection().push({id: 1}); }); - // test("`update` with non-normal id", function() { - // var Collection = Backbone.Collection.extend({ - // model: Backbone.Model.extend({idAttribute: '_id'}) - // }); - // var collection = new Collection({_id: 1}); - // collection.update([{_id: 1, a: 1}], {add: false}); - // equal(collection.first().get('a'), 1); - // }); + test("`update` with non-normal id", function() { + var Collection = Backbone.Collection.extend({ + model: Backbone.Model.extend({idAttribute: '_id'}) + }); + var collection = new Collection({_id: 1}); + collection.update([{_id: 1, a: 1}], {add: false}); + equal(collection.first().get('a'), 1); + }); test("#1894 - `sort` can optionally be turned off", 0, function() { var Collection = Backbone.Collection.extend({ @@ -906,8 +914,27 @@ $(document).ready(function() { return data.data; } })); - var res = {status: 'ok', data:[{id: 1}]} + var res = {status: 'ok', data:[{id: 1}]}; collection.update(res, {parse: true}); }); + asyncTest("#1939 - `parse` is passed `options`", 1, function () { + var collection = new (Backbone.Collection.extend({ + url: '/', + parse: function (data, options) { + strictEqual(options.xhr.someHeader, 'headerValue'); + return data; + } + })); + var ajax = Backbone.ajax; + Backbone.ajax = function (params) { + _.defer(params.success); + return {someHeader: 'headerValue'}; + }; + collection.fetch({ + success: function () { start(); } + }); + Backbone.ajax = ajax; + }); + }); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index c3f1d61dd0..946c25bb0e 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -86,6 +86,30 @@ $(document).ready(function() { b.trigger('change'); }); + test("listenTo with context", 1, function() { + var a = _.extend({}, Backbone.Events); + var ctx = {}; + a.listenTo(a, 'foo', function(){ equal(this, ctx); }, ctx); + a.trigger('foo'); + }); + + test("stopListening with context", 2, function() { + var a = _.extend({}, Backbone.Events); + var ctx = {}; + var calledWithContext = false; + var calledWithoutContext = false; + + a.listenTo(a, 'foo', function(){ calledWithContext = true; }, ctx); + a.listenTo(a, 'foo', function(){ calledWithoutContext = true; }); + + a.stopListening(a, 'foo', null, ctx); + + a.trigger('foo'); + + equal(false, calledWithContext); + equal(true, calledWithoutContext); + }); + test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; _.extend(obj, Backbone.Events); From 2ae0e9d902fd6ba357696267d069e54f750aa817 Mon Sep 17 00:00:00 2001 From: Dan Heberden Date: Tue, 18 Dec 2012 10:00:24 -0800 Subject: [PATCH 005/176] add `grab` method to get elements in a collection that match the indexes in the provided list array Former-commit-id: 18df81c229cab4acde8f8157df9bb1001a51e9db --- lodash.js | 20 ++++++++++++++++++++ test/test.js | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lodash.js b/lodash.js index 7e659648c2..f3d8b4634b 100644 --- a/lodash.js +++ b/lodash.js @@ -2175,6 +2175,25 @@ return collection; } + /** + * Grabs the elements in the `collection` using the specified indexes + * in the `list` array. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Array} list The array of indexes to grab. + * @ returns {Array} Returns a new array of elements that matched the list array. + * @example + * + * _.grab( ['a', 'b', 'c', 'd', 'e', 'f'], [0, 2, 5] ); + * // => ['a', 'c', 'f'] + */ + function grab(collection, list) { + return invoke(list, function(a){ return a[this]; }, collection); + } + /** * Creates an object composed of keys returned from running each element of * `collection` through a `callback`. The corresponding value of each key is an @@ -4239,6 +4258,7 @@ lodash.forIn = forIn; lodash.forOwn = forOwn; lodash.functions = functions; + lodash.grab = grab; lodash.groupBy = groupBy; lodash.initial = initial; lodash.intersection = intersection; diff --git a/test/test.js b/test/test.js index c1b12c4707..7b767d449a 100644 --- a/test/test.js +++ b/test/test.js @@ -667,6 +667,28 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.grab'); + + (function() { + test('should get items in range', function() { + var result = _.grab(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]); + deepEqual( result, ['a', 1.4, { 'foo': 'bar' } ]); + }); + test('should work with an object for `collection`', function() { + var result = _.grab({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']); + deepEqual(result, ['apple', 'count']); + }); + test('no list should return an empty array', function() { + deepEqual(_.grab(['a', 'b', 'c']), [] ); + }); + test('out of range selections should return undefined', function() { + var result = _.grab(['a', 'b', 'c'], [1, 9001]); + deepEqual( result, ['b', undefined]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.groupBy'); (function() { From c86a16df7fc69e58e5ac01b13743c0ffc5da0ec5 Mon Sep 17 00:00:00 2001 From: Dan Heberden Date: Tue, 18 Dec 2012 12:52:44 -0800 Subject: [PATCH 006/176] change .grab to .at, add unlimited args or numbers or arrays and simplify function call to use values and pick Former-commit-id: 3deb82ad9f55cd7261453a40bb0f046a5340790d --- lodash.js | 44 ++++++++++++++++++++++++-------------------- test/test.js | 12 ++++-------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lodash.js b/lodash.js index f3d8b4634b..26d7373883 100644 --- a/lodash.js +++ b/lodash.js @@ -1937,6 +1937,29 @@ /*--------------------------------------------------------------------------*/ + /** + * Retrieves the elements in the `collection` at specified indexes. Indexes may + * be specified as individual arguments or as arrays of indexes. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Number|Array} number|[index1, index2, ...] The index(es) of `collection` + * to retrieve, either as individual arguments or arrays. + * @returns {Array} Returns a new array of elements that matched the provided indexes. + * @example + * + * _.at( ['a', 'b', 'c', 'd', 'e', 'f'], [0, 2, 5] ); + * // => ['a', 'c', 'f'] + * + * _.at( ['lodash', 'javascript', 'fast'], 0, 2 ); + * // => ['lodash, 'fast'] + */ + function at(collection, list) { + return values(pick(collection || [], concat.apply(arguments, slice(arguments, 1)))); + } + /** * Checks if a given `target` element is present in a `collection` using strict * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used @@ -2175,25 +2198,6 @@ return collection; } - /** - * Grabs the elements in the `collection` using the specified indexes - * in the `list` array. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|String} collection The collection to iterate over. - * @param {Array} list The array of indexes to grab. - * @ returns {Array} Returns a new array of elements that matched the list array. - * @example - * - * _.grab( ['a', 'b', 'c', 'd', 'e', 'f'], [0, 2, 5] ); - * // => ['a', 'c', 'f'] - */ - function grab(collection, list) { - return invoke(list, function(a){ return a[this]; }, collection); - } - /** * Creates an object composed of keys returned from running each element of * `collection` through a `callback`. The corresponding value of each key is an @@ -4241,6 +4245,7 @@ // add functions that return wrapped values when chaining lodash.after = after; lodash.assign = assign; + lodash.at = at; lodash.bind = bind; lodash.bindAll = bindAll; lodash.bindKey = bindKey; @@ -4258,7 +4263,6 @@ lodash.forIn = forIn; lodash.forOwn = forOwn; lodash.functions = functions; - lodash.grab = grab; lodash.groupBy = groupBy; lodash.initial = initial; lodash.intersection = intersection; diff --git a/test/test.js b/test/test.js index 7b767d449a..4bb64da7d8 100644 --- a/test/test.js +++ b/test/test.js @@ -667,23 +667,19 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.grab'); + QUnit.module('lodash.at'); (function() { test('should get items in range', function() { - var result = _.grab(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]); + var result = _.at(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]); deepEqual( result, ['a', 1.4, { 'foo': 'bar' } ]); }); test('should work with an object for `collection`', function() { - var result = _.grab({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']); + var result = _.at({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']); deepEqual(result, ['apple', 'count']); }); test('no list should return an empty array', function() { - deepEqual(_.grab(['a', 'b', 'c']), [] ); - }); - test('out of range selections should return undefined', function() { - var result = _.grab(['a', 'b', 'c'], [1, 9001]); - deepEqual( result, ['b', undefined]); + deepEqual(_.at(['a', 'b', 'c']), [] ); }); }()); From 4a0897c73438534668cccb799e6a3c1da51cc06e Mon Sep 17 00:00:00 2001 From: Dan Heberden Date: Tue, 18 Dec 2012 15:09:57 -0800 Subject: [PATCH 007/176] build in functionality to at, add string support, optimize, and add more tests Former-commit-id: 951ef27e55fff5a70d09916b55b85f9e725f751a --- lodash.js | 16 ++++++++++++++-- test/test.js | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index 26d7373883..6449dad27a 100644 --- a/lodash.js +++ b/lodash.js @@ -1956,8 +1956,20 @@ * _.at( ['lodash', 'javascript', 'fast'], 0, 2 ); * // => ['lodash, 'fast'] */ - function at(collection, list) { - return values(pick(collection || [], concat.apply(arguments, slice(arguments, 1)))); + function at(collection) { + var index = -1, + props = concat.apply(arrayRef, slice(arguments, 1)), + length = props.length, + result = Array(length); + + if (noCharByIndex && isString(collection)) { + collection = collection.split(''); + } + + while(++index < length) { + result[index] = collection[props[index]]; + } + return result; } /** diff --git a/test/test.js b/test/test.js index 4bb64da7d8..95375298d8 100644 --- a/test/test.js +++ b/test/test.js @@ -681,6 +681,12 @@ test('no list should return an empty array', function() { deepEqual(_.at(['a', 'b', 'c']), [] ); }); + test('should work on strings', function() { + deepEqual(_.at("helio", [0,3]), ['h', 'i']); + }); + test('should work with multple args', function() { + deepEqual(_.at(['a','b','c','d'], 0, 2, 3), ['a', 'c', 'd']); + }); }()); /*--------------------------------------------------------------------------*/ From eccd6463f65607ed49f28af25162dccc08a6004b Mon Sep 17 00:00:00 2001 From: Dan Heberden Date: Tue, 18 Dec 2012 15:30:38 -0800 Subject: [PATCH 008/176] update dependency for at method Former-commit-id: 600a1079d3591880654df0b861810b7c070047e9 --- build.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build.js b/build.js index 0f42a66cfd..3f699546a2 100755 --- a/build.js +++ b/build.js @@ -67,6 +67,7 @@ var dependencyMap = { 'after': [], 'assign': ['isArguments'], + 'at': ['isString'], 'bind': ['isFunction', 'isObject'], 'bindAll': ['bind', 'functions'], 'bindKey': ['isFunction', 'isObject'], From 5c55cf0efb75ea1bd925117e08cf47982bba8788 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 19:05:39 -0800 Subject: [PATCH 009/176] Make path convention consistent in package.json. Former-commit-id: bf1bde8a2e78a520dca92ddd7b95f9fce12eb446 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 35922b1db3..ef471b85cf 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "main": "./lodash.js" }, "scripts": { - "build": "node build", - "test": "node test/test && node test/test-build", - "install": "node build/post-install" + "build": "node ./build.js", + "test": "node ./test/test.js && node ./test/test-build.js", + "install": "node ./build/post-install.js" } } From 0d42e840455ecff5e4aebbacd454f799c53a7cad Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 01:08:55 -0800 Subject: [PATCH 010/176] Add a benchmark for `_.some` with `thisArg` and avoid corrupting the aggregate score if a single benchmark errors. [ci skip] Former-commit-id: 2042fdaab870ad2de2fb4938f5033d21f3dd1ae3 --- perf/perf.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/perf/perf.js b/perf/perf.js index d8dda55b30..625e9ee9e3 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -78,7 +78,8 @@ * @returns {Number} Returns the adjusted Hz. */ function getHz(bench) { - return 1 / (bench.stats.mean + bench.stats.moe); + var result = 1 / (bench.stats.mean + bench.stats.moe); + return isFinite(result) ? result : 0; } /** @@ -1419,6 +1420,20 @@ ) ); + suites.push( + Benchmark.Suite('`_.some` with `thisArg` iterating an array (slow path)') + .add(buildName, '\ + lodash.some(objects, function(value, index) {\ + return this["key" + index] == 19;\ + }, object)' + ) + .add(otherName, '\ + _.some(objects, function(value, index) {\ + return this["key" + index] == 19;\ + }, object)' + ) + ); + suites.push( Benchmark.Suite('`_.some` iterating an object') .add(buildName, '\ From 12bc852c89888d2be0d1758b71720c09bb6eafb7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 01:49:50 -0800 Subject: [PATCH 011/176] Update Chrome extension sandboxing link in README.md. [ci skip] Former-commit-id: 17363260102ec1e874309eeea62bb077e2479303 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d6c4893b8..19924c1c7c 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ lodash backbone ``` * CSP builds, supporting default [Content Security Policy](http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html) restrictions, may be created using the `csp` modifier argument. - The `csp` modifier is an alais of the `mobile` modifier. Chrome extensions will require [sandboxing](http://developer.chrome.com/trunk/extensions/sandboxingEval.html) or the use of either the `csp`, `mobile`, or `underscore` build. + The `csp` modifier is an alais of the `mobile` modifier. Chrome extensions will require [sandboxing](http://developer.chrome.com/extensions/sandboxingEval.html) or the use of either the `csp`, `mobile`, or `underscore` build. ```bash lodash csp ``` From 7bea30b2e6b6a9589045ca3649ea2c68b4291fb3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 02:45:56 -0800 Subject: [PATCH 012/176] Optimize `_.invert`, `_.pairs`, and `_.values`. Former-commit-id: d2725dc8c75254784d450f2a7e997e079b8c3183 --- build.js | 6 ++--- lodash.js | 78 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/build.js b/build.js index 899d190a8b..0f42a66cfd 100755 --- a/build.js +++ b/build.js @@ -97,7 +97,7 @@ 'indexOf': ['sortedIndex'], 'initial': [], 'intersection': ['indexOf'], - 'invert': ['forOwn'], + 'invert': ['keys'], 'invoke': ['forEach'], 'isArguments': [], 'isArray': [], @@ -129,7 +129,7 @@ 'object': [], 'omit': ['forIn', 'indexOf'], 'once': [], - 'pairs': ['forOwn'], + 'pairs': ['keys'], 'partial': ['isFunction', 'isObject'], 'pick': ['forIn'], 'pluck': ['map'], @@ -155,7 +155,7 @@ 'uniq': ['identity', 'indexOf'], 'uniqueId': [], 'value': ['mixin'], - 'values': ['forOwn'], + 'values': ['keys'], 'where': ['filter', 'keys'], 'without': ['indexOf'], 'wrap': [], diff --git a/lodash.js b/lodash.js index f4a8bb12db..7e659648c2 100644 --- a/lodash.js +++ b/lodash.js @@ -892,6 +892,26 @@ */ var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + /** + * Creates an array composed of the own enumerable property names of `object`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns a new array of property names. + * @example + * + * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); + * // => ['one', 'two', 'three'] (order is not guaranteed) + */ + var keys = !nativeKeys ? shimKeys : function(object) { + // avoid iterating over the `prototype` property + return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype') + ? shimKeys(object) + : (isObject(object) ? nativeKeys(object) : []); + }; + /** * A fallback implementation of `isPlainObject` that checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -1179,10 +1199,15 @@ * // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) */ function invert(object) { - var result = {}; - forOwn(object, function(value, key) { - result[value] = key; - }); + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + result[object[key]] = key; + } return result; } @@ -1684,26 +1709,6 @@ return typeof value == 'undefined'; } - /** - * Creates an array composed of the own enumerable property names of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (order is not guaranteed) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - // avoid iterating over the `prototype` property - return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype') - ? shimKeys(object) - : (isObject(object) ? nativeKeys(object) : []); - }; - /** * Merges enumerable properties of the source object(s) into the `destination` * object. Subsequent sources will overwrite propery assignments of previous @@ -1844,10 +1849,15 @@ * // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) */ function pairs(object) { - var result = []; - forOwn(object, function(value, key) { - result.push([key, value]); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } return result; } @@ -1914,10 +1924,14 @@ * // => [1, 2, 3] */ function values(object) { - var result = []; - forOwn(object, function(value) { - result.push(value); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } return result; } From 647746ea72492c709eb75eb60c328c56ce779dec Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 07:41:34 -0800 Subject: [PATCH 013/176] Update vendors, builds, and docs. Former-commit-id: 8e6ca9a1334c73671aba1b4c974d738dbd7d72e1 --- doc/README.md | 186 ++++++++++++++--------------- lodash.min.js | 69 +++++------ lodash.underscore.js | 72 ++++++----- lodash.underscore.min.js | 55 ++++----- vendor/backbone/backbone.js | 50 ++++---- vendor/backbone/test/collection.js | 49 ++++++-- vendor/backbone/test/events.js | 24 ++++ 7 files changed, 286 insertions(+), 219 deletions(-) diff --git a/doc/README.md b/doc/README.md index 1341019713..faef8e4ecc 100644 --- a/doc/README.md +++ b/doc/README.md @@ -186,7 +186,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2728 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -210,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -235,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -263,7 +263,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -291,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2862 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -323,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -348,7 +348,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -372,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2974 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -397,7 +397,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3001 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -426,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3017 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -451,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3076 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -489,7 +489,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -517,7 +517,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3159 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -561,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3177 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3191 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -585,7 +585,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -624,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -649,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3315 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -706,7 +706,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4182 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -736,7 +736,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4199 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -757,7 +757,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4216 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -788,7 +788,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1967 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -826,7 +826,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -858,7 +858,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2044 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -887,7 +887,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2069 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2083 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +916,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +945,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -977,7 +977,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2204 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1009,7 +1009,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2237 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1038,7 +1038,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1070,7 +1070,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1102,7 +1102,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2357 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1128,7 +1128,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2406 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1159,7 +1159,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2430 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1189,7 +1189,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2472 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1220,7 +1220,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2510 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1246,7 +1246,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2531 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1270,7 +1270,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1300,7 +1300,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2588 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1329,7 +1329,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1361,7 +1361,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2667 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1385,7 +1385,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2698 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1423,7 +1423,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3348 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1451,7 +1451,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3381 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1482,7 +1482,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3397 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3411 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1513,7 +1513,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3443 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1554,7 +1554,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3480 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1581,7 +1581,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1607,7 +1607,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3577 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1632,7 +1632,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1659,7 +1659,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1685,7 +1685,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3628 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3685 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1763,7 +1763,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1827,7 +1827,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1023 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1863,7 +1863,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1118 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1896,7 +1896,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1140 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1986,7 +1986,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1139 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1159 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2013,7 +2013,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1184 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2038,7 +2038,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1181 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2089,7 +2089,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1230 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2116,7 +2116,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1224 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1249 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2140,7 +2140,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2164,7 +2164,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2188,7 +2188,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2218,7 +2218,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2249,7 +2249,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2287,7 +2287,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2311,7 +2311,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2346,7 +2346,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2373,7 +2373,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1596 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2397,7 +2397,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1549 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2427,7 +2427,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2462,7 +2462,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2486,7 +2486,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1666 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1691 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2510,7 +2510,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1683 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1708 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2534,7 +2534,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L908 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2558,7 +2558,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2593,7 +2593,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1812 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2624,7 +2624,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2648,7 +2648,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2679,7 +2679,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2710,7 +2710,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3762 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2734,7 +2734,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3766 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3780 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2759,7 +2759,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3806 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2789,7 +2789,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2809,7 +2809,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3855 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2837,7 +2837,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2872,7 +2872,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3978 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2950,7 +2950,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4109 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2982,7 +2982,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4135 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3006,7 +3006,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4155 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3040,7 +3040,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.min.js b/lodash.min.js index 40126c4a5d..8a28924d99 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -6,37 +6,38 @@ ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" -,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s} -function A(e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o= -e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g -,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt= -p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype= -{valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0, -number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e) -}:m,gn=At?function(e){return typeof e=="function"&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D, -n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if(typeof t!="function")for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0; -return typeof t=="number"?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'" -),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source= -l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]|| -(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice" -],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file +,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return pn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e +,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A(e,t,n){var r=!0,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments +.length,t=u(t,r,et);if(mn(e)){var s=-1,o=e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=hn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/ +,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable +,Tt=Y.toString,Nt=lt.test(Nt=p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e() +{this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean" +:!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},dn=w(pn),vn=a(sn,{g:"if(t[i]==null)"+sn.g}),mn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var gn=wt?function(e){if(!e||typeof +e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=hn +,n.map=D,n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!mn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=hn(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t= +e?e.length:0;return typeof t=="number"?t:hn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+ +r+"))==null?'':__t)+'"),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n) +}catch(p){throw p.source=l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function( +e,t){n.prototype[t]||(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an +(["concat","slice","splice"],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports= +n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index a68dd807b9..dc9ac65590 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -715,6 +715,23 @@ return result }; + /** + * Creates an array composed of the own enumerable property names of `object`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns a new array of property names. + * @example + * + * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); + * // => ['one', 'two', 'three'] (order is not guaranteed) + */ + var keys = !nativeKeys ? shimKeys : function(object) { + return (isObject(object) ? nativeKeys(object) : []); + }; + /** * A fallback implementation of `isPlainObject` that checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -912,10 +929,15 @@ * // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) */ function invert(object) { - var result = {}; - forOwn(object, function(value, key) { - result[value] = key; - }); + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + result[object[key]] = key; + } return result; } @@ -1371,23 +1393,6 @@ return typeof value == 'undefined'; } - /** - * Creates an array composed of the own enumerable property names of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (order is not guaranteed) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - return (isObject(object) ? nativeKeys(object) : []); - }; - /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of @@ -1440,10 +1445,15 @@ * // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) */ function pairs(object) { - var result = []; - forOwn(object, function(value, key) { - result.push([key, value]); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } return result; } @@ -1501,10 +1511,14 @@ * // => [1, 2, 3] */ function values(object) { - var result = []; - forOwn(object, function(value) { - result.push(value); - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } return result; } diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index daba5025c4..03ad89b12a 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,31 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||typeof e=="undefined")return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1 -,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft= -K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029" -:"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1> -e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert= -v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r; -return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+ -(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function( -e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" -.split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file +(e,t,n){return e?typeof e!="function"?function(t){return t[e]}:typeof t!="undefined"?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)}:e:q}function o(e){return"\\"+Tt[e]}function u(e){return At[e]}function a(){}function f(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n, +r){var i=3>arguments.length,t=s(t,r,V);if(Mt(e)){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Lt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Mt(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st= +f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt= +{"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},Ot=v(At),Mt=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"== +it.call(e)}),n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t +[u],o))continue e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Mt(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=Lt(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Lt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings +),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch( +f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype +.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._= +n})(this); \ No newline at end of file diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index 38cc991290..f4cfabd26b 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -190,25 +190,27 @@ // An inversion-of-control version of `on`. Tell *this* object to listen to // an event in another object ... keeping track of what it's listening to. - listenTo: function(object, events, callback) { + listenTo: function(object, events, callback, context) { + context = context || this; var listeners = this._listeners || (this._listeners = {}); var id = object._listenerId || (object._listenerId = _.uniqueId('l')); listeners[id] = object; - object.on(events, callback || this, this); + object.on(events, callback || context, context); return this; }, // Tell this object to stop listening to either specific events ... or // to every object it's currently listening to. - stopListening: function(object, events, callback) { + stopListening: function(object, events, callback, context) { + context = context || this; var listeners = this._listeners; if (!listeners) return; if (object) { - object.off(events, callback, this); + object.off(events, callback, context); if (!events && !callback) delete listeners[object._listenerId]; } else { for (var id in listeners) { - listeners[id].off(null, null, this); + listeners[id].off(null, null, context); } this._listeners = {}; } @@ -237,7 +239,7 @@ this.attributes = {}; this._changes = []; if (options && options.collection) this.collection = options.collection; - if (options && options.parse) attrs = this.parse(attrs); + if (options && options.parse) attrs = this.parse(attrs, options); if (defaults = _.result(this, 'defaults')) _.defaults(attrs, defaults); this.set(attrs, {silent: true}); this._currentAttributes = _.clone(this.attributes); @@ -352,7 +354,7 @@ var model = this; var success = options.success; options.success = function(resp, status, xhr) { - if (!model.set(model.parse(resp), options)) return false; + if (!model.set(model.parse(resp, options), options)) return false; if (success) success(model, resp, options); }; return this.sync('read', this, options); @@ -394,7 +396,7 @@ var success = options.success; options.success = function(resp, status, xhr) { done = true; - var serverAttrs = model.parse(resp); + var serverAttrs = model.parse(resp, options); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); if (!model.set(serverAttrs, options)) return false; if (success) success(model, resp, options); @@ -453,7 +455,7 @@ // **parse** converts a response into the hash of attributes to be `set` on // the model. The default implementation is just to pass the response along. - parse: function(resp) { + parse: function(resp, options) { return resp; }, @@ -567,8 +569,8 @@ }, // Run validation against the next complete set of model attributes, - // returning `true` if all is well. If a specific `error` callback has - // been passed, call that instead of firing the general `"error"` event. + // returning `true` if all is well. Otherwise, fire a general + // `"error"` event and call the error callback, if specified. _validate: function(attrs, options) { if (!this.validate) return true; attrs = _.extend({}, this.attributes, attrs); @@ -636,11 +638,10 @@ } models[i] = model; - existing = model.id != null && this._byId[model.id]; // If a duplicate is found, prevent it from being added and // optionally merge it into the existing model. - if (existing || this._byCid[model.cid]) { - if (options && options.merge && existing) { + if (existing = this.get(model)) { + if (options && options.merge) { existing.set(model.attributes, options); needsSort = sort; } @@ -651,7 +652,7 @@ // Listen to added models' events, and index models for lookup by // `id` and by `cid`. model.on('all', this._onModelEvent, this); - this._byCid[model.cid] = model; + this._byId[model.cid] = model; if (model.id != null) this._byId[model.id] = model; } @@ -685,7 +686,7 @@ model = this.get(models[i]); if (!model) continue; delete this._byId[model.id]; - delete this._byCid[model.cid]; + delete this._byId[model.cid]; index = this.indexOf(model); this.models.splice(index, 1); this.length--; @@ -734,7 +735,8 @@ // Get a model from the set by id. get: function(obj) { if (obj == null) return void 0; - return this._byId[obj.id != null ? obj.id : obj] || this._byCid[obj.cid || obj]; + this._idAttr || (this._idAttr = this.model.prototype.idAttribute); + return this._byId[obj.id || obj.cid || obj[this._idAttr] || obj]; }, // Get the model at the given index. @@ -781,9 +783,8 @@ update: function(models, options) { var model, i, l, existing; var add = [], remove = [], modelMap = {}; - var idAttr = this.model.prototype.idAttribute; options = _.extend({add: true, merge: true, remove: true}, options); - if (options.parse) models = this.parse(models); + if (options.parse) models = this.parse(models, options); // Allow a single model (or no argument) to be passed. if (!_.isArray(models)) models = models ? [models] : []; @@ -794,7 +795,7 @@ // Determine which models to add and merge, and which to remove. for (i = 0, l = models.length; i < l; i++) { model = models[i]; - existing = this.get(model.id || model.cid || model[idAttr]); + existing = this.get(model); if (options.remove && existing) modelMap[existing.cid] = true; if ((options.add && !existing) || (options.merge && existing)) { add.push(model); @@ -818,7 +819,7 @@ // any `add` or `remove` events. Fires `reset` when finished. reset: function(models, options) { options || (options = {}); - if (options.parse) models = this.parse(models); + if (options.parse) models = this.parse(models, options); for (var i = 0, l = this.models.length; i < l; i++) { this._removeReference(this.models[i]); } @@ -865,7 +866,7 @@ // **parse** converts a response into a list of models to be added to the // collection. The default implementation is just to pass it through. - parse: function(resp) { + parse: function(resp, options) { return resp; }, @@ -886,7 +887,6 @@ this.length = 0; this.models = []; this._byId = {}; - this._byCid = {}; }, // Prepare a model or hash of attributes to be added to this collection. @@ -1473,7 +1473,7 @@ }; // Make the request, allowing the user to override any Ajax options. - var xhr = Backbone.ajax(_.extend(params, options)); + var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); model.trigger('request', model, xhr, options); return xhr; }; @@ -1499,7 +1499,7 @@ if (protoProps && _.has(protoProps, 'constructor')) { child = protoProps.constructor; } else { - child = function(){ parent.apply(this, arguments); }; + child = function(){ return parent.apply(this, arguments); }; } // Add static properties to the constructor function, if supplied. diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index 339a50e8b2..28b857a444 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -62,13 +62,15 @@ $(document).ready(function() { strictEqual(collection.last().get('a'), 4); }); - test("get", 3, function() { + test("get", 5, function() { equal(col.get(0), d); equal(col.get(2), b); + equal(col.get({id: 1}), c); + equal(col.get(c.clone()), c); equal(col.get(col.first().cid), col.first()); }); - test("get with non-default ids", 2, function() { + test("get with non-default ids", 4, function() { var col = new Backbone.Collection(); var MongoModel = Backbone.Model.extend({ idAttribute: '_id' @@ -78,6 +80,12 @@ $(document).ready(function() { equal(col.get(100), model); model.set({_id: 101}); equal(col.get(101), model); + + var Col2 = Backbone.Collection.extend({ model: MongoModel }); + col2 = new Col2(); + col2.push(model); + equal(col2.get({_id: 101}), model); + equal(col2.get(model.clone()), model); }); test("update index when id changes", 3, function() { @@ -882,14 +890,14 @@ $(document).ready(function() { new Collection().push({id: 1}); }); - // test("`update` with non-normal id", function() { - // var Collection = Backbone.Collection.extend({ - // model: Backbone.Model.extend({idAttribute: '_id'}) - // }); - // var collection = new Collection({_id: 1}); - // collection.update([{_id: 1, a: 1}], {add: false}); - // equal(collection.first().get('a'), 1); - // }); + test("`update` with non-normal id", function() { + var Collection = Backbone.Collection.extend({ + model: Backbone.Model.extend({idAttribute: '_id'}) + }); + var collection = new Collection({_id: 1}); + collection.update([{_id: 1, a: 1}], {add: false}); + equal(collection.first().get('a'), 1); + }); test("#1894 - `sort` can optionally be turned off", 0, function() { var Collection = Backbone.Collection.extend({ @@ -906,8 +914,27 @@ $(document).ready(function() { return data.data; } })); - var res = {status: 'ok', data:[{id: 1}]} + var res = {status: 'ok', data:[{id: 1}]}; collection.update(res, {parse: true}); }); + asyncTest("#1939 - `parse` is passed `options`", 1, function () { + var collection = new (Backbone.Collection.extend({ + url: '/', + parse: function (data, options) { + strictEqual(options.xhr.someHeader, 'headerValue'); + return data; + } + })); + var ajax = Backbone.ajax; + Backbone.ajax = function (params) { + _.defer(params.success); + return {someHeader: 'headerValue'}; + }; + collection.fetch({ + success: function () { start(); } + }); + Backbone.ajax = ajax; + }); + }); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index c3f1d61dd0..946c25bb0e 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -86,6 +86,30 @@ $(document).ready(function() { b.trigger('change'); }); + test("listenTo with context", 1, function() { + var a = _.extend({}, Backbone.Events); + var ctx = {}; + a.listenTo(a, 'foo', function(){ equal(this, ctx); }, ctx); + a.trigger('foo'); + }); + + test("stopListening with context", 2, function() { + var a = _.extend({}, Backbone.Events); + var ctx = {}; + var calledWithContext = false; + var calledWithoutContext = false; + + a.listenTo(a, 'foo', function(){ calledWithContext = true; }, ctx); + a.listenTo(a, 'foo', function(){ calledWithoutContext = true; }); + + a.stopListening(a, 'foo', null, ctx); + + a.trigger('foo'); + + equal(false, calledWithContext); + equal(true, calledWithoutContext); + }); + test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; _.extend(obj, Backbone.Events); From bfea443e55911f3fabfd63c55d39a8c403632b50 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 20:28:34 -0800 Subject: [PATCH 014/176] Cleanup `_.at` and add build tests. Former-commit-id: 7648376e1ef447ae83d621b449b73acec355bb67 --- build.js | 38 +++++++--- build/pre-compile.js | 1 + doc/README.md | 163 +++++++++++++++++++++++++------------------ lodash.js | 23 +++--- test/test-build.js | 6 ++ test/test.js | 60 +++++++++------- 6 files changed, 178 insertions(+), 113 deletions(-) diff --git a/build.js b/build.js index 3f699546a2..9150046b85 100755 --- a/build.js +++ b/build.js @@ -241,6 +241,7 @@ /** List of methods used by Underscore */ var underscoreMethods = _.without.apply(_, [allMethods].concat([ + 'at', 'bindKey', 'cloneDeep', 'forIn', @@ -945,6 +946,32 @@ return source; } + /** + * Removes all `noCharByIndex` references from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function removeNoCharByIndex(source) { + // remove `noCharByIndex` from `_.at` + source = source.replace(matchFunction(source, 'at'), function(match) { + return match.replace(/^ *if *\(noCharByIndex[^}]+}\n/m, ''); + }); + + // remove `noCharByIndex` from `_.reduceRight` + source = source.replace(matchFunction(source, 'reduceRight'), function(match) { + return match.replace(/}\s*else if *\(noCharByIndex[^}]+/, ''); + }); + + // remove `noCharByIndex` from `_.toArray` + source = source.replace(matchFunction(source, 'toArray'), function(match) { + return match.replace(/noCharByIndex[^:]+:/, ''); + }); + + return source; + } + /** * Removes all `noNodeClass` references from `source`. * @@ -1866,19 +1893,10 @@ return match.replace(/(?:\s*\/\/.*)*\n( *)if *\(iteratesOwnLast[\s\S]+?\n\1}/, ''); }); - // remove `noCharByIndex` from `_.reduceRight` - source = source.replace(matchFunction(source, 'reduceRight'), function(match) { - return match.replace(/}\s*else if *\(noCharByIndex[^}]+/, ''); - }); - - // remove `noCharByIndex` from `_.toArray` - source = source.replace(matchFunction(source, 'toArray'), function(match) { - return match.replace(/noCharByIndex[^:]+:/, ''); - }); - source = removeVar(source, 'iteratorTemplate'); source = removeCreateFunction(source); source = removeNoArgsClass(source); + source = removeNoCharByIndex(source); source = removeNoNodeClass(source); } else { diff --git a/build/pre-compile.js b/build/pre-compile.js index 6bcc7ea18f..1aaa93ba4c 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -64,6 +64,7 @@ 'amd', 'any', 'assign', + 'at', 'attachEvent', 'bind', 'bindAll', diff --git a/doc/README.md b/doc/README.md index faef8e4ecc..a9d81ce549 100644 --- a/doc/README.md +++ b/doc/README.md @@ -49,6 +49,7 @@ ## `Collections` * [`_.all`](#_everycollection--callbackidentity-thisarg) * [`_.any`](#_somecollection--callbackidentity-thisarg) +* [`_.at`](#_atcollection-number-index1-index2-) * [`_.collect`](#_mapcollection--callbackidentity-thisarg) * [`_.contains`](#_containscollection-target--fromindex0) * [`_.countBy`](#_countbycollection-callbackproperty--thisarg) @@ -186,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2728 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2762 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -210,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2792 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -235,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -263,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2854 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -291,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2896 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -323,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2931 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -348,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2955 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -372,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2974 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3008 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -397,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3001 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3035 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -426,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3065 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -451,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3076 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3110 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -489,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3149 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -517,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3159 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3193 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -561,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -585,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3259 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -624,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3318 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -649,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3315 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -706,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4182 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4216 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -736,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4199 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4233 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -757,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4216 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4250 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -785,10 +786,38 @@ _([1, 2, 3]).valueOf(); ## `“Collections” Methods` + + +### `_.at(collection, number|[index1, index2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1959 "View in source") [Ⓣ][1] + +Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `number|[index1, index2, ...]` *(Array|Number|String)*: The index(es) of `collection` to retrieve, either as individual arguments or arrays. + +#### Returns +*(Array)*: Returns a new array of elements that matched the provided indexes. + +#### Example +```js +_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); +// => ['a', 'c', 'e'] + +_.at(['moe', 'larry', 'curly'], 0, 2); +// => ['moe', 'curly'] +``` + +* * * + + + + ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2001 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -826,7 +855,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -858,7 +887,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2044 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2078 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -887,7 +916,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2083 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +945,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2161 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +974,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2196 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -977,7 +1006,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2204 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2238 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1009,7 +1038,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2271 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1038,7 +1067,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2303 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1070,7 +1099,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2345 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1102,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2357 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2391 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1128,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2406 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2440 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1159,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2430 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2464 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1189,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2472 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2506 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1220,9 +1249,9 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2510 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2544 "View in source") [Ⓣ][1] -The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. +The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. @@ -1246,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2565 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1270,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2597 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1300,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2588 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2622 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1329,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2668 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1361,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2701 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1385,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2732 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1423,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3348 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3382 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1451,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3381 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3415 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1482,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3411 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3445 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1513,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3491 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1554,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3480 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3514 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1581,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3547 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1607,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3577 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1632,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3591 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1659,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3635 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1685,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3662 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1711,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3697 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1738,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3685 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1763,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3772 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2654,7 +2683,7 @@ Creates a shallow clone of `object` composed of the specified properties. Proper #### Arguments 1. `object` *(Object)*: The source object. -2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to pick or the function called per iteration. +2. `callback|[prop1, prop2, ...]` *(Array|Function|String)*: The function called per iteration or properties to pick, either as individual arguments or arrays. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -2710,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3762 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3796 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2734,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3780 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2759,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3840 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2789,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3866 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2809,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2837,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3927 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2872,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3978 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2950,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4109 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4143 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2982,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4135 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4169 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3006,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4189 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3040,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4415 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 6449dad27a..393d3937bd 100644 --- a/lodash.js +++ b/lodash.js @@ -1872,8 +1872,8 @@ * @memberOf _ * @category Objects * @param {Object} object The source object. - * @param {Function|String} callback|[prop1, prop2, ...] The properties to pick - * or the function called per iteration. + * @param {Array|Function|String} callback|[prop1, prop2, ...] The function called + * per iteration or properties to pick, either as individual arguments or arrays. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns an object composed of the picked properties. * @example @@ -1938,23 +1938,23 @@ /*--------------------------------------------------------------------------*/ /** - * Retrieves the elements in the `collection` at specified indexes. Indexes may - * be specified as individual arguments or as arrays of indexes. + * Creates an array of elements from the specified index(es), or keys, of the `collection`. + * Indexes may be specified as individual arguments or as arrays of indexes. * * @static * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Number|Array} number|[index1, index2, ...] The index(es) of `collection` - * to retrieve, either as individual arguments or arrays. + * @param {Array|Number|String} number|[index1, index2, ...] The index(es) of + * `collection` to retrieve, either as individual arguments or arrays. * @returns {Array} Returns a new array of elements that matched the provided indexes. * @example * - * _.at( ['a', 'b', 'c', 'd', 'e', 'f'], [0, 2, 5] ); - * // => ['a', 'c', 'f'] + * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); + * // => ['a', 'c', 'e'] * - * _.at( ['lodash', 'javascript', 'fast'], 0, 2 ); - * // => ['lodash, 'fast'] + * _.at(['moe', 'larry', 'curly'], 0, 2); + * // => ['moe', 'curly'] */ function at(collection) { var index = -1, @@ -1965,7 +1965,6 @@ if (noCharByIndex && isString(collection)) { collection = collection.split(''); } - while(++index < length) { result[index] = collection[props[index]]; } @@ -2526,7 +2525,7 @@ } /** - * The opposite of `_.filter`, this method returns the values of a + * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * * @static diff --git a/test/test-build.js b/test/test-build.js index d59674686e..68b3092d31 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -95,6 +95,7 @@ var collectionsMethods = [ 'all', 'any', + 'at', 'collect', 'contains', 'countBy', @@ -249,6 +250,7 @@ /** List of methods used by Underscore */ var underscoreMethods = _.without.apply(_, [allMethods].concat([ + 'at', 'bindKey', 'cloneDeep', 'forIn', @@ -386,6 +388,10 @@ func(array); func(object); } + else if (methodName == 'at') { + func(array, 0, 2); + func(object, 'a', 'c'); + } else if (methodName == 'invoke') { func(array, 'slice'); func(object, 'toFixed'); diff --git a/test/test.js b/test/test.js index 95375298d8..9715a76a32 100644 --- a/test/test.js +++ b/test/test.js @@ -197,6 +197,42 @@ }); }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash.at'); + + (function() { + test('should return `undefined` for nonexistent keys', function() { + var actual = _.at(['a', 'b', 'c'], [0, 2, 4]); + deepEqual(actual, ['a', 'c', undefined]); + }); + + test('should return an empty array when no keys are passed', function() { + deepEqual(_.at(['a', 'b', 'c']), []); + }); + + test('should accept multiple key arguments', function() { + var actual = _.at(['a', 'b', 'c', 'd'], 0, 2, 3); + deepEqual(actual, ['a', 'c', 'd']); + }); + + test('should work with an object for `collection`', function() { + var actual = _.at({ 'a': 1, 'b': 2, 'c': 3 }, ['a', 'c']); + deepEqual(actual, [1, 3]); + }); + + _.each({ + 'literal': 'abc', + 'object': Object('abc') + }, + function(collection, key) { + test('should work with a string ' + key + ' for `collection`', function() { + deepEqual(_.at(collection, [0, 2]), ['a', 'c']); + }); + }); + }()); + /*--------------------------------------------------------------------------*/ QUnit.module('lodash.bind'); @@ -667,30 +703,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.at'); - - (function() { - test('should get items in range', function() { - var result = _.at(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]); - deepEqual( result, ['a', 1.4, { 'foo': 'bar' } ]); - }); - test('should work with an object for `collection`', function() { - var result = _.at({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']); - deepEqual(result, ['apple', 'count']); - }); - test('no list should return an empty array', function() { - deepEqual(_.at(['a', 'b', 'c']), [] ); - }); - test('should work on strings', function() { - deepEqual(_.at("helio", [0,3]), ['h', 'i']); - }); - test('should work with multple args', function() { - deepEqual(_.at(['a','b','c','d'], 0, 2, 3), ['a', 'c', 'd']); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.groupBy'); (function() { From 69dfa1a17577b4ab7d8ae7f34a318021944630b3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 21:35:43 -0800 Subject: [PATCH 015/176] Clarify `_.merge` documentation. [closes #143] [ci skip] Former-commit-id: efcec739bf2682da9b3dde27a43ff3b76aa4d6e8 --- doc/README.md | 2 +- lodash.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/README.md b/doc/README.md index a9d81ce549..43a3e5ce4d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2589,7 +2589,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] -Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. #### Arguments 1. `object` *(Object)*: The destination object. diff --git a/lodash.js b/lodash.js index 393d3937bd..4f28eb93cb 100644 --- a/lodash.js +++ b/lodash.js @@ -1710,9 +1710,9 @@ } /** - * Merges enumerable properties of the source object(s) into the `destination` - * object. Subsequent sources will overwrite propery assignments of previous - * sources. + * Recursively merges own enumerable properties of the source object(s), that + * don't resolve to `null`/`undefined`, into the `destination` object. Subsequent + * sources will overwrite propery assignments of previous sources. * * @static * @memberOf _ From c122007e17c4d798d352b43755ee2a1e388d8b3d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 21:53:30 -0800 Subject: [PATCH 016/176] Rebuild minified files and docs. [ci skip] Former-commit-id: 161ba27aa3bd38c48d8f15057343944dc6a674c2 --- doc/README.md | 146 +++++++++++++++++++++---------------------- lodash.js | 18 +++--- lodash.min.js | 36 +++++------ lodash.underscore.js | 12 ++-- 4 files changed, 107 insertions(+), 105 deletions(-) diff --git a/doc/README.md b/doc/README.md index 43a3e5ce4d..1e66e32775 100644 --- a/doc/README.md +++ b/doc/README.md @@ -49,7 +49,7 @@ ## `Collections` * [`_.all`](#_everycollection--callbackidentity-thisarg) * [`_.any`](#_somecollection--callbackidentity-thisarg) -* [`_.at`](#_atcollection-number-index1-index2-) +* [`_.at`](#_atcollection--index1-index2-) * [`_.collect`](#_mapcollection--callbackidentity-thisarg) * [`_.contains`](#_containscollection-target--fromindex0) * [`_.countBy`](#_countbycollection-callbackproperty--thisarg) @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2762 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2829 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2854 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2896 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2898 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2931 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2933 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2957 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3010 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3037 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3065 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3227 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3259 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3320 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3351 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4216 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4218 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4235 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4252 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -788,17 +788,17 @@ _([1, 2, 3]).valueOf(); -### `_.at(collection, number|[index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1959 "View in source") [Ⓣ][1] +### `_.at(collection [, index1, index2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1961 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `number|[index1, index2, ...]` *(Array|Number|String)*: The index(es) of `collection` to retrieve, either as individual arguments or arrays. +2. `[index1, index2, ...]` *(Array|Number|String)*: The index(es) of `collection` to retrieve, either as individual arguments or arrays. #### Returns -*(Array)*: Returns a new array of elements that matched the provided indexes. +*(Array)*: Returns a new array of elements corresponding to the provided indexes. #### Example ```js @@ -817,7 +817,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2001 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -855,7 +855,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2050 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -887,7 +887,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2078 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2080 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +916,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2119 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +945,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2161 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2163 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -974,7 +974,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2196 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2198 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1006,7 +1006,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2238 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1038,7 +1038,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2271 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1067,7 +1067,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2303 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1099,7 +1099,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2347 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1131,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2391 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2393 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2466 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2506 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2508 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1249,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2597 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2622 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2624 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2668 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2701 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3382 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3415 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3445 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3447 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3493 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3547 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3549 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3591 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3593 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3635 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3662 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3774 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2691,10 +2691,10 @@ Creates a shallow clone of `object` composed of the specified properties. Proper #### Example ```js -_.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); -// => { 'name': 'moe', 'age': 40 } +_.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); +// => { 'name': 'moe' } -_.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { +_.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { return key.charAt(0) != '_'; }); // => { 'name': 'moe' } @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3796 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3798 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3840 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3842 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3866 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3868 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3891 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3927 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4014 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4143 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4145 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4415 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4417 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 4f28eb93cb..0d2c6c48ad 100644 --- a/lodash.js +++ b/lodash.js @@ -1878,10 +1878,10 @@ * @returns {Object} Returns an object composed of the picked properties. * @example * - * _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); - * // => { 'name': 'moe', 'age': 40 } + * _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); + * // => { 'name': 'moe' } * - * _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { + * _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { * return key.charAt(0) != '_'; * }); * // => { 'name': 'moe' } @@ -1938,16 +1938,18 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements from the specified index(es), or keys, of the `collection`. - * Indexes may be specified as individual arguments or as arrays of indexes. + * Creates an array of elements from the specified index(es), or keys, of the + * `collection`. Indexes may be specified as individual arguments or as arrays + * of indexes. * * @static * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Array|Number|String} number|[index1, index2, ...] The index(es) of - * `collection` to retrieve, either as individual arguments or arrays. - * @returns {Array} Returns a new array of elements that matched the provided indexes. + * @param {Array|Number|String} [index1, index2, ...] The index(es) of + * `collection` to retrieve, either as individual arguments or arrays. + * @returns {Array} Returns a new array of elements corresponding to the + * provided indexes. * @example * * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); diff --git a/lodash.min.js b/lodash.min.js index 8a28924d99..d43768e2fd 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -23,21 +23,21 @@ e),function(t){var r=n[t]=e[t];n.prototype[t]=function(){var e=[this.__wrapped__ {this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean" :!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},dn=w(pn),vn=a(sn,{g:"if(t[i]==null)"+sn.g}),mn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var gn=wt?function(e){if(!e||typeof -e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=hn -,n.map=D,n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!mn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=hn(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t= -e?e.length:0;return typeof t=="number"?t:hn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+ -r+"))==null?'':__t)+'"),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n) -}catch(p){throw p.source=l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function( -e,t){n.prototype[t]||(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an -(["concat","slice","splice"],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports= -n)._=n:K._=n:e._=n})(this); \ No newline at end of file +e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.at=function(e){var t=-1,n=yt.apply(G,p(arguments,1)),r=n.length,i=Array(r);for(Gt&&N(e)&&(e=e.split(""));++tR(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert= +w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=hn,n.map=D,n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!mn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=hn(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i} +},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null== +t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:hn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate|| +pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" +:(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e +){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e) +{var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice"],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define( +function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index dc9ac65590..7ed70985ae 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1468,16 +1468,16 @@ * @memberOf _ * @category Objects * @param {Object} object The source object. - * @param {Function|String} callback|[prop1, prop2, ...] The properties to pick - * or the function called per iteration. + * @param {Array|Function|String} callback|[prop1, prop2, ...] The function called + * per iteration or properties to pick, either as individual arguments or arrays. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns an object composed of the picked properties. * @example * - * _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); - * // => { 'name': 'moe', 'age': 40 } + * _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); + * // => { 'name': 'moe' } * - * _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { + * _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { * return key.charAt(0) != '_'; * }); * // => { 'name': 'moe' } @@ -2063,7 +2063,7 @@ } /** - * The opposite of `_.filter`, this method returns the values of a + * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * * @static From 11912008dd3b07e4d63e636d8d76748b5582cfc1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 22:41:50 -0800 Subject: [PATCH 017/176] Account for `at` in an `underscore` build test. Former-commit-id: 7222681ef1e5ec17e940789efc38e99be97c0116 --- test/test-build.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-build.js b/test/test-build.js index 68b3092d31..f4a9de16d4 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -783,6 +783,7 @@ _.each([ 'assign', + 'at', 'bindKey', 'forIn', 'forOwn', From d0d3c8ef57ba3ded3fd865a161dee5beca6a3e7c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 18 Dec 2012 23:12:51 -0800 Subject: [PATCH 018/176] Remove unused variable, `index`, in `_.isEqual`. Former-commit-id: 21f364b6fa0505f9ccb579660f1bda4e38cbe3d3 --- doc/README.md | 162 +++++++++++++++++++++---------------------- lodash.js | 3 +- lodash.underscore.js | 3 +- 3 files changed, 83 insertions(+), 85 deletions(-) diff --git a/doc/README.md b/doc/README.md index 1e66e32775..72dffc0dfb 100644 --- a/doc/README.md +++ b/doc/README.md @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2763 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2855 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2898 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2932 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2957 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3010 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3009 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3036 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3111 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3150 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3194 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3227 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3226 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3260 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3319 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3350 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4218 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4234 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4252 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4251 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -789,7 +789,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1960 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -817,7 +817,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2002 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -855,7 +855,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2049 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -887,7 +887,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2079 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +916,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2118 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +945,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -974,7 +974,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2197 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1006,7 +1006,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2239 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1038,7 +1038,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1067,7 +1067,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2304 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1099,7 +1099,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2346 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1131,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2441 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2465 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2508 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2507 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1249,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2545 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2566 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2598 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2623 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2669 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2702 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2733 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3383 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3416 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3493 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3515 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3592 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3698 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3720 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3774 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3773 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2278,7 +2278,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1501 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2316,7 +2316,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1518 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2340,7 +2340,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1581 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2375,7 +2375,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1603 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2402,7 +2402,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1620 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2426,7 +2426,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1548 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2456,7 +2456,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1648 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2491,7 +2491,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1673 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2515,7 +2515,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1691 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1690 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2539,7 +2539,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1707 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2587,7 +2587,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1742 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2622,7 +2622,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1816 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2653,7 +2653,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2677,7 +2677,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1888 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2708,7 +2708,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1925 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3797 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3815 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3867 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3891 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3890 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3928 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4013 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4144 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4190 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4416 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 0d2c6c48ad..fd20cea5f3 100644 --- a/lodash.js +++ b/lodash.js @@ -1424,8 +1424,7 @@ return stackB[length] == b; } } - var index = -1, - result = true, + var result = true, size = 0; // add `a` and `b` to the stack of traversed objects diff --git a/lodash.underscore.js b/lodash.underscore.js index 7ed70985ae..b62d81aed9 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1144,8 +1144,7 @@ return stackB[length] == b; } } - var index = -1, - result = true, + var result = true, size = 0; // add `a` and `b` to the stack of traversed objects From 34173fd60fa323192cdd3098eebd02d1f82dc361 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 20 Dec 2012 02:17:38 -0500 Subject: [PATCH 019/176] Upgrade to UglifyJS2. Former-commit-id: dd326a5f401d8359f92f46552e2f59c1accf7cc1 --- .travis.yml | 2 +- build/minify.js | 54 +++++++++++++++++------------ lodash.min.js | 73 +++++++++++++++++++--------------------- lodash.underscore.min.js | 55 ++++++++++++++---------------- 4 files changed, 93 insertions(+), 91 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b22b6adb1..b478dee6be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ node_js: - 0.8 before_script: - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor" - - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/7ecae09d413eb48dd5785fe877f24e60ac3bbcef | tar xvz -C vendor" + - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/505f1be36ef60fd25a992a522f116d5179ab317f | tar xvz -C vendor" diff --git a/build/minify.js b/build/minify.js index 8bc9f7a1c8..c9f166d2f5 100755 --- a/build/minify.js +++ b/build/minify.js @@ -17,7 +17,7 @@ /** Load other modules */ var preprocess = require('./pre-compile.js'), postprocess = require('./post-compile.js'), - uglifyJS = require('../vendor/uglifyjs/uglify-js.js'); + uglifyJS = require('../vendor/uglifyjs/tools/node.js'); /** The Closure Compiler command-line options */ var closureOptions = ['--warning_level=QUIET']; @@ -155,9 +155,8 @@ compiler.on('exit', function(status) { // `status` contains the process exit code - var exception = null; if (status) { - exception = new Error(error); + var exception = new Error(error); exception.status = status; } callback(exception, output); @@ -178,31 +177,42 @@ * @param {Function} callback The function called once the process has completed. */ function uglify(source, label, callback) { - var exception, - result, - ugly = uglifyJS.uglify; - if (!this.isSilent) { console.log('Compressing ' + path.basename(this.outputPath, '.js') + ' using ' + label + '...'); } try { - result = ugly.gen_code( - // enable unsafe transformations - ugly.ast_squeeze_more( - ugly.ast_squeeze( - // munge variable and function names, excluding the special `define` - // function exposed by AMD loaders - ugly.ast_mangle(uglifyJS.parser.parse(source), { - 'except': ['define'] - } - ))), { - 'ascii_only': true + // 1. parse + var toplevel = uglifyJS.parse(source); + + // 2. compress + // // enable unsafe comparisons + toplevel.figure_out_scope(); + toplevel = toplevel.transform(uglifyJS.Compressor({ + 'unsafe_comps': true, + 'warnings': false + })); + + // 3. mangle + // excluding the `define` function exposed by AMD loaders + toplevel.figure_out_scope(); + toplevel.compute_char_frequency(); + toplevel.mangle_names({ + 'except': ['define'] + }); + + // 4. output + // restrict lines to 500 characters for consistency with the Closure Compiler + var stream = uglifyJS.OutputStream({ + 'ascii_only': true, + 'max_line_len': 500, }); - } catch(e) { - exception = e; + + toplevel.print(stream); + } + catch(e) { + var exception = e; } - // lines are restricted to 500 characters for consistency with the Closure Compiler - callback(exception, result && ugly.split_lines(result, 500)); + callback(exception, stream && String(stream)); } /*--------------------------------------------------------------------------*/ diff --git a/lodash.min.js b/lodash.min.js index d43768e2fd..892f8eb2d4 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,42 +2,37 @@ Lo-Dash 1.0.0-rc.3 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||tt);if(i)for(var s={},n=t-1;++nt||typeof e=="undefined")return 1;if( -ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" -,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return pn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e -,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A(e,t,n){var r=!0,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments -.length,t=u(t,r,et);if(mn(e)){var s=-1,o=e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=hn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(mn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/ -,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable -,Tt=Y.toString,Nt=lt.test(Nt=p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e() -{this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean" -:!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},dn=w(pn),vn=a(sn,{g:"if(t[i]==null)"+sn.g}),mn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var gn=wt?function(e){if(!e||typeof -e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.at=function(e){var t=-1,n=yt.apply(G,p(arguments,1)),r=n.length,i=Array(r);for(Gt&&N(e)&&(e=e.split(""));++tR(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert= -w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=hn,n.map=D,n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!mn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=hn(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i} -},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null== -t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:hn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate|| -pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" -:(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e -){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e) -{var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice"],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define( -function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file +;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(Et.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return Et.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 +}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=W,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:nt,f:Qt,g:"",h:Xt,i:nr,j:wt,k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; +if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++ie;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function g(n){return yr[n]}function h(n){return $t.call(n)==Mt}function y(n){var t=X;if(!n||typeof n!="object"||h(n))return t; +var r=n.constructor;return!j(r)&&(!tr||!p(n))||r instanceof r?tt?(sr(n,function(n,r,e){return t=!Et.call(e,r),X}),t===X):(sr(n,function(n,r){t=r}),t===X||Et.call(n,t)):t}function m(n){var t=[];return vr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(n==W)return n;if(r&&(t=X),r=x(n)){var o=$t.call(n);if(!er[o]||tr&&p(n))return n;var i=_r(n)}if(!r||!t)return r?i?v(n):pr({},n):n;switch(r=ur[o],o){case zt:case Ct:return new r(+n);case Kt:case Vt:return new r(n);case Ut:return r(n.source,vt.exec(n)) +}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:vr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(Et.call(n,"index")&&(a.index=n.index),Et.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return sr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=gr(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(n==W||t==W)return n===t;var u=$t.call(n),o=$t.call(t); +if(u==Mt&&(u=Lt),o==Mt&&(o=Lt),u!=o)return X;switch(u){case zt:case Ct:return+n==+t;case Kt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ut:case Vt:return n==t+""}if(o=u==Pt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=Lt||tr&&(p(n)||p(t)))return X;var u=!Yt&&h(n)?Object:n.constructor,i=!Yt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return X}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=Q,f=0; +if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return sr(n,function(n,u,o){return Et.call(o,u)?(f++,a=Et.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&sr(t,function(n,t,r){return Et.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?or[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==ot&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)vr(e[u],function(t,r){var e,u,o; +if(t&&((u=_r(t))||dr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?_r(o)?o:[]:dr(o)?o:{})),n[r]=E(o,t,ot,i,a))}else t!=W&&(n[r]=t)});return n}function S(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:lr(n,function(n){return r>++e?void 0:!(o=n===t)}),o}function $(n,t,r){var e=Q,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else lr(n,function(n,r,u){return e=!!t(n,r,u) +});return e}function q(n,t,r){var e=[],t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else lr(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,X):void 0}),e}function R(n,t,r){if(t&&r===void 0&&_r(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==X;);else lr(n,t,r);return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(_r(n))for(;u>++e;)o[e]=t(n[e],e,n); +else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=-1,i=n?n.length:0,f=e;if(t||!_r(n))t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,f=n)});else for(;i>++o;)n[o]>f&&(f=n[o]);return f}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; +if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else lr(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return t==W||r?n[0]:v(n,0,Tt(It(0,t),e))}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];_r(o)?St.apply(u,t?o:z(o)):u.push(o)}return u +}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,t==W||r?1:It(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=X);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e; +if(c)var s=p+"",s=Et.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&arguments.length>2?qt.call.apply(qt,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return St.apply(n,arguments),n=e.apply(r,n),new r(n)}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global; +Z.global===Z&&(n=Z);var nt,tt,rt=[],et=new function(){},ut=0,ot=et,it=30,at=n._,ft=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:""};var ar={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; +return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),Et.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=W,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=mr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) +},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=sr,r.forOwn=vr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),(Et.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Tt(It(0,e-(t==W||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; +n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=Et.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=typeof t=="function",u=[];return R(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments) +}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=-1,i=n?n.length:0,f=e;if(t||!_r(n))t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,f=n)});else for(;i>++o;)f>n[o]&&(f=n[o]);return f},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=X; +return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=xt.apply(rt,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),sr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,t==W&&(t=n,n=0);for(var e=-1,t=It(0,jt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r; +return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return R(n,function(n){var e=Ot(Bt()*(++t+1));r[t]=r[e],r[e]=n}),r},r.sortBy=function(n,t,r){var e=[],t=a(t,r);for(R(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(o);n--;)e[n]=e[n].c;return e},r.tap=function(n,t){return t(n),n},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a); +return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=W,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return typeof(n?n.length:0)=="number"?nr&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(xt.apply(rt,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=gr(t);return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t]; +u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return St.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=pr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,Q)},r.contains=k,r.escape=function(n){return n==W?"":(n+"").replace(dt,l)},r.every=$,r.find=N,r.has=function(n,t){return n?Et.call(n,t):X +},r.identity=G,r.indexOf=C,r.isArguments=h,r.isArray=_r,r.isBoolean=function(n){return n===Q||n===X||$t.call(n)==zt},r.isDate=function(n){return n instanceof Date||$t.call(n)==Ct},r.isElement=function(n){return n?1===n.nodeType:X},r.isEmpty=function(n){var t=Q;if(!n)return t;var r=$t.call(n),e=n.length;return r==Pt||r==Vt||r==Mt||Zt&&h(n)||r==Lt&&typeof e=="number"&&j(n.splice)?!e:(vr(n,function(){return t=X}),t)},r.isEqual=w,r.isFinite=function(n){return Rt(n)&&!Ft(parseFloat(n))},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n +},r.isNull=function(n){return n===W},r.isNumber=O,r.isObject=x,r.isPlainObject=dr,r.isRegExp=function(n){return n instanceof RegExp||$t.call(n)==Ut},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W; +return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t +}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) +},r.uniqueId=function(n){return(n==W?"":n+"")+ ++ut},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" +},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return new r(n)}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n; +r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 03ad89b12a..f0eb6761ea 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -3,32 +3,29 @@ Build: `lodash underscore -m -o ./lodash.underscore.min.js` Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||typeof e=="undefined")return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n, -r){var i=3>arguments.length,t=s(t,r,V);if(Mt(e)){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Lt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Mt(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st= -f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt= -{"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},Ot=v(At),Mt=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"== -it.call(e)}),n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t -[u],o))continue e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Mt(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){for(var t=-1,n=Lt(e),r=n.length,i=Array(r);++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Lt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings -),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch( -f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype -.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._= -n})(this); \ No newline at end of file +;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&r===void 0?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;e>++r&&t(n[r],r,n)!==Y;);else for(r in n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}}function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function i(n,t){var r=n.b,e=t.b,n=n.a,t=t.a; +if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1}return e>r?-1:1}function a(n,t,r){function e(){var u=arguments,o=t;return r.length&&(u=u.length?r.concat(p(u)):r),this instanceof e?(s.prototype=n.prototype,o=new s,s.prototype=J,u=n.apply(o,u),j(u)?u:o):n.apply(o,u)}return e}function f(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:V}function c(n){return"\\"+Ft[n]}function l(n){return Tt[n] +}function s(){}function p(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function v(n){return qt[n]}function g(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]=e[u]}return n}function h(n){var t=[];return r(n,function(n,r){t.push(r)}),t}function _(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]==J&&(n[u]=e[u])}return n}function m(n){var t=[]; +return e(n,function(n,r){b(n)&&t.push(r)}),t.sort()}function y(n){for(var t=-1,r=Rt(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function d(n,t,r,u){if(n===t)return 0!==n||1/n==1/t;if(n==J||t==J)return n===t;var o=lt.call(n),i=lt.call(t);if(o!=i)return K;switch(o){case bt:case jt:return+n==+t;case wt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case At:case Et:return n==t+""}if(i=o==dt,!i){if(n.__wrapped__||t.__wrapped__)return d(n.__wrapped__||n,t.__wrapped__||t);if(o!=xt)return K;var o=n.constructor,a=t.constructor; +if(!(o==a||b(o)&&o instanceof o&&b(a)&&a instanceof a))return K}for(r||(r=[]),u||(u=[]),o=r.length;o--;)if(r[o]==n)return u[o]==t;var f=H,c=0;if(r.push(n),u.push(t),i){if(c=n.length,f=c==t.length)for(;c--&&(f=d(n[c],t[c],r,u)););return f}return e(n,function(n,e,o){return ft.call(o,e)?(c++,!(f=ft.call(t,e)&&d(n,t[e],r,u))&&Y):void 0}),f&&e(t,function(n,t,r){return ft.call(r,t)?!(f=--c>-1)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?Nt[typeof n]:K}function w(n){return typeof n=="number"||lt.call(n)==wt +}function x(n){return typeof n=="string"||lt.call(n)==Et}function A(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function E(n,t){var r=K;return typeof(n?n.length:0)=="number"?r=I(n,t)>-1:u(n,function(n){return(r=n===t)&&Y}),r}function O(n,t,r){var e=H,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r&&(e=!!t(n[r],r,n)););else u(n,function(n,r,u){return!(e=!!t(n,r,u))&&Y});return e}function S(n,t,r){var e=[],t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r;){var i=n[r];t(i,r,n)&&e.push(i) +}else u(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function k(n,t,r){var e,t=f(t,r);return N(n,function(n,r,u){return t(n,r,u)?(e=n,Y):void 0}),e}function N(n,t,r){if(t&&r===void 0&&Bt(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==Y;);else u(n,t,r)}function F(n,t,r){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),t=f(t,r);if(Bt(n))for(;o>++e;)i[e]=t(n[e],e,n);else u(n,function(n,r,u){i[++e]=t(n,r,u)});return i}function R(n,t,r){var e=-1/0,o=-1,i=n?n.length:0,a=e;if(t||!Bt(n))t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,a=n) +});else for(;i>++o;)n[o]>a&&(a=n[o]);return a}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);a>++i;)r=t(r,n[i],i,n)}else u(n,function(n,e,u){r=o?(o=K,n):t(r,n,e,u)});return r}function B(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r&&!(e=t(n[r],r,n)););else u(n,function(n,r,u){return(e=t(n,r,u))&&Y +});return!!e}function M(n,t,r){if(n){var e=n.length;return t==J||r?n[0]:p(n,0,mt(_t(0,t),e))}}function $(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];Bt(o)?ct.apply(u,t?o:$(o)):u.push(o)}return u}function I(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?_t(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function z(n,t,r){return p(n,t==J||r?1:_t(0,t))}function C(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?f(r,e):V,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e; +return u}function P(n,t,r,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof t=="function"&&(e=r,r=t,t=K),r&&(a=[],r=f(r,e));o>++u;){var e=n[u],c=r?r(e,u,n):e;(t?!u||a[a.length-1]!==c:0>I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&arguments.length>2?st.call.apply(st,arguments):a(n,t,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__];return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n +}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,_t=Math.max,mt=Math.min,yt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",xt="[object Object]",At="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=y(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) +}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=m(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=U(n[u],n)}return n},o.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},o.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];return t[0]}},o.countBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),ft.call(e,r)?e[r]++:e[r]=1 +}),e},o.debounce=function(n,t,r){function e(){a=J,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},o.defaults=_,o.defer=function(n){var r=p(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},o.delay=function(n,r){var e=p(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},o.difference=function(n){for(var t=-1,r=n.length,e=it.apply(W,arguments),u=[];r>++t;){var o=n[t];0>I(e,o,r)&&u.push(o) +}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=m,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,mt(_t(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;u>++e;){var i=n[e];if(0>I(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=y,o.invoke=function(n,t){var r=p(arguments,2),e=typeof t=="function",u=[]; +return N(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=-1,i=n?n.length:0,a=e;if(t||!Bt(n))t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,a=n)});else for(;i>++o;)a>n[o]&&(a=n[o]);return a},o.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1] +}return u},o.omit=function(n){var t=it.apply(W,arguments),r={};return e(n,function(n,e){0>I(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},o.pick=function(n){for(var t=0,r=it.apply(W,arguments),e=r.length,u={};e>++t;){var o=r[t];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,t,r){n=+n||0,r=+r||1,t==J&&(t=n,n=0); +for(var e=-1,t=_t(0,ot((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},o.reject=function(n,t,r){return t=f(t,r),S(n,function(n,r,e){return!t(n,r,e)})},o.rest=z,o.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return N(n,function(n){var e=at(yt()*(++t+1));r[t]=r[e],r[e]=n}),r},o.sortBy=function(n,t,r){var e=[],t=f(t,r);for(N(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(i);n--;)e[n]=e[n].c;return e},o.tap=function(n,t){return t(n),n},o.throttle=function(n,t){function r(){a=new Date,i=J,u=n.apply(o,e) +}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},o.toArray=function(n){return typeof(n?n.length:0)=="number"?p(n):A(n)},o.union=function(){return P(it.apply(W,arguments))},o.uniq=P,o.values=A,o.where=function(n,t){var r=Rt(t);return S(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break +}return!!u})},o.without=function(n){for(var t=-1,r=n.length,e=[];r>++t;){var u=n[t];0>I(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);r>++t;)e[t]=T(arguments,t);return e},o.collect=F,o.drop=z,o.each=N,o.extend=g,o.methods=m,o.select=S,o.tail=z,o.unique=P,o.clone=function(n){return n&&Nt[typeof n]?Bt(n)?p(n):g({},n):n},o.contains=E,o.escape=function(n){return n==J?"":(n+"").replace(et,l) +},o.every=O,o.find=k,o.has=function(n,t){return n?ft.call(n,t):K},o.identity=V,o.indexOf=I,o.isArray=Bt,o.isBoolean=function(n){return n===H||n===K||lt.call(n)==bt},o.isDate=function(n){return n instanceof Date||lt.call(n)==jt},o.isElement=function(n){return n?1===n.nodeType:K},o.isEmpty=function(n){if(!n)return H;if(Bt(n)||x(n))return!n.length;for(var t in n)if(ft.call(n,t))return K;return H},o.isEqual=d,o.isFinite=function(n){return vt(n)&&!gt(parseFloat(n))},o.isFunction=b,o.isNaN=function(n){return w(n)&&n!=+n +},o.isNull=function(n){return n===J},o.isNumber=w,o.isObject=j,o.isRegExp=function(n){return n instanceof RegExp||lt.call(n)==At},o.isString=x,o.isUndefined=function(n){return n===void 0},o.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?_t(0,e+r):mt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(yt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J; +return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=_({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; +try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,_t(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this +},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o +})(this); \ No newline at end of file From e9d23cc1ea57c26ef122b393f72adebd9a9f74c6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 20 Dec 2012 02:29:21 -0500 Subject: [PATCH 020/176] Use `child_process.execFile` instead of `child_process.exec` in `post-install.js`. Former-commit-id: 2f6b0827641ceb1c6b418af9de87ef3c70243d5f --- build/post-install.js | 56 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/build/post-install.js b/build/post-install.js index 8b59affce7..b6c0f61a62 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -3,7 +3,7 @@ 'use strict'; /** Load Node modules */ - var exec = require('child_process').exec, + var execFile = require('child_process').execFile, fs = require('fs'), https = require('https'), path = require('path'), @@ -20,14 +20,11 @@ var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '7ecae09d413eb48dd5785fe877f24e60ac3bbcef'; + var uglifyId = '505f1be36ef60fd25a992a522f116d5179ab317f'; /** The media type for raw blob data */ var mediaType = 'application/vnd.github.v3.raw'; - /** Reassign `existsSync` for older versions of Node */ - fs.existsSync || (fs.existsSync = path.existsSync); - /** Used to reference parts of the blob href */ var location = (function() { var host = 'api.github.com', @@ -42,6 +39,21 @@ }; }()); + /** The message to display when the install mode is undetectable */ + var oopsMessage = [ + 'Oops! There was a problem detecting the install mode. If you’re installing the', + 'Lo-Dash command-line executable (via `npm install -g lodash`), you’ll need to', + 'manually install UglifyJS and the Closure Compiler by running:', + '', + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", + '', + 'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url + ].join('\n'); + + /** Reassign `existsSync` for older versions of Node */ + fs.existsSync || (fs.existsSync = path.existsSync); + /*--------------------------------------------------------------------------*/ /** @@ -99,9 +111,14 @@ .on('error', callback); } - /*--------------------------------------------------------------------------*/ - - exec('npm -g root', function(exception, stdout) { + /** + * The `child_process.execFile` callback. + * + * @private + * @param {Object|Undefined} exception The error object. + * @param {String} stdout The stdout buffer. + */ + function onExecFile(exception, stdout) { if (!exception) { try { var root = stdout.trim(), @@ -111,17 +128,7 @@ } } if (exception) { - console.error([ - 'Oops! There was a problem detecting the install mode. If you’re installing the', - 'Lo-Dash command-line executable (via `npm install -g lodash`), you’ll need to', - 'manually install UglifyJS and the Closure Compiler by running:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", - '', - 'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url - ].join('\n')); - + console.error(oopsMessage); console.error(exception); } if (!isGlobal) { @@ -144,5 +151,14 @@ }); } }); - }); + } + + /*--------------------------------------------------------------------------*/ + + try { + execFile('npm', [ '-g', 'root' ], onExecFile); + } catch(e) { + console.error(oopsMessage); + console.error(e); + } }()); From 282a5e0b01d58ea4540a47d858d78bc2aaab3dc2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 20 Dec 2012 02:43:16 -0500 Subject: [PATCH 021/176] Correct `href` value in post-install.js. Former-commit-id: 63b220d6dfecad7c1ebb5079efef603145e97392 --- build/post-install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/post-install.js b/build/post-install.js index b6c0f61a62..a0510ca379 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -33,7 +33,7 @@ return { 'host': host, - 'href': host + origin + pathname, + 'href': origin + pathname, 'origin': origin, 'pathname': pathname }; From 1b347fc185cc47baa5b81b52af5b0bc749340271 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 21 Dec 2012 12:38:55 -0600 Subject: [PATCH 022/176] Tweak `_.uniqueId` to avoid problems with buggy minifiers. Former-commit-id: e940c336b227ce89661cd6ada5f3e722a0204318 --- doc/README.md | 8 ++++---- lodash.js | 3 ++- lodash.min.js | 2 +- vendor/underscore/underscore-min.js | 6 +++++- vendor/underscore/underscore.js | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/README.md b/doc/README.md index 72dffc0dfb..be3e983125 100644 --- a/doc/README.md +++ b/doc/README.md @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4218 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4234 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4235 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4252 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4417 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index fd20cea5f3..644f170324 100644 --- a/lodash.js +++ b/lodash.js @@ -4188,7 +4188,8 @@ * // => '105' */ function uniqueId(prefix) { - return (prefix == null ? '' : prefix + '') + (++idCounter); + var id = ++idCounter; + return (prefix == null ? '' : prefix + '') + id; } /*--------------------------------------------------------------------------*/ diff --git a/lodash.min.js b/lodash.min.js index 892f8eb2d4..929b3a838e 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -33,6 +33,6 @@ u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];retur },r.isNull=function(n){return n===W},r.isNumber=O,r.isObject=x,r.isPlainObject=dr,r.isRegExp=function(n){return n instanceof RegExp||$t.call(n)==Ut},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W; return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t }),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) -},r.uniqueId=function(n){return(n==W?"":n+"")+ ++ut},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" +},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" },r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return new r(n)}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n; r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index f5e1155aed..16a5f62c05 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -1 +1,5 @@ -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +// Underscore.js 1.4.3 +// http://underscorejs.org +// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. +// Underscore may be freely distributed under the MIT license. +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index ac28c6d8ad..b943608c95 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -1075,7 +1075,7 @@ // Useful for temporary DOM ids. var idCounter = 0; _.uniqueId = function(prefix) { - var id = '' + (++idCounter); + var id = ++idCounter + ''; return prefix ? prefix + id : id; }; From 3908fa5c57f73101fbfab56061b78e9cbc117f1f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 21 Dec 2012 18:07:05 -0600 Subject: [PATCH 023/176] Simplify build/post-install.js. Former-commit-id: a3f657f9721b18cef3c43b36a64e83b77d63eeea --- build/post-install.js | 53 ++++--------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/build/post-install.js b/build/post-install.js index a0510ca379..bae89fd7b3 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -3,8 +3,7 @@ 'use strict'; /** Load Node modules */ - var execFile = require('child_process').execFile, - fs = require('fs'), + var fs = require('fs'), https = require('https'), path = require('path'), tar = require('../vendor/tar/tar.js'), @@ -39,21 +38,6 @@ }; }()); - /** The message to display when the install mode is undetectable */ - var oopsMessage = [ - 'Oops! There was a problem detecting the install mode. If you’re installing the', - 'Lo-Dash command-line executable (via `npm install -g lodash`), you’ll need to', - 'manually install UglifyJS and the Closure Compiler by running:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", - '', - 'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url - ].join('\n'); - - /** Reassign `existsSync` for older versions of Node */ - fs.existsSync || (fs.existsSync = path.existsSync); - /*--------------------------------------------------------------------------*/ /** @@ -111,29 +95,9 @@ .on('error', callback); } - /** - * The `child_process.execFile` callback. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} stdout The stdout buffer. - */ - function onExecFile(exception, stdout) { - if (!exception) { - try { - var root = stdout.trim(), - isGlobal = fs.existsSync(root) && path.resolve(basePath, '..') == fs.realpathSync(root); - } catch(e) { - exception = e; - } - } - if (exception) { - console.error(oopsMessage); - console.error(exception); - } - if (!isGlobal) { - return; - } + /*--------------------------------------------------------------------------*/ + + if (process.env.npm_config_global === 'true') { // download the Closure Compiler getDependency({ 'title': 'the Closure Compiler', @@ -152,13 +116,4 @@ } }); } - - /*--------------------------------------------------------------------------*/ - - try { - execFile('npm', [ '-g', 'root' ], onExecFile); - } catch(e) { - console.error(oopsMessage); - console.error(e); - } }()); From c1e543c9fef03dc41c5500d658c927aa65c6ef2c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 21 Dec 2012 20:04:02 -0600 Subject: [PATCH 024/176] Cleanup .npmignore. [ci skip] Former-commit-id: bca4d773ba803c28a128ec162b41e033998b5d0a --- .npmignore | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.npmignore b/.npmignore index 4a44df3f34..08210e2d72 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ .* *.custom.* *.d.ts +CONTRIBUTING.md doc/*.php node_modules/ perf/*.html @@ -12,8 +13,8 @@ test/*.sh vendor/*.gz vendor/backbone/ vendor/benchmark.js/*.jar -vendor/closure-compiler -vendor/docdown +vendor/closure-compiler/ +vendor/docdown/ vendor/firebug-lite/ vendor/json3/ vendor/jquery/ @@ -21,5 +22,5 @@ vendor/qunit/qunit/*.css vendor/qunit/qunit/*-1.8.0.js vendor/requirejs/ vendor/underscore/*-min.js -vendor/uglifyjs +vendor/uglifyjs/ vendor/underscore/test/ From 32b5b5b1c4ea986732333c6a97b62f4b7fb0d5f1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Dec 2012 11:56:52 -0600 Subject: [PATCH 025/176] Catch module load errors in build/post-install.js. Former-commit-id: 6671d4925749d8b4d6da9ddd732bc7f436b6740d --- build/post-install.js | 60 +++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/build/post-install.js b/build/post-install.js index bae89fd7b3..b83dd1fb9d 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -4,10 +4,7 @@ /** Load Node modules */ var fs = require('fs'), - https = require('https'), - path = require('path'), - tar = require('../vendor/tar/tar.js'), - zlib = require('zlib'); + path = require('path'); /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); @@ -88,7 +85,7 @@ var decompressor = zlib.createUnzip(), parser = new tar.Extract({ 'path': path }); - decompressor.on('error', callback) + decompressor.on('error', callback); parser.on('end', callback).on('error', callback); response.pipe(decompressor).pipe(parser); }) @@ -98,22 +95,41 @@ /*--------------------------------------------------------------------------*/ if (process.env.npm_config_global === 'true') { - // download the Closure Compiler - getDependency({ - 'title': 'the Closure Compiler', - 'id': closureId, - 'path': vendorPath, - 'onComplete': function() { - // download UglifyJS - getDependency({ - 'title': 'UglifyJS', - 'id': uglifyId, - 'path': vendorPath, - 'onComplete': function() { - process.exit(); - } - }); - } - }); + // catch module load errors + try { + var https = require('https'), + tar = require('../vendor/tar/tar.js'), + zlib = require('zlib'); + + // download the Closure Compiler + getDependency({ + 'title': 'the Closure Compiler', + 'id': closureId, + 'path': vendorPath, + 'onComplete': function() { + // download UglifyJS + getDependency({ + 'title': 'UglifyJS', + 'id': uglifyId, + 'path': vendorPath, + 'onComplete': function() { + process.exit(); + } + }); + } + }); + } catch(e) { + console.log([ + 'Oops! There was a problem installing dependencies required by the Lo-Dash', + 'command-line executable. To manually install UglifyJS and the Closure Compiler', + 'run:', + '', + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", + '' + ].join('\n')); + + console.log(e); + } } }()); From bd8f882c94bf4397db0278dc167948e1e8444929 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Dec 2012 11:57:14 -0600 Subject: [PATCH 026/176] Tweak `_.reduce` documentation. Former-commit-id: 58d8a724dbf53594420e355c3d29ae28b53a7886 --- doc/README.md | 2 +- lodash.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/README.md b/doc/README.md index be3e983125..ab0b3a6ee6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1190,7 +1190,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2465 "View in source") [Ⓣ][1] -Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. +Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. #### Aliases *foldl, inject* diff --git a/lodash.js b/lodash.js index 644f170324..34cf62250e 100644 --- a/lodash.js +++ b/lodash.js @@ -2443,9 +2443,9 @@ } /** - * Boils down a `collection` to a single value. The initial state of the - * reduction is `accumulator` and each successive step of it should be returned - * by the `callback`. The `callback` is bound to `thisArg` and invoked with 4 + * Reduces a `collection` to a single value. The initial state of the reduction + * is `accumulator` and each successive step of it should be returned by the + * `callback`. The `callback` is bound to `thisArg` and invoked with four * arguments; for arrays they are (accumulator, value, index|key, collection). * * @static From bda4747e9c14c7084ea4b92208681973c00e86e0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Dec 2012 14:51:28 -0600 Subject: [PATCH 027/176] Use `@license` in the copyright/license header. [closes #138] Former-commit-id: 3b924dad24d56e0fd33e4df1341b09c6165521a1 --- build.js | 13 +- build/minify.js | 1 + build/post-compile.js | 27 ++-- build/pre-compile.js | 15 +- doc/README.md | 208 +++++++++++++-------------- lodash.js | 3 +- lodash.min.js | 9 +- lodash.underscore.js | 9 +- lodash.underscore.min.js | 11 +- test/test-build.js | 37 +---- vendor/docdown/src/DocDown/Alias.php | 119 ++++++++------- vendor/docdown/src/DocDown/Entry.php | 175 +++++++++++----------- 12 files changed, 307 insertions(+), 320 deletions(-) diff --git a/build.js b/build.js index 9150046b85..b9881c0b29 100755 --- a/build.js +++ b/build.js @@ -420,12 +420,7 @@ * @returns {String} Returns the modified source. */ function addCommandsToHeader(source, commands) { - return source.replace(/(\/\*!\n)( \*)?( *Lo-Dash [\w.-]+)(.*)/, function() { - // convert unmatched groups to empty strings - var parts = _.map(slice.call(arguments, 1), function(part) { - return part || ''; - }); - + return source.replace(/(\/\**\n)( \*)( *@license[\s*]+)( *Lo-Dash [\w.-]+)(.*)/, function() { // remove `node path/to/build.js` from `commands` if (commands[0] == 'node') { commands.splice(0, 2); @@ -440,9 +435,11 @@ return command; }); // add build commands to copyright/license header + var parts = slice.call(arguments, 1); return ( parts[0] + - parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' + + parts[1] + + parts[2] + parts[3] + ' (Custom Build)' + parts[4] + '\n' + parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' ); }); @@ -1944,7 +1941,7 @@ var token = '%output%', index = iife.indexOf(token); - source = source.match(/\/\*![\s\S]+?\*\/\n/) + + source = source.match(/^\/\**[\s\S]+?\*\/\n/) + iife.slice(0, index) + source.replace(/^[\s\S]+?\(function[^{]+?{|}\(this\)\)[;\s]*$/g, '') + iife.slice(index + token.length); diff --git a/build/minify.js b/build/minify.js index c9f166d2f5..a6860c81d6 100755 --- a/build/minify.js +++ b/build/minify.js @@ -204,6 +204,7 @@ // restrict lines to 500 characters for consistency with the Closure Compiler var stream = uglifyJS.OutputStream({ 'ascii_only': true, + 'comments': true, 'max_line_len': 500, }); diff --git a/build/post-compile.js b/build/post-compile.js index 6ea6cda9f2..bcb4cc8bba 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -6,15 +6,13 @@ var fs = require('fs'); /** The minimal license/copyright template */ - var licenseTemplate = { - 'lodash': - '/*!\n' + - ' Lo-Dash <%= VERSION %> lodash.com/license\n' + - ' Underscore.js 1.4.3 underscorejs.org/LICENSE\n' + - '*/', - 'underscore': - '/*! Underscore.js <%= VERSION %> underscorejs.org/LICENSE */' - }; + var licenseTemplate = [ + '/**', + ' * @license', + ' * Lo-Dash <%= VERSION %> lodash.com/license', + ' * Underscore.js 1.4.3 underscorejs.org/LICENSE', + ' */' + ].join('\n'); /*--------------------------------------------------------------------------*/ @@ -26,6 +24,9 @@ * @returns {String} Returns the processed source. */ function postprocess(source) { + // remove old copyright/license header + source = source.replace(/^\/\**[\s\S]+?\*\/\n/, ''); + // move vars exposed by the Closure Compiler into the IIFE source = source.replace(/^((?:(['"])use strict\2;)?(?:var (?:[a-z]+=(?:!0|!1|null)[,;])+)?)([\s\S]*?function[^)]+\){)/, '$3$1'); @@ -53,9 +54,11 @@ if (!snippet) { return source; } - // add copyright/license header - return licenseTemplate[/call\(this\);?$/.test(source) ? 'underscore' : 'lodash'] - .replace('<%= VERSION %>', snippet[2]) + '\n;' + source; + // add new copyright/license header + var version = snippet[2]; + source = licenseTemplate.replace('<%= VERSION %>', version) + '\n;' + source; + + return source; } /*--------------------------------------------------------------------------*/ diff --git a/build/pre-compile.js b/build/pre-compile.js index 1aaa93ba4c..f4f19ca5d5 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -191,11 +191,7 @@ // properties used by the `backbone` and `underscore` builds '__chain__', - 'chain', - - // properties used by underscore.js - '_chain', - '_wrapped' + 'chain' ]; /*--------------------------------------------------------------------------*/ @@ -217,9 +213,6 @@ if (options.isTemplate) { return source; } - // remove copyright/license header to add later in post-compile.js - source = source.replace(/\/\*![\s\S]+?\*\//, ''); - // add brackets to whitelisted properties so the Closure Compiler won't mung them // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), function(match, prop) { @@ -229,9 +222,6 @@ // remove brackets from `_.escape()` in `_.template` source = source.replace(/__e *= *_\['escape']/g, '__e=_.escape'); - // remove brackets from `_.escape()` in underscore.js `_.template` - source = source.replace(/_\['escape'\]\(__t'/g, '_.escape(__t'); - // remove brackets from `collection.indexOf` in `_.contains` source = source.replace("collection['indexOf'](target)", 'collection.indexOf(target)'); @@ -252,9 +242,6 @@ return (captured || '') + string; }); - // add newline to `+"__p+='"` in underscore.js `_.template` - source = source.replace(/\+"__p\+='"/g, '+"\\n__p+=\'"'); - // add newline to `body + '}'` in `createFunction` source = source.replace(/body *\+ *'}'/, 'body+"\\n}"'); diff --git a/doc/README.md b/doc/README.md index ab0b3a6ee6..8cf29490c0 100644 --- a/doc/README.md +++ b/doc/README.md @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2763 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2829 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2898 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2932 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2933 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2957 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3009 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3010 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3036 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3037 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3111 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3150 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3194 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3227 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3319 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3320 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3351 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -681,7 +681,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L279 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4218 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4219 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4236 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4252 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4253 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -789,7 +789,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1961 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -817,7 +817,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2002 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -855,7 +855,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2049 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2050 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -887,7 +887,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2079 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2080 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +916,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2118 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2119 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +945,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2163 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -974,7 +974,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2198 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1006,7 +1006,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2239 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1038,7 +1038,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1067,7 +1067,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1099,7 +1099,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2347 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1131,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2393 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2441 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2465 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2466 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2507 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2508 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1249,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2598 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2623 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2624 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2669 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2702 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3383 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3447 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3493 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3515 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3549 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3592 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3593 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3720 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3773 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3774 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1828,7 +1828,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L813 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L814 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1856,7 +1856,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1023 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1024 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1892,7 +1892,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1118 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1119 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1925,7 +1925,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1140 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1141 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1951,7 +1951,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L869 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L870 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1987,7 +1987,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L894 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2015,7 +2015,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1159 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1160 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2042,7 +2042,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1184 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1185 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2067,7 +2067,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1202 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2091,7 +2091,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L831 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L832 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2118,7 +2118,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1230 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2145,7 +2145,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1249 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1250 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2169,7 +2169,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1267 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2193,7 +2193,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1284 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2217,7 +2217,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2247,7 +2247,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2278,7 +2278,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1501 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2316,7 +2316,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1518 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2340,7 +2340,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1581 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2375,7 +2375,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2402,7 +2402,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1620 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2426,7 +2426,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1549 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2456,7 +2456,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1648 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2491,7 +2491,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1673 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2515,7 +2515,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1690 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1691 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2539,7 +2539,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1708 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2563,7 +2563,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2587,7 +2587,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1742 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2622,7 +2622,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2653,7 +2653,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2677,7 +2677,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1888 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2708,7 +2708,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1925 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3797 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3798 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3815 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3842 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3867 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3868 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3890 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3891 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4014 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4144 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4145 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4190 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4418 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3081,7 +3081,7 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L299 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L300 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3093,7 +3093,7 @@ _.uniqueId(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L309 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3105,7 +3105,7 @@ _.uniqueId(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L317 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L318 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3117,7 +3117,7 @@ _.uniqueId(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L326 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L327 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3129,7 +3129,7 @@ _.uniqueId(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L336 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 34cf62250e..433b31610a 100644 --- a/lodash.js +++ b/lodash.js @@ -1,4 +1,5 @@ -/*! +/** + * @license * Lo-Dash 1.0.0-rc.3 * (c) 2012 John-David Dalton * Based on Underscore.js 1.4.3 diff --git a/lodash.min.js b/lodash.min.js index 929b3a838e..81f7ea1061 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,7 +1,8 @@ -/*! - Lo-Dash 1.0.0-rc.3 lodash.com/license - Underscore.js 1.4.3 underscorejs.org/LICENSE -*/ +/** + * @license + * Lo-Dash 1.0.0-rc.3 lodash.com/license + * Underscore.js 1.4.3 underscorejs.org/LICENSE + */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(Et.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return Et.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 }return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=W,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:nt,f:Qt,g:"",h:Xt,i:nr,j:wt,k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++ie;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; diff --git a/lodash.underscore.js b/lodash.underscore.js index b62d81aed9..a07274287d 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1,4 +1,5 @@ -/*! +/** + * @license * Lo-Dash 1.0.0-rc.3 (Custom Build) * Build: `lodash underscore -d -o ./lodash.underscore.js` * (c) 2012 John-David Dalton @@ -1981,9 +1982,9 @@ } /** - * Boils down a `collection` to a single value. The initial state of the - * reduction is `accumulator` and each successive step of it should be returned - * by the `callback`. The `callback` is bound to `thisArg` and invoked with 4 + * Reduces a `collection` to a single value. The initial state of the reduction + * is `accumulator` and each successive step of it should be returned by the + * `callback`. The `callback` is bound to `thisArg` and invoked with four * arguments; for arrays they are (accumulator, value, index|key, collection). * * @static diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index f0eb6761ea..1caaefa1d5 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -1,8 +1,9 @@ -/*! - Lo-Dash 1.0.0-rc.3 (Custom Build) lodash.com/license - Build: `lodash underscore -m -o ./lodash.underscore.min.js` - Underscore.js 1.4.3 underscorejs.org/LICENSE -*/ +/** + * @license + * Lo-Dash 1.0.0-rc.3 (Custom Build) lodash.com/license + * Build: `lodash underscore -m -o ./lodash.underscore.min.js` + * Underscore.js 1.4.3 underscorejs.org/LICENSE + */ ;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&r===void 0?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;e>++r&&t(n[r],r,n)!==Y;);else for(r in n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}}function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function i(n,t){var r=n.b,e=t.b,n=n.a,t=t.a; if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1}return e>r?-1:1}function a(n,t,r){function e(){var u=arguments,o=t;return r.length&&(u=u.length?r.concat(p(u)):r),this instanceof e?(s.prototype=n.prototype,o=new s,s.prototype=J,u=n.apply(o,u),j(u)?u:o):n.apply(o,u)}return e}function f(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:V}function c(n){return"\\"+Ft[n]}function l(n){return Tt[n] }function s(){}function p(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function v(n){return qt[n]}function g(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]=e[u]}return n}function h(n){var t=[];return r(n,function(n,r){t.push(r)}),t}function _(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]==J&&(n[u]=e[u])}return n}function m(n){var t=[]; diff --git a/test/test-build.js b/test/test-build.js index f4a9de16d4..6e4f764477 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -569,8 +569,8 @@ QUnit.module('independent builds'); (function() { - var reComment = /\/\*![\s\S]+?\*\//, - reCustom = /Custom Build/; + var reCustom = /Custom Build/, + reLicense = /^\/\**\s+\* @license[\s\S]+?\*\/\n/; asyncTest('debug only', function() { var start = _.once(QUnit.start); @@ -585,7 +585,7 @@ build(['-d', '-s', 'backbone'], function(source, filePath) { equal(path.basename(filePath, '.js'), 'lodash.custom'); - var comment = source.match(reComment); + var comment = source.match(reLicense); ok(reCustom.test(comment)); start(); }); @@ -604,7 +604,7 @@ build(['-m', '-s', 'backbone'], function(source, filePath) { equal(path.basename(filePath, '.js'), 'lodash.custom.min'); - var comment = source.match(reComment); + var comment = source.match(reLicense); ok(reCustom.test(comment)); start(); }); @@ -985,35 +985,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('minify underscore'); - - (function() { - asyncTest('`node minify underscore.js`', function() { - var source = fs.readFileSync(path.join(__dirname, '..', 'vendor', 'underscore', 'underscore.js'), 'utf8'), - start = _.once(QUnit.start); - - minify(source, { - 'isSilent': true, - 'workingName': 'underscore.min', - 'onComplete': function(result) { - var context = createContext(); - - try { - vm.runInContext(result, context); - } catch(e) { - console.log(e); - } - var underscore = context._ || {}; - ok(_.isString(underscore.VERSION)); - ok(!/Lo-Dash/.test(result) && result.match(/\n/g).length < source.match(/\n/g).length); - start(); - } - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('mobile build'); (function() { diff --git a/vendor/docdown/src/DocDown/Alias.php b/vendor/docdown/src/DocDown/Alias.php index 1ca539d716..0a7c552e0d 100644 --- a/vendor/docdown/src/DocDown/Alias.php +++ b/vendor/docdown/src/DocDown/Alias.php @@ -29,15 +29,16 @@ public function __construct( $name, $owner ) { $this->_category = $owner->getCategory(); $this->_desc = $owner->getDesc(); $this->_example = $owner->getExample(); + $this->_isCtor = $owner->isCtor(); + $this->_isLicense = $owner->isLicense(); + $this->_isPlugin = $owner->isPlugin(); + $this->_isPrivate = $owner->isPrivate(); + $this->_isStatic = $owner->isStatic(); $this->_lineNumber = $owner->getLineNumber(); $this->_members = $owner->getMembers(); $this->_params = $owner->getParams(); $this->_returns = $owner->getReturns(); $this->_type = $owner->getType(); - $this->_isCtor = $owner->isCtor(); - $this->_isPlugin = $owner->isPlugin(); - $this->_isPrivate = $owner->isPrivate(); - $this->_isStatic = $owner->isStatic(); } /*--------------------------------------------------------------------------*/ @@ -97,119 +98,129 @@ public function getExample() { } /** - * Resolves the owner entry's line number. + * Checks if the entry is an alias. * * @memberOf Alias - * @returns {Number} The owner entry's line number. + * @returns {Boolean} Returns `true`. */ - public function getLineNumber() { - return $this->_lineNumber; + public function isAlias() { + return true; } /** - * Extracts the owner entry's `member` data. + * Checks if the owner entry is a constructor. * * @memberOf Alias - * @param {Number} $index The index of the array value to return. - * @returns {Array|String} The owner entry's `member` data. + * @returns {Boolean} Returns `true` if a constructor, else `false`. */ - public function getMembers( $index = null ) { - return $index !== null - ? @$this->_members[$index] - : $this->_members; + public function isCtor() { + return $this->_isCtor; } /** - * Extracts the owner entry's `name` data. + * Checks if the owner entry is a license. * * @memberOf Alias - * @returns {String} The owner entry's `name` data. + * @returns {Boolean} Returns `true` if a license, else `false`. */ - public function getName() { - return $this->_name; + public function isLicense() { + return $this->_isLicense; } /** - * Extracts the owner entry's `param` data. + * Checks if the owner entry *is* assigned to a prototype. * * @memberOf Alias - * @param {Number} $index The index of the array value to return. - * @returns {Array} The owner entry's `param` data. + * @returns {Boolean} Returns `true` if assigned to a prototype, else `false`. */ - public function getParams( $index = null ) { - return $index !== null - ? @$this->_params[$index] - : $this->_params; + public function isPlugin() { + return $this->_isPlugin; } /** - * Extracts the owner entry's `returns` data. + * Checks if the owner entry is private. * * @memberOf Alias - * @returns {String} The owner entry's `returns` data. + * @returns {Boolean} Returns `true` if private, else `false`. */ - public function getReturns() { - return $this->_returns; + public function isPrivate() { + return $this->_isPrivate; } /** - * Extracts the owner entry's `type` data. + * Checks if the owner entry is *not* assigned to a prototype. * * @memberOf Alias - * @returns {String} The owner entry's `type` data. + * @returns {Boolean} Returns `true` if not assigned to a prototype, else `false`. */ - public function getType() { - return $this->_type; + public function isStatic() { + return $this->_isStatic; } /** - * Checks if the entry is an alias. + * Resolves the owner entry's line number. * * @memberOf Alias - * @returns {Boolean} Returns `true`. + * @returns {Number} The owner entry's line number. */ - public function isAlias() { - return true; + public function getLineNumber() { + return $this->_lineNumber; } /** - * Checks if the owner entry is a constructor. + * Extracts the owner entry's `member` data. * * @memberOf Alias - * @returns {Boolean} Returns `true` if a constructor, else `false`. + * @param {Number} $index The index of the array value to return. + * @returns {Array|String} The owner entry's `member` data. */ - public function isCtor() { - return $this->_isCtor; + public function getMembers( $index = null ) { + return $index !== null + ? @$this->_members[$index] + : $this->_members; } /** - * Checks if the owner entry *is* assigned to a prototype. + * Extracts the owner entry's `name` data. * * @memberOf Alias - * @returns {Boolean} Returns `true` if assigned to a prototype, else `false`. + * @returns {String} The owner entry's `name` data. */ - public function isPlugin() { - return $this->_isPlugin; + public function getName() { + return $this->_name; } /** - * Checks if the owner entry is private. + * Extracts the owner entry's `param` data. * * @memberOf Alias - * @returns {Boolean} Returns `true` if private, else `false`. + * @param {Number} $index The index of the array value to return. + * @returns {Array} The owner entry's `param` data. */ - public function isPrivate() { - return $this->_isPrivate; + public function getParams( $index = null ) { + return $index !== null + ? @$this->_params[$index] + : $this->_params; } /** - * Checks if the owner entry is *not* assigned to a prototype. + * Extracts the owner entry's `returns` data. * * @memberOf Alias - * @returns {Boolean} Returns `true` if not assigned to a prototype, else `false`. + * @returns {String} The owner entry's `returns` data. */ - public function isStatic() { - return $this->_isStatic; + public function getReturns() { + return $this->_returns; + } + + /** + * Extracts the owner entry's `type` data. + * + * @memberOf Alias + * @returns {String} The owner entry's `type` data. + */ + public function getType() { + return $this->_type; } } ?> \ No newline at end of file diff --git a/vendor/docdown/src/DocDown/Entry.php b/vendor/docdown/src/DocDown/Entry.php index e545d33607..f7e96f76e2 100644 --- a/vendor/docdown/src/DocDown/Entry.php +++ b/vendor/docdown/src/DocDown/Entry.php @@ -217,6 +217,100 @@ public function getExample() { return $result; } + /** + * Checks if the entry is an alias. + * + * @memberOf Entry + * @returns {Boolean} Returns `false`. + */ + public function isAlias() { + return false; + } + + /** + * Checks if the entry is a constructor. + * + * @memberOf Entry + * @returns {Boolean} Returns `true` if a constructor, else `false`. + */ + public function isCtor() { + if (!isset($this->_isCtor)) { + $this->_isCtor = !!preg_match('/\* *@constructor\b/', $this->entry); + } + return $this->_isCtor; + } + + /** + * Checks if the entry is a license. + * + * @memberOf Entry + * @returns {Boolean} Returns `true` if a license, else `false`. + */ + public function isLicense() { + if (!isset($this->_isLicense)) { + $this->_isLicense = !!preg_match('/\* *@license\b/', $this->entry); + } + return $this->_isLicense; + } + + /** + * Checks if the entry *is* assigned to a prototype. + * + * @memberOf Entry + * @returns {Boolean} Returns `true` if assigned to a prototype, else `false`. + */ + public function isPlugin() { + if (!isset($this->_isPlugin)) { + $this->_isPlugin = !$this->isCtor() && !$this->isPrivate() && !$this->isStatic(); + } + return $this->_isPlugin; + } + + /** + * Checks if the entry is private. + * + * @memberOf Entry + * @returns {Boolean} Returns `true` if private, else `false`. + */ + public function isPrivate() { + if (!isset($this->_isPrivate)) { + $this->_isPrivate = $this->isLicense() || !!preg_match('/\* *@private\b/', $this->entry) || !preg_match('/\* *@[a-z]+\b/', $this->entry); + } + return $this->_isPrivate; + } + + /** + * Checks if the entry is *not* assigned to a prototype. + * + * @memberOf Entry + * @returns {Boolean} Returns `true` if not assigned to a prototype, else `false`. + */ + public function isStatic() { + if (isset($this->_isStatic)) { + return $this->_isStatic; + } + + $public = !$this->isPrivate(); + $result = $public && !!preg_match('/\* *@static\b/', $this->entry); + + // set in cases where it isn't explicitly stated + if ($public && !$result) { + if ($parent = array_pop(preg_split('/[#.]/', $this->getMembers(0)))) { + foreach (Entry::getEntries($this->source) as $entry) { + $entry = new Entry($entry, $this->source); + if ($entry->getName() == $parent) { + $result = !$entry->isCtor(); + break; + } + } + } else { + $result = true; + } + } + $this->_isStatic = $result; + return $result; + } + /** * Resolves the entry's line number. * @@ -344,86 +438,5 @@ public function getType() { $this->_type = $result; return $result; } - - /** - * Checks if the entry is an alias. - * - * @memberOf Entry - * @returns {Boolean} Returns `false`. - */ - public function isAlias() { - return false; - } - - /** - * Checks if the entry is a constructor. - * - * @memberOf Entry - * @returns {Boolean} Returns `true` if a constructor, else `false`. - */ - public function isCtor() { - if (!isset($this->_isCtor)) { - $this->_isCtor = !!preg_match('/\* *@constructor\b/', $this->entry); - } - return $this->_isCtor; - } - - /** - * Checks if the entry *is* assigned to a prototype. - * - * @memberOf Entry - * @returns {Boolean} Returns `true` if assigned to a prototype, else `false`. - */ - public function isPlugin() { - if (!isset($this->_isPlugin)) { - $this->_isPlugin = !$this->isCtor() && !$this->isPrivate() && !$this->isStatic(); - } - return $this->_isPlugin; - } - - /** - * Checks if the entry is private. - * - * @memberOf Entry - * @returns {Boolean} Returns `true` if private, else `false`. - */ - public function isPrivate() { - if (!isset($this->_isPrivate)) { - $this->_isPrivate = !!preg_match('/\* *@private\b/', $this->entry) || !preg_match('/\* *@[a-z]+\b/', $this->entry); - } - return $this->_isPrivate; - } - - /** - * Checks if the entry is *not* assigned to a prototype. - * - * @memberOf Entry - * @returns {Boolean} Returns `true` if not assigned to a prototype, else `false`. - */ - public function isStatic() { - if (isset($this->_isStatic)) { - return $this->_isStatic; - } - - $public = !$this->isPrivate(); - $result = $public && !!preg_match('/\* *@static\b/', $this->entry); - - // set in cases where it isn't explicitly stated - if ($public && !$result) { - if ($parent = array_pop(preg_split('/[#.]/', $this->getMembers(0)))) { - foreach (Entry::getEntries($this->source) as $entry) { - $entry = new Entry($entry, $this->source); - if ($entry->getName() == $parent) { - $result = !$entry->isCtor(); - break; - } - } - } else { - $result = true; - } - } - $this->_isStatic = $result; - return $result; - } } ?> \ No newline at end of file From 0ad6ac95b2add1a9d1506f92c32f0ba83183072f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 23 Dec 2012 10:10:28 -0600 Subject: [PATCH 028/176] Avoid `setTimeout` inconsistencies in the unit tests. Former-commit-id: fdbe08fcb381bf7771a1a7e474882d82e5bdbdf2 --- test/test.js | 85 ++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/test/test.js b/test/test.js index 9715a76a32..4cf17f350f 100644 --- a/test/test.js +++ b/test/test.js @@ -431,21 +431,21 @@ QUnit.module('lodash.debounce'); (function() { + test('subsequent "immediate" debounced calls return the last `func` result', function() { + var debounced = _.debounce(function(value) { return value; }, 32, true), + result = [debounced('x'), debounced('y')]; + + deepEqual(result, ['x', 'x']); + }); + asyncTest('subsequent debounced calls return the last `func` result', function() { - var debounced = _.debounce(function(value) { return value; }, 90); + var debounced = _.debounce(function(value) { return value; }, 32); debounced('x'); setTimeout(function() { equal(debounced('y'), 'x'); QUnit.start(); - }, 120); - }); - - test('subsequent "immediate" debounced calls return the last `func` result', function() { - var debounced = _.debounce(function(value) { return value; }, 90, true), - result = [debounced('x'), debounced('y')]; - - deepEqual(result, ['x', 'x']); + }, 64); }); }()); @@ -1785,46 +1785,37 @@ deepEqual(result, ['x', 'x']); }); - asyncTest('supports recursive calls', function() { - var counter = 0; - var throttled = _.throttle(function() { - counter++; - if (counter < 4) { - throttled(); - } - }, 90); + test('should clear timeout when `func` is called', function() { + var counter = 0, + oldDate = Date, + throttled = _.throttle(function() { counter++; }, 32); - setTimeout(function() { - ok(counter > 1); - QUnit.start(); - }, 180); + throttled(); + throttled(); + window.Date = function() { return Object(Infinity); }; throttled(); - }); + window.Date = oldDate; - asyncTest('should clear timeout when `func` is called', function() { - var now = new Date, - times = []; + equal(counter, 2); + }); + asyncTest('supports recursive calls', function() { + var counter = 0; var throttled = _.throttle(function() { - times.push(new Date - now); + counter++; + if (counter < 10) { + throttled(); + } }, 32); - setTimeout(throttled, 32); - setTimeout(throttled, 32); - setTimeout(throttled, 64); - setTimeout(throttled, 64); + throttled(); + equal(counter, 1); setTimeout(function() { - var actual = _.every(times, function(value, index) { - return index - ? (value - times[index - 1]) > 2 - : true; - }); - - ok(actual); + ok(counter < 3) QUnit.start(); - }, 260); + }, 32); }); asyncTest('should not trigger a trailing call when invoked once', function() { @@ -1837,12 +1828,11 @@ setTimeout(function() { equal(counter, 1); QUnit.start(); - }, 64); + }, 96); }); asyncTest('should trigger trailing call when invoked repeatedly', function() { - var actual, - counter = 0, + var counter = 0, limit = 80, throttled = _.throttle(function() { counter++; }, 32), start = new Date; @@ -1850,18 +1840,13 @@ while ((new Date - start) < limit) { throttled(); } - setTimeout(function() { - actual = counter + 2; - throttled(); - throttled(); - }, 128); + var lastCount = counter; + ok(lastCount > 1); setTimeout(function() { - equal(counter, actual); + ok(counter > lastCount); QUnit.start(); - }, 256); - - ok(counter > 1); + }, 96); }); }()); From 408a5c168f5222602d51e1499337744d4546ae33 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 23 Dec 2012 16:49:00 -0600 Subject: [PATCH 029/176] Optimize `_.max` and `_.min` for gzip. Former-commit-id: e4d6eb949824718aa967208203b7c487df7e02f5 --- doc/README.md | 110 +++++++++++++++++++-------------------- lodash.js | 40 +++++++------- lodash.min.js | 4 +- lodash.underscore.js | 40 +++++++------- lodash.underscore.min.js | 12 ++--- 5 files changed, 107 insertions(+), 99 deletions(-) diff --git a/doc/README.md b/doc/README.md index 8cf29490c0..977a4adf9f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2798 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2833 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2860 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2898 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2902 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2937 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2957 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2961 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3010 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3014 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3041 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3071 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3155 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3199 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3227 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3231 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3324 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3355 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4219 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4223 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4236 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4240 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4253 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4257 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1131,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2395 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2446 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2508 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2512 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1249,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2550 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2571 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2603 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2674 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2707 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3388 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3421 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3493 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3497 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3520 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3617 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3597 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3641 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3668 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3703 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3725 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3774 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3778 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3820 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3846 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3872 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3891 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3895 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3933 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4018 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4149 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4175 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4195 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4418 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4422 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 433b31610a..ec351da4e2 100644 --- a/lodash.js +++ b/lodash.js @@ -2346,11 +2346,19 @@ */ function max(collection, callback, thisArg) { var computed = -Infinity, - index = -1, - length = collection ? collection.length : 0, result = computed; - if (callback || !isArray(collection)) { + if (!callback && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value > result) { + result = value; + } + } + } else { callback = !callback && isString(collection) ? charAtCallback : createCallback(callback, thisArg); @@ -2362,12 +2370,6 @@ result = value; } }); - } else { - while (++index < length) { - if (collection[index] > result) { - result = collection[index]; - } - } } return result; } @@ -2392,11 +2394,19 @@ */ function min(collection, callback, thisArg) { var computed = Infinity, - index = -1, - length = collection ? collection.length : 0, result = computed; - if (callback || !isArray(collection)) { + if (!callback && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value < result) { + result = value; + } + } + } else { callback = !callback && isString(collection) ? charAtCallback : createCallback(callback, thisArg); @@ -2408,12 +2418,6 @@ result = value; } }); - } else { - while (++index < length) { - if (collection[index] < result) { - result = collection[index]; - } - } } return result; } diff --git a/lodash.min.js b/lodash.min.js index 81f7ea1061..fb8ebfbe01 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -13,7 +13,7 @@ if(u==Mt&&(u=Lt),o==Mt&&(o=Lt),u!=o)return X;switch(u){case zt:case Ct:return+n= if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return sr(n,function(n,u,o){return Et.call(o,u)?(f++,a=Et.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&sr(t,function(n,t,r){return Et.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?or[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==ot&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)vr(e[u],function(t,r){var e,u,o; if(t&&((u=_r(t))||dr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?_r(o)?o:[]:dr(o)?o:{})),n[r]=E(o,t,ot,i,a))}else t!=W&&(n[r]=t)});return n}function S(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:lr(n,function(n){return r>++e?void 0:!(o=n===t)}),o}function $(n,t,r){var e=Q,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else lr(n,function(n,r,u){return e=!!t(n,r,u) });return e}function q(n,t,r){var e=[],t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else lr(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,X):void 0}),e}function R(n,t,r){if(t&&r===void 0&&_r(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==X;);else lr(n,t,r);return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(_r(n))for(;u>++e;)o[e]=t(n[e],e,n); -else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=-1,i=n?n.length:0,f=e;if(t||!_r(n))t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,f=n)});else for(;i>++o;)n[o]>f&&(f=n[o]);return f}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; +else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else lr(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return t==W||r?n[0]:v(n,0,Tt(It(0,t),e))}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];_r(o)?St.apply(u,t?o:z(o)):u.push(o)}return u }function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,t==W||r?1:It(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=X);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e; if(c)var s=p+"",s=Et.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&arguments.length>2?qt.call.apply(qt,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return St.apply(n,arguments),n=e.apply(r,n),new r(n)}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global; @@ -25,7 +25,7 @@ r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpo return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),Et.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=W,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=mr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) },r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=sr,r.forOwn=vr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),(Et.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Tt(It(0,e-(t==W||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=Et.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=typeof t=="function",u=[];return R(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments) -}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=-1,i=n?n.length:0,f=e;if(t||!_r(n))t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,f=n)});else for(;i>++o;)f>n[o]&&(f=n[o]);return f},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=X; +}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=X; return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=xt.apply(rt,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),sr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,t==W&&(t=n,n=0);for(var e=-1,t=It(0,jt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r; return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return R(n,function(n){var e=Ot(Bt()*(++t+1));r[t]=r[e],r[e]=n}),r},r.sortBy=function(n,t,r){var e=[],t=a(t,r);for(R(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(o);n--;)e[n]=e[n].c;return e},r.tap=function(n,t){return t(n),n},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a); return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=W,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return typeof(n?n.length:0)=="number"?nr&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(xt.apply(rt,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=gr(t);return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t]; diff --git a/lodash.underscore.js b/lodash.underscore.js index a07274287d..e8d3fbec00 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1888,11 +1888,19 @@ */ function max(collection, callback, thisArg) { var computed = -Infinity, - index = -1, - length = collection ? collection.length : 0, result = computed; - if (callback || !isArray(collection)) { + if (!callback && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value > result) { + result = value; + } + } + } else { callback = createCallback(callback, thisArg); each(collection, function(value, index, collection) { @@ -1902,12 +1910,6 @@ result = value; } }); - } else { - while (++index < length) { - if (collection[index] > result) { - result = collection[index]; - } - } } return result; } @@ -1932,11 +1934,19 @@ */ function min(collection, callback, thisArg) { var computed = Infinity, - index = -1, - length = collection ? collection.length : 0, result = computed; - if (callback || !isArray(collection)) { + if (!callback && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value < result) { + result = value; + } + } + } else { callback = createCallback(callback, thisArg); each(collection, function(value, index, collection) { @@ -1946,12 +1956,6 @@ result = value; } }); - } else { - while (++index < length) { - if (collection[index] < result) { - result = collection[index]; - } - } } return result; } diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 1caaefa1d5..93338db71a 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -10,16 +10,16 @@ if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1}return e>r?-1: return e(n,function(n,r){b(n)&&t.push(r)}),t.sort()}function y(n){for(var t=-1,r=Rt(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function d(n,t,r,u){if(n===t)return 0!==n||1/n==1/t;if(n==J||t==J)return n===t;var o=lt.call(n),i=lt.call(t);if(o!=i)return K;switch(o){case bt:case jt:return+n==+t;case wt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case At:case Et:return n==t+""}if(i=o==dt,!i){if(n.__wrapped__||t.__wrapped__)return d(n.__wrapped__||n,t.__wrapped__||t);if(o!=xt)return K;var o=n.constructor,a=t.constructor; if(!(o==a||b(o)&&o instanceof o&&b(a)&&a instanceof a))return K}for(r||(r=[]),u||(u=[]),o=r.length;o--;)if(r[o]==n)return u[o]==t;var f=H,c=0;if(r.push(n),u.push(t),i){if(c=n.length,f=c==t.length)for(;c--&&(f=d(n[c],t[c],r,u)););return f}return e(n,function(n,e,o){return ft.call(o,e)?(c++,!(f=ft.call(t,e)&&d(n,t[e],r,u))&&Y):void 0}),f&&e(t,function(n,t,r){return ft.call(r,t)?!(f=--c>-1)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?Nt[typeof n]:K}function w(n){return typeof n=="number"||lt.call(n)==wt }function x(n){return typeof n=="string"||lt.call(n)==Et}function A(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function E(n,t){var r=K;return typeof(n?n.length:0)=="number"?r=I(n,t)>-1:u(n,function(n){return(r=n===t)&&Y}),r}function O(n,t,r){var e=H,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r&&(e=!!t(n[r],r,n)););else u(n,function(n,r,u){return!(e=!!t(n,r,u))&&Y});return e}function S(n,t,r){var e=[],t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r;){var i=n[r];t(i,r,n)&&e.push(i) -}else u(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function k(n,t,r){var e,t=f(t,r);return N(n,function(n,r,u){return t(n,r,u)?(e=n,Y):void 0}),e}function N(n,t,r){if(t&&r===void 0&&Bt(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==Y;);else u(n,t,r)}function F(n,t,r){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),t=f(t,r);if(Bt(n))for(;o>++e;)i[e]=t(n[e],e,n);else u(n,function(n,r,u){i[++e]=t(n,r,u)});return i}function R(n,t,r){var e=-1/0,o=-1,i=n?n.length:0,a=e;if(t||!Bt(n))t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,a=n) -});else for(;i>++o;)n[o]>a&&(a=n[o]);return a}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);a>++i;)r=t(r,n[i],i,n)}else u(n,function(n,e,u){r=o?(o=K,n):t(r,n,e,u)});return r}function B(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r&&!(e=t(n[r],r,n)););else u(n,function(n,r,u){return(e=t(n,r,u))&&Y -});return!!e}function M(n,t,r){if(n){var e=n.length;return t==J||r?n[0]:p(n,0,mt(_t(0,t),e))}}function $(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];Bt(o)?ct.apply(u,t?o:$(o)):u.push(o)}return u}function I(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?_t(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function z(n,t,r){return p(n,t==J||r?1:_t(0,t))}function C(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?f(r,e):V,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e; -return u}function P(n,t,r,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof t=="function"&&(e=r,r=t,t=K),r&&(a=[],r=f(r,e));o>++u;){var e=n[u],c=r?r(e,u,n):e;(t?!u||a[a.length-1]!==c:0>I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&arguments.length>2?st.call.apply(st,arguments):a(n,t,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__];return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n -}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,_t=Math.max,mt=Math.min,yt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",xt="[object Object]",At="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +}else u(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function k(n,t,r){var e,t=f(t,r);return N(n,function(n,r,u){return t(n,r,u)?(e=n,Y):void 0}),e}function N(n,t,r){if(t&&r===void 0&&Bt(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==Y;);else u(n,t,r)}function F(n,t,r){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),t=f(t,r);if(Bt(n))for(;o>++e;)i[e]=t(n[e],e,n);else u(n,function(n,r,u){i[++e]=t(n,r,u)});return i}function R(n,t,r){var e=-1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;i>++r;){var a=n[r]; +a>o&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);a>++i;)r=t(r,n[i],i,n)}else u(n,function(n,e,u){r=o?(o=K,n):t(r,n,e,u)});return r}function B(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r); +if(Bt(n))for(var r=-1,o=n.length;o>++r&&!(e=t(n[r],r,n)););else u(n,function(n,r,u){return(e=t(n,r,u))&&Y});return!!e}function M(n,t,r){if(n){var e=n.length;return t==J||r?n[0]:p(n,0,mt(_t(0,t),e))}}function $(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];Bt(o)?ct.apply(u,t?o:$(o)):u.push(o)}return u}function I(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?_t(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function z(n,t,r){return p(n,t==J||r?1:_t(0,t)) +}function C(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?f(r,e):V,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function P(n,t,r,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof t=="function"&&(e=r,r=t,t=K),r&&(a=[],r=f(r,e));o>++u;){var e=n[u],c=r?r(e,u,n):e;(t?!u||a[a.length-1]!==c:0>I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&arguments.length>2?st.call.apply(st,arguments):a(n,t,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__]; +return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,_t=Math.max,mt=Math.min,yt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",xt="[object Object]",At="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=y(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) }),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=m(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=U(n[u],n)}return n},o.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},o.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];return t[0]}},o.countBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),ft.call(e,r)?e[r]++:e[r]=1 }),e},o.debounce=function(n,t,r){function e(){a=J,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},o.defaults=_,o.defer=function(n){var r=p(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},o.delay=function(n,r){var e=p(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},o.difference=function(n){for(var t=-1,r=n.length,e=it.apply(W,arguments),u=[];r>++t;){var o=n[t];0>I(e,o,r)&&u.push(o) }return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=m,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,mt(_t(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;u>++e;){var i=n[e];if(0>I(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=y,o.invoke=function(n,t){var r=p(arguments,2),e=typeof t=="function",u=[]; -return N(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=-1,i=n?n.length:0,a=e;if(t||!Bt(n))t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,a=n)});else for(;i>++o;)a>n[o]&&(a=n[o]);return a},o.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1] +return N(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;i>++r;){var a=n[r];o>a&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},o.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1] }return u},o.omit=function(n){var t=it.apply(W,arguments),r={};return e(n,function(n,e){0>I(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},o.pick=function(n){for(var t=0,r=it.apply(W,arguments),e=r.length,u={};e>++t;){var o=r[t];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,t,r){n=+n||0,r=+r||1,t==J&&(t=n,n=0); for(var e=-1,t=_t(0,ot((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},o.reject=function(n,t,r){return t=f(t,r),S(n,function(n,r,e){return!t(n,r,e)})},o.rest=z,o.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return N(n,function(n){var e=at(yt()*(++t+1));r[t]=r[e],r[e]=n}),r},o.sortBy=function(n,t,r){var e=[],t=f(t,r);for(N(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(i);n--;)e[n]=e[n].c;return e},o.tap=function(n,t){return t(n),n},o.throttle=function(n,t){function r(){a=new Date,i=J,u=n.apply(o,e) }var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},o.toArray=function(n){return typeof(n?n.length:0)=="number"?p(n):A(n)},o.union=function(){return P(it.apply(W,arguments))},o.uniq=P,o.values=A,o.where=function(n,t){var r=Rt(t);return S(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break From ef7cb26b0122b09bb670561711c1ae83e38fd240 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 24 Dec 2012 02:19:42 -0600 Subject: [PATCH 030/176] Update vendor/underscore and continue to tweak `_.throttle` unit tests to avoid false fails. Former-commit-id: b5ba7b53e3bbebb3fa42da7e197f746515c8efb0 --- test/test.js | 2 +- vendor/underscore/test/functions.js | 118 +++++++++++----------------- vendor/underscore/underscore-min.js | 2 +- vendor/underscore/underscore.js | 16 ++-- 4 files changed, 59 insertions(+), 79 deletions(-) diff --git a/test/test.js b/test/test.js index 4cf17f350f..06972c0af6 100644 --- a/test/test.js +++ b/test/test.js @@ -1833,7 +1833,7 @@ asyncTest('should trigger trailing call when invoked repeatedly', function() { var counter = 0, - limit = 80, + limit = 48, throttled = _.throttle(function() { counter++; }, 32), start = new Date; diff --git a/vendor/underscore/test/functions.js b/vendor/underscore/test/functions.js index de141729c3..2641dfbd28 100644 --- a/vendor/underscore/test/functions.js +++ b/vendor/underscore/test/functions.js @@ -95,80 +95,67 @@ $(document).ready(function() { asyncTest("throttle", 2, function() { var counter = 0; var incr = function(){ counter++; }; - var throttledIncr = _.throttle(incr, 100); - throttledIncr(); throttledIncr(); throttledIncr(); - setTimeout(throttledIncr, 70); - setTimeout(throttledIncr, 120); - setTimeout(throttledIncr, 140); - setTimeout(throttledIncr, 190); - setTimeout(throttledIncr, 220); - setTimeout(throttledIncr, 240); - _.delay(function(){ equal(counter, 1, "incr was called immediately"); }, 30); - _.delay(function(){ equal(counter, 4, "incr was throttled"); start(); }, 400); + var throttledIncr = _.throttle(incr, 32); + throttledIncr(); throttledIncr(); + + equal(counter, 1, "incr was called immediately"); + _.delay(function(){ equal(counter, 2, "incr was throttled"); start(); }, 64); }); asyncTest("throttle arguments", 2, function() { var value = 0; var update = function(val){ value = val; }; - var throttledUpdate = _.throttle(update, 100); - throttledUpdate(1); throttledUpdate(2); throttledUpdate(3); - setTimeout(function(){ throttledUpdate(4); }, 120); - setTimeout(function(){ throttledUpdate(5); }, 140); - setTimeout(function(){ throttledUpdate(6); }, 250); - _.delay(function(){ equal(value, 1, "updated to latest value"); }, 40); - _.delay(function(){ equal(value, 6, "updated to latest value"); start(); }, 400); + var throttledUpdate = _.throttle(update, 32); + throttledUpdate(1); throttledUpdate(2); + _.delay(function(){ throttledUpdate(3); }, 64); + equal(value, 1, "updated to latest value"); + _.delay(function(){ equal(value, 3, "updated to latest value"); start(); }, 96); }); asyncTest("throttle once", 2, function() { var counter = 0; var incr = function(){ return ++counter; }; - var throttledIncr = _.throttle(incr, 100); + var throttledIncr = _.throttle(incr, 32); var result = throttledIncr(); _.delay(function(){ equal(result, 1, "throttled functions return their value"); equal(counter, 1, "incr was called once"); start(); - }, 220); + }, 64); }); asyncTest("throttle twice", 1, function() { var counter = 0; var incr = function(){ counter++; }; - var throttledIncr = _.throttle(incr, 100); + var throttledIncr = _.throttle(incr, 32); throttledIncr(); throttledIncr(); - _.delay(function(){ equal(counter, 2, "incr was called twice"); start(); }, 220); + _.delay(function(){ equal(counter, 2, "incr was called twice"); start(); }, 64); }); - asyncTest("throttle repeatedly with results", 9, function() { + asyncTest("throttle repeatedly with results", 6, function() { var counter = 0; var incr = function(){ return ++counter; }; - var throttledIncr = _.throttle(incr, 100); + var throttledIncr = _.throttle(incr, 64); var results = []; var saveResult = function() { results.push(throttledIncr()); }; - saveResult(); saveResult(); saveResult(); - setTimeout(saveResult, 70); - setTimeout(saveResult, 120); - setTimeout(saveResult, 140); - setTimeout(saveResult, 190); - setTimeout(saveResult, 240); - setTimeout(saveResult, 260); + saveResult(); saveResult(); + _.delay(saveResult, 32); + _.delay(saveResult, 80); + _.delay(saveResult, 96); + _.delay(saveResult, 144); _.delay(function() { equal(results[0], 1, "incr was called once"); equal(results[1], 1, "incr was throttled"); equal(results[2], 1, "incr was throttled"); - equal(results[3], 1, "incr was throttled"); - equal(results[4], 2, "incr was called twice"); - equal(results[5], 2, "incr was throttled"); - equal(results[6], 2, "incr was throttled"); - equal(results[7], 3, "incr was called thrice"); - equal(results[8], 3, "incr was throttled"); + equal(results[3], 2, "incr was called twice"); + equal(results[4], 2, "incr was throttled"); + equal(results[5], 3, "incr was called trailing"); start(); - }, 400); + }, 192); }); - asyncTest("throttle triggers trailing call after repeatedly invoked", 2, function() { - var actual; + asyncTest("throttle triggers trailing call when invoked repeatedly", 2, function() { var counter = 0; - var limit = 80; + var limit = 48; var incr = function(){ counter++; }; var throttledIncr = _.throttle(incr, 32); @@ -176,62 +163,49 @@ $(document).ready(function() { while ((new Date - stamp) < limit) { throttledIncr(); } - _.delay(function() { - actual = counter + 2; - throttledIncr(); - throttledIncr(); - }, 64); + var lastCount = counter; + ok(counter > 1); _.delay(function() { - equal(counter, actual); + ok(counter > lastCount); start(); - }, 128); - - ok(counter > 1); + }, 96); }); asyncTest("debounce", 1, function() { var counter = 0; var incr = function(){ counter++; }; - var debouncedIncr = _.debounce(incr, 50); - debouncedIncr(); debouncedIncr(); debouncedIncr(); - setTimeout(debouncedIncr, 30); - setTimeout(debouncedIncr, 60); - setTimeout(debouncedIncr, 90); - setTimeout(debouncedIncr, 120); - setTimeout(debouncedIncr, 150); - _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 220); + var debouncedIncr = _.debounce(incr, 32); + debouncedIncr(); debouncedIncr(); + _.delay(debouncedIncr, 16); + _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 96); }); - asyncTest("debounce asap", 5, function() { - var a, b, c; + asyncTest("debounce asap", 4, function() { + var a, b; var counter = 0; var incr = function(){ return ++counter; }; - var debouncedIncr = _.debounce(incr, 50, true); + var debouncedIncr = _.debounce(incr, 64, true); a = debouncedIncr(); b = debouncedIncr(); - c = debouncedIncr(); equal(a, 1); equal(b, 1); - equal(c, 1); equal(counter, 1, 'incr was called immediately'); - setTimeout(debouncedIncr, 30); - setTimeout(debouncedIncr, 60); - setTimeout(debouncedIncr, 90); - setTimeout(debouncedIncr, 120); - setTimeout(debouncedIncr, 150); - _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 220); + _.delay(debouncedIncr, 16); + _.delay(debouncedIncr, 32); + _.delay(debouncedIncr, 48); + _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 128); }); asyncTest("debounce asap recursively", 2, function() { var counter = 0; var debouncedIncr = _.debounce(function(){ counter++; - if (counter < 5) debouncedIncr(); - }, 50, true); + if (counter < 10) debouncedIncr(); + }, 32, true); debouncedIncr(); - equal(counter, 1, 'incr was called immediately'); - _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 70); + equal(counter, 1, "incr was called immediately"); + _.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 96); }); test("once", function() { diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index 16a5f62c05..8676092016 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -2,4 +2,4 @@ // http://underscorejs.org // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFunction(/./)&&(w.isFunction=function(n){return"[object Function]"==l.call(n)}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index b943608c95..b2619be82d 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -938,8 +938,8 @@ return obj === Object(obj); }; - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + // Add some isType methods: isArguments, isString, isNumber, isDate, isRegExp. + each(['Arguments', 'String', 'Number', 'Date', 'RegExp'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) == '[object ' + name + ']'; }; @@ -953,10 +953,16 @@ }; } - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { + // Is a given variable a function? + _.isFunction = function(obj) { + return typeof obj === 'function'; + }; + + // Define a fallback for older versions of Chrome, Firefox, and Safari, where + // a regexp is `typeof` "function". + if (_.isFunction(/./)) { _.isFunction = function(obj) { - return typeof obj === 'function'; + return toString.call(obj) == '[object Function]'; }; } From e3b80a5e0972450544ae99590bed1291286001ac Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 25 Dec 2012 17:06:51 -0600 Subject: [PATCH 031/176] Simplify `_.toArray` and wrapper methods. Former-commit-id: b0440d401bd58cfa2d7aaf213549a824963474c3 --- build.js | 2 + doc/README.md | 90 ++++++++++++++++++++-------------------- lodash.js | 10 ++--- lodash.min.js | 68 +++++++++++++++--------------- lodash.underscore.js | 5 +-- lodash.underscore.min.js | 2 +- 6 files changed, 87 insertions(+), 90 deletions(-) diff --git a/build.js b/build.js index b9881c0b29..a9ae40f274 100755 --- a/build.js +++ b/build.js @@ -363,6 +363,8 @@ return match.replace(/^( *)return new lodash.+/m, function() { var indent = arguments[1]; return indent + [ + '', + 'var result = func.apply(lodash, args);', 'if (this.__chain__) {', ' result = new lodash(result);', ' result.__chain__ = true;', diff --git a/doc/README.md b/doc/README.md index 977a4adf9f..bc06ddef6f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2767 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2797 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2833 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2832 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2860 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2859 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2902 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2901 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2937 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2936 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3013 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3040 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3070 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3154 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3199 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3198 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3230 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3264 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3323 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3355 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3354 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4223 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4220 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4237 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4254 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2737 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3388 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3387 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3421 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3450 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3497 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3496 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3519 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3552 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3597 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3596 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3641 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3640 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3668 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3667 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3702 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3725 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3777 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3801 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3819 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3845 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3872 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3869 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3895 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3892 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3930 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4015 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4146 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4172 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4192 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4422 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4419 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index ec351da4e2..916c925e56 100644 --- a/lodash.js +++ b/lodash.js @@ -2705,8 +2705,7 @@ * // => [2, 3, 4] */ function toArray(collection) { - var length = collection ? collection.length : 0; - if (typeof length == 'number') { + if (collection && typeof collection.length == 'number') { return noCharByIndex && isString(collection) ? collection.split('') : slice(collection); @@ -3850,9 +3849,7 @@ lodash.prototype[methodName] = function() { var args = [this.__wrapped__]; push.apply(args, arguments); - - var result = func.apply(lodash, args); - return new lodash(result); + return new lodash(func.apply(lodash, args)); }; }); } @@ -4447,8 +4444,7 @@ each(['concat', 'slice', 'splice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - var result = func.apply(this.__wrapped__, arguments); - return new lodash(result); + return new lodash(func.apply(this.__wrapped__, arguments)); }; }); diff --git a/lodash.min.js b/lodash.min.js index fb8ebfbe01..59466280b8 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,37 +3,37 @@ * Lo-Dash 1.0.0-rc.3 lodash.com/license * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(Et.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return Et.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 -}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=W,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:nt,f:Qt,g:"",h:Xt,i:nr,j:wt,k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; -if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++ie;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function g(n){return yr[n]}function h(n){return $t.call(n)==Mt}function y(n){var t=X;if(!n||typeof n!="object"||h(n))return t; -var r=n.constructor;return!j(r)&&(!tr||!p(n))||r instanceof r?tt?(sr(n,function(n,r,e){return t=!Et.call(e,r),X}),t===X):(sr(n,function(n,r){t=r}),t===X||Et.call(n,t)):t}function m(n){var t=[];return vr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(n==W)return n;if(r&&(t=X),r=x(n)){var o=$t.call(n);if(!er[o]||tr&&p(n))return n;var i=_r(n)}if(!r||!t)return r?i?v(n):pr({},n):n;switch(r=ur[o],o){case zt:case Ct:return new r(+n);case Kt:case Vt:return new r(n);case Ut:return r(n.source,vt.exec(n)) -}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:vr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(Et.call(n,"index")&&(a.index=n.index),Et.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return sr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=gr(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(n==W||t==W)return n===t;var u=$t.call(n),o=$t.call(t); -if(u==Mt&&(u=Lt),o==Mt&&(o=Lt),u!=o)return X;switch(u){case zt:case Ct:return+n==+t;case Kt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ut:case Vt:return n==t+""}if(o=u==Pt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=Lt||tr&&(p(n)||p(t)))return X;var u=!Yt&&h(n)?Object:n.constructor,i=!Yt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return X}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=Q,f=0; -if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return sr(n,function(n,u,o){return Et.call(o,u)?(f++,a=Et.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&sr(t,function(n,t,r){return Et.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?or[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==ot&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)vr(e[u],function(t,r){var e,u,o; -if(t&&((u=_r(t))||dr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?_r(o)?o:[]:dr(o)?o:{})),n[r]=E(o,t,ot,i,a))}else t!=W&&(n[r]=t)});return n}function S(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:lr(n,function(n){return r>++e?void 0:!(o=n===t)}),o}function $(n,t,r){var e=Q,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else lr(n,function(n,r,u){return e=!!t(n,r,u) -});return e}function q(n,t,r){var e=[],t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else lr(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,X):void 0}),e}function R(n,t,r){if(t&&r===void 0&&_r(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==X;);else lr(n,t,r);return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(_r(n))for(;u>++e;)o[e]=t(n[e],e,n); -else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; -if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else lr(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return t==W||r?n[0]:v(n,0,Tt(It(0,t),e))}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];_r(o)?St.apply(u,t?o:z(o)):u.push(o)}return u -}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,t==W||r?1:It(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=X);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e; -if(c)var s=p+"",s=Et.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&arguments.length>2?qt.call.apply(qt,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return St.apply(n,arguments),n=e.apply(r,n),new r(n)}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global; -Z.global===Z&&(n=Z);var nt,tt,rt=[],et=new function(){},ut=0,ot=et,it=30,at=n._,ft=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:""};var ar={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; -return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),Et.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=W,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=mr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) -},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=sr,r.forOwn=vr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),(Et.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Tt(It(0,e-(t==W||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; -n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=Et.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=typeof t=="function",u=[];return R(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments) -}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=X; -return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=xt.apply(rt,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),sr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,t==W&&(t=n,n=0);for(var e=-1,t=It(0,jt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r; -return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return R(n,function(n){var e=Ot(Bt()*(++t+1));r[t]=r[e],r[e]=n}),r},r.sortBy=function(n,t,r){var e=[],t=a(t,r);for(R(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(o);n--;)e[n]=e[n].c;return e},r.tap=function(n,t){return t(n),n},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a); -return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=W,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return typeof(n?n.length:0)=="number"?nr&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(xt.apply(rt,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=gr(t);return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t]; -u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return St.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=pr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,Q)},r.contains=k,r.escape=function(n){return n==W?"":(n+"").replace(dt,l)},r.every=$,r.find=N,r.has=function(n,t){return n?Et.call(n,t):X -},r.identity=G,r.indexOf=C,r.isArguments=h,r.isArray=_r,r.isBoolean=function(n){return n===Q||n===X||$t.call(n)==zt},r.isDate=function(n){return n instanceof Date||$t.call(n)==Ct},r.isElement=function(n){return n?1===n.nodeType:X},r.isEmpty=function(n){var t=Q;if(!n)return t;var r=$t.call(n),e=n.length;return r==Pt||r==Vt||r==Mt||Zt&&h(n)||r==Lt&&typeof e=="number"&&j(n.splice)?!e:(vr(n,function(){return t=X}),t)},r.isEqual=w,r.isFinite=function(n){return Rt(n)&&!Ft(parseFloat(n))},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n -},r.isNull=function(n){return n===W},r.isNumber=O,r.isObject=x,r.isPlainObject=dr,r.isRegExp=function(n){return n instanceof RegExp||$t.call(n)==Ut},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W; -return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t -}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) -},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" -},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return new r(n)}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n; -r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file +;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||et);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(xt.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return xt.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 +}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=null,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:X,f:Gt,g:"",h:Jt,i:Xt,j:_t,k:"",l:!0},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; +if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r=Function,e="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(e+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(e+="if(k(l)){l=l.split('')}"),e+="while(++iu;u++)e+="i='"+t.j[u]+"';if(","constructor"==t.j[u]&&(e+="!(f&&f.prototype===l)&&"),e+="h.call(l,i)){"+t.g+"}"}return(t.b||t.h)&&(e+="}"),e+=t.c+";return t",r("e,h,j,k,p,n,s","return function("+n+"){"+e+"}")(a,xt,h,A,rr,Nt,At)}function c(n){return"\\"+er[n]}function l(n){return sr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e]; +return u}function g(n){return vr[n]}function h(n){return Et.call(n)==It}function y(n){var t=!1;if(!n||typeof n!="object"||h(n))return t;var r=n.constructor;return!j(r)&&(!Yt||!p(n))||r instanceof r?Y?(cr(n,function(n,r,e){return t=!xt.call(e,r),!1}),!1===t):(cr(n,function(n,r){t=r}),!1===t||xt.call(n,t)):t}function m(n){var t=[];return lr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(null==n)return n;if(r&&(t=!1),r=x(n)){var o=Et.call(n);if(!nr[o]||Yt&&p(n))return n;var i=hr(n)}if(!r||!t)return r?i?v(n):fr({},n):n; +switch(r=tr[o],o){case Bt:case Mt:return new r(+n);case Pt:case Kt:return new r(n);case Ct:return r(n.source,lt.exec(n))}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:lr)(n,function(n,r){a[r]=_(n,t,null,e,u)}),i&&(xt.call(n,"index")&&(a.index=n.index),xt.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return cr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=pr(n),e=r.length,u={};e>++t;){var o=r[t]; +u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;var u=Et.call(n),o=Et.call(t);if(u==It&&(u=zt),o==It&&(o=zt),u!=o)return!1;switch(u){case Bt:case Mt:return+n==+t;case Pt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ct:case Kt:return n==t+""}if(o=u==Tt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=zt||Yt&&(p(n)||p(t)))return!1;var u=!Qt&&h(n)?Object:n.constructor,i=!Qt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return!1 +}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=!0,f=0;if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return cr(n,function(n,u,o){return xt.call(o,u)?(f++,a=xt.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&cr(t,function(n,t,r){return xt.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?rr[typeof n]:!1}function O(n){return typeof n=="number"||Et.call(n)==Pt}function A(n){return typeof n=="string"||Et.call(n)==Kt +}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==rt&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)lr(e[u],function(t,r){var e,u,o;if(t&&((u=hr(t))||yr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?hr(o)?o:[]:yr(o)?o:{})),n[r]=E(o,t,rt,i,a))}else null!=t&&(n[r]=t)});return n}function S(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=!1,r=(0>r?Rt(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:ar(n,function(n){return r>++e?void 0:!(o=n===t) +}),o}function $(n,t,r){var e=!0,t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else ar(n,function(n,r,u){return e=!!t(n,r,u)});return e}function q(n,t,r){var e=[],t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else ar(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,!1):void 0}),e}function R(n,t,r){if(t&&r===void 0&&hr(n))for(var r=-1,e=n.length;e>++r&&!1!==t(n[r],r,n););else ar(n,t,r); +return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(hr(n))for(;u>++e;)o[e]=t(n[e],e,n);else ar(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&hr(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),ar(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,rt);if(hr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n) +}else ar(n,function(n,e,o){r=u?(u=!1,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length;if(typeof o!="number")var f=pr(n),o=f.length;else Xt&&A(n)&&(u=n.split(""));return t=a(t,e,rt),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else ar(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return null==t||r?n[0]:v(n,0,Ft(Rt(0,t),e)) +}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];hr(o)?Ot.apply(u,t?o:z(o)):u.push(o)}return u}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?Rt(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,null==t||r?1:Rt(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i; +typeof t=="function"&&(e=r,r=t,t=!1);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e;if(c)var s=p+"",s=xt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Vt||St&&arguments.length>2?St.call.apply(St,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return Ot.apply(n,arguments),new r(e.apply(r,n)) +}})}function J(){return this.__wrapped__}var Q=typeof exports=="object"&&exports,W=typeof global=="object"&&global;W.global===W&&(n=W);var X,Y,Z=[],nt=new function(){},tt=0,rt=nt,et=30,ut=n._,ot=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/\w*$/,pt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,st=RegExp("^"+(nt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),vt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,gt=/<%=([\s\S]+?)%>/g,ht=/($^)/,yt=/[&<>"']/g,mt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),dt=Math.ceil,bt=Z.concat,wt=Math.floor,jt=st.test(jt=Object.getPrototypeOf)&&jt,xt=nt.hasOwnProperty,Ot=Z.push,At=nt.propertyIsEnumerable,Et=nt.toString,St=st.test(St=v.bind)&&St,kt=st.test(kt=Array.isArray)&&kt,$t=n.isFinite,qt=n.isNaN,Nt=st.test(Nt=Object.keys)&&Nt,Rt=Math.max,Ft=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=St&&!/\n|true/.test(St+Lt),Vt=St&&!Ut,Gt=Nt&&(Lt||Ut),Ht=(Ht={0:1,length:1},Z.splice.call(Ht,0,1),Ht[0]),Jt=!0; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;X=!/valueOf/.test(t),Y="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!h(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=Et.call(document)==zt}catch(Zt){}var nr={"[object Function]":!1};nr[It]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=!0;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String;var rr={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:gt,variable:""};var ur={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vr=b(sr),gr=f(ur,{g:"if(t[i]==null)"+ur.g}),hr=kt||function(n){return Qt&&n instanceof Array||Et.call(n)==Tt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==Et.call(n)});var yr=jt?function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,r=typeof t=="function"&&(r=jt(t))&&jt(r);return r?n==r||jt(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=fr,r.at=function(n){var t=-1,r=bt.apply(Z,v(arguments,1)),e=r.length,u=Array(e);for(Xt&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; +return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),xt.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=null,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=gr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) +},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=bt.apply(Z,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=cr,r.forOwn=lr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),(xt.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Ft(Rt(0,e-(null==t||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; +n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=xt.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=typeof t=="function",u=[];return R(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},r.keys=pr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return xt.call(r,e)?r[e]:r[e]=n.apply(this,arguments) +}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&hr(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),ar(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=bt.apply(Z,arguments);return cr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=!1; +return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=bt.apply(Z,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),cr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,null==t&&(t=n,n=0); +for(var e=-1,t=Rt(0,dt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return R(n,function(n){var e=wt(Dt()*(++t+1));r[t]=r[e],r[e]=n}),r},r.sortBy=function(n,t,r){var e=[],t=a(t,r);for(R(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(o);n--;)e[n]=e[n].c;return e},r.tap=function(n,t){return t(n),n},r.throttle=function(n,t){function r(){a=new Date,i=null,u=n.apply(o,e) +}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=null,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return n&&typeof n.length=="number"?Xt&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(bt.apply(Z,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=pr(t);return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]]; +if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return Ot.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=fr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,!0)},r.contains=k,r.escape=function(n){return null==n?"":(n+"").replace(yt,l) +},r.every=$,r.find=N,r.has=function(n,t){return n?xt.call(n,t):!1},r.identity=G,r.indexOf=C,r.isArguments=h,r.isArray=hr,r.isBoolean=function(n){return!0===n||!1===n||Et.call(n)==Bt},r.isDate=function(n){return n instanceof Date||Et.call(n)==Mt},r.isElement=function(n){return n?1===n.nodeType:!1},r.isEmpty=function(n){var t=!0;if(!n)return t;var r=Et.call(n),e=n.length;return r==Tt||r==Kt||r==It||Wt&&h(n)||r==zt&&typeof e=="number"&&j(n.splice)?!e:(lr(n,function(){return t=!1}),t)},r.isEqual=w,r.isFinite=function(n){return $t(n)&&!qt(parseFloat(n)) +},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n},r.isNull=function(n){return null===n},r.isNumber=O,r.isObject=x,r.isPlainObject=yr,r.isRegExp=function(n){return n instanceof RegExp||Et.call(n)==Ct},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?Rt(0,e+r):Ft(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=ut,this},r.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+wt(Dt()*((+t||0)-n+1)) +},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:null;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||ht,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||ht).source+"|"+f.source+"|"+(f===gt?vt:ht).source+"|"+(e.evaluate||i.evaluate||ht).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(mt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ot.test(r||e)),a=f+t.length,t +}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(pt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(at,""):l).replace(ft,"$1").replace(ct,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return null==n?"":(n+"").replace(it,g) +},r.uniqueId=function(n){var t=++tt;return(null==n?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,lr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Ot.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return null==t||r?n[e-1]:v(n,Rt(0,e-t))}},r.take=P,r.head=P,lr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return null==t||e?u:new r(u) +})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,ar(["join","pop","shift"],function(n){var t=Z[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ar(["push","reverse","sort","unshift"],function(n){var t=Z[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ar(["concat","slice","splice"],function(n){var t=Z[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) +}}),Ht&&ar(["pop","shift","splice"],function(n){var t=Z[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Q?typeof module=="object"&&module&&module.exports==Q?(module.exports=r)._=r:Q._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index e8d3fbec00..ad77ca21ad 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -2241,8 +2241,7 @@ * // => [2, 3, 4] */ function toArray(collection) { - var length = collection ? collection.length : 0; - if (typeof length == 'number') { + if (collection && typeof collection.length == 'number') { return slice(collection); } return values(collection); @@ -3298,7 +3297,7 @@ lodash.prototype[methodName] = function() { var args = [this.__wrapped__]; push.apply(args, arguments); - + var result = func.apply(lodash, args); if (this.__chain__) { result = new lodash(result); diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 93338db71a..cbe0b9c909 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -22,7 +22,7 @@ o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpo return N(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;i>++r;){var a=n[r];o>a&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},o.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1] }return u},o.omit=function(n){var t=it.apply(W,arguments),r={};return e(n,function(n,e){0>I(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},o.pick=function(n){for(var t=0,r=it.apply(W,arguments),e=r.length,u={};e>++t;){var o=r[t];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,t,r){n=+n||0,r=+r||1,t==J&&(t=n,n=0); for(var e=-1,t=_t(0,ot((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},o.reject=function(n,t,r){return t=f(t,r),S(n,function(n,r,e){return!t(n,r,e)})},o.rest=z,o.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return N(n,function(n){var e=at(yt()*(++t+1));r[t]=r[e],r[e]=n}),r},o.sortBy=function(n,t,r){var e=[],t=f(t,r);for(N(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(i);n--;)e[n]=e[n].c;return e},o.tap=function(n,t){return t(n),n},o.throttle=function(n,t){function r(){a=new Date,i=J,u=n.apply(o,e) -}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},o.toArray=function(n){return typeof(n?n.length:0)=="number"?p(n):A(n)},o.union=function(){return P(it.apply(W,arguments))},o.uniq=P,o.values=A,o.where=function(n,t){var r=Rt(t);return S(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break +}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},o.toArray=function(n){return n&&typeof n.length=="number"?p(n):A(n)},o.union=function(){return P(it.apply(W,arguments))},o.uniq=P,o.values=A,o.where=function(n,t){var r=Rt(t);return S(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break }return!!u})},o.without=function(n){for(var t=-1,r=n.length,e=[];r>++t;){var u=n[t];0>I(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);r>++t;)e[t]=T(arguments,t);return e},o.collect=F,o.drop=z,o.each=N,o.extend=g,o.methods=m,o.select=S,o.tail=z,o.unique=P,o.clone=function(n){return n&&Nt[typeof n]?Bt(n)?p(n):g({},n):n},o.contains=E,o.escape=function(n){return n==J?"":(n+"").replace(et,l) },o.every=O,o.find=k,o.has=function(n,t){return n?ft.call(n,t):K},o.identity=V,o.indexOf=I,o.isArray=Bt,o.isBoolean=function(n){return n===H||n===K||lt.call(n)==bt},o.isDate=function(n){return n instanceof Date||lt.call(n)==jt},o.isElement=function(n){return n?1===n.nodeType:K},o.isEmpty=function(n){if(!n)return H;if(Bt(n)||x(n))return!n.length;for(var t in n)if(ft.call(n,t))return K;return H},o.isEqual=d,o.isFinite=function(n){return vt(n)&&!gt(parseFloat(n))},o.isFunction=b,o.isNaN=function(n){return w(n)&&n!=+n },o.isNull=function(n){return n===J},o.isNumber=w,o.isObject=j,o.isRegExp=function(n){return n instanceof RegExp||lt.call(n)==At},o.isString=x,o.isUndefined=function(n){return n===void 0},o.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?_t(0,e+r):mt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(yt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J; From f4120a9c8cf312205d76eb21faa1b4944630efca Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 25 Dec 2012 23:12:19 -0600 Subject: [PATCH 032/176] Consistently coerce keys to strings before passing them to `hasOwnProperty` and init Array lengths when possible. Former-commit-id: 5bd397eafbae888c7e6c76e62a7021b85796e65a --- doc/README.md | 114 +++++++++++++++++++-------------------- lodash.js | 31 ++++++----- lodash.min.js | 68 +++++++++++------------ lodash.underscore.js | 31 ++++++----- lodash.underscore.min.js | 50 ++++++++--------- 5 files changed, 152 insertions(+), 142 deletions(-) diff --git a/doc/README.md b/doc/README.md index bc06ddef6f..398ba38f8a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -187,7 +187,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2767 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2772 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +211,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2797 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2802 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +236,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2837 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +264,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2859 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +292,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2901 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2906 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +324,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2936 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2941 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +349,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2965 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +373,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3018 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +398,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3045 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +427,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3075 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +452,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3120 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +490,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3154 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3159 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +518,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3203 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +562,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3230 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3235 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +586,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3264 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3269 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +625,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3323 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3328 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +650,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3359 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +707,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4225 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +737,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4242 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +758,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4254 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4259 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1067,7 +1067,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2307 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1099,7 +1099,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2349 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1131,7 +1131,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2395 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2397 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1157,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2448 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1188,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2472 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1218,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2512 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2514 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1249,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2550 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2552 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1275,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2571 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2573 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1299,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2606 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1329,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1358,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2677 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1390,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2712 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1414,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2737 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2742 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1452,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3387 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3392 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1480,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3425 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1511,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3455 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1542,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3501 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1583,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3524 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1610,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1636,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3621 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1661,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3596 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1688,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3640 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3645 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1714,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3672 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1740,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3702 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3707 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1767,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3729 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1792,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3777 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3782 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2739,7 +2739,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3801 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3806 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2763,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3824 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2788,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3845 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3850 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2818,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3869 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3874 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2838,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3897 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2866,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3935 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2901,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4020 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2979,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4151 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3011,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4172 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4177 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3035,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4192 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4197 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3069,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4424 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 916c925e56..32452ba040 100644 --- a/lodash.js +++ b/lodash.js @@ -2052,7 +2052,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection); + key = callback(value, key, collection) + ''; (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); }); return result; @@ -2242,7 +2242,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection); + key = callback(value, key, collection) + ''; (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); return result; @@ -2272,11 +2272,13 @@ */ function invoke(collection, methodName) { var args = slice(arguments, 2), + index = -1, isFunc = typeof methodName == 'function', - result = []; + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); forEach(collection, function(value) { - result.push((isFunc ? methodName : value[methodName]).apply(value, args)); + result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); }); return result; } @@ -2570,7 +2572,8 @@ */ function shuffle(collection) { var index = -1, - result = Array(collection ? collection.length : 0); + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); forEach(collection, function(value) { var rand = floor(nativeRandom() * (++index + 1)); @@ -2672,18 +2675,20 @@ * // => ['moe', 'larry', 'brendan'] */ function sortBy(collection, callback, thisArg) { - var result = []; - callback = createCallback(callback, thisArg); + var index = -1, + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); - forEach(collection, function(value, index, collection) { - result.push({ - 'criteria': callback(value, index, collection), + callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { + result[++index] = { + 'criteria': callback(value, key, collection), 'index': index, 'value': value - }); + }; }); - var length = result.length; + length = result.length; result.sort(compareAscending); while (length--) { result[length] = result[length].value; @@ -3640,7 +3645,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = resolver ? resolver.apply(this, arguments) : arguments[0]; + var key = (resolver ? resolver.apply(this, arguments) : arguments[0]) + ''; return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); diff --git a/lodash.min.js b/lodash.min.js index 59466280b8..834ebc5cf0 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,37 +3,37 @@ * Lo-Dash 1.0.0-rc.3 lodash.com/license * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||et);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(xt.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return xt.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 -}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=null,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:X,f:Gt,g:"",h:Jt,i:Xt,j:_t,k:"",l:!0},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; -if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r=Function,e="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(e+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(e+="if(k(l)){l=l.split('')}"),e+="while(++iu;u++)e+="i='"+t.j[u]+"';if(","constructor"==t.j[u]&&(e+="!(f&&f.prototype===l)&&"),e+="h.call(l,i)){"+t.g+"}"}return(t.b||t.h)&&(e+="}"),e+=t.c+";return t",r("e,h,j,k,p,n,s","return function("+n+"){"+e+"}")(a,xt,h,A,rr,Nt,At)}function c(n){return"\\"+er[n]}function l(n){return sr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e]; -return u}function g(n){return vr[n]}function h(n){return Et.call(n)==It}function y(n){var t=!1;if(!n||typeof n!="object"||h(n))return t;var r=n.constructor;return!j(r)&&(!Yt||!p(n))||r instanceof r?Y?(cr(n,function(n,r,e){return t=!xt.call(e,r),!1}),!1===t):(cr(n,function(n,r){t=r}),!1===t||xt.call(n,t)):t}function m(n){var t=[];return lr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(null==n)return n;if(r&&(t=!1),r=x(n)){var o=Et.call(n);if(!nr[o]||Yt&&p(n))return n;var i=hr(n)}if(!r||!t)return r?i?v(n):fr({},n):n; -switch(r=tr[o],o){case Bt:case Mt:return new r(+n);case Pt:case Kt:return new r(n);case Ct:return r(n.source,lt.exec(n))}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:lr)(n,function(n,r){a[r]=_(n,t,null,e,u)}),i&&(xt.call(n,"index")&&(a.index=n.index),xt.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return cr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=pr(n),e=r.length,u={};e>++t;){var o=r[t]; -u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;var u=Et.call(n),o=Et.call(t);if(u==It&&(u=zt),o==It&&(o=zt),u!=o)return!1;switch(u){case Bt:case Mt:return+n==+t;case Pt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ct:case Kt:return n==t+""}if(o=u==Tt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=zt||Yt&&(p(n)||p(t)))return!1;var u=!Qt&&h(n)?Object:n.constructor,i=!Qt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return!1 -}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=!0,f=0;if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return cr(n,function(n,u,o){return xt.call(o,u)?(f++,a=xt.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&cr(t,function(n,t,r){return xt.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?rr[typeof n]:!1}function O(n){return typeof n=="number"||Et.call(n)==Pt}function A(n){return typeof n=="string"||Et.call(n)==Kt -}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==rt&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)lr(e[u],function(t,r){var e,u,o;if(t&&((u=hr(t))||yr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?hr(o)?o:[]:yr(o)?o:{})),n[r]=E(o,t,rt,i,a))}else null!=t&&(n[r]=t)});return n}function S(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=!1,r=(0>r?Rt(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:ar(n,function(n){return r>++e?void 0:!(o=n===t) -}),o}function $(n,t,r){var e=!0,t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else ar(n,function(n,r,u){return e=!!t(n,r,u)});return e}function q(n,t,r){var e=[],t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else ar(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,!1):void 0}),e}function R(n,t,r){if(t&&r===void 0&&hr(n))for(var r=-1,e=n.length;e>++r&&!1!==t(n[r],r,n););else ar(n,t,r); -return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(hr(n))for(;u>++e;)o[e]=t(n[e],e,n);else ar(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&hr(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),ar(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,rt);if(hr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n) -}else ar(n,function(n,e,o){r=u?(u=!1,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length;if(typeof o!="number")var f=pr(n),o=f.length;else Xt&&A(n)&&(u=n.split(""));return t=a(t,e,rt),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(hr(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else ar(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return null==t||r?n[0]:v(n,0,Ft(Rt(0,t),e)) -}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];hr(o)?Ot.apply(u,t?o:z(o)):u.push(o)}return u}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?Rt(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,null==t||r?1:Rt(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i; -typeof t=="function"&&(e=r,r=t,t=!1);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e;if(c)var s=p+"",s=xt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Vt||St&&arguments.length>2?St.call.apply(St,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return Ot.apply(n,arguments),new r(e.apply(r,n)) -}})}function J(){return this.__wrapped__}var Q=typeof exports=="object"&&exports,W=typeof global=="object"&&global;W.global===W&&(n=W);var X,Y,Z=[],nt=new function(){},tt=0,rt=nt,et=30,ut=n._,ot=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/\w*$/,pt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,st=RegExp("^"+(nt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),vt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,gt=/<%=([\s\S]+?)%>/g,ht=/($^)/,yt=/[&<>"']/g,mt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),dt=Math.ceil,bt=Z.concat,wt=Math.floor,jt=st.test(jt=Object.getPrototypeOf)&&jt,xt=nt.hasOwnProperty,Ot=Z.push,At=nt.propertyIsEnumerable,Et=nt.toString,St=st.test(St=v.bind)&&St,kt=st.test(kt=Array.isArray)&&kt,$t=n.isFinite,qt=n.isNaN,Nt=st.test(Nt=Object.keys)&&Nt,Rt=Math.max,Ft=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=St&&!/\n|true/.test(St+Lt),Vt=St&&!Ut,Gt=Nt&&(Lt||Ut),Ht=(Ht={0:1,length:1},Z.splice.call(Ht,0,1),Ht[0]),Jt=!0; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;X=!/valueOf/.test(t),Y="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!h(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=Et.call(document)==zt}catch(Zt){}var nr={"[object Function]":!1};nr[It]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=!0;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String;var rr={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:gt,variable:""};var ur={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vr=b(sr),gr=f(ur,{g:"if(t[i]==null)"+ur.g}),hr=kt||function(n){return Qt&&n instanceof Array||Et.call(n)==Tt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==Et.call(n)});var yr=jt?function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,r=typeof t=="function"&&(r=jt(t))&&jt(r);return r?n==r||jt(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=fr,r.at=function(n){var t=-1,r=bt.apply(Z,v(arguments,1)),e=r.length,u=Array(e);for(Xt&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; -return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),xt.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=null,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=gr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) -},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=bt.apply(Z,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=cr,r.forOwn=lr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u),(xt.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Ft(Rt(0,e-(null==t||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; -n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=xt.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=typeof t=="function",u=[];return R(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},r.keys=pr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return xt.call(r,e)?r[e]:r[e]=n.apply(this,arguments) -}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&hr(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),ar(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=bt.apply(Z,arguments);return cr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r=!1; -return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=bt.apply(Z,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),cr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,null==t&&(t=n,n=0); -for(var e=-1,t=Rt(0,dt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return R(n,function(n){var e=wt(Dt()*(++t+1));r[t]=r[e],r[e]=n}),r},r.sortBy=function(n,t,r){var e=[],t=a(t,r);for(R(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(o);n--;)e[n]=e[n].c;return e},r.tap=function(n,t){return t(n),n},r.throttle=function(n,t){function r(){a=new Date,i=null,u=n.apply(o,e) -}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=null,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return n&&typeof n.length=="number"?Xt&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(bt.apply(Z,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=pr(t);return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]]; -if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return Ot.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=fr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,!0)},r.contains=k,r.escape=function(n){return null==n?"":(n+"").replace(yt,l) -},r.every=$,r.find=N,r.has=function(n,t){return n?xt.call(n,t):!1},r.identity=G,r.indexOf=C,r.isArguments=h,r.isArray=hr,r.isBoolean=function(n){return!0===n||!1===n||Et.call(n)==Bt},r.isDate=function(n){return n instanceof Date||Et.call(n)==Mt},r.isElement=function(n){return n?1===n.nodeType:!1},r.isEmpty=function(n){var t=!0;if(!n)return t;var r=Et.call(n),e=n.length;return r==Tt||r==Kt||r==It||Wt&&h(n)||r==zt&&typeof e=="number"&&j(n.splice)?!e:(lr(n,function(){return t=!1}),t)},r.isEqual=w,r.isFinite=function(n){return $t(n)&&!qt(parseFloat(n)) -},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n},r.isNull=function(n){return null===n},r.isNumber=O,r.isObject=x,r.isPlainObject=yr,r.isRegExp=function(n){return n instanceof RegExp||Et.call(n)==Ct},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?Rt(0,e+r):Ft(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=ut,this},r.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+wt(Dt()*((+t||0)-n+1)) -},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:null;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||ht,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||ht).source+"|"+f.source+"|"+(f===gt?vt:ht).source+"|"+(e.evaluate||i.evaluate||ht).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(mt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ot.test(r||e)),a=f+t.length,t -}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(pt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(at,""):l).replace(ft,"$1").replace(ct,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return null==n?"":(n+"").replace(it,g) -},r.uniqueId=function(n){var t=++tt;return(null==n?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,lr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Ot.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return null==t||r?n[e-1]:v(n,Rt(0,e-t))}},r.take=P,r.head=P,lr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return null==t||e?u:new r(u) -})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,ar(["join","pop","shift"],function(n){var t=Z[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ar(["push","reverse","sort","unshift"],function(n){var t=Z[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ar(["concat","slice","splice"],function(n){var t=Z[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) -}}),Ht&&ar(["pop","shift","splice"],function(n){var t=Z[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Q?typeof module=="object"&&module&&module.exports==Q?(module.exports=r)._=r:Q._=r:n._=r})(this); \ No newline at end of file +;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(Et.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return Et.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 +}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=W,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:nt,f:Qt,g:"",h:Xt,i:nr,j:wt,k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; +if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++ie;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function g(n){return yr[n]}function h(n){return $t.call(n)==Mt}function y(n){var t=X;if(!n||typeof n!="object"||h(n))return t; +var r=n.constructor;return!j(r)&&(!tr||!p(n))||r instanceof r?tt?(sr(n,function(n,r,e){return t=!Et.call(e,r),X}),t===X):(sr(n,function(n,r){t=r}),t===X||Et.call(n,t)):t}function m(n){var t=[];return vr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(n==W)return n;if(r&&(t=X),r=x(n)){var o=$t.call(n);if(!er[o]||tr&&p(n))return n;var i=_r(n)}if(!r||!t)return r?i?v(n):pr({},n):n;switch(r=ur[o],o){case zt:case Ct:return new r(+n);case Kt:case Vt:return new r(n);case Ut:return r(n.source,vt.exec(n)) +}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:vr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(Et.call(n,"index")&&(a.index=n.index),Et.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return sr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=gr(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(n==W||t==W)return n===t;var u=$t.call(n),o=$t.call(t); +if(u==Mt&&(u=Lt),o==Mt&&(o=Lt),u!=o)return X;switch(u){case zt:case Ct:return+n==+t;case Kt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ut:case Vt:return n==t+""}if(o=u==Pt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=Lt||tr&&(p(n)||p(t)))return X;var u=!Yt&&h(n)?Object:n.constructor,i=!Yt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return X}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=Q,f=0; +if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return sr(n,function(n,u,o){return Et.call(o,u)?(f++,a=Et.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&sr(t,function(n,t,r){return Et.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?or[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==ot&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)vr(e[u],function(t,r){var e,u,o; +if(t&&((u=_r(t))||dr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?_r(o)?o:[]:dr(o)?o:{})),n[r]=E(o,t,ot,i,a))}else t!=W&&(n[r]=t)});return n}function S(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:lr(n,function(n){return r>++e?void 0:!(o=n===t)}),o}function $(n,t,r){var e=Q,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else lr(n,function(n,r,u){return e=!!t(n,r,u) +});return e}function q(n,t,r){var e=[],t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else lr(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,X):void 0}),e}function R(n,t,r){if(t&&r===void 0&&_r(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==X;);else lr(n,t,r);return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(_r(n))for(;u>++e;)o[e]=t(n[e],e,n); +else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; +if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else lr(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return t==W||r?n[0]:v(n,0,Tt(It(0,t),e))}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];_r(o)?St.apply(u,t?o:z(o)):u.push(o)}return u +}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,t==W||r?1:It(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=X);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e; +if(c)var s=p+"",s=Et.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&arguments.length>2?qt.call.apply(qt,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return St.apply(n,arguments),new r(e.apply(r,n))}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global; +Z.global===Z&&(n=Z);var nt,tt,rt=[],et=new function(){},ut=0,ot=et,it=30,at=n._,ft=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:""};var ar={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; +return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u)+"",Et.call(e,r)?e[r]++:e[r]=1}),e},r.debounce=function(n,t,r){function e(){a=W,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},r.defaults=mr,r.defer=function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},r.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e) +},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=sr,r.forOwn=vr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u)+"",(Et.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Tt(It(0,e-(t==W||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; +n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=Et.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r=X;return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=xt.apply(rt,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),sr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,t==W&&(t=n,n=0); +for(var e=-1,t=It(0,jt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=n?n.length:0,e=Array(typeof r=="number"?r:0);return R(n,function(n){var r=Ot(Bt()*(++t+1));e[t]=e[r],e[r]=n}),e},r.sortBy=function(n,t,r){var e=-1,u=n?n.length:0,i=Array(typeof u=="number"?u:0),t=a(t,r);for(R(n,function(n,r,u){i[++e]={a:t(n,r,u),b:e,c:n}}),u=i.length,i.sort(o);u--;)i[u]=i[u].c;return i},r.tap=function(n,t){return t(n),n +},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=W,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return n&&typeof n.length=="number"?nr&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(xt.apply(rt,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=gr(t); +return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return St.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=pr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,Q) +},r.contains=k,r.escape=function(n){return n==W?"":(n+"").replace(dt,l)},r.every=$,r.find=N,r.has=function(n,t){return n?Et.call(n,t):X},r.identity=G,r.indexOf=C,r.isArguments=h,r.isArray=_r,r.isBoolean=function(n){return n===Q||n===X||$t.call(n)==zt},r.isDate=function(n){return n instanceof Date||$t.call(n)==Ct},r.isElement=function(n){return n?1===n.nodeType:X},r.isEmpty=function(n){var t=Q;if(!n)return t;var r=$t.call(n),e=n.length;return r==Pt||r==Vt||r==Mt||Zt&&h(n)||r==Lt&&typeof e=="number"&&j(n.splice)?!e:(vr(n,function(){return t=X +}),t)},r.isEqual=w,r.isFinite=function(n){return Rt(n)&&!Ft(parseFloat(n))},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n},r.isNull=function(n){return n===W},r.isNumber=O,r.isObject=x,r.isPlainObject=dr,r.isRegExp=function(n){return n instanceof RegExp||$t.call(n)==Ut},r.isString=A,r.isUndefined=function(n){return n===void 0},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t +}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) +},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" +},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n; +r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index ad77ca21ad..608a0deb3f 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1595,7 +1595,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection); + key = callback(value, key, collection) + ''; (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); }); return result; @@ -1784,7 +1784,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection); + key = callback(value, key, collection) + ''; (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); return result; @@ -1814,11 +1814,13 @@ */ function invoke(collection, methodName) { var args = slice(arguments, 2), + index = -1, isFunc = typeof methodName == 'function', - result = []; + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); forEach(collection, function(value) { - result.push((isFunc ? methodName : value[methodName]).apply(value, args)); + result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); }); return result; } @@ -2106,7 +2108,8 @@ */ function shuffle(collection) { var index = -1, - result = Array(collection ? collection.length : 0); + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); forEach(collection, function(value) { var rand = floor(nativeRandom() * (++index + 1)); @@ -2208,18 +2211,20 @@ * // => ['moe', 'larry', 'brendan'] */ function sortBy(collection, callback, thisArg) { - var result = []; - callback = createCallback(callback, thisArg); + var index = -1, + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); - forEach(collection, function(value, index, collection) { - result.push({ - 'criteria': callback(value, index, collection), + callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { + result[++index] = { + 'criteria': callback(value, key, collection), 'index': index, 'value': value - }); + }; }); - var length = result.length; + length = result.length; result.sort(compareAscending); while (length--) { result[length] = result[length].value; @@ -3110,7 +3115,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = resolver ? resolver.apply(this, arguments) : arguments[0]; + var key = (resolver ? resolver.apply(this, arguments) : arguments[0]) + ''; return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index cbe0b9c909..e01f87cbc8 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,29 +4,29 @@ * Build: `lodash underscore -m -o ./lodash.underscore.min.js` * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&r===void 0?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;e>++r&&t(n[r],r,n)!==Y;);else for(r in n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}}function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function i(n,t){var r=n.b,e=t.b,n=n.a,t=t.a; -if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1}return e>r?-1:1}function a(n,t,r){function e(){var u=arguments,o=t;return r.length&&(u=u.length?r.concat(p(u)):r),this instanceof e?(s.prototype=n.prototype,o=new s,s.prototype=J,u=n.apply(o,u),j(u)?u:o):n.apply(o,u)}return e}function f(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:V}function c(n){return"\\"+Ft[n]}function l(n){return Tt[n] -}function s(){}function p(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function v(n){return qt[n]}function g(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]=e[u]}return n}function h(n){var t=[];return r(n,function(n,r){t.push(r)}),t}function _(n){if(!n)return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];if(e)for(var u in e)n[u]==J&&(n[u]=e[u])}return n}function m(n){var t=[]; -return e(n,function(n,r){b(n)&&t.push(r)}),t.sort()}function y(n){for(var t=-1,r=Rt(n),e=r.length,u={};e>++t;){var o=r[t];u[n[o]]=o}return u}function d(n,t,r,u){if(n===t)return 0!==n||1/n==1/t;if(n==J||t==J)return n===t;var o=lt.call(n),i=lt.call(t);if(o!=i)return K;switch(o){case bt:case jt:return+n==+t;case wt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case At:case Et:return n==t+""}if(i=o==dt,!i){if(n.__wrapped__||t.__wrapped__)return d(n.__wrapped__||n,t.__wrapped__||t);if(o!=xt)return K;var o=n.constructor,a=t.constructor; -if(!(o==a||b(o)&&o instanceof o&&b(a)&&a instanceof a))return K}for(r||(r=[]),u||(u=[]),o=r.length;o--;)if(r[o]==n)return u[o]==t;var f=H,c=0;if(r.push(n),u.push(t),i){if(c=n.length,f=c==t.length)for(;c--&&(f=d(n[c],t[c],r,u)););return f}return e(n,function(n,e,o){return ft.call(o,e)?(c++,!(f=ft.call(t,e)&&d(n,t[e],r,u))&&Y):void 0}),f&&e(t,function(n,t,r){return ft.call(r,t)?!(f=--c>-1)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?Nt[typeof n]:K}function w(n){return typeof n=="number"||lt.call(n)==wt -}function x(n){return typeof n=="string"||lt.call(n)==Et}function A(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function E(n,t){var r=K;return typeof(n?n.length:0)=="number"?r=I(n,t)>-1:u(n,function(n){return(r=n===t)&&Y}),r}function O(n,t,r){var e=H,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r&&(e=!!t(n[r],r,n)););else u(n,function(n,r,u){return!(e=!!t(n,r,u))&&Y});return e}function S(n,t,r){var e=[],t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;o>++r;){var i=n[r];t(i,r,n)&&e.push(i) -}else u(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function k(n,t,r){var e,t=f(t,r);return N(n,function(n,r,u){return t(n,r,u)?(e=n,Y):void 0}),e}function N(n,t,r){if(t&&r===void 0&&Bt(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==Y;);else u(n,t,r)}function F(n,t,r){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),t=f(t,r);if(Bt(n))for(;o>++e;)i[e]=t(n[e],e,n);else u(n,function(n,r,u){i[++e]=t(n,r,u)});return i}function R(n,t,r){var e=-1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;i>++r;){var a=n[r]; -a>o&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);a>++i;)r=t(r,n[i],i,n)}else u(n,function(n,e,u){r=o?(o=K,n):t(r,n,e,u)});return r}function B(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r); -if(Bt(n))for(var r=-1,o=n.length;o>++r&&!(e=t(n[r],r,n)););else u(n,function(n,r,u){return(e=t(n,r,u))&&Y});return!!e}function M(n,t,r){if(n){var e=n.length;return t==J||r?n[0]:p(n,0,mt(_t(0,t),e))}}function $(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];Bt(o)?ct.apply(u,t?o:$(o)):u.push(o)}return u}function I(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?_t(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function z(n,t,r){return p(n,t==J||r?1:_t(0,t)) -}function C(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?f(r,e):V,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function P(n,t,r,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof t=="function"&&(e=r,r=t,t=K),r&&(a=[],r=f(r,e));o>++u;){var e=n[u],c=r?r(e,u,n):e;(t?!u||a[a.length-1]!==c:0>I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&arguments.length>2?st.call.apply(st,arguments):a(n,t,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__]; -return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,_t=Math.max,mt=Math.min,yt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",xt="[object Object]",At="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=y(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) -}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=m(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=U(n[u],n)}return n},o.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},o.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];return t[0]}},o.countBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),ft.call(e,r)?e[r]++:e[r]=1 -}),e},o.debounce=function(n,t,r){function e(){a=J,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},o.defaults=_,o.defer=function(n){var r=p(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},o.delay=function(n,r){var e=p(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},o.difference=function(n){for(var t=-1,r=n.length,e=it.apply(W,arguments),u=[];r>++t;){var o=n[t];0>I(e,o,r)&&u.push(o) -}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=m,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u),(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,mt(_t(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;u>++e;){var i=n[e];if(0>I(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=y,o.invoke=function(n,t){var r=p(arguments,2),e=typeof t=="function",u=[]; -return N(n,function(n){u.push((e?t:n[t]).apply(n,r))}),u},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=t?t.apply(this,arguments):arguments[0];return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;i>++r;){var a=n[r];o>a&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},o.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1] -}return u},o.omit=function(n){var t=it.apply(W,arguments),r={};return e(n,function(n,e){0>I(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},o.pick=function(n){for(var t=0,r=it.apply(W,arguments),e=r.length,u={};e>++t;){var o=r[t];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,t,r){n=+n||0,r=+r||1,t==J&&(t=n,n=0); -for(var e=-1,t=_t(0,ot((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},o.reject=function(n,t,r){return t=f(t,r),S(n,function(n,r,e){return!t(n,r,e)})},o.rest=z,o.shuffle=function(n){var t=-1,r=Array(n?n.length:0);return N(n,function(n){var e=at(yt()*(++t+1));r[t]=r[e],r[e]=n}),r},o.sortBy=function(n,t,r){var e=[],t=f(t,r);for(N(n,function(n,r,u){e.push({a:t(n,r,u),b:r,c:n})}),n=e.length,e.sort(i);n--;)e[n]=e[n].c;return e},o.tap=function(n,t){return t(n),n},o.throttle=function(n,t){function r(){a=new Date,i=J,u=n.apply(o,e) -}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},o.toArray=function(n){return n&&typeof n.length=="number"?p(n):A(n)},o.union=function(){return P(it.apply(W,arguments))},o.uniq=P,o.values=A,o.where=function(n,t){var r=Rt(t);return S(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break -}return!!u})},o.without=function(n){for(var t=-1,r=n.length,e=[];r>++t;){var u=n[t];0>I(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);r>++t;)e[t]=T(arguments,t);return e},o.collect=F,o.drop=z,o.each=N,o.extend=g,o.methods=m,o.select=S,o.tail=z,o.unique=P,o.clone=function(n){return n&&Nt[typeof n]?Bt(n)?p(n):g({},n):n},o.contains=E,o.escape=function(n){return n==J?"":(n+"").replace(et,l) -},o.every=O,o.find=k,o.has=function(n,t){return n?ft.call(n,t):K},o.identity=V,o.indexOf=I,o.isArray=Bt,o.isBoolean=function(n){return n===H||n===K||lt.call(n)==bt},o.isDate=function(n){return n instanceof Date||lt.call(n)==jt},o.isElement=function(n){return n?1===n.nodeType:K},o.isEmpty=function(n){if(!n)return H;if(Bt(n)||x(n))return!n.length;for(var t in n)if(ft.call(n,t))return K;return H},o.isEqual=d,o.isFinite=function(n){return vt(n)&&!gt(parseFloat(n))},o.isFunction=b,o.isNaN=function(n){return w(n)&&n!=+n -},o.isNull=function(n){return n===J},o.isNumber=w,o.isObject=j,o.isRegExp=function(n){return n instanceof RegExp||lt.call(n)==At},o.isString=x,o.isUndefined=function(n){return n===void 0},o.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?_t(0,e+r):mt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(yt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J; -return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=_({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; -try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,_t(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this -},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o +;(function(n,r){function t(n,r){var t;if(n)for(t in r||(r=V),n)if(fr.call(n,t)&&r(n[t],t,n)===Y)break}function e(n,r){var t;if(n)for(t in r||(r=V),n)if(r(n[t],t,n)===Y)break}function u(n,r,t){if(n){var r=r&&t===void 0?r:f(r,t),e=n.length,t=-1;if(typeof e=="number")for(;e>++t&&r(n[t],t,n)!==Y;);else for(t in n)if(fr.call(n,t)&&r(n[t],t,n)===Y)break}}function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function i(n,r){var t=n.b,e=r.b,n=n.a,r=r.a; +if(n!==r){if(n>r||n===void 0)return 1;if(r>n||r===void 0)return-1}return e>t?-1:1}function a(n,r,t){function e(){var u=arguments,o=r;return t.length&&(u=u.length?t.concat(p(u)):t),this instanceof e?(s.prototype=n.prototype,o=new s,s.prototype=J,u=n.apply(o,u),j(u)?u:o):n.apply(o,u)}return e}function f(n,r,t){return n?typeof n!="function"?function(r){return r[n]}:r!==void 0?t?function(t,e,u,o){return n.call(r,t,e,u,o)}:function(t,e,u){return n.call(r,t,e,u)}:n:V}function c(n){return"\\"+Fr[n]}function l(n){return Tr[n] +}function s(){}function p(n,r,t){r||(r=0),t===void 0&&(t=n?n.length:0);for(var e=-1,t=t-r||0,u=Array(0>t?0:t);t>++e;)u[e]=n[r+e];return u}function v(n){return qr[n]}function g(n){if(!n)return n;for(var r=1,t=arguments.length;t>r;r++){var e=arguments[r];if(e)for(var u in e)n[u]=e[u]}return n}function h(n){var r=[];return t(n,function(n,t){r.push(t)}),r}function _(n){if(!n)return n;for(var r=1,t=arguments.length;t>r;r++){var e=arguments[r];if(e)for(var u in e)n[u]==J&&(n[u]=e[u])}return n}function m(n){var r=[]; +return e(n,function(n,t){b(n)&&r.push(t)}),r.sort()}function y(n){for(var r=-1,t=Rr(n),e=t.length,u={};e>++r;){var o=t[r];u[n[o]]=o}return u}function d(n,r,t,u){if(n===r)return 0!==n||1/n==1/r;if(n==J||r==J)return n===r;var o=lr.call(n),i=lr.call(r);if(o!=i)return K;switch(o){case br:case jr:return+n==+r;case wr:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case xr:case Er:return n==r+""}if(i=o==dr,!i){if(n.__wrapped__||r.__wrapped__)return d(n.__wrapped__||n,r.__wrapped__||r);if(o!=Ar)return K;var o=n.constructor,a=r.constructor; +if(!(o==a||b(o)&&o instanceof o&&b(a)&&a instanceof a))return K}for(t||(t=[]),u||(u=[]),o=t.length;o--;)if(t[o]==n)return u[o]==r;var f=H,c=0;if(t.push(n),u.push(r),i){if(c=n.length,f=c==r.length)for(;c--&&(f=d(n[c],r[c],t,u)););return f}return e(n,function(n,e,o){return fr.call(o,e)?(c++,!(f=fr.call(r,e)&&d(n,r[e],t,u))&&Y):void 0}),f&&e(r,function(n,r,t){return fr.call(t,r)?!(f=--c>-1)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?Nr[typeof n]:K}function w(n){return typeof n=="number"||lr.call(n)==wr +}function A(n){return typeof n=="string"||lr.call(n)==Er}function x(n){for(var r=-1,t=Rr(n),e=t.length,u=Array(e);e>++r;)u[r]=n[t[r]];return u}function E(n,r){var t=K;return typeof(n?n.length:0)=="number"?t=I(n,r)>-1:u(n,function(n){return(t=n===r)&&Y}),t}function O(n,r,t){var e=H,r=f(r,t);if(Br(n))for(var t=-1,o=n.length;o>++t&&(e=!!r(n[t],t,n)););else u(n,function(n,t,u){return!(e=!!r(n,t,u))&&Y});return e}function S(n,r,t){var e=[],r=f(r,t);if(Br(n))for(var t=-1,o=n.length;o>++t;){var i=n[t];r(i,t,n)&&e.push(i) +}else u(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function k(n,r,t){var e,r=f(r,t);return N(n,function(n,t,u){return r(n,t,u)?(e=n,Y):void 0}),e}function N(n,r,t){if(r&&t===void 0&&Br(n))for(var t=-1,e=n.length;e>++t&&r(n[t],t,n)!==Y;);else u(n,r,t)}function F(n,r,t){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),r=f(r,t);if(Br(n))for(;o>++e;)i[e]=r(n[e],e,n);else u(n,function(n,t,u){i[++e]=r(n,t,u)});return i}function R(n,r,t){var e=-1/0,o=e;if(!r&&Br(n))for(var t=-1,i=n.length;i>++t;){var a=n[t]; +a>o&&(o=a)}else r=f(r,t),u(n,function(n,t,u){t=r(n,t,u),t>e&&(e=t,o=n)});return o}function T(n,r){return F(n,r+"")}function q(n,r,t,e){var o=3>arguments.length,r=f(r,e,Y);if(Br(n)){var i=-1,a=n.length;for(o&&(t=n[++i]);a>++i;)t=r(t,n[i],i,n)}else u(n,function(n,e,u){t=o?(o=K,n):r(t,n,e,u)});return t}function B(n,r,t,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rr(n),u=i.length;return r=f(r,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,t=o?(o=K,n[a]):r(t,n[a],a,f)}),t}function D(n,r,t){var e,r=f(r,t); +if(Br(n))for(var t=-1,o=n.length;o>++t&&!(e=r(n[t],t,n)););else u(n,function(n,t,u){return(e=r(n,t,u))&&Y});return!!e}function M(n,r,t){if(n){var e=n.length;return r==J||t?n[0]:p(n,0,mr(_r(0,r),e))}}function $(n,r){for(var t=-1,e=n?n.length:0,u=[];e>++t;){var o=n[t];Br(o)?cr.apply(u,r?o:$(o)):u.push(o)}return u}function I(n,r,t){var e=-1,u=n?n.length:0;if(typeof t=="number")e=(0>t?_r(0,u+t):t||0)-1;else if(t)return e=C(n,r),n[e]===r?e:-1;for(;u>++e;)if(n[e]===r)return e;return-1}function z(n,r,t){return p(n,r==J||t?1:_r(0,r)) +}function C(n,r,t,e){for(var u=0,o=n?n.length:u,t=t?f(t,e):V,r=t(r);o>u;)e=u+o>>>1,r>t(n[e])?u=e+1:o=e;return u}function P(n,r,t,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof r=="function"&&(e=t,t=r,r=K),t&&(a=[],t=f(t,e));o>++u;){var e=n[u],c=t?t(e,u,n):e;(r?!u||a[a.length-1]!==c:0>I(a,c))&&(t&&a.push(c),i.push(e))}return i}function U(n,r){return Or||sr&&arguments.length>2?sr.call.apply(sr,arguments):a(n,r,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(r){var t=o[r]=n[r];o.prototype[r]=function(){var n=[this.__wrapped__]; +return cr.apply(n,arguments),n=t.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nr=/&(?:amp|lt|gt|quot|#x27);/g,rr=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),tr=/($^)/,er=/[&<>"']/g,ur=/['\n\r\t\u2028\u2029\\]/g,or=Math.ceil,ir=W.concat,ar=Math.floor,fr=Q.hasOwnProperty,cr=W.push,lr=Q.toString,sr=rr.test(sr=p.bind)&&sr,pr=rr.test(pr=Array.isArray)&&pr,vr=n.isFinite,gr=n.isNaN,hr=rr.test(hr=Object.keys)&&hr,_r=Math.max,mr=Math.min,yr=Math.random,dr="[object Array]",br="[object Boolean]",jr="[object Date]",wr="[object Number]",Ar="[object Object]",xr="[object RegExp]",Er="[object String]",Q=!!n.attachEvent,Q=sr&&!/\n|true/.test(sr+Q),Or=sr&&!Q,Sr=(Sr={0:1,length:1},W.splice.call(Sr,0,1),Sr[0]),kr=arguments.constructor==Object,Nr={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Fr={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lr.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?fr.call(n,"callee"):K});var Rr=hr?function(n){return j(n)?hr(n):[]}:h,Tr={"&":"&","<":"<",">":">",'"':""","'":"'"},qr=y(Tr),Br=pr||function(n){return kr&&n instanceof Array||lr.call(n)==dr};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lr.call(n) +}),o.after=function(n,r){return 1>n?r():function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var r=arguments,t=r.length>1?0:(r=m(n),-1),e=r.length;e>++t;){var u=r[t];n[u]=U(n[u],n)}return n},o.compact=function(n){for(var r=-1,t=n?n.length:0,e=[];t>++r;){var u=n[r];u&&e.push(u)}return e},o.compose=function(){var n=arguments;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}},o.countBy=function(n,r,t){var e={},r=f(r,t);return N(n,function(n,t,u){t=r(n,t,u)+"",fr.call(e,t)?e[t]++:e[t]=1 +}),e},o.debounce=function(n,r,t){function e(){a=J,t||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=t&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,r),f&&(o=n.apply(i,u)),o}},o.defaults=_,o.defer=function(n){var t=p(arguments,1);return setTimeout(function(){n.apply(r,t)},1)},o.delay=function(n,t){var e=p(arguments,2);return setTimeout(function(){n.apply(r,e)},t)},o.difference=function(n){for(var r=-1,t=n.length,e=ir.apply(W,arguments),u=[];t>++r;){var o=n[r];0>I(e,o,t)&&u.push(o) +}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=m,o.groupBy=function(n,r,t){var e={},r=f(r,t);return N(n,function(n,t,u){t=r(n,t,u)+"",(fr.call(e,t)?e[t]:e[t]=[]).push(n)}),e},o.initial=function(n,r,t){if(!n)return[];var e=n.length;return p(n,0,mr(_r(0,e-(r==J||t?1:r||0)),e))},o.intersection=function(n){var r=arguments,t=r.length,e=-1,u=n?n.length:0,o=[];n:for(;u>++e;){var i=n[e];if(0>I(o,i)){for(var a=t;--a;)if(0>I(r[a],i))continue n;o.push(i)}}return o},o.invert=y,o.invoke=function(n,r){var t=p(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return N(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},o.keys=Rr,o.map=F,o.max=R,o.memoize=function(n,r){var t={};return function(){var e=(r?r.apply(this,arguments):arguments[0])+"";return fr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},o.min=function(n,r,t){var e=1/0,o=e;if(!r&&Br(n))for(var t=-1,i=n.length;i>++t;){var a=n[t];o>a&&(o=a)}else r=f(r,t),u(n,function(n,t,u){t=r(n,t,u),e>t&&(e=t,o=n)});return o},o.object=function(n,r){for(var t=-1,e=n?n.length:0,u={};e>++t;){var o=n[t];r?u[o]=r[t]:u[o[0]]=o[1] +}return u},o.omit=function(n){var r=ir.apply(W,arguments),t={};return e(n,function(n,e){0>I(r,e,1)&&(t[e]=n)}),t},o.once=function(n){var r,t=K;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var r=-1,t=Rr(n),e=t.length,u=Array(e);e>++r;){var o=t[r];u[r]=[o,n[o]]}return u},o.pick=function(n){for(var r=0,t=ir.apply(W,arguments),e=t.length,u={};e>++r;){var o=t[r];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,r,t){n=+n||0,t=+t||1,r==J&&(r=n,n=0); +for(var e=-1,r=_r(0,or((r-n)/t)),u=Array(r);r>++e;)u[e]=n,n+=t;return u},o.reject=function(n,r,t){return r=f(r,t),S(n,function(n,t,e){return!r(n,t,e)})},o.rest=z,o.shuffle=function(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return N(n,function(n){var t=ar(yr()*(++r+1));e[r]=e[t],e[t]=n}),e},o.sortBy=function(n,r,t){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),r=f(r,t);for(N(n,function(n,t,u){o[++e]={a:r(n,t,u),b:e,c:n}}),u=o.length,o.sort(i);u--;)o[u]=o[u].c;return o},o.tap=function(n,r){return r(n),n +},o.throttle=function(n,r){function t(){a=new Date,i=J,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=r-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(t,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,r,t){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=r.call(t,e);return u},o.toArray=function(n){return n&&typeof n.length=="number"?p(n):x(n)},o.union=function(){return P(ir.apply(W,arguments))},o.uniq=P,o.values=x,o.where=function(n,r){var t=Rr(r);return S(n,function(n){for(var e=t.length;e--;){var u=n[t[e]]===r[t[e]]; +if(!u)break}return!!u})},o.without=function(n){for(var r=-1,t=n.length,e=[];t>++r;){var u=n[r];0>I(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,r){return function(){var t=[n];return cr.apply(t,arguments),r.apply(this,t)}},o.zip=function(n){for(var r=-1,t=n?R(T(arguments,"length")):0,e=Array(t);t>++r;)e[r]=T(arguments,r);return e},o.collect=F,o.drop=z,o.each=N,o.extend=g,o.methods=m,o.select=S,o.tail=z,o.unique=P,o.clone=function(n){return n&&Nr[typeof n]?Br(n)?p(n):g({},n):n},o.contains=E,o.escape=function(n){return n==J?"":(n+"").replace(er,l) +},o.every=O,o.find=k,o.has=function(n,r){return n?fr.call(n,r):K},o.identity=V,o.indexOf=I,o.isArray=Br,o.isBoolean=function(n){return n===H||n===K||lr.call(n)==br},o.isDate=function(n){return n instanceof Date||lr.call(n)==jr},o.isElement=function(n){return n?1===n.nodeType:K},o.isEmpty=function(n){if(!n)return H;if(Br(n)||A(n))return!n.length;for(var r in n)if(fr.call(n,r))return K;return H},o.isEqual=d,o.isFinite=function(n){return vr(n)&&!gr(parseFloat(n))},o.isFunction=b,o.isNaN=function(n){return w(n)&&n!=+n +},o.isNull=function(n){return n===J},o.isNumber=w,o.isObject=j,o.isRegExp=function(n){return n instanceof RegExp||lr.call(n)==xr},o.isString=A,o.isUndefined=function(n){return n===void 0},o.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?_r(0,e+t):mr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,r){return n==J&&r==J&&(r=1),n=+n||0,r==J&&(r=n,n=0),n+ar(yr()*((+r||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,r){var t=n?n[r]:J; +return b(t)?n[r]():t},o.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Rr(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,r,t){n||(n="");var t=_({},t,o.templateSettings),e=0,u="__p+='",i=t.variable;n.replace(RegExp((t.escape||tr).source+"|"+(t.interpolate||tr).source+"|"+(t.evaluate||tr).source+"|$","g"),function(r,t,o,i,a){u+=n.slice(e,a).replace(ur,c),u+=t?"'+_['escape']("+t+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+r.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; +try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return r?a(r):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nr,v)},o.uniqueId=function(n){var r=++X+"";return n?n+r:r},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,r,t){if(n){var e=n.length;return r==J||t?n[e-1]:p(n,_r(0,e-r))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this +},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var r=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Sr&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var r=W[n];o.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o })(this); \ No newline at end of file From cc1e0daaa4be04b1fea2252b494b56c3d1c17a27 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 27 Dec 2012 00:08:19 -0600 Subject: [PATCH 033/176] Update vendor/underscore. Former-commit-id: 9a00fa6c531e8cf0990526b7034cbde67ef335b3 --- vendor/underscore/underscore-min.js | 2 +- vendor/underscore/underscore.js | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index 8676092016..a3bb5f3543 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -2,4 +2,4 @@ // http://underscorejs.org // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFunction(/./)&&(w.isFunction=function(n){return"[object Function]"==l.call(n)}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index b2619be82d..b943608c95 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -938,8 +938,8 @@ return obj === Object(obj); }; - // Add some isType methods: isArguments, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'String', 'Number', 'Date', 'RegExp'], function(name) { + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) == '[object ' + name + ']'; }; @@ -953,16 +953,10 @@ }; } - // Is a given variable a function? - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - - // Define a fallback for older versions of Chrome, Firefox, and Safari, where - // a regexp is `typeof` "function". - if (_.isFunction(/./)) { + // Optimize `isFunction` if appropriate. + if (typeof (/./) !== 'function') { _.isFunction = function(obj) { - return toString.call(obj) == '[object Function]'; + return typeof obj === 'function'; }; } From ac25e21a0ccae784415f1e9f59b9539a1771e45e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 27 Dec 2012 00:44:57 -0600 Subject: [PATCH 034/176] Avoid minifying `typeof x == 'undefined'` checks into `x === void 0`. Former-commit-id: 23c998b48a1d2e1bca19dad6bf16fa94aeebed31 --- build/minify.js | 3 ++- lodash.min.js | 42 ++++++++++++++++----------------- lodash.underscore.min.js | 50 ++++++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/build/minify.js b/build/minify.js index a6860c81d6..794a5a805a 100755 --- a/build/minify.js +++ b/build/minify.js @@ -185,9 +185,10 @@ var toplevel = uglifyJS.parse(source); // 2. compress - // // enable unsafe comparisons + // enable unsafe comparisons toplevel.figure_out_scope(); toplevel = toplevel.transform(uglifyJS.Compressor({ + 'comparisons': false, 'unsafe_comps': true, 'warnings': false })); diff --git a/lodash.min.js b/lodash.min.js index 834ebc5cf0..e352430f29 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,35 +3,35 @@ * Lo-Dash 1.0.0-rc.3 lodash.com/license * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;e>++r;){var i=n[r]+"";(Et.call(o,i)?o[i]:o[i]=[]).push(n[r])}return function(r){if(u){var e=r+"";return Et.call(o,e)&&C(o[e],r)>-1}return C(n,r,t)>-1}}function u(n){return n.charCodeAt(0)}function o(n,t){var r=n.b,e=t.b,n=n.a,t=t.a;if(n!==t){if(n>t||n===void 0)return 1;if(t>n||t===void 0)return-1 -}return e>r?-1:1}function i(n,t,r){function e(){var a=arguments,f=o?this:t;return u||(n=t[i]),r.length&&(a=a.length?r.concat(v(a)):r),this instanceof e?(s.prototype=n.prototype,f=new s,s.prototype=W,a=n.apply(f,a),x(a)?a:f):n.apply(f,a)}var u=j(n),o=!r,i=t;return o&&(r=t),u||(t=n),e}function a(n,t,r){return n?typeof n!="function"?function(t){return t[n]}:t!==void 0?r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n:G}function f(){for(var n,t={b:"",c:"",e:nt,f:Qt,g:"",h:Xt,i:nr,j:wt,k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; +;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),r===void 0&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);r>++e;)u[e]=n[t+e];return u}function g(n){return yr[n]}function h(n){return $t.call(n)==Mt}function y(n){var t=X;if(!n||typeof n!="object"||h(n))return t; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++e++t;){var o=r[t];u[n[o]]=o}return u}function w(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(n==W||t==W)return n===t;var u=$t.call(n),o=$t.call(t); -if(u==Mt&&(u=Lt),o==Mt&&(o=Lt),u!=o)return X;switch(u){case zt:case Ct:return+n==+t;case Kt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Ut:case Vt:return n==t+""}if(o=u==Pt,!o){if(n.__wrapped__||t.__wrapped__)return w(n.__wrapped__||n,t.__wrapped__||t);if(u!=Lt||tr&&(p(n)||p(t)))return X;var u=!Yt&&h(n)?Object:n.constructor,i=!Yt&&h(t)?Object:t.constructor;if(!(u==i||j(u)&&u instanceof u&&j(i)&&i instanceof i))return X}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;var a=Q,f=0; -if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return sr(n,function(n,u,o){return Et.call(o,u)?(f++,a=Et.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&sr(t,function(n,t,r){return Et.call(r,t)?a=--f>-1:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?or[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function E(n,t,r){var e=arguments,u=0,o=2,i=e[3],a=e[4];for(r!==ot&&(i=[],a=[],typeof r!="number"&&(o=e.length));o>++u;)vr(e[u],function(t,r){var e,u,o; -if(t&&((u=_r(t))||dr(t))){for(var f=i.length;f--&&!(e=i[f]==t););e?n[r]=a[f]:(i.push(t),a.push((o=n[r],o=u?_r(o)?o:[]:dr(o)?o:{})),n[r]=E(o,t,ot,i,a))}else t!=W&&(n[r]=t)});return n}function S(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;)u[t]=n[r[t]];return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;return typeof u=="number"?o=(A(n)?n.indexOf(t,r):C(n,t,r))>-1:lr(n,function(n){return r>++e?void 0:!(o=n===t)}),o}function $(n,t,r){var e=Q,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&(e=!!t(n[r],r,n)););else lr(n,function(n,r,u){return e=!!t(n,r,u) -});return e}function q(n,t,r){var e=[],t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r;){var o=n[r];t(o,r,n)&&e.push(o)}else lr(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function N(n,t,r){var e,t=a(t,r);return R(n,function(n,r,u){return t(n,r,u)?(e=n,X):void 0}),e}function R(n,t,r){if(t&&r===void 0&&_r(n))for(var r=-1,e=n.length;e>++r&&t(n[r],r,n)!==X;);else lr(n,t,r);return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),t=a(t,r);if(_r(n))for(;u>++e;)o[e]=t(n[e],e,n); -else lr(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function D(n,t,r){var e=-1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];f>o&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);i>++o;)r=t(r,n[o],o,n)}else lr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length; -if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;u>++r&&!(e=t(n[r],r,n)););else lr(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function P(n,t,r){if(n){var e=n.length;return t==W||r?n[0]:v(n,0,Tt(It(0,t),e))}}function z(n,t){for(var r=-1,e=n?n.length:0,u=[];e>++r;){var o=n[r];_r(o)?St.apply(u,t?o:z(o)):u.push(o)}return u -}function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;u>++e;)if(n[e]===t)return e;return-1}function K(n,t,r){return v(n,t==W||r?1:It(0,t))}function L(n,t,r,e){for(var u=0,o=n?n.length:u,r=r?a(r,e):G,t=r(t);o>u;)e=u+o>>>1,t>r(n[e])?u=e+1:o=e;return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=X);var c=!t&&o>=75;if(c)var l={};for(r&&(f=[],r=a(r,e));o>++u;){var e=n[u],p=r?r(e,u,n):e; -if(c)var s=p+"",s=Et.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&arguments.length>2?qt.call.apply(qt,arguments):i(n,t,v(arguments,2))}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return St.apply(n,arguments),new r(e.apply(r,n))}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global; +}for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:vr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(Et.call(n,"index")&&(a.index=n.index),Et.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return sr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=gr(n),e=r.length,u={};++tr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; +if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:""};var ar={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));e>++t;)u[t]=n[r[t]];return u},r.bind=V,r.bindAll=function(n){for(var t=arguments,r=t.length>1?0:(t=d(n),-1),e=t.length;e>++r;){var u=t[r];n[u]=V(n[u],n)}return n},r.bindKey=function(n,t){return i(n,t,v(arguments,2))},r.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];r>++t;){var u=n[t];u&&e.push(u)}return e},r.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)]; +}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++t++t;){var i=n[t];u(i)||o.push(i)}return o},r.filter=q,r.flatten=z,r.forEach=R,r.forIn=sr,r.forOwn=vr,r.functions=d,r.groupBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n,r,u){r=t(n,r,u)+"",(Et.call(e,r)?e[r]:e[r]=[]).push(n)}),e},r.initial=function(n,t,r){if(!n)return[];var e=n.length;return v(n,0,Tt(It(0,e-(t==W||r?1:t||0)),e))},r.intersection=function(n){var t=arguments,r=t.length,u={0:{}},o=-1,i=n?n.length:0,a=i>=100,f=[],c=f; -n:for(;i>++o;){var l=n[o];if(a)var p=l+"",p=Et.call(u[0],p)?!(c=u[0][p]):c=u[0][p]=[];if(p||0>C(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;i>++r;){var f=n[r];o>f&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),e>r&&(e=r,o=n)});return o},r.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};e>++r;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},r.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=xt.apply(rt,arguments);return sr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r=X;return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);e>++t;){var o=r[t];u[t]=[o,n[o]]}return u},r.partial=function(n){return i(n,v(arguments,1))},r.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=xt.apply(rt,arguments),i=o.length;i>++u;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),sr(n,function(n,r,u){t(n,r,u)&&(e[r]=n)});return e},r.pluck=I,r.range=function(n,t,r){n=+n||0,r=+r||1,t==W&&(t=n,n=0); -for(var e=-1,t=It(0,jt((t-n)/r)),u=Array(t);t>++e;)u[e]=n,n+=r;return u},r.reject=function(n,t,r){return t=a(t,r),q(n,function(n,r,e){return!t(n,r,e)})},r.rest=K,r.shuffle=function(n){var t=-1,r=n?n.length:0,e=Array(typeof r=="number"?r:0);return R(n,function(n){var r=Ot(Bt()*(++t+1));e[t]=e[r],e[r]=n}),e},r.sortBy=function(n,t,r){var e=-1,u=n?n.length:0,i=Array(typeof u=="number"?u:0),t=a(t,r);for(R(n,function(n,r,u){i[++e]={a:t(n,r,u),b:e,c:n}}),u=i.length,i.sort(o);u--;)i[u]=i[u].c;return i},r.tap=function(n,t){return t(n),n -},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(r,c)):(clearTimeout(i),i=W,a=f,u=n.apply(o,e)),u}},r.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=t.call(r,e);return u},r.toArray=function(n){return n&&typeof n.length=="number"?nr&&A(n)?n.split(""):v(n):S(n)},r.union=function(){return U(xt.apply(rt,arguments))},r.uniq=U,r.values=S,r.where=function(n,t){var r=gr(t); -return q(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];r>++t;){var i=n[t];u(i)||o.push(i)}return o},r.wrap=function(n,t){return function(){var r=[n];return St.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r=n?D(I(arguments,"length")):0,e=Array(r);r>++t;)e[t]=I(arguments,t);return e},r.collect=F,r.drop=K,r.each=R,r.extend=pr,r.methods=d,r.select=q,r.tail=K,r.unique=U,H(r),r.clone=_,r.cloneDeep=function(n){return _(n,Q) +},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r=X;return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +}),t)},r.isEqual=w,r.isFinite=function(n){return Rt(n)&&!Ft(parseFloat(n))},r.isFunction=j,r.isNaN=function(n){return O(n)&&n!=+n},r.isNull=function(n){return n===W},r.isNumber=O,r.isObject=x,r.isPlainObject=dr,r.isRegExp=function(n){return n instanceof RegExp||$t.call(n)==Ut},r.isString=A,r.isUndefined=function(n){return typeof n=="undefined"},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this },r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t }),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) },r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index e01f87cbc8..4b31944fd2 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,29 +4,29 @@ * Build: `lodash underscore -m -o ./lodash.underscore.min.js` * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,r){function t(n,r){var t;if(n)for(t in r||(r=V),n)if(fr.call(n,t)&&r(n[t],t,n)===Y)break}function e(n,r){var t;if(n)for(t in r||(r=V),n)if(r(n[t],t,n)===Y)break}function u(n,r,t){if(n){var r=r&&t===void 0?r:f(r,t),e=n.length,t=-1;if(typeof e=="number")for(;e>++t&&r(n[t],t,n)!==Y;);else for(t in n)if(fr.call(n,t)&&r(n[t],t,n)===Y)break}}function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function i(n,r){var t=n.b,e=r.b,n=n.a,r=r.a; -if(n!==r){if(n>r||n===void 0)return 1;if(r>n||r===void 0)return-1}return e>t?-1:1}function a(n,r,t){function e(){var u=arguments,o=r;return t.length&&(u=u.length?t.concat(p(u)):t),this instanceof e?(s.prototype=n.prototype,o=new s,s.prototype=J,u=n.apply(o,u),j(u)?u:o):n.apply(o,u)}return e}function f(n,r,t){return n?typeof n!="function"?function(r){return r[n]}:r!==void 0?t?function(t,e,u,o){return n.call(r,t,e,u,o)}:function(t,e,u){return n.call(r,t,e,u)}:n:V}function c(n){return"\\"+Fr[n]}function l(n){return Tr[n] -}function s(){}function p(n,r,t){r||(r=0),t===void 0&&(t=n?n.length:0);for(var e=-1,t=t-r||0,u=Array(0>t?0:t);t>++e;)u[e]=n[r+e];return u}function v(n){return qr[n]}function g(n){if(!n)return n;for(var r=1,t=arguments.length;t>r;r++){var e=arguments[r];if(e)for(var u in e)n[u]=e[u]}return n}function h(n){var r=[];return t(n,function(n,t){r.push(t)}),r}function _(n){if(!n)return n;for(var r=1,t=arguments.length;t>r;r++){var e=arguments[r];if(e)for(var u in e)n[u]==J&&(n[u]=e[u])}return n}function m(n){var r=[]; -return e(n,function(n,t){b(n)&&r.push(t)}),r.sort()}function y(n){for(var r=-1,t=Rr(n),e=t.length,u={};e>++r;){var o=t[r];u[n[o]]=o}return u}function d(n,r,t,u){if(n===r)return 0!==n||1/n==1/r;if(n==J||r==J)return n===r;var o=lr.call(n),i=lr.call(r);if(o!=i)return K;switch(o){case br:case jr:return+n==+r;case wr:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case xr:case Er:return n==r+""}if(i=o==dr,!i){if(n.__wrapped__||r.__wrapped__)return d(n.__wrapped__||n,r.__wrapped__||r);if(o!=Ar)return K;var o=n.constructor,a=r.constructor; -if(!(o==a||b(o)&&o instanceof o&&b(a)&&a instanceof a))return K}for(t||(t=[]),u||(u=[]),o=t.length;o--;)if(t[o]==n)return u[o]==r;var f=H,c=0;if(t.push(n),u.push(r),i){if(c=n.length,f=c==r.length)for(;c--&&(f=d(n[c],r[c],t,u)););return f}return e(n,function(n,e,o){return fr.call(o,e)?(c++,!(f=fr.call(r,e)&&d(n,r[e],t,u))&&Y):void 0}),f&&e(r,function(n,r,t){return fr.call(t,r)?!(f=--c>-1)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?Nr[typeof n]:K}function w(n){return typeof n=="number"||lr.call(n)==wr -}function A(n){return typeof n=="string"||lr.call(n)==Er}function x(n){for(var r=-1,t=Rr(n),e=t.length,u=Array(e);e>++r;)u[r]=n[t[r]];return u}function E(n,r){var t=K;return typeof(n?n.length:0)=="number"?t=I(n,r)>-1:u(n,function(n){return(t=n===r)&&Y}),t}function O(n,r,t){var e=H,r=f(r,t);if(Br(n))for(var t=-1,o=n.length;o>++t&&(e=!!r(n[t],t,n)););else u(n,function(n,t,u){return!(e=!!r(n,t,u))&&Y});return e}function S(n,r,t){var e=[],r=f(r,t);if(Br(n))for(var t=-1,o=n.length;o>++t;){var i=n[t];r(i,t,n)&&e.push(i) -}else u(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function k(n,r,t){var e,r=f(r,t);return N(n,function(n,t,u){return r(n,t,u)?(e=n,Y):void 0}),e}function N(n,r,t){if(r&&t===void 0&&Br(n))for(var t=-1,e=n.length;e>++t&&r(n[t],t,n)!==Y;);else u(n,r,t)}function F(n,r,t){var e=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0),r=f(r,t);if(Br(n))for(;o>++e;)i[e]=r(n[e],e,n);else u(n,function(n,t,u){i[++e]=r(n,t,u)});return i}function R(n,r,t){var e=-1/0,o=e;if(!r&&Br(n))for(var t=-1,i=n.length;i>++t;){var a=n[t]; -a>o&&(o=a)}else r=f(r,t),u(n,function(n,t,u){t=r(n,t,u),t>e&&(e=t,o=n)});return o}function T(n,r){return F(n,r+"")}function q(n,r,t,e){var o=3>arguments.length,r=f(r,e,Y);if(Br(n)){var i=-1,a=n.length;for(o&&(t=n[++i]);a>++i;)t=r(t,n[i],i,n)}else u(n,function(n,e,u){t=o?(o=K,n):r(t,n,e,u)});return t}function B(n,r,t,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Rr(n),u=i.length;return r=f(r,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,t=o?(o=K,n[a]):r(t,n[a],a,f)}),t}function D(n,r,t){var e,r=f(r,t); -if(Br(n))for(var t=-1,o=n.length;o>++t&&!(e=r(n[t],t,n)););else u(n,function(n,t,u){return(e=r(n,t,u))&&Y});return!!e}function M(n,r,t){if(n){var e=n.length;return r==J||t?n[0]:p(n,0,mr(_r(0,r),e))}}function $(n,r){for(var t=-1,e=n?n.length:0,u=[];e>++t;){var o=n[t];Br(o)?cr.apply(u,r?o:$(o)):u.push(o)}return u}function I(n,r,t){var e=-1,u=n?n.length:0;if(typeof t=="number")e=(0>t?_r(0,u+t):t||0)-1;else if(t)return e=C(n,r),n[e]===r?e:-1;for(;u>++e;)if(n[e]===r)return e;return-1}function z(n,r,t){return p(n,r==J||t?1:_r(0,r)) -}function C(n,r,t,e){for(var u=0,o=n?n.length:u,t=t?f(t,e):V,r=t(r);o>u;)e=u+o>>>1,r>t(n[e])?u=e+1:o=e;return u}function P(n,r,t,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof r=="function"&&(e=t,t=r,r=K),t&&(a=[],t=f(t,e));o>++u;){var e=n[u],c=t?t(e,u,n):e;(r?!u||a[a.length-1]!==c:0>I(a,c))&&(t&&a.push(c),i.push(e))}return i}function U(n,r){return Or||sr&&arguments.length>2?sr.call.apply(sr,arguments):a(n,r,p(arguments,2))}function V(n){return n}function G(n){N(m(n),function(r){var t=o[r]=n[r];o.prototype[r]=function(){var n=[this.__wrapped__]; -return cr.apply(n,arguments),n=t.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nr=/&(?:amp|lt|gt|quot|#x27);/g,rr=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),tr=/($^)/,er=/[&<>"']/g,ur=/['\n\r\t\u2028\u2029\\]/g,or=Math.ceil,ir=W.concat,ar=Math.floor,fr=Q.hasOwnProperty,cr=W.push,lr=Q.toString,sr=rr.test(sr=p.bind)&&sr,pr=rr.test(pr=Array.isArray)&&pr,vr=n.isFinite,gr=n.isNaN,hr=rr.test(hr=Object.keys)&&hr,_r=Math.max,mr=Math.min,yr=Math.random,dr="[object Array]",br="[object Boolean]",jr="[object Date]",wr="[object Number]",Ar="[object Object]",xr="[object RegExp]",Er="[object String]",Q=!!n.attachEvent,Q=sr&&!/\n|true/.test(sr+Q),Or=sr&&!Q,Sr=(Sr={0:1,length:1},W.splice.call(Sr,0,1),Sr[0]),kr=arguments.constructor==Object,Nr={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Fr={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lr.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?fr.call(n,"callee"):K});var Rr=hr?function(n){return j(n)?hr(n):[]}:h,Tr={"&":"&","<":"<",">":">",'"':""","'":"'"},qr=y(Tr),Br=pr||function(n){return kr&&n instanceof Array||lr.call(n)==dr};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lr.call(n) -}),o.after=function(n,r){return 1>n?r():function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var r=arguments,t=r.length>1?0:(r=m(n),-1),e=r.length;e>++t;){var u=r[t];n[u]=U(n[u],n)}return n},o.compact=function(n){for(var r=-1,t=n?n.length:0,e=[];t>++r;){var u=n[r];u&&e.push(u)}return e},o.compose=function(){var n=arguments;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}},o.countBy=function(n,r,t){var e={},r=f(r,t);return N(n,function(n,t,u){t=r(n,t,u)+"",fr.call(e,t)?e[t]++:e[t]=1 -}),e},o.debounce=function(n,r,t){function e(){a=J,t||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=t&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,r),f&&(o=n.apply(i,u)),o}},o.defaults=_,o.defer=function(n){var t=p(arguments,1);return setTimeout(function(){n.apply(r,t)},1)},o.delay=function(n,t){var e=p(arguments,2);return setTimeout(function(){n.apply(r,e)},t)},o.difference=function(n){for(var r=-1,t=n.length,e=ir.apply(W,arguments),u=[];t>++r;){var o=n[r];0>I(e,o,t)&&u.push(o) -}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=m,o.groupBy=function(n,r,t){var e={},r=f(r,t);return N(n,function(n,t,u){t=r(n,t,u)+"",(fr.call(e,t)?e[t]:e[t]=[]).push(n)}),e},o.initial=function(n,r,t){if(!n)return[];var e=n.length;return p(n,0,mr(_r(0,e-(r==J||t?1:r||0)),e))},o.intersection=function(n){var r=arguments,t=r.length,e=-1,u=n?n.length:0,o=[];n:for(;u>++e;){var i=n[e];if(0>I(o,i)){for(var a=t;--a;)if(0>I(r[a],i))continue n;o.push(i)}}return o},o.invert=y,o.invoke=function(n,r){var t=p(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return N(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},o.keys=Rr,o.map=F,o.max=R,o.memoize=function(n,r){var t={};return function(){var e=(r?r.apply(this,arguments):arguments[0])+"";return fr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},o.min=function(n,r,t){var e=1/0,o=e;if(!r&&Br(n))for(var t=-1,i=n.length;i>++t;){var a=n[t];o>a&&(o=a)}else r=f(r,t),u(n,function(n,t,u){t=r(n,t,u),e>t&&(e=t,o=n)});return o},o.object=function(n,r){for(var t=-1,e=n?n.length:0,u={};e>++t;){var o=n[t];r?u[o]=r[t]:u[o[0]]=o[1] -}return u},o.omit=function(n){var r=ir.apply(W,arguments),t={};return e(n,function(n,e){0>I(r,e,1)&&(t[e]=n)}),t},o.once=function(n){var r,t=K;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var r=-1,t=Rr(n),e=t.length,u=Array(e);e>++r;){var o=t[r];u[r]=[o,n[o]]}return u},o.pick=function(n){for(var r=0,t=ir.apply(W,arguments),e=t.length,u={};e>++r;){var o=t[r];o in n&&(u[o]=n[o])}return u},o.pluck=T,o.range=function(n,r,t){n=+n||0,t=+t||1,r==J&&(r=n,n=0); -for(var e=-1,r=_r(0,or((r-n)/t)),u=Array(r);r>++e;)u[e]=n,n+=t;return u},o.reject=function(n,r,t){return r=f(r,t),S(n,function(n,t,e){return!r(n,t,e)})},o.rest=z,o.shuffle=function(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return N(n,function(n){var t=ar(yr()*(++r+1));e[r]=e[t],e[t]=n}),e},o.sortBy=function(n,r,t){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0),r=f(r,t);for(N(n,function(n,t,u){o[++e]={a:r(n,t,u),b:e,c:n}}),u=o.length,o.sort(i);u--;)o[u]=o[u].c;return o},o.tap=function(n,r){return r(n),n -},o.throttle=function(n,r){function t(){a=new Date,i=J,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=r-(f-a);return e=arguments,o=this,c>0?i||(i=setTimeout(t,c)):(clearTimeout(i),i=J,a=f,u=n.apply(o,e)),u}},o.times=function(n,r,t){for(var n=+n||0,e=-1,u=Array(n);n>++e;)u[e]=r.call(t,e);return u},o.toArray=function(n){return n&&typeof n.length=="number"?p(n):x(n)},o.union=function(){return P(ir.apply(W,arguments))},o.uniq=P,o.values=x,o.where=function(n,r){var t=Rr(r);return S(n,function(n){for(var e=t.length;e--;){var u=n[t[e]]===r[t[e]]; -if(!u)break}return!!u})},o.without=function(n){for(var r=-1,t=n.length,e=[];t>++r;){var u=n[r];0>I(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,r){return function(){var t=[n];return cr.apply(t,arguments),r.apply(this,t)}},o.zip=function(n){for(var r=-1,t=n?R(T(arguments,"length")):0,e=Array(t);t>++r;)e[r]=T(arguments,r);return e},o.collect=F,o.drop=z,o.each=N,o.extend=g,o.methods=m,o.select=S,o.tail=z,o.unique=P,o.clone=function(n){return n&&Nr[typeof n]?Br(n)?p(n):g({},n):n},o.contains=E,o.escape=function(n){return n==J?"":(n+"").replace(er,l) -},o.every=O,o.find=k,o.has=function(n,r){return n?fr.call(n,r):K},o.identity=V,o.indexOf=I,o.isArray=Br,o.isBoolean=function(n){return n===H||n===K||lr.call(n)==br},o.isDate=function(n){return n instanceof Date||lr.call(n)==jr},o.isElement=function(n){return n?1===n.nodeType:K},o.isEmpty=function(n){if(!n)return H;if(Br(n)||A(n))return!n.length;for(var r in n)if(fr.call(n,r))return K;return H},o.isEqual=d,o.isFinite=function(n){return vr(n)&&!gr(parseFloat(n))},o.isFunction=b,o.isNaN=function(n){return w(n)&&n!=+n -},o.isNull=function(n){return n===J},o.isNumber=w,o.isObject=j,o.isRegExp=function(n){return n instanceof RegExp||lr.call(n)==xr},o.isString=A,o.isUndefined=function(n){return n===void 0},o.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?_r(0,e+t):mr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,r){return n==J&&r==J&&(r=1),n=+n||0,r==J&&(r=n,n=0),n+ar(yr()*((+r||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,r){var t=n?n[r]:J; -return b(t)?n[r]():t},o.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Rr(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,r,t){n||(n="");var t=_({},t,o.templateSettings),e=0,u="__p+='",i=t.variable;n.replace(RegExp((t.escape||tr).source+"|"+(t.interpolate||tr).source+"|"+(t.evaluate||tr).source+"|$","g"),function(r,t,o,i,a){u+=n.slice(e,a).replace(ur,c),u+=t?"'+_['escape']("+t+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+r.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; -try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return r?a(r):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nr,v)},o.uniqueId=function(n){var r=++X+"";return n?n+r:r},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,r,t){if(n){var e=n.length;return r==J||t?n[e-1]:p(n,_r(0,e-r))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this -},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var r=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Sr&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var r=W[n];o.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o +;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&typeof r=="undefined"?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=Rt(n),u=i.length; +return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1; +else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) +}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o) +}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,_t(yt(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return N(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J; +return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; +try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,yt(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this +},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o })(this); \ No newline at end of file From 05cf5bc8dbd4233f0ab813570972616b3c0a0f65 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 27 Dec 2012 09:53:14 -0600 Subject: [PATCH 035/176] Defer downloading required minifies until the `lodash` command-line executable is used for the first time. Former-commit-id: 83df0ac5875e8647168fffb7043a4cc197d27d79 --- build/minify.js | 155 ++++++++++++++++++++++++++++++++++++++---- build/post-install.js | 135 ------------------------------------ package.json | 3 +- 3 files changed, 141 insertions(+), 152 deletions(-) delete mode 100644 build/post-install.js diff --git a/build/minify.js b/build/minify.js index 794a5a805a..904301d083 100755 --- a/build/minify.js +++ b/build/minify.js @@ -2,26 +2,56 @@ ;(function() { 'use strict'; - /** The Node filesystem, path, `zlib`, and child process modules */ + /** Load Node modules */ var fs = require('fs'), - gzip = require('zlib').gzip, + https = require('https'), path = require('path'), - spawn = require('child_process').spawn; + spawn = require('child_process').spawn, + tar = require('../vendor/tar/tar.js'), + zlib = require('zlib'); + + /** Load other modules */ + var preprocess = require('./pre-compile.js'), + postprocess = require('./post-compile.js'); + + /** The Git object ID of `closure-compiler.tar.gz` */ + var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; + + /** The Git object ID of `uglifyjs.tar.gz` */ + var uglifyId = '505f1be36ef60fd25a992a522f116d5179ab317f'; /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); - /** The path of the directory where the Closure Compiler is located */ - var closurePath = path.join(basePath, 'vendor', 'closure-compiler', 'compiler.jar'); + /** The path of the `vendor` directory */ + var vendorPath = path.join(basePath, 'vendor'); - /** Load other modules */ - var preprocess = require('./pre-compile.js'), - postprocess = require('./post-compile.js'), - uglifyJS = require('../vendor/uglifyjs/tools/node.js'); + /** The path to the Closure Compiler `.jar` */ + var closurePath = path.join(vendorPath, 'closure-compiler', 'compiler.jar'); + + /** The path to the UglifyJS module */ + var uglifyPath = path.join(vendorPath, 'uglifyjs', 'tools', 'node.js'); /** The Closure Compiler command-line options */ var closureOptions = ['--warning_level=QUIET']; + /** The media type for raw blob data */ + var mediaType = 'application/vnd.github.v3.raw'; + + /** Used to reference parts of the blob href */ + var location = (function() { + var host = 'api.github.com', + origin = 'https://api.github.com', + pathname = '/repos/bestiejs/lodash/git/blobs'; + + return { + 'host': host, + 'href': origin + pathname, + 'origin': origin, + 'pathname': pathname + }; + }()); + /** The Closure Compiler optimization modes */ var optimizationModes = { 'simple': 'SIMPLE_OPTIMIZATIONS', @@ -79,7 +109,30 @@ source = fs.readFileSync(filePath, 'utf8'); } - new Minify(source, options); + // fetch the Closure Compiler + getDependency({ + 'id': 'closure-compiler', + 'hashId': closureId, + 'path': vendorPath, + 'title': 'the Closure Compiler', + 'onComplete': function(exception) { + var error = exception; + + // fetch UglifyJS + getDependency({ + 'id': 'uglifyjs', + 'hashId': uglifyId, + 'title': 'UglifyJS', + 'path': vendorPath, + 'onComplete': function(exception) { + error || (error = exception); + if (!error) { + new Minify(source, options); + } + } + }); + } + }); } /** @@ -121,6 +174,76 @@ /*--------------------------------------------------------------------------*/ + /** + * Fetches a required `.tar.gz` dependency with the given Git object ID from + * the Lo-Dash repo on GitHub. The object ID may be obtained by running + * `git hash-object path/to/dependency.tar.gz`. + * + * @private + * @param {Object} options The options object. + * id - The Git object ID of the `.tar.gz` file. + * onComplete - The function, invoked with one argument (exception), + * called once the extraction has finished. + * path - The path of the extraction directory. + * title - The dependency's title used in status updates logged to the console. + */ + function getDependency(options) { + options || (options = {}); + + var ran, + destPath = options.path, + hashId = options.hashId, + id = options.id, + onComplete = options.onComplete, + title = options.title; + + // exit early if dependency exists + if (fs.existsSync(path.join(destPath, id))) { + onComplete(); + return; + } + var callback = function(exception) { + if (ran) { + return; + } + if (exception) { + console.error([ + 'There was a problem installing ' + title + '.', + 'Try running the command as root, via `sudo`, or manually install by running:', + '', + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + hashId + " | tar xvz -C '" + destPath + "'", + '' + ].join('\n')); + } + ran = true; + process.removeListener('uncaughtException', callback); + onComplete(exception); + }; + + console.log('Downloading ' + title + '...'); + process.on('uncaughtException', callback); + + https.get({ + 'host': location.host, + 'path': location.pathname + '/' + hashId, + 'headers': { + // By default, all GitHub blob API endpoints return a JSON document + // containing Base64-encoded blob data. Overriding the `Accept` header + // with the GitHub raw media type returns the blob data directly. + // See http://developer.github.com/v3/media/. + 'Accept': mediaType + } + }, function(response) { + var decompressor = zlib.createUnzip(), + parser = new tar.Extract({ 'path': destPath }); + + parser.on('end', callback); + response.pipe(decompressor).pipe(parser); + }); + } + + /*--------------------------------------------------------------------------*/ + /** * Compresses a `source` string using the Closure Compiler. Yields the * minified result, and any exceptions encountered, to a `callback` function. @@ -181,6 +304,8 @@ console.log('Compressing ' + path.basename(this.outputPath, '.js') + ' using ' + label + '...'); } try { + var uglifyJS = require(uglifyPath); + // 1. parse var toplevel = uglifyJS.parse(source); @@ -232,7 +357,7 @@ } result = postprocess(result); this.compiled.simple.source = result; - gzip(result, onClosureSimpleGzip.bind(this)); + zlib.gzip(result, onClosureSimpleGzip.bind(this)); } /** @@ -268,7 +393,7 @@ } result = postprocess(result); this.compiled.advanced.source = result; - gzip(result, onClosureAdvancedGzip.bind(this)); + zlib.gzip(result, onClosureAdvancedGzip.bind(this)); } /** @@ -304,7 +429,7 @@ } result = postprocess(result); this.uglified.source = result; - gzip(result, onUglifyGzip.bind(this)); + zlib.gzip(result, onUglifyGzip.bind(this)); } /** @@ -340,7 +465,7 @@ } result = postprocess(result); this.hybrid.simple.source = result; - gzip(result, onSimpleHybridGzip.bind(this)); + zlib.gzip(result, onSimpleHybridGzip.bind(this)); } /** @@ -376,7 +501,7 @@ } result = postprocess(result); this.hybrid.advanced.source = result; - gzip(result, onAdvancedHybridGzip.bind(this)); + zlib.gzip(result, onAdvancedHybridGzip.bind(this)); } /** diff --git a/build/post-install.js b/build/post-install.js deleted file mode 100644 index b83dd1fb9d..0000000000 --- a/build/post-install.js +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** Load Node modules */ - var fs = require('fs'), - path = require('path'); - - /** The path of the directory that is the base of the repository */ - var basePath = fs.realpathSync(path.join(__dirname, '..')); - - /** The path of the `vendor` directory */ - var vendorPath = path.join(basePath, 'vendor'); - - /** The Git object ID of `closure-compiler.tar.gz` */ - var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; - - /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '505f1be36ef60fd25a992a522f116d5179ab317f'; - - /** The media type for raw blob data */ - var mediaType = 'application/vnd.github.v3.raw'; - - /** Used to reference parts of the blob href */ - var location = (function() { - var host = 'api.github.com', - origin = 'https://api.github.com', - pathname = '/repos/bestiejs/lodash/git/blobs'; - - return { - 'host': host, - 'href': origin + pathname, - 'origin': origin, - 'pathname': pathname - }; - }()); - - /*--------------------------------------------------------------------------*/ - - /** - * Fetches a required `.tar.gz` dependency with the given Git object ID from - * the Lo-Dash repo on GitHub. The object ID may be obtained by running - * `git hash-object path/to/dependency.tar.gz`. - * - * @private - * @param {Object} options The options object. - * id - The Git object ID of the `.tar.gz` file. - * onComplete - The function, invoked with one argument (exception), - * called once the extraction has finished. - * path - The path of the extraction directory. - * title - The dependency's title used in status updates logged to the console. - */ - function getDependency(options) { - options || (options = {}); - - var id = options.id, - onComplete = options.onComplete, - path = options.path, - title = options.title; - - function callback(exception) { - if (exception) { - console.error([ - 'There was a problem installing ' + title + '. To manually install, run:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + id + " | tar xvz -C '" + path + "'" - ].join('\n')); - } - onComplete(exception); - } - - console.log('Downloading ' + title + '...'); - - https.get({ - 'host': location.host, - 'path': location.pathname + '/' + id, - 'headers': { - // By default, all GitHub blob API endpoints return a JSON document - // containing Base64-encoded blob data. Overriding the `Accept` header - // with the GitHub raw media type returns the blob data directly. - // See http://developer.github.com/v3/media/. - 'Accept': mediaType - } - }, function(response) { - var decompressor = zlib.createUnzip(), - parser = new tar.Extract({ 'path': path }); - - decompressor.on('error', callback); - parser.on('end', callback).on('error', callback); - response.pipe(decompressor).pipe(parser); - }) - .on('error', callback); - } - - /*--------------------------------------------------------------------------*/ - - if (process.env.npm_config_global === 'true') { - // catch module load errors - try { - var https = require('https'), - tar = require('../vendor/tar/tar.js'), - zlib = require('zlib'); - - // download the Closure Compiler - getDependency({ - 'title': 'the Closure Compiler', - 'id': closureId, - 'path': vendorPath, - 'onComplete': function() { - // download UglifyJS - getDependency({ - 'title': 'UglifyJS', - 'id': uglifyId, - 'path': vendorPath, - 'onComplete': function() { - process.exit(); - } - }); - } - }); - } catch(e) { - console.log([ - 'Oops! There was a problem installing dependencies required by the Lo-Dash', - 'command-line executable. To manually install UglifyJS and the Closure Compiler', - 'run:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", - '' - ].join('\n')); - - console.log(e); - } - } -}()); diff --git a/package.json b/package.json index ef471b85cf..f0e2776d9e 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ }, "scripts": { "build": "node ./build.js", - "test": "node ./test/test.js && node ./test/test-build.js", - "install": "node ./build/post-install.js" + "test": "node ./test/test.js && node ./test/test-build.js" } } From 8ec7b84a7873f23e3a5c7546b941321e9d1e7631 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 27 Dec 2012 09:54:41 -0600 Subject: [PATCH 036/176] Remove unneeded default `ran` value from `_.once`. Former-commit-id: 4d4fc057c0cf9108183e7e7158f305214eed4323 --- lodash.js | 4 ++-- lodash.min.js | 2 +- lodash.underscore.js | 4 ++-- lodash.underscore.min.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lodash.js b/lodash.js index 32452ba040..405fb93b65 100644 --- a/lodash.js +++ b/lodash.js @@ -3670,8 +3670,8 @@ * // Application is only created once. */ function once(func) { - var result, - ran = false; + var ran, + result; return function() { if (ran) { diff --git a/lodash.min.js b/lodash.min.js index e352430f29..8d30ffda9f 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -26,7 +26,7 @@ return t[0]}},r.countBy=function(n,t,r){var e={},t=a(t,r);return R(n,function(n, },r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r=X;return function(){return r?t:(r=Q,t=n.apply(this,arguments),n=W,t)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpo }),e},o.debounce=function(n,t,r){function e(){a=J,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,clearTimeout(a),a=setTimeout(e,t),f&&(o=n.apply(i,u)),o}},o.defaults=y,o.defer=function(n){var r=p(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},o.delay=function(n,r){var e=p(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},o.difference=function(n){for(var t=-1,r=n.length,e=it.apply(W,arguments),u=[];++tI(e,o,r)&&u.push(o) }return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,_t(yt(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); return N(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r=K;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++t Date: Fri, 28 Dec 2012 19:47:44 -0600 Subject: [PATCH 037/176] Update vendors. Former-commit-id: baf89d2c3bd7077462995bffa7f8bff1e1cf28f9 --- vendor/backbone/backbone.js | 409 ++++++++++++-------------- vendor/backbone/test/collection.js | 79 ++++- vendor/backbone/test/events.js | 28 +- vendor/backbone/test/model.js | 290 ++++++++++++------ vendor/backbone/test/router.js | 22 +- vendor/backbone/test/view.js | 16 - vendor/underscore/test/arrays.js | 2 +- vendor/underscore/test/collections.js | 2 +- vendor/underscore/test/objects.js | 4 +- vendor/underscore/test/utility.js | 20 +- vendor/underscore/underscore-min.js | 2 +- vendor/underscore/underscore.js | 2 +- 12 files changed, 497 insertions(+), 379 deletions(-) diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index f4cfabd26b..dd262c8359 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -160,7 +160,8 @@ if (callback || context) { for (j = 0, k = list.length; j < k; j++) { ev = list[j]; - if ((callback && callback !== (ev.callback._callback || ev.callback)) || + if ((callback && callback !== ev.callback && + callback !== ev.callback._callback) || (context && context !== ev.context)) { events.push(ev); } @@ -190,27 +191,25 @@ // An inversion-of-control version of `on`. Tell *this* object to listen to // an event in another object ... keeping track of what it's listening to. - listenTo: function(object, events, callback, context) { - context = context || this; + listenTo: function(object, events, callback) { var listeners = this._listeners || (this._listeners = {}); var id = object._listenerId || (object._listenerId = _.uniqueId('l')); listeners[id] = object; - object.on(events, callback || context, context); + object.on(events, callback || this, this); return this; }, // Tell this object to stop listening to either specific events ... or // to every object it's currently listening to. - stopListening: function(object, events, callback, context) { - context = context || this; + stopListening: function(object, events, callback) { var listeners = this._listeners; if (!listeners) return; if (object) { - object.off(events, callback, context); + object.off(events, callback, this); if (!events && !callback) delete listeners[object._listenerId]; } else { for (var id in listeners) { - listeners[id].off(null, null, context); + listeners[id].off(null, null, this); } this._listeners = {}; } @@ -235,15 +234,14 @@ var defaults; var attrs = attributes || {}; this.cid = _.uniqueId('c'); - this.changed = {}; this.attributes = {}; - this._changes = []; if (options && options.collection) this.collection = options.collection; - if (options && options.parse) attrs = this.parse(attrs, options); - if (defaults = _.result(this, 'defaults')) _.defaults(attrs, defaults); - this.set(attrs, {silent: true}); - this._currentAttributes = _.clone(this.attributes); - this._previousAttributes = _.clone(this.attributes); + if (options && options.parse) attrs = this.parse(attrs, options) || {}; + if (defaults = _.result(this, 'defaults')) { + attrs = _.defaults({}, attrs, defaults); + } + this.set(attrs, options); + this.changed = {}; this.initialize.apply(this, arguments); }; @@ -287,47 +285,72 @@ return this.get(attr) != null; }, + // ---------------------------------------------------------------------- + // Set a hash of model attributes on the object, firing `"change"` unless // you choose to silence it. set: function(key, val, options) { - var attr, attrs; + var attr, attrs, unset, changes, silent, changing, prev, current; if (key == null) return this; // Handle both `"key", value` and `{key: value}` -style arguments. - if (_.isObject(key)) { + if (typeof key === 'object') { attrs = key; options = val; } else { (attrs = {})[key] = val; } - // Extract attributes and options. - var silent = options && options.silent; - var unset = options && options.unset; + options || (options = {}); // Run validation. if (!this._validate(attrs, options)) return false; + // Extract attributes and options. + unset = options.unset; + silent = options.silent; + changes = []; + changing = this._changing; + this._changing = true; + + if (!changing) { + this._previousAttributes = _.clone(this.attributes); + this.changed = {}; + } + current = this.attributes, prev = this._previousAttributes; + // Check for changes of `id`. if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; - var now = this.attributes; - - // For each `set` attribute... + // For each `set` attribute, update or delete the current value. for (attr in attrs) { val = attrs[attr]; - - // Update or delete the current value, and track the change. - unset ? delete now[attr] : now[attr] = val; - this._changes.push(attr, val); + if (!_.isEqual(current[attr], val)) changes.push(attr); + if (!_.isEqual(prev[attr], val)) { + this.changed[attr] = val; + } else { + delete this.changed[attr]; + } + unset ? delete current[attr] : current[attr] = val; } - // Signal that the model's state has potentially changed, and we need - // to recompute the actual changes. - this._hasComputed = false; + // Trigger all relevant attribute changes. + if (!silent) { + if (changes.length) this._pending = true; + for (var i = 0, l = changes.length; i < l; i++) { + this.trigger('change:' + changes[i], this, current[changes[i]], options); + } + } - // Fire the `"change"` events. - if (!silent) this.change(options); + if (changing) return this; + if (!silent) { + while (this._pending) { + this._pending = false; + this.trigger('change', this, options); + } + } + this._pending = false; + this._changing = false; return this; }, @@ -345,15 +368,53 @@ return this.set(attrs, _.extend({}, options, {unset: true})); }, + // Determine if the model has changed since the last `"change"` event. + // If you specify an attribute name, determine if that attribute has changed. + hasChanged: function(attr) { + if (attr == null) return !_.isEmpty(this.changed); + return _.has(this.changed, attr); + }, + + // Return an object containing all the attributes that have changed, or + // false if there are no changed attributes. Useful for determining what + // parts of a view need to be updated and/or what attributes need to be + // persisted to the server. Unset attributes will be set to undefined. + // You can also pass an attributes object to diff against the model, + // determining if there *would be* a change. + changedAttributes: function(diff) { + if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; + var val, changed = false; + var old = this._changing ? this._previousAttributes : this.attributes; + for (var attr in diff) { + if (_.isEqual(old[attr], (val = diff[attr]))) continue; + (changed || (changed = {}))[attr] = val; + } + return changed; + }, + + // Get the previous value of an attribute, recorded at the time the last + // `"change"` event was fired. + previous: function(attr) { + if (attr == null || !this._previousAttributes) return null; + return this._previousAttributes[attr]; + }, + + // Get all of the attributes of the model at the time of the previous + // `"change"` event. + previousAttributes: function() { + return _.clone(this._previousAttributes); + }, + + // --------------------------------------------------------------------- + // Fetch the model from the server. If the server's representation of the // model differs from its current attributes, they will be overriden, // triggering a `"change"` event. fetch: function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) options.parse = true; - var model = this; var success = options.success; - options.success = function(resp, status, xhr) { + options.success = function(model, resp, options) { if (!model.set(model.parse(resp, options), options)) return false; if (success) success(model, resp, options); }; @@ -364,55 +425,50 @@ // If the server returns an attributes hash that differs, the model's // state will be `set` again. save: function(key, val, options) { - var attrs, current, done; + var attrs, model, success, method, xhr, attributes = this.attributes; // Handle both `"key", value` and `{key: value}` -style arguments. - if (key == null || _.isObject(key)) { + if (key == null || typeof key === 'object') { attrs = key; options = val; - } else if (key != null) { + } else { (attrs = {})[key] = val; } - options = options ? _.clone(options) : {}; - // If we're "wait"-ing to set changed attributes, validate early. - if (options.wait) { - if (attrs && !this._validate(attrs, options)) return false; - current = _.clone(this.attributes); - } + // If we're not waiting and attributes exist, save acts as `set(attr).save(null, opts)`. + if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false; - // Regular saves `set` attributes before persisting to the server. - var silentOptions = _.extend({}, options, {silent: true}); - if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) { - return false; - } + options = _.extend({validate: true}, options); // Do not persist invalid models. - if (!attrs && !this._validate(null, options)) return false; + if (!this._validate(attrs, options)) return false; + + // Set temporary attributes if `{wait: true}`. + if (attrs && options.wait) { + this.attributes = _.extend({}, attributes, attrs); + } // After a successful server-side save, the client is (optionally) // updated with the server-side state. - var model = this; - var success = options.success; - options.success = function(resp, status, xhr) { - done = true; + success = options.success; + options.success = function(model, resp, options) { + // Ensure attributes are restored during synchronous saves. + model.attributes = attributes; var serverAttrs = model.parse(resp, options); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); - if (!model.set(serverAttrs, options)) return false; + if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { + return false; + } if (success) success(model, resp, options); }; // Finish configuring and sending the Ajax request. - var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); + method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); if (method == 'patch') options.attrs = attrs; - var xhr = this.sync(method, this, options); + xhr = this.sync(method, this, options); - // When using `wait`, reset attributes to original values unless - // `success` has been called already. - if (!done && options.wait) { - this.clear(silentOptions); - this.set(current, silentOptions); - } + // Restore attributes. + if (attrs && options.wait) this.attributes = attributes; return xhr; }, @@ -429,13 +485,13 @@ model.trigger('destroy', model, model.collection, options); }; - options.success = function(resp) { + options.success = function(model, resp, options) { if (options.wait || model.isNew()) destroy(); if (success) success(model, resp, options); }; if (this.isNew()) { - options.success(); + options.success(this, null, options); return false; } @@ -469,115 +525,20 @@ return this.id == null; }, - // Call this method to manually fire a `"change"` event for this model and - // a `"change:attribute"` event for each changed attribute. - // Calling this will cause all objects observing the model to update. - change: function(options) { - var changing = this._changing; - this._changing = true; - - // Generate the changes to be triggered on the model. - var triggers = this._computeChanges(true); - - this._pending = !!triggers.length; - - for (var i = triggers.length - 2; i >= 0; i -= 2) { - this.trigger('change:' + triggers[i], this, triggers[i + 1], options); - } - - if (changing) return this; - - // Trigger a `change` while there have been changes. - while (this._pending) { - this._pending = false; - this.trigger('change', this, options); - this._previousAttributes = _.clone(this.attributes); - } - - this._changing = false; - return this; - }, - - // Determine if the model has changed since the last `"change"` event. - // If you specify an attribute name, determine if that attribute has changed. - hasChanged: function(attr) { - if (!this._hasComputed) this._computeChanges(); - if (attr == null) return !_.isEmpty(this.changed); - return _.has(this.changed, attr); - }, - - // Return an object containing all the attributes that have changed, or - // false if there are no changed attributes. Useful for determining what - // parts of a view need to be updated and/or what attributes need to be - // persisted to the server. Unset attributes will be set to undefined. - // You can also pass an attributes object to diff against the model, - // determining if there *would be* a change. - changedAttributes: function(diff) { - if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; - var val, changed = false, old = this._previousAttributes; - for (var attr in diff) { - if (_.isEqual(old[attr], (val = diff[attr]))) continue; - (changed || (changed = {}))[attr] = val; - } - return changed; - }, - - // Looking at the built up list of `set` attribute changes, compute how - // many of the attributes have actually changed. If `loud`, return a - // boiled-down list of only the real changes. - _computeChanges: function(loud) { - this.changed = {}; - var already = {}; - var triggers = []; - var current = this._currentAttributes; - var changes = this._changes; - - // Loop through the current queue of potential model changes. - for (var i = changes.length - 2; i >= 0; i -= 2) { - var key = changes[i], val = changes[i + 1]; - if (already[key]) continue; - already[key] = true; - - // Check if the attribute has been modified since the last change, - // and update `this.changed` accordingly. If we're inside of a `change` - // call, also add a trigger to the list. - if (!_.isEqual(current[key], val)) { - this.changed[key] = val; - if (!loud) continue; - triggers.push(key, val); - current[key] = val; - } - } - if (loud) this._changes = []; - - // Signals `this.changed` is current to prevent duplicate calls from `this.hasChanged`. - this._hasComputed = true; - return triggers; - }, - - // Get the previous value of an attribute, recorded at the time the last - // `"change"` event was fired. - previous: function(attr) { - if (attr == null || !this._previousAttributes) return null; - return this._previousAttributes[attr]; - }, - - // Get all of the attributes of the model at the time of the previous - // `"change"` event. - previousAttributes: function() { - return _.clone(this._previousAttributes); + // Check if the model is currently in a valid state. + isValid: function(options) { + return !this.validate || !this.validate(this.attributes, options); }, // Run validation against the next complete set of model attributes, // returning `true` if all is well. Otherwise, fire a general // `"error"` event and call the error callback, if specified. _validate: function(attrs, options) { - if (!this.validate) return true; + if (!options.validate || !this.validate) return true; attrs = _.extend({}, this.attributes, attrs); - var error = this.validate(attrs, options); + var error = this.validationError = this.validate(attrs, options) || null; if (!error) return true; - if (options && options.error) options.error(this, error, options); - this.trigger('error', this, error, options); + this.trigger('invalid', this, error, options || {}); return false; } @@ -620,20 +581,22 @@ return Backbone.sync.apply(this, arguments); }, - // Add a model, or list of models to the set. Pass **silent** to avoid - // firing the `add` event for every new model. + // Add a model, or list of models to the set. add: function(models, options) { - var i, args, length, model, existing, needsSort; - var at = options && options.at; - var sort = ((options && options.sort) == null ? true : options.sort); models = _.isArray(models) ? models.slice() : [models]; + options || (options = {}); + var i, l, model, attrs, existing, sort, doSort, sortAttr, at, add; + add = []; + at = options.at; + sort = this.comparator && (at == null) && (options.sort == null || options.sort); + sortAttr = _.isString(this.comparator) ? this.comparator : null; // Turn bare objects into model references, and prevent invalid models // from being added. - for (i = models.length - 1; i >= 0; i--) { - if(!(model = this._prepareModel(models[i], options))) { - this.trigger("error", this, models[i], options); - models.splice(i, 1); + for (i = 0, l = models.length; i < l; i++) { + attrs = models[i]; + if(!(model = this._prepareModel(attrs, options))) { + this.trigger('invalid', this, attrs, options); continue; } models[i] = model; @@ -641,14 +604,16 @@ // If a duplicate is found, prevent it from being added and // optionally merge it into the existing model. if (existing = this.get(model)) { - if (options && options.merge) { - existing.set(model.attributes, options); - needsSort = sort; + if (options.merge) { + existing.set(attrs === model ? model.attributes : attrs, options); + if (sort && !doSort && existing.hasChanged(sortAttr)) doSort = true; } - models.splice(i, 1); continue; } + // This is a new model, push it to the `add` list. + add.push(model); + // Listen to added models' events, and index models for lookup by // `id` and by `cid`. model.on('all', this._onModelEvent, this); @@ -657,31 +622,37 @@ } // See if sorting is needed, update `length` and splice in new models. - if (models.length) needsSort = sort; - this.length += models.length; - args = [at != null ? at : this.models.length, 0]; - push.apply(args, models); - splice.apply(this.models, args); + if (add.length) { + if (sort) doSort = true; + this.length += add.length; + if (at != null) { + splice.apply(this.models, [at, 0].concat(add)); + } else { + push.apply(this.models, add); + } + } - // Sort the collection if appropriate. - if (needsSort && this.comparator && at == null) this.sort({silent: true}); + // Silently sort the collection if appropriate. + if (doSort) this.sort({silent: true}); - if (options && options.silent) return this; + if (options.silent) return this; // Trigger `add` events. - while (model = models.shift()) { - model.trigger('add', model, this, options); + for (i = 0, l = add.length; i < l; i++) { + (model = add[i]).trigger('add', model, this, options); } + // Trigger `sort` if the collection was sorted. + if (doSort) this.trigger('sort', this, options); + return this; }, - // Remove a model, or a list of models from the set. Pass silent to avoid - // firing the `remove` event for every model removed. + // Remove a model, or a list of models from the set. remove: function(models, options) { - var i, l, index, model; - options || (options = {}); models = _.isArray(models) ? models.slice() : [models]; + options || (options = {}); + var i, l, index, model; for (i = 0, l = models.length; i < l; i++) { model = this.get(models[i]); if (!model) continue; @@ -762,14 +733,16 @@ if (!this.comparator) { throw new Error('Cannot sort a set without a comparator'); } + options || (options = {}); + // Run sort based on type of `comparator`. if (_.isString(this.comparator) || this.comparator.length === 1) { this.models = this.sortBy(this.comparator, this); } else { this.models.sort(_.bind(this.comparator, this)); } - if (!options || !options.silent) this.trigger('sort', this, options); + if (!options.silent) this.trigger('sort', this, options); return this; }, @@ -781,10 +754,10 @@ // Smartly update a collection with a change set of models, adding, // removing, and merging as necessary. update: function(models, options) { - var model, i, l, existing; - var add = [], remove = [], modelMap = {}; options = _.extend({add: true, merge: true, remove: true}, options); if (options.parse) models = this.parse(models, options); + var model, i, l, existing; + var add = [], remove = [], modelMap = {}; // Allow a single model (or no argument) to be passed. if (!_.isArray(models)) models = models ? [models] : []; @@ -836,9 +809,8 @@ fetch: function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) options.parse = true; - var collection = this; var success = options.success; - options.success = function(resp, status, xhr) { + options.success = function(collection, resp, options) { var method = options.update ? 'update' : 'reset'; collection[method](resp, options); if (success) success(collection, resp, options); @@ -850,9 +822,9 @@ // collection immediately, unless `wait: true` is passed, in which case we // wait for the server to agree. create: function(model, options) { - var collection = this; options = options ? _.clone(options) : {}; model = this._prepareModel(model, options); + var collection = this; if (!model) return false; if (!options.wait) collection.add(model, options); var success = options.success; @@ -929,7 +901,7 @@ 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', 'max', 'min', 'sortedIndex', 'toArray', 'size', 'first', 'head', 'take', - 'initial', 'rest', 'tail', 'last', 'without', 'indexOf', 'shuffle', + 'initial', 'rest', 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf', 'isEmpty']; // Mix in each Underscore method as a proxy to `Collection#models`. @@ -969,7 +941,7 @@ // Cached regular expressions for matching named param parts and splatted // parts of route strings. var optionalParam = /\((.*?)\)/g; - var namedParam = /:\w+/g; + var namedParam = /(\(\?)?:\w+/g; var splatParam = /\*\w+/g; var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; @@ -1020,7 +992,9 @@ _routeToRegExp: function(route) { route = route.replace(escapeRegExp, '\\$&') .replace(optionalParam, '(?:$1)?') - .replace(namedParam, '([^\/]+)') + .replace(namedParam, function(match, optional){ + return optional ? match : '([^\/]+)'; + }) .replace(splatParam, '(.*?)'); return new RegExp('^' + route + '$'); }, @@ -1121,9 +1095,9 @@ // Depending on whether we're using pushState or hashes, and whether // 'onhashchange' is supported, determine how we check the URL state. if (this._hasPushState) { - Backbone.$(window).bind('popstate', this.checkUrl); + Backbone.$(window).on('popstate', this.checkUrl); } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { - Backbone.$(window).bind('hashchange', this.checkUrl); + Backbone.$(window).on('hashchange', this.checkUrl); } else if (this._wantsHashChange) { this._checkUrlInterval = setInterval(this.checkUrl, this.interval); } @@ -1155,7 +1129,7 @@ // Disable Backbone.history, perhaps temporarily. Not useful in a real app, // but possibly useful for unit testing Routers. stop: function() { - Backbone.$(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl); + Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl); clearInterval(this._checkUrlInterval); History.started = false; }, @@ -1298,18 +1272,6 @@ return this; }, - // For small amounts of DOM Elements, where a full-blown template isn't - // needed, use **make** to manufacture elements, one at a time. - // - // var el = this.make('li', {'class': 'row'}, this.model.escape('title')); - // - make: function(tagName, attributes, content) { - var el = document.createElement(tagName); - if (attributes) Backbone.$(el).attr(attributes); - if (content != null) Backbone.$(el).html(content); - return el; - }, - // Change the view's element (`this.el` property), including event // re-delegation. setElement: function(element, delegate) { @@ -1347,9 +1309,9 @@ method = _.bind(method, this); eventName += '.delegateEvents' + this.cid; if (selector === '') { - this.$el.bind(eventName, method); + this.$el.on(eventName, method); } else { - this.$el.delegate(selector, eventName, method); + this.$el.on(eventName, selector, method); } } }, @@ -1358,7 +1320,7 @@ // You usually don't need to use this, but may wish to if you have multiple // Backbone views attached to the same DOM element. undelegateEvents: function() { - this.$el.unbind('.delegateEvents' + this.cid); + this.$el.off('.delegateEvents' + this.cid); }, // Performs the initial configuration of a View with a set of options. @@ -1379,7 +1341,8 @@ var attrs = _.extend({}, _.result(this, 'attributes')); if (this.id) attrs.id = _.result(this, 'id'); if (this.className) attrs['class'] = _.result(this, 'className'); - this.setElement(this.make(_.result(this, 'tagName'), attrs), false); + var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); + this.setElement($el, false); } else { this.setElement(_.result(this, 'el'), false); } @@ -1461,13 +1424,13 @@ } var success = options.success; - options.success = function(resp, status, xhr) { - if (success) success(resp, status, xhr); + options.success = function(resp) { + if (success) success(model, resp, options); model.trigger('sync', model, resp, options); }; var error = options.error; - options.error = function(xhr, status, thrown) { + options.error = function(xhr) { if (error) error(model, xhr, options); model.trigger('error', model, xhr, options); }; diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index 28b857a444..0bca07d945 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -82,7 +82,7 @@ $(document).ready(function() { equal(col.get(101), model); var Col2 = Backbone.Collection.extend({ model: MongoModel }); - col2 = new Col2(); + var col2 = new Col2(); col2.push(model); equal(col2.get({_id: 101}), model); equal(col2.get(model.clone()), model); @@ -362,7 +362,9 @@ $(document).ready(function() { test("model destroy removes from all collections", 3, function() { var e = new Backbone.Model({id: 5, title: 'Othello'}); - e.sync = function(method, model, options) { options.success({}); }; + e.sync = function(method, model, options) { + options.success(model, [], options); + }; var colE = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]); e.destroy(); @@ -417,7 +419,7 @@ $(document).ready(function() { equal(model.collection, collection); }); - test("create enforces validation", 1, function() { + test("create with validate:true enforces validation", 1, function() { var ValidatingModel = Backbone.Model.extend({ validate: function(attrs) { return "fail"; @@ -427,10 +429,10 @@ $(document).ready(function() { model: ValidatingModel }); var col = new ValidatingCollection(); - equal(col.create({"foo":"bar"}), false); + equal(col.create({"foo":"bar"}, {validate:true}), false); }); - test("a failing create runs the error callback", 1, function() { + test("a failing create returns model with errors", function() { var ValidatingModel = Backbone.Model.extend({ validate: function(attrs) { return "fail"; @@ -439,11 +441,10 @@ $(document).ready(function() { var ValidatingCollection = Backbone.Collection.extend({ model: ValidatingModel }); - var flag = false; - var callback = function(model, error) { flag = true; }; var col = new ValidatingCollection(); - col.create({"foo":"bar"}, { error: callback }); - equal(flag, true); + var m = col.create({"foo":"bar"}); + equal(m.validationError, 'fail'); + equal(col.length, 1); }); test("initialize", 1, function() { @@ -567,7 +568,7 @@ $(document).ready(function() { equal(col.length, 0); }); - test("#861, adding models to a collection which do not pass validation", function() { + test("#861, adding models to a collection which do not pass validation, with validate:true", function() { var Model = Backbone.Model.extend({ validate: function(attrs) { if (attrs.id == 3) return "id can't be 3"; @@ -581,18 +582,18 @@ $(document).ready(function() { var collection = new Collection; collection.on("error", function() { ok(true); }); - collection.add([{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}]); + collection.add([{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}], {validate:true}); deepEqual(collection.pluck('id'), [1, 2, 4, 5, 6]); }); - test("Invalid models are discarded.", 5, function() { + test("Invalid models are discarded with validate:true.", 5, function() { var collection = new Backbone.Collection; collection.on('test', function() { ok(true); }); collection.model = Backbone.Model.extend({ validate: function(attrs){ if (!attrs.valid) return 'invalid'; } }); var model = new collection.model({id: 1, valid: true}); - collection.add([model, {id: 2}]); + collection.add([model, {id: 2}], {validate:true}); model.trigger('test'); ok(collection.get(model.cid)); ok(collection.get(1)); @@ -656,7 +657,7 @@ $(document).ready(function() { } }; col.sync = m.sync = function( method, collection, options ){ - options.success(); + options.success(collection, [], options); }; col.fetch(opts); col.create(m, opts); @@ -674,7 +675,9 @@ $(document).ready(function() { test("#1447 - create with wait adds model.", 1, function() { var collection = new Backbone.Collection; var model = new Backbone.Model; - model.sync = function(method, model, options){ options.success(); }; + model.sync = function(method, model, options){ + options.success(model, [], options); + }; collection.on('add', function(){ ok(true); }); collection.create(model, {wait: true}); }); @@ -880,6 +883,24 @@ $(document).ready(function() { equal(c.length, 2); }); + test("update + merge with default values defined", function() { + var Model = Backbone.Model.extend({ + defaults: { + key: 'value' + } + }); + var m = new Model({id: 1}); + var col = new Backbone.Collection([m], {model: Model}); + equal(col.first().get('key'), 'value'); + + col.update({id: 1, key: 'other'}); + equal(col.first().get('key'), 'other'); + + col.update({id: 1, other: 'value'}); + equal(col.first().get('key'), 'other'); + equal(col.length, 1); + }); + test("#1894 - Push should not trigger a sort", 0, function() { var Collection = Backbone.Collection.extend({ comparator: 'id', @@ -937,4 +958,32 @@ $(document).ready(function() { Backbone.ajax = ajax; }); + test("`add` only `sort`s when necessary", 2, function () { + var collection = new (Backbone.Collection.extend({ + comparator: 'a' + }))([{id: 1}, {id: 2}, {id: 3}]); + collection.on('sort', function () { ok(true); }); + collection.add({id: 4}); // do sort, new model + collection.add({id: 1, a: 1}, {merge: true}); // do sort, comparator change + collection.add({id: 1, b: 1}, {merge: true}); // don't sort, no comparator change + collection.add({id: 1, a: 1}, {merge: true}); // don't sort, no comparator change + collection.add(collection.models); // don't sort, nothing new + collection.add(collection.models, {merge: true}); // don't sort + }); + + test("`add` only `sort`s when necessary with comparator function", 3, function () { + var collection = new (Backbone.Collection.extend({ + comparator: function(a, b) { + a.get('a') > b.get('a') ? 1 : (a.get('a') < b.get('a') ? -1 : 0); + } + }))([{id: 1}, {id: 2}, {id: 3}]); + collection.on('sort', function () { ok(true); }); + collection.add({id: 4}); // do sort, new model + collection.add({id: 1, a: 1}, {merge: true}); // do sort, model change + collection.add({id: 1, b: 1}, {merge: true}); // do sort, model change + collection.add({id: 1, a: 1}, {merge: true}); // don't sort, no model change + collection.add(collection.models); // don't sort, nothing new + collection.add(collection.models, {merge: true}); // don't sort + }); + }); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index 946c25bb0e..cf6c8f53a0 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -86,30 +86,6 @@ $(document).ready(function() { b.trigger('change'); }); - test("listenTo with context", 1, function() { - var a = _.extend({}, Backbone.Events); - var ctx = {}; - a.listenTo(a, 'foo', function(){ equal(this, ctx); }, ctx); - a.trigger('foo'); - }); - - test("stopListening with context", 2, function() { - var a = _.extend({}, Backbone.Events); - var ctx = {}; - var calledWithContext = false; - var calledWithoutContext = false; - - a.listenTo(a, 'foo', function(){ calledWithContext = true; }, ctx); - a.listenTo(a, 'foo', function(){ calledWithoutContext = true; }); - - a.stopListening(a, 'foo', null, ctx); - - a.trigger('foo'); - - equal(false, calledWithContext); - equal(true, calledWithoutContext); - }); - test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; _.extend(obj, Backbone.Events); @@ -384,4 +360,8 @@ $(document).ready(function() { Backbone.trigger('all'); }); + test("once without a callback is a noop", 0, function() { + _.extend({}, Backbone.Events).once('event').trigger('event'); + }); + }); diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index c097298016..8b8fe7109d 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -202,9 +202,9 @@ $(document).ready(function() { ok(changeCount == 1, "Change count should NOT have incremented."); a.validate = function(attrs) { - equal(attrs.foo, void 0, "don't ignore values when unsetting"); + equal(attrs.foo, void 0, "validate:true passed while unsetting"); }; - a.unset('foo'); + a.unset('foo', {validate: true}); equal(a.get('foo'), void 0, "Foo should have changed"); delete a.validate; ok(changeCount == 2, "Change count should have incremented for unset."); @@ -213,6 +213,24 @@ $(document).ready(function() { equal(a.id, undefined, "Unsetting the id should remove the id property."); }); + test("#2030 - set with failed validate, followed by another set triggers change", function () { + var attr = 0, main = 0, error = 0; + var Model = Backbone.Model.extend({ + validate: function (attr) { + if (attr.x > 1) { + error++; + return "this is an error"; + } + } + }); + var model = new Model({x:0}); + model.on('change:x', function () { attr++; }); + model.on('change', function () { main++; }); + model.set({x:2}, {validate:true}); + model.set({x:1}, {validate:true}); + deepEqual([attr, main, error], [1, 1, 1]); + }); + test("set triggers changes in the correct order", function() { var value = null; var model = new Backbone.Model; @@ -223,15 +241,16 @@ $(document).ready(function() { equal(value, 'last'); }); - test("set falsy values in the correct order", 1, function() { + test("set falsy values in the correct order", 2, function() { var model = new Backbone.Model({result: 'result'}); model.on('change', function() { - equal(model.changed.result, false); + equal(model.changed.result, void 0); + equal(model.previous('result'), false); }); model.set({result: void 0}, {silent: true}); model.set({result: null}, {silent: true}); model.set({result: false}, {silent: true}); - model.change(); + model.set({result: void 0}); }); test("multiple unsets", 1, function() { @@ -245,14 +264,12 @@ $(document).ready(function() { equal(i, 2, 'Unset does not fire an event for missing attributes.'); }); - test("unset and changedAttributes", 2, function() { + test("unset and changedAttributes", 1, function() { var model = new Backbone.Model({a: 1}); - model.unset('a', {silent: true}); - var changedAttributes = model.changedAttributes(); - ok('a' in changedAttributes, 'changedAttributes should contain unset properties'); - - changedAttributes = model.changedAttributes(); - ok('a' in changedAttributes, 'changedAttributes should contain unset properties when running changedAttributes again after an unset.'); + model.on('change', function() { + ok('a' in model.changedAttributes(), 'changedAttributes should contain unset properties'); + }); + model.unset('a'); }); test("using a non-default id attribute.", 5, function() { @@ -272,6 +289,21 @@ $(document).ready(function() { equal(model.get('name'), ''); }); + test("setting an object", 1, function() { + var model = new Backbone.Model({ + custom: { foo: 1 } + }); + model.on('change', function() { + ok(1); + }); + model.set({ + custom: { foo: 1 } // no change should be fired + }); + model.set({ + custom: { foo: 2 } // change event should be fired + }); + }); + test("clear", 3, function() { var changed; var model = new Backbone.Model({id: 1, name : "Model"}); @@ -308,9 +340,9 @@ $(document).ready(function() { equal(model.get('two'), 4); }); - test("change, hasChanged, changedAttributes, previous, previousAttributes", 12, function() { - var model = new Backbone.Model({name : "Tim", age : 10}); - equal(model.changedAttributes(), false); + test("change, hasChanged, changedAttributes, previous, previousAttributes", 9, function() { + var model = new Backbone.Model({name: "Tim", age: 10}); + deepEqual(model.changedAttributes(), false); model.on('change', function() { ok(model.hasChanged('name'), 'name changed'); ok(!model.hasChanged('age'), 'age did not'); @@ -320,17 +352,13 @@ $(document).ready(function() { }); equal(model.hasChanged(), false); equal(model.hasChanged(undefined), false); - model.set({name : 'Rob'}, {silent : true}); - equal(model.hasChanged(), true); - equal(model.hasChanged(undefined), true); - equal(model.hasChanged('name'), true); - model.change(); + model.set({name : 'Rob'}); equal(model.get('name'), 'Rob'); }); test("changedAttributes", 3, function() { var model = new Backbone.Model({a: 'a', b: 'b'}); - equal(model.changedAttributes(), false); + deepEqual(model.changedAttributes(), false); equal(model.changedAttributes({a: 'a'}), false); equal(model.changedAttributes({a: 'b'}).a, 'b'); }); @@ -341,8 +369,7 @@ $(document).ready(function() { model.on('change', function(model, options) { value = options.prefix + model.get('name'); }); - model.set({name: 'Bob'}, {silent: true}); - model.change({prefix: 'Mr. '}); + model.set({name: 'Bob'}, {prefix: 'Mr. '}); equal(value, 'Mr. Bob'); model.set({name: 'Sue'}, {prefix: 'Ms. '}); equal(value, 'Ms. Sue'); @@ -368,19 +395,21 @@ $(document).ready(function() { model.set({lastName: 'Hicks'}); }); - test("validate after save", 1, function() { + test("validate after save", 2, function() { var lastError, model = new Backbone.Model(); model.validate = function(attrs) { if (attrs.admin) return "Can't change admin status."; }; model.sync = function(method, model, options) { - options.success.call(this, {admin: true}); + options.success.call(this, this, {admin: true}, options); }; - model.save(null, {error: function(model, error) { + model.on('invalid', function(model, error) { lastError = error; - }}); + }); + model.save(null); equal(lastError, "Can't change admin status."); + equal(model.validationError, "Can't change admin status."); }); test("save", 2, function() { @@ -406,13 +435,24 @@ $(document).ready(function() { test("save in positional style", 1, function() { var model = new Backbone.Model(); model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.save('title', 'Twelfth Night'); equal(model.get('title'), 'Twelfth Night'); }); - + test("save with non-object success response", 2, function () { + var model = new Backbone.Model(); + model.sync = function(method, model, options) { + options.success(model, '', options); + options.success(model, null, options); + }; + model.save({testing:'empty'}, { + success: function (model) { + deepEqual(model.attributes, {testing:'empty'}); + } + }); + }); test("fetch", 2, function() { doc.fetch(); @@ -442,14 +482,16 @@ $(document).ready(function() { model.validate = function(attrs) { if (attrs.admin != this.get('admin')) return "Can't change admin status."; }; - model.on('error', function(model, error) { + model.on('invalid', function(model, error) { lastError = error; }); var result = model.set({a: 100}); equal(result, model); equal(model.get('a'), 100); equal(lastError, undefined); - result = model.set({a: 200, admin: false}); + result = model.set({admin: true}); + equal(model.get('admin'), true); + result = model.set({a: 200, admin: false}, {validate:true}); equal(lastError, "Can't change admin status."); equal(result, false); equal(model.get('a'), 100); @@ -467,10 +509,10 @@ $(document).ready(function() { model.set({name: "Two"}); equal(model.get('name'), 'Two'); equal(error, undefined); - model.unset('name'); + model.unset('name', {validate: true}); equal(error, true); equal(model.get('name'), 'Two'); - model.clear(); + model.clear({validate:true}); equal(model.get('name'), 'Two'); delete model.validate; model.clear(); @@ -483,21 +525,18 @@ $(document).ready(function() { model.validate = function(attrs) { if (attrs.admin) return "Can't change admin status."; }; - var callback = function(model, error) { - lastError = error; - }; - model.on('error', function(model, error) { + model.on('invalid', function(model, error) { boundError = true; }); - var result = model.set({a: 100}, {error: callback}); + var result = model.set({a: 100}, {validate:true}); equal(result, model); equal(model.get('a'), 100); - equal(lastError, undefined); + equal(model.validationError, null); equal(boundError, undefined); - result = model.set({a: 200, admin: true}, {error: callback}); + result = model.set({a: 200, admin: true}, {validate:true}); equal(result, false); equal(model.get('a'), 100); - equal(lastError, "Can't change admin status."); + equal(model.validationError, "Can't change admin status."); equal(boundError, true); }); @@ -592,6 +631,13 @@ $(document).ready(function() { ok(model.get('x') === a); }); + test("set same value does not trigger change", 0, function() { + var model = new Backbone.Model({x: 1}); + model.on('change change:x', function() { ok(false); }); + model.set({x: 1}); + model.set({x: 1}); + }); + test("unset does not fire a change for undefined attributes", 0, function() { var model = new Backbone.Model({x: undefined}); model.on('change:x', function(){ ok(false); }); @@ -603,19 +649,29 @@ $(document).ready(function() { ok('x' in model.attributes); }); - test("change fires change:attr", 1, function() { + test("hasChanged works outside of change events, and true within", 6, function() { var model = new Backbone.Model({x: 1}); + model.on('change:x', function() { + ok(model.hasChanged('x')); + equal(model.get('x'), 1); + }); model.set({x: 2}, {silent: true}); - model.on('change:x', function(){ ok(true); }); - model.change(); + ok(model.hasChanged()); + equal(model.hasChanged('x'), true); + model.set({x: 1}); + ok(model.hasChanged()); + equal(model.hasChanged('x'), true); }); - test("hasChanged is false after original values are set", 2, function() { - var model = new Backbone.Model({x: 1}); - model.on('change:x', function(){ ok(false); }); - model.set({x: 2}, {silent: true}); + test("hasChanged gets cleared on the following set", 4, function() { + var model = new Backbone.Model; + model.set({x: 1}); ok(model.hasChanged()); - model.set({x: 1}, {silent: true}); + model.set({x: 1}); + ok(!model.hasChanged()); + model.set({x: 2}); + ok(model.hasChanged()); + model.set({}); ok(!model.hasChanged()); }); @@ -664,7 +720,7 @@ $(document).ready(function() { test("#1030 - `save` with `wait` results in correct attributes if success is called during sync", 2, function() { var model = new Backbone.Model({x: 1, y: 2}); model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.on("change:x", function() { ok(true); }); model.save({x: 3}, {wait: true}); @@ -691,25 +747,19 @@ $(document).ready(function() { model.set({x: true}); deepEqual(events, ['change:y', 'change:x', 'change']); events = []; - model.change(); - deepEqual(events, ['change:z', 'change']); + model.set({z: true}); + deepEqual(events, []); }); test("nested `change` only fires once", 1, function() { var model = new Backbone.Model(); model.on('change', function() { ok(true); - model.change(); + model.set({x: true}); }); model.set({x: true}); }); - test("no `'change'` event if no changes", 0, function() { - var model = new Backbone.Model(); - model.on('change', function() { ok(false); }); - model.change(); - }); - test("nested `set` during `'change'`", 6, function() { var count = 0; var model = new Backbone.Model(); @@ -721,13 +771,13 @@ $(document).ready(function() { model.set({y: true}); break; case 1: - deepEqual(this.changedAttributes(), {y: true}); - equal(model.previous('x'), true); + deepEqual(this.changedAttributes(), {x: true, y: true}); + equal(model.previous('x'), undefined); model.set({z: true}); break; case 2: - deepEqual(this.changedAttributes(), {z: true}); - equal(model.previous('y'), true); + deepEqual(this.changedAttributes(), {x: true, y: true, z: true}); + equal(model.previous('y'), undefined); break; default: ok(false); @@ -736,30 +786,34 @@ $(document).ready(function() { model.set({x: true}); }); - test("nested `'change'` with silent", 3, function() { + test("nested `change` with silent", 3, function() { var count = 0; var model = new Backbone.Model(); - model.on('change:y', function() { ok(true); }); + model.on('change:y', function() { ok(false); }); model.on('change', function() { switch(count++) { case 0: deepEqual(this.changedAttributes(), {x: true}); model.set({y: true}, {silent: true}); + model.set({z: true}); break; case 1: - deepEqual(this.changedAttributes(), {y: true, z: true}); + deepEqual(this.changedAttributes(), {x: true, y: true, z: true}); + break; + case 2: + deepEqual(this.changedAttributes(), {z: false}); break; default: ok(false); } }); model.set({x: true}); - model.set({z: true}); + model.set({z: false}); }); - test("nested `'change:attr'` with silent", 1, function() { + test("nested `change:attr` with silent", 0, function() { var model = new Backbone.Model(); - model.on('change:y', function(){ ok(true); }); + model.on('change:y', function(){ ok(false); }); model.on('change', function() { model.set({y: true}, {silent: true}); model.set({z: true}); @@ -777,21 +831,25 @@ $(document).ready(function() { equal(val, 2); }); model.set({x: true}); - model.change(); }); - test("multiple nested changes with silent", 2, function() { + test("multiple nested changes with silent", 1, function() { var changes = []; var model = new Backbone.Model(); model.on('change:b', function(model, val) { changes.push(val); }); model.on('change', function() { model.set({b: 1}); - model.set({b: 2}, {silent: true}); }); model.set({b: 0}); deepEqual(changes, [0, 1]); - model.change(); - deepEqual(changes, [0, 1, 2, 1]); + }); + + test("basic silent change semantics", 1, function() { + var model = new Backbone.Model; + model.set({x: 1}); + model.on('change', function(){ ok(true); }); + model.set({x: 2}, {silent: true}); + model.set({x: 1}); }); test("nested set multiple times", 1, function() { @@ -828,7 +886,7 @@ $(document).ready(function() { } }; model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.save({id: 1}, opts); model.fetch(opts); @@ -866,7 +924,7 @@ $(document).ready(function() { validate: function(){ return 'invalid'; } }); var model = new Model({id: 1}); - model.on('error', function(){ ok(true); }); + model.on('invalid', function(){ ok(true); }); model.save(); }); @@ -885,7 +943,7 @@ $(document).ready(function() { var Model = Backbone.Model.extend({ sync: function(method, model, options) { setTimeout(function(){ - options.success(); + options.success(model, {}, options); start(); }, 0); } @@ -895,9 +953,9 @@ $(document).ready(function() { .save(null, {wait: true}); }); - test("#1664 - Changing from one value, silently to another, back to original does not trigger change.", 0, function() { + test("#1664 - Changing from one value, silently to another, back to original triggers a change.", 1, function() { var model = new Backbone.Model({x:1}); - model.on('change:x', function() { ok(false); }); + model.on('change:x', function() { ok(true); }); model.set({x:2},{silent:true}); model.set({x:3},{silent:true}); model.set({x:1}); @@ -910,15 +968,11 @@ $(document).ready(function() { model.set({a:'c'}, {silent:true}); model.set({b:2}, {silent:true}); model.unset('c', {silent:true}); - model.set({a:'a'}, {silent:true}); - model.set({b:1}, {silent:true}); - model.set({c:'item'}, {silent:true}); }); model.on('change:a change:b change:c', function(model, val) { changes.push(val); }); model.set({a:'a', b:1, c:'item'}); deepEqual(changes, ['a',1,'item']); - model.change(); - deepEqual(changes, ['a',1,'item']); + deepEqual(model.attributes, {a: 'c', b: 2}); }); test("#1791 - `attributes` is available for `parse`", function() { @@ -929,7 +983,7 @@ $(document).ready(function() { expect(0); }); - test("silent changes in last `change` event back to original does not trigger change", 2, function() { + test("silent changes in last `change` event back to original triggers change", 2, function() { var changes = []; var model = new Backbone.Model(); model.on('change:a change:b change:c', function(model, val) { changes.push(val); }); @@ -938,9 +992,8 @@ $(document).ready(function() { }); model.set({a:'a'}); deepEqual(changes, ['a']); - model.set({a:'a'}, {silent:true}); - model.change(); - deepEqual(changes, ['a']); + model.set({a:'a'}); + deepEqual(changes, ['a', 'a']); }); test("#1943 change calculations should use _.isEqual", function() { @@ -949,4 +1002,65 @@ $(document).ready(function() { equal(model.changedAttributes(), false); }); + test("#1964 - final `change` event is always fired, regardless of interim changes", 1, function () { + var model = new Backbone.Model(); + model.on('change:property', function() { + model.set('property', 'bar'); + }); + model.on('change', function() { + ok(true); + }); + model.set('property', 'foo'); + }); + + test("isValid", function() { + var model = new Backbone.Model({valid: true}); + model.validate = function(attrs) { + if (!attrs.valid) return "invalid"; + }; + equal(model.isValid(), true); + equal(model.set({valid: false}, {validate:true}), false); + equal(model.isValid(), true); + model.set({valid:false}); + equal(model.isValid(), false); + ok(!model.set('valid', false, {validate: true})); + }); + + test("#1179 - isValid returns true in the absence of validate.", 1, function() { + var model = new Backbone.Model(); + model.validate = null; + ok(model.isValid()); + }); + + test("#1961 - Creating a model with {validate:true} will call validate and use the error callback", function () { + var Model = Backbone.Model.extend({ + validate: function (attrs) { + if (attrs.id === 1) return "This shouldn't happen"; + } + }); + var model = new Model({id: 1}, {validate: true}); + equal(model.validationError, "This shouldn't happen"); + }); + + test("toJSON receives attrs during save(..., {wait: true})", 1, function() { + var Model = Backbone.Model.extend({ + url: '/test', + toJSON: function() { + strictEqual(this.attributes.x, 1); + return _.clone(this.attributes); + } + }); + var model = new Model; + model.save({x: 1}, {wait: true}); + }); + + test("#2034 - nested set with silent only triggers one change", 1, function() { + var model = new Backbone.Model(); + model.on('change', function() { + model.set({b: true}, {silent: true}); + ok(true); + }); + model.set({a: true}); + }); + }); diff --git a/vendor/backbone/test/router.js b/vendor/backbone/test/router.js index 50be7effb7..b1c6a71a81 100644 --- a/vendor/backbone/test/router.js +++ b/vendor/backbone/test/router.js @@ -70,6 +70,7 @@ $(document).ready(function() { "contacts/new": "newContact", "contacts/:id": "loadContact", "optional(/:item)": "optionalItem", + "named/optional/(y:z)": "namedOptional", "splat/*args/end": "splat", "*first/complex-:part/*rest": "complex", ":entity?*args": "query", @@ -110,23 +111,27 @@ $(document).ready(function() { this.arg = arg != void 0 ? arg : null; }, - splat : function(args) { + splat: function(args) { this.args = args; }, - complex : function(first, part, rest) { + complex: function(first, part, rest) { this.first = first; this.part = part; this.rest = rest; }, - query : function(entity, args) { + query: function(entity, args) { this.entity = entity; this.queryArgs = args; }, - anything : function(whatever) { + anything: function(whatever) { this.anything = whatever; + }, + + namedOptional: function(z) { + this.z = z; } }); @@ -502,4 +507,13 @@ $(document).ready(function() { strictEqual(history.getFragment('/fragment '), 'fragment'); }); + test("#1980 - Optional parameters.", 2, function() { + location.replace('http://example.com#named/optional/y'); + Backbone.history.checkUrl(); + strictEqual(router.z, undefined); + location.replace('http://example.com#named/optional/y123'); + Backbone.history.checkUrl(); + strictEqual(router.z, '123'); + }); + }); diff --git a/vendor/backbone/test/view.js b/vendor/backbone/test/view.js index 444d90b2c4..7496c9da2a 100644 --- a/vendor/backbone/test/view.js +++ b/vendor/backbone/test/view.js @@ -29,22 +29,6 @@ $(document).ready(function() { strictEqual(view.$('a b').html(), 'test'); }); - test("make", 3, function() { - var div = view.make('div', {id: 'test-div'}, "one two three"); - - equal(div.tagName.toLowerCase(), 'div'); - equal(div.id, 'test-div'); - equal($(div).text(), 'one two three'); - }); - - test("make can take falsy values for content", 2, function() { - var div = view.make('div', {id: 'test-div'}, 0); - equal($(div).text(), '0'); - - div = view.make('div', {id: 'test-div'}, ''); - equal($(div).text(), ''); - }); - test("initialize", 1, function() { var View = Backbone.View.extend({ initialize: function() { diff --git a/vendor/underscore/test/arrays.js b/vendor/underscore/test/arrays.js index 7145099b43..9b7bb0de32 100644 --- a/vendor/underscore/test/arrays.js +++ b/vendor/underscore/test/arrays.js @@ -182,7 +182,7 @@ $(document).ready(function() { equal(_.indexOf(null, 2), -1, 'handles nulls properly'); numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3]; - index = _.lastIndexOf(numbers, 2, 2); + var index = _.lastIndexOf(numbers, 2, 2); equal(index, 1, 'supports the fromIndex argument'); }); diff --git a/vendor/underscore/test/collections.js b/vendor/underscore/test/collections.js index 2214ed79c0..6e000993d8 100644 --- a/vendor/underscore/test/collections.js +++ b/vendor/underscore/test/collections.js @@ -22,7 +22,7 @@ $(document).ready(function() { equal(answers.join(", "), 'one, two, three', 'iterating over objects works, and ignores the object prototype.'); delete obj.constructor.prototype.four; - answer = null; + var answer = null; _.each([1, 2, 3], function(num, index, arr){ if (_.include(arr, num)) answer = true; }); ok(answer, 'can reference the original collection from inside the iterator'); diff --git a/vendor/underscore/test/objects.js b/vendor/underscore/test/objects.js index 939bffddf6..73bdf6b4ed 100644 --- a/vendor/underscore/test/objects.js +++ b/vendor/underscore/test/objects.js @@ -555,7 +555,7 @@ $(document).ready(function() { value(); ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain'); }); - + test("has", function () { var obj = {foo: "bar", func: function () {} }; ok (_.has(obj, "foo"), "has() checks that the object has a property."); @@ -563,7 +563,7 @@ $(document).ready(function() { ok (_.has(obj, "func"), "has() works for functions too."); obj.hasOwnProperty = null; ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted."); - child = {}; + var child = {}; child.prototype = obj; ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.") }); diff --git a/vendor/underscore/test/utility.js b/vendor/underscore/test/utility.js index 4da269ddbc..0bca8c8929 100644 --- a/vendor/underscore/test/utility.js +++ b/vendor/underscore/test/utility.js @@ -25,6 +25,20 @@ $(document).ready(function() { equal(_.identity(moe), moe, 'moe is the same as his identity'); }); + test("random", function() { + var array = _.range(1000); + var min = Math.pow(2, 31); + var max = Math.pow(2, 62); + + ok(_.every(array, function() { + return _.random(min, max) >= min; + }), "should produce a random number greater than or equal to the minimum number"); + + ok(_.some(array, function() { + return _.random(Number.MAX_VALUE) > 0; + }), "should produce a random number when passed `Number.MAX_VALUE`"); + }); + test("uniqueId", function() { var ids = [], i = 0; while(i++ < 100) ids.push(_.uniqueId()); @@ -82,7 +96,7 @@ $(document).ready(function() { equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.'); var fancyTemplate = _.template("
    <% \ - for (key in people) { \ + for (var key in people) { \ %>
  • <%= people[key] %>
  • <% } %>
"); result = fancyTemplate({people : {moe : "Moe", larry : "Larry", curly : "Curly"}}); equal(result, "
  • Moe
  • Larry
  • Curly
", 'can run arbitrary javascript in templates'); @@ -137,7 +151,7 @@ $(document).ready(function() { interpolate : /\{\{=([\s\S]+?)\}\}/g }; - var custom = _.template("
    {{ for (key in people) { }}
  • {{= people[key] }}
  • {{ } }}
"); + var custom = _.template("
    {{ for (var key in people) { }}
  • {{= people[key] }}
  • {{ } }}
"); result = custom({people : {moe : "Moe", larry : "Larry", curly : "Curly"}}); equal(result, "
  • Moe
  • Larry
  • Curly
", 'can run arbitrary javascript in templates'); @@ -152,7 +166,7 @@ $(document).ready(function() { interpolate : /<\?=([\s\S]+?)\?>/g }; - var customWithSpecialChars = _.template("
"); + var customWithSpecialChars = _.template("
"); result = customWithSpecialChars({people : {moe : "Moe", larry : "Larry", curly : "Curly"}}); equal(result, "
  • Moe
  • Larry
  • Curly
", 'can run arbitrary javascript in templates'); diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index a3bb5f3543..307393e73e 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -2,4 +2,4 @@ // http://underscorejs.org // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var M=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=M(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&M(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return M(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var S={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};S.unescape=w.invert(S.escape);var T={escape:RegExp("["+w.keys(S.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(S.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return S[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index b943608c95..e228c95c4b 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -1019,7 +1019,7 @@ max = min; min = 0; } - return min + (0 | Math.random() * (max - min + 1)); + return min + Math.floor(Math.random() * (max - min + 1)); }; // List of HTML entities for escaping. From 716a5b9b5acfe38dcf789cdec065bed9ac2044d8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 28 Dec 2012 20:22:04 -0600 Subject: [PATCH 038/176] Update `_.random` docs and add unit tests. Former-commit-id: d4a033bf83ad5fce7bb3b09467305730a89adc01 --- doc/README.md | 4 ++-- lodash.js | 4 ++-- test/test.js | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/README.md b/doc/README.md index 398ba38f8a..39838da46f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2852,10 +2852,10 @@ Produces a random number between `min` and `max` *(inclusive)*. If only one argu #### Example ```js _.random(0, 5); -// => a number between 1 and 5 +// => a number between 0 and 5 _.random(5); -// => also a number between 1 and 5 +// => also a number between 0 and 5 ``` * * * diff --git a/lodash.js b/lodash.js index 405fb93b65..a79941cd9b 100644 --- a/lodash.js +++ b/lodash.js @@ -3889,10 +3889,10 @@ * @example * * _.random(0, 5); - * // => a number between 1 and 5 + * // => a number between 0 and 5 * * _.random(5); - * // => also a number between 1 and 5 + * // => also a number between 0 and 5 */ function random(min, max) { if (min == null && max == null) { diff --git a/test/test.js b/test/test.js index 06972c0af6..8bc19960cd 100644 --- a/test/test.js +++ b/test/test.js @@ -1396,6 +1396,24 @@ } notEqual(actual, 5); }); + + test('supports large integer values', function() { + var array = Array(1000), + min = Math.pow(2, 31), + max = Math.pow(2, 62); + + ok(_.every(array, function() { + return _.random(min, max) >= min; + })); + + ok(_.some(array, function() { + return _.random(Number.MAX_VALUE) > 0; + })); + }); + + test('should coerce arguments to numbers', function() { + strictEqual(_.random('1', '1'), 1); + }); }()); /*--------------------------------------------------------------------------*/ From 99e02f30fb41d66c37125a4f54f50430c0937980 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 29 Dec 2012 16:03:22 -0600 Subject: [PATCH 039/176] Simplify `createIterator`. and remove whitespace between `else {` in template text. Former-commit-id: a673f0edbe9b8655cbe1e91d9063e58130172495 --- build.js | 17 ++++++++--------- build/pre-compile.js | 8 ++++---- lodash.js | 40 ++++++++++++++++++++++------------------ 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/build.js b/build.js index a9ae40f274..253450ae4b 100755 --- a/build.js +++ b/build.js @@ -169,12 +169,12 @@ /** Used to inline `iteratorTemplate` */ var iteratorOptions = [ 'args', - 'arrayLoop', + 'arrays', 'bottom', 'firstArg', 'hasDontEnumBug', 'isKeysFast', - 'objectLoop', + 'loop', 'nonEnumArgs', 'noCharByIndex', 'shadowed', @@ -893,7 +893,7 @@ // remove optimized branch in `iteratorTemplate` source = source.replace(getIteratorTemplate(source), function(match) { - return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysFast[\s\S]+?["']\1<% *} *else *\{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); + return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysFast[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); }); // remove data object property assignment in `createIterator` @@ -980,7 +980,7 @@ */ function removeNoNodeClass(source) { // remove `noNodeClass` assignment - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var noNodeClass[\s\S]+?catch[^}]+}\n/, ''); + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *{(?:\s*\/\/.*)*\n *var noNodeClass[\s\S]+?catch[^}]+}\n/, ''); // remove `noNodeClass` from `shimIsPlainObject` source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) { @@ -1097,7 +1097,7 @@ } /** - * Hard-codes the `useStrict` template option value for `iteratorTemplate`. + * Hard-codes the `strict` template option value for `iteratorTemplate`. * * @private * @param {String} source The source to process. @@ -1109,9 +1109,9 @@ if (value) { source = source.replace(/^[\s\S]*?function[^{]+{/, "$&\n 'use strict';"); } - // replace `useStrict` branch in `iteratorTemplate` with hard-coded option + // replace `strict` branch in `iteratorTemplate` with hard-coded option source = source.replace(getIteratorTemplate(source), function(match) { - return match.replace(/(?: *\/\/.*\n)*(\s*)["'] *<%.+?useStrict.+/, value ? '$1"\'use strict\';\\n" +' : ''); + return match.replace(/(?: *\/\/.*\n)*(\s*)["'] *<%.+?strict.+/, value ? '$1"\'use strict\';\\n" +' : ''); }); return source; @@ -1780,7 +1780,6 @@ source = removeIsArgumentsFallback(source); } - source = removeFromCreateIterator(source, 'nativeKeys'); source = removeCreateFunction(source); } @@ -1916,7 +1915,7 @@ .replace(/'(?:\\n|\s)+'/g, "''") .replace(/__p *\+= *' *';/g, '') .replace(/(__p *\+= *)' *' *\+/g, '$1') - .replace(/(\{) *;|; *(\})/g, '$1$2') + .replace(/({) *;|; *(\})/g, '$1$2') .replace(/\(\(__t *= *\( *([^)]+) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)'); // remove the with-statement diff --git a/build/pre-compile.js b/build/pre-compile.js index f4f19ca5d5..a4ca3c661d 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -35,12 +35,12 @@ /** Used to minify `compileIterator` option properties */ var iteratorOptions = [ 'args', - 'arrayLoop', + 'arrays', 'bottom', 'firstArg', 'hasDontEnumBug', 'isKeysFast', - 'objectLoop', + 'loop', 'nonEnumArgs', 'noCharByIndex', 'shadowed', @@ -235,7 +235,7 @@ string = string.slice(captured.length); } // avoids removing the '\n' of the `stringEscapes` object - string = string.replace(/\[object |delete |else |function | in |return\s+[\w"']|throw |typeof |use strict|var |@ |(["'])\\n\1|\\\\n|\\n|\s+/g, function(match) { + string = string.replace(/\[object |delete |else (?!{)|function | in |return\s+[\w"']|throw |typeof |use strict|var |@ |(["'])\\n\1|\\\\n|\\n|\s+/g, function(match) { return match == false || match == '\\n' ? '' : match; }); // prepend object literal property name @@ -256,7 +256,7 @@ .replace('"\';\n"', '"\';"') // remove `useSourceURL` variable - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, ''); + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, ''); // remove debug sourceURL use in `_.template` source = source.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, ''); diff --git a/lodash.js b/lodash.js index a79941cd9b..8591d7cb12 100644 --- a/lodash.js +++ b/lodash.js @@ -359,7 +359,7 @@ '<%= top %>;\n' + // array-like iteration: - '<% if (arrayLoop) { %>' + + '<% if (arrays) { %>' + 'var length = iteratee.length; index = -1;\n' + "if (typeof length == 'number') {" + @@ -372,7 +372,7 @@ // iterate over the array-like value ' while (++index < length) {\n' + - ' <%= arrayLoop %>\n' + + ' <%= loop %>\n' + ' }\n' + '}\n' + 'else {' + @@ -384,7 +384,7 @@ ' if (length && isArguments(iteratee)) {\n' + ' while (++index < length) {\n' + " index += '';\n" + - ' <%= objectLoop %>\n' + + ' <%= loop %>\n' + ' }\n' + ' } else {' + ' <% } %>' + @@ -408,7 +408,7 @@ ' while (++ownIndex < length) {\n' + ' index = ownProps[ownIndex];\n' + " <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %>" + - ' <%= objectLoop %>\n' + + ' <%= loop %>\n' + ' <% if (!hasDontEnumBug) { %>}\n<% } %>' + ' }' + @@ -421,7 +421,7 @@ ' if (useHas) { %>hasOwnProperty.call(iteratee, index)<% }' + ' %>) {' + ' <% } %>\n' + - ' <%= objectLoop %>;' + + ' <%= loop %>;' + ' <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n' + ' }' + ' <% } %>' + @@ -438,11 +438,11 @@ " if (shadowed[k] == 'constructor') {" + ' %>!(ctor && ctor.prototype === iteratee) && <%' + ' } %>hasOwnProperty.call(iteratee, index)) {\n' + - ' <%= objectLoop %>\n' + + ' <%= loop %>\n' + ' }' + ' <% } %>' + ' <% } %>' + - ' <% if (arrayLoop || nonEnumArgs) { %>\n}<% } %>\n' + + ' <% if (arrays || nonEnumArgs) { %>\n}<% } %>\n' + // add code to the bottom of the iteration function '<%= bottom %>;\n' + @@ -454,9 +454,10 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - "for (var argsIndex = 1, argsLength = typeof guard == 'number' ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n" + + "var argsIndex = 0, argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'while (++argsIndex < argsLength) {\n' + ' if ((iteratee = arguments[argsIndex])) {', - 'objectLoop': 'result[index] = iteratee[index]', + 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -464,15 +465,15 @@ * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. */ var eachIteratorOptions = { + 'arrays': true, 'args': 'collection, callback, thisArg', 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", - 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', - 'objectLoop': 'if (callback(iteratee[index], index, collection) === false) return result' + 'loop': 'if (callback(iteratee[index], index, collection) === false) return result' }; /** Reusable iterator options for `forIn` and `forOwn` */ var forOwnIteratorOptions = { - 'arrayLoop': null + 'arrays': false }; /*--------------------------------------------------------------------------*/ @@ -648,25 +649,28 @@ * * @private * @param {Object} [options1, options2, ...] The compile options object(s). + * arrays - A boolean to specify support for iterating arrays and array-like objects. * useHas - A boolean to specify using `hasOwnProperty` checks in the object loop. * args - A string of comma separated arguments the iteration function will accept. * top - A string of code to execute before the iteration branches. - * arrayLoop - A string of code to execute in the array loop. - * objectLoop - A string of code to execute in the object loop. + * loop - A string of code to execute in the object loop. * bottom - A string of code to execute after the iteration branches. * * @returns {Function} Returns the compiled function. */ function createIterator() { var data = { - 'arrayLoop': '', - 'bottom': '', + // support properties 'hasDontEnumBug': hasDontEnumBug, 'isKeysFast': isKeysFast, - 'objectLoop': '', 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, + + // iterator options + 'arrays': false, + 'bottom': '', + 'loop': '', 'top': '', 'useHas': true }; @@ -1139,7 +1143,7 @@ * // => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' } */ var defaults = createIterator(assignIteratorOptions, { - 'objectLoop': 'if (result[index] == null) ' + assignIteratorOptions.objectLoop + 'loop': 'if (result[index] == null) ' + assignIteratorOptions.loop }); /** From 7fdf00d5e95432ecb470639152e82d048e056a8d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 30 Dec 2012 11:14:10 -0600 Subject: [PATCH 040/176] Workaround UglifyJS `comments` option bug. Former-commit-id: 705510311c4eee0739e85054c6d8edded427efe3 --- build/minify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/minify.js b/build/minify.js index 904301d083..9cce7d13f7 100755 --- a/build/minify.js +++ b/build/minify.js @@ -330,7 +330,7 @@ // restrict lines to 500 characters for consistency with the Closure Compiler var stream = uglifyJS.OutputStream({ 'ascii_only': true, - 'comments': true, + 'comments': /\* *@license/, 'max_line_len': 500, }); From a14be3a42c8acf6d6d8db80f4e18cba214eeac00 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 30 Dec 2012 12:18:32 -0600 Subject: [PATCH 041/176] Add "imports" option to `_.templateSettings`. [closes #148] Former-commit-id: 16a019d27aea2e7a72665f62adf4c4c35e29b4bf --- build.js | 5 +- build/pre-compile.js | 1 + doc/README.md | 232 ++++++++++++++++++++++++------------------- lodash.js | 48 +++++++-- lodash.min.js | 57 +++++------ lodash.underscore.js | 28 +++--- test/test-build.js | 5 + test/test.js | 24 +++-- 8 files changed, 242 insertions(+), 158 deletions(-) diff --git a/build.js b/build.js index 253450ae4b..b7505bfdc2 100755 --- a/build.js +++ b/build.js @@ -147,7 +147,7 @@ 'sortBy': ['forEach'], 'sortedIndex': ['identity'], 'tap': ['mixin'], - 'template': ['escape'], + 'template': ['defaults', 'escape', 'keys', 'values'], 'throttle': [], 'times': [], 'toArray': ['isString', 'values'], @@ -1398,6 +1398,9 @@ source = removeVar(source, 'cloneableClasses'); source = removeVar(source, 'ctorByClass'); + source = removeVar(source, 'templateImports'); + source = source.replace(/,\s*'imports'.+/, ''); + // remove large array optimizations source = removeFunction(source, 'cachedContains'); source = removeVar(source, 'largeArraySize'); diff --git a/build/pre-compile.js b/build/pre-compile.js index a4ca3c661d..6ffee418e2 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -105,6 +105,7 @@ 'groupBy', 'has', 'head', + 'imports', 'identity', 'include', 'index', diff --git a/doc/README.md b/doc/README.md index 39838da46f..b8657abd11 100644 --- a/doc/README.md +++ b/doc/README.md @@ -170,6 +170,8 @@ * [`_.templateSettings.evaluate`](#_templatesettingsevaluate) * [`_.templateSettings.interpolate`](#_templatesettingsinterpolate) * [`_.templateSettings.variable`](#_templatesettingsvariable) +* [`_.templateSettings.imports`](#_templatesettingstemplateimports) +* [`_.templateSettings.imports._`](#_templatesettingsimports_) @@ -187,7 +189,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2798 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +213,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2802 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +238,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2837 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2863 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +266,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2890 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +294,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2906 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2932 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +326,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +351,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2965 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2991 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +375,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3044 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +400,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3045 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3071 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -427,7 +429,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +454,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +492,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3159 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3185 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +520,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3203 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3229 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +564,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +588,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3295 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +627,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3328 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3354 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +652,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3359 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3385 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -707,7 +709,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4261 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -737,7 +739,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4242 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4278 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -758,7 +760,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4259 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4295 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -789,7 +791,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1987 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -817,7 +819,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2029 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -855,7 +857,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2076 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -887,7 +889,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2106 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -916,7 +918,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2145 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -945,7 +947,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2189 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -974,7 +976,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2224 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1006,7 +1008,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2266 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1038,7 +1040,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2299 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1067,7 +1069,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2333 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1099,7 +1101,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2375 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1131,7 +1133,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2397 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1157,7 +1159,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2448 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2474 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1188,7 +1190,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2472 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2498 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1218,7 +1220,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2540 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1249,7 +1251,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2578 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1275,7 +1277,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1299,7 +1301,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2606 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2632 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1329,7 +1331,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2657 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1358,7 +1360,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2677 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1390,7 +1392,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2712 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1414,7 +1416,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2742 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1452,7 +1454,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3418 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1480,7 +1482,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3425 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1511,7 +1513,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3455 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3481 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1542,7 +1544,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3501 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3527 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1583,7 +1585,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3524 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3550 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1610,7 +1612,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3583 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1636,7 +1638,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3647 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1661,7 +1663,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3627 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1688,7 +1690,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3645 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1714,7 +1716,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3672 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3698 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1740,7 +1742,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1767,7 +1769,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3729 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3755 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1792,7 +1794,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3782 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3808 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1828,7 +1830,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L840 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1856,7 +1858,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1024 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1050 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1892,7 +1894,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1925,7 +1927,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1951,7 +1953,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L896 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1987,7 +1989,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2015,7 +2017,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1160 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2042,7 +2044,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1211 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2067,7 +2069,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1228 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2091,7 +2093,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L858 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2118,7 +2120,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1257 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2145,7 +2147,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2169,7 +2171,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1293 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2193,7 +2195,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1310 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2217,7 +2219,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1335 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2247,7 +2249,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1377 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2278,7 +2280,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1528 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2316,7 +2318,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2340,7 +2342,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1608 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2375,7 +2377,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1630 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2402,7 +2404,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2426,7 +2428,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2456,7 +2458,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1675 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2491,7 +2493,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2515,7 +2517,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1691 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2539,7 +2541,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1734 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2563,7 +2565,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L935 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2587,7 +2589,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1769 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2622,7 +2624,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1843 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2653,7 +2655,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1877 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2677,7 +2679,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1915 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2708,7 +2710,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1952 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2739,7 +2741,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2763,7 +2765,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3824 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3850 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2788,7 +2790,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3876 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2818,7 +2820,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3874 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3900 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2838,7 +2840,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3923 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2866,7 +2868,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3961 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2901,7 +2903,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2979,7 +2981,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4187 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3011,7 +3013,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4177 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4213 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3035,7 +3037,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4233 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3069,7 +3071,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4460 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3081,7 +3083,7 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L320 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3093,7 +3095,7 @@ _.uniqueId(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L329 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3105,7 +3107,7 @@ _.uniqueId(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L338 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3117,7 +3119,7 @@ _.uniqueId(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L327 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L347 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3129,7 +3131,7 @@ _.uniqueId(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L336 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L356 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3138,6 +3140,30 @@ _.uniqueId(); + + +### `_.templateSettings.templateImports` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L299 "View in source") [Ⓣ][1] + +*(Object)*: Used to import variables into the compiled template. + +* * * + + + + + + +### `_.templateSettings.imports._` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] + +*(Object)*: A reference to the `lodash` function. + +* * * + + + + diff --git a/lodash.js b/lodash.js index 8591d7cb12..e58e0373cf 100644 --- a/lodash.js +++ b/lodash.js @@ -288,6 +288,26 @@ this.__wrapped__ = value; } + /** + * Used to import variables into the compiled template. + * + * @name imports + * @static + * @memberOf _.templateSettings + * @type Object + */ + var templateImports = { + + /** + * A reference to the `lodash` function. + * + * @static + * @memberOf _.templateSettings.imports + * @type Object + */ + '_': lodash + }; + /** * By default, the template delimiters used by Lo-Dash are similar to those in * embedded Ruby (ERB). Change the following template settings to use alternative @@ -333,7 +353,9 @@ * @memberOf _.templateSettings * @type String */ - 'variable': '' + 'variable': '', + + 'imports': templateImports }; /*--------------------------------------------------------------------------*/ @@ -4030,13 +4052,10 @@ options || (options = {}); var isEvaluating, - result, - settings = lodash.templateSettings, index = 0, + settings = lodash.templateSettings, interpolate = options.interpolate || settings.interpolate || reNoMatch, - source = "__p += '", - variable = options.variable || settings.variable, - hasVariable = variable; + source = "__p += '"; // compile regexp to match each delimiter var reDelimiters = RegExp( @@ -4072,9 +4091,23 @@ source += "';\n"; + // resolve imported variables + var imports = options.imports, + importsKeys = ['_'], + importsValues = [lodash]; + + if (imports && imports != templateImports) { + isEvaluating = true; + imports = defaults({}, imports, settings.imports); + importsKeys = keys(imports); + importsValues = values(imports); + } // if `variable` is not specified and the template contains "evaluate" // delimiters, wrap a with-statement around the generated code to add the // data object to the top of the scope chain + var variable = options.variable || settings.variable, + hasVariable = variable; + if (!hasVariable) { variable = 'obj'; if (isEvaluating) { @@ -4113,12 +4146,11 @@ : ''; try { - result = Function('_', 'return ' + source + sourceURL)(lodash); + var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues); } catch(e) { e.source = source; throw e; } - if (data) { return result(data); } diff --git a/lodash.min.js b/lodash.min.js index 8d30ffda9f..e6ebc78ecc 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,36 +4,37 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++ee;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return yr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; -if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):pr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),pr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(dr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; +if(typeof o!="number")var f=hr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(dr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:""};var ar={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:ar};var fr={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},mr=b(yr),_r=f(fr,{g:"if(t[i]==null)"+fr.g}),dr=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var br=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=sr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=hr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&dr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=hr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,t,e){n||(n=""),e||(e={});var u,o,i=r.templateSettings,a=0,f=e.interpolate||i.interpolate||_t,l="__p+='",p=e.variable||i.variable,s=p;n.replace(RegExp((e.escape||i.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(e.evaluate||i.evaluate||_t).source+"|$","g"),function(t,r,e,o,i,f){return e||(e=o),l+=n.slice(a,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),i&&(l+="';"+i+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),u||(u=i||ft.test(r||e)),a=f+t.length,t -}),l+="';\n",s||(p="obj",u?l="with("+p+"){"+l+"}":(e=RegExp("(\\(\\s*)"+p+"\\."+p+"\\b","g"),l=l.replace(gt,"$&"+p+".").replace(e,"$1__d"))),l=(u?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+p+"){"+(s?"":p+"||("+p+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(s?"":",__d="+p+"."+p+"||"+p)+";")+l+"return __p}";try{o=Function("_","return "+l)(r)}catch(v){throw v.source=l,v}return t?o(t):(o.source=l,o)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g) -},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+"" -},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n; -r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file +},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,0r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:hr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){n||(n=""),u||(u={});var o,i=0,a=r.templateSettings,f=u.interpolate||a.interpolate||_t,l="__p+='";n.replace(RegExp((u.escape||a.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||a.evaluate||_t).source+"|$","g"),function(t,r,e,u,a,f){return e||(e=u),l+=n.slice(i,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),a&&(l+="';"+a+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),o||(o=a||ft.test(r||e)),i=f+t.length,t +});var l=l+"';\n",p=u.imports,f=["_"],s=[r];p&&p!=ar&&(o=Q,p=_r({},p,a.imports),f=hr(p),s=S(p)),a=u=u.variable||a.variable,a||(u="obj",o?l="with("+u+"){"+l+"}":(p=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),l=l.replace(gt,"$&"+u+".").replace(p,"$1__d"))),l=(o?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+u+"){"+(a?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(a?"":",__d="+u+"."+u+"||"+u)+";")+l+"return __p}"; +try{var v=Function(f,"return "+l).apply(t,s)}catch(g){throw g.source=l,g}return e?v(e):(v.source=l,v)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,gr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t)) +}},r.take=P,r.head=P,gr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,pr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),pr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),pr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Wt&&pr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r +})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 6922cef2b1..4de230df26 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -282,9 +282,10 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - "for (var argsIndex = 1, argsLength = typeof guard == 'number' ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n" + + "var argsIndex = 0, argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'while (++argsIndex < argsLength) {\n' + ' if ((iteratee = arguments[argsIndex])) {', - 'objectLoop': 'result[index] = iteratee[index]', + 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -292,15 +293,15 @@ * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. */ var eachIteratorOptions = { + 'arrays': true, 'args': 'collection, callback, thisArg', 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", - 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', - 'objectLoop': 'if (callback(iteratee[index], index, collection) === false) return result' + 'loop': 'if (callback(iteratee[index], index, collection) === false) return result' }; /** Reusable iterator options for `forIn` and `forOwn` */ var forOwnIteratorOptions = { - 'arrayLoop': null + 'arrays': false }; /*--------------------------------------------------------------------------*/ @@ -424,24 +425,27 @@ * * @private * @param {Object} [options1, options2, ...] The compile options object(s). + * arrays - A boolean to specify support for iterating arrays and array-like objects. * useHas - A boolean to specify using `hasOwnProperty` checks in the object loop. * args - A string of comma separated arguments the iteration function will accept. * top - A string of code to execute before the iteration branches. - * arrayLoop - A string of code to execute in the array loop. - * objectLoop - A string of code to execute in the object loop. + * loop - A string of code to execute in the object loop. * bottom - A string of code to execute after the iteration branches. * * @returns {Function} Returns the compiled function. */ function createIterator() { var data = { - 'arrayLoop': '', - 'bottom': '', + // support properties 'hasDontEnumBug': hasDontEnumBug, - 'objectLoop': '', 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, + + // iterator options + 'arrays': false, + 'bottom': '', + 'loop': '', 'top': '', 'useHas': true }; @@ -3343,10 +3347,10 @@ * @example * * _.random(0, 5); - * // => a number between 1 and 5 + * // => a number between 0 and 5 * * _.random(5); - * // => also a number between 1 and 5 + * // => also a number between 0 and 5 */ function random(min, max) { if (min == null && max == null) { diff --git a/test/test-build.js b/test/test-build.js index 6e4f764477..3dae56ff3b 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -351,6 +351,7 @@ object = { 'a': 1, 'b': 2, 'c': 3 }, noop = function() {}, string = 'abc', + template = '<%= a %>', func = lodash[methodName]; try { @@ -442,6 +443,9 @@ else if (utilityMethods.indexOf(methodName) > -1) { if (methodName == 'result') { func(object, 'b'); + } else if (methodName == 'template') { + func(template, object); + func(template, null, { 'imports': object })(object); } else if (methodName == 'times') { func(2, noop, object); } else { @@ -765,6 +769,7 @@ ok(lodash.some([false, true, false]), '_.some: ' + basename); equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename); + equal('imports' in lodash.templateSettings, false, '_.templateSettings should not have an "imports" property: ' + basename); equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename); start(); diff --git a/test/test.js b/test/test.js index 8bc19960cd..6f03922041 100644 --- a/test/test.js +++ b/test/test.js @@ -1768,20 +1768,25 @@ }); test('should tokenize delimiters', function() { - var compiled = _.template(''); - equal(compiled({ 'type': 1 }), ''); + var compiled = _.template(''), + data = { 'type': 1 }; + + equal(compiled(data), ''); }); test('should work with "interpolate" delimiters containing ternary operators', function() { - var compiled = _.template('<%= value ? value : "b" %>'); - equal(compiled({ 'value': 'a' }), 'a'); + var compiled = _.template('<%= value ? value : "b" %>'), + data = { 'value': 'a' }; + + equal(compiled(data), 'a'); }); test('should parse delimiters with newlines', function() { var expected = '<<\nprint("

" + (value ? "yes" : "no") + "

")\n>>', - compiled = _.template(expected, null, { 'evaluate': /<<(.+?)>>/g }); + compiled = _.template(expected, null, { 'evaluate': /<<(.+?)>>/g }), + data = { 'value': true }; - equal(compiled({ 'value': true }), expected); + equal(compiled(data), expected); }); test('should parse ES6 template delimiters', function() { @@ -1789,6 +1794,13 @@ equal(_.template('1${value}3', data), '123'); equal(_.template('${"{" + value + "\\}"}', data), '{2}'); }); + + test('supports the "imports" option', function() { + var options = { 'imports': { 'a': 1 } }, + compiled = _.template('<%= a %>', null, options); + + equal(compiled({}), '1'); + }); }()); /*--------------------------------------------------------------------------*/ From 62246d7d439940ce7f793c7717943875c47ddfe1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 31 Dec 2012 14:45:53 -0600 Subject: [PATCH 042/176] Update platform.js. Former-commit-id: 5e5170b0c29175469d4b80010297d31afa14b5c8 --- vendor/platform.js/platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/platform.js/platform.js b/vendor/platform.js/platform.js index a63ceab256..8a45ab23ef 100644 --- a/vendor/platform.js/platform.js +++ b/vendor/platform.js/platform.js @@ -885,7 +885,7 @@ * The CPU architecture the OS is built for. * * @memberOf platform.os - * @type String|Null + * @type Number|Null */ 'architecture': null, From 87dc6631eee78d43bc66b03b727ec9a9fef8ec50 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 31 Dec 2012 14:46:45 -0600 Subject: [PATCH 043/176] Cleanup "imports" template option. Former-commit-id: f9f52b1f63908bcb7db7837a9bda067f2855acbb --- build.js | 11 +- doc/README.md | 252 +++++++++++++++++++++++-------------------- lodash.js | 78 ++++++-------- lodash.min.js | 53 +++++---- lodash.underscore.js | 8 +- 5 files changed, 200 insertions(+), 202 deletions(-) diff --git a/build.js b/build.js index b7505bfdc2..10a8e05228 100755 --- a/build.js +++ b/build.js @@ -1398,8 +1398,8 @@ source = removeVar(source, 'cloneableClasses'); source = removeVar(source, 'ctorByClass'); - source = removeVar(source, 'templateImports'); - source = source.replace(/,\s*'imports'.+/, ''); + // remove `_.templateSettings.imports assignment + source = source.replace(/,[^']*'imports':[^}]+}/, ''); // remove large array optimizations source = removeFunction(source, 'cachedContains'); @@ -1748,6 +1748,13 @@ source = removeIsArgumentsFallback(source); } + // remove `iteratorTemplate` dependency checks from `_.template` + source = source.replace(matchFunction(source, 'template'), function(match) { + return match + .replace(/iteratorTemplate *&& */g, '') + .replace(/iteratorTemplate *\?([^:]+):[^,;]+/g, '$1'); + }); + /*----------------------------------------------------------------------*/ if (isLegacy) { diff --git a/doc/README.md b/doc/README.md index b8657abd11..ec5f7117c9 100644 --- a/doc/README.md +++ b/doc/README.md @@ -161,6 +161,14 @@ + + +## `Methods` +* [`_.templateSettings.imports._`](#_templatesettingsimports_) + + + + ## `Properties` @@ -170,8 +178,7 @@ * [`_.templateSettings.evaluate`](#_templatesettingsevaluate) * [`_.templateSettings.interpolate`](#_templatesettingsinterpolate) * [`_.templateSettings.variable`](#_templatesettingsvariable) -* [`_.templateSettings.imports`](#_templatesettingstemplateimports) -* [`_.templateSettings.imports._`](#_templatesettingsimports_) +* [`_.templateSettings.imports`](#_templatesettingsimports) @@ -189,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2787 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -213,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2817 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -238,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2863 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2852 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -266,7 +273,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2890 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2879 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -294,7 +301,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2932 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -326,7 +333,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -351,7 +358,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2991 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2980 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -375,7 +382,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3044 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3033 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -400,7 +407,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3060 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -429,7 +436,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3090 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -454,7 +461,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3135 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -492,7 +499,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3174 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -520,7 +527,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3229 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3218 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -564,7 +571,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3250 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -588,7 +595,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -627,7 +634,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3343 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -652,7 +659,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3385 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3374 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -709,7 +716,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4245 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -739,7 +746,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4262 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -760,7 +767,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4279 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -791,7 +798,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1976 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -819,7 +826,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2018 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -857,7 +864,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2076 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2065 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -889,7 +896,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2106 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -918,7 +925,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2134 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -947,7 +954,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2178 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -976,7 +983,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2224 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2213 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1008,7 +1015,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1040,7 +1047,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2299 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2288 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1069,7 +1076,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2322 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1101,7 +1108,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2364 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1133,7 +1140,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2412 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1159,7 +1166,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2474 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2463 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1190,7 +1197,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2498 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2487 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1220,7 +1227,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2540 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2529 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1251,7 +1258,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2578 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1277,7 +1284,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2588 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1301,7 +1308,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2632 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2621 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1331,7 +1338,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2646 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1360,7 +1367,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2692 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1392,7 +1399,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2727 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1416,7 +1423,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2757 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1454,7 +1461,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3418 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3407 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1482,7 +1489,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3440 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1513,7 +1520,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3470 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1544,7 +1551,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3527 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1585,7 +1592,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3550 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3539 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1612,7 +1619,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3583 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3572 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1638,7 +1645,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3647 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1663,7 +1670,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3627 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1690,7 +1697,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3660 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1716,7 +1723,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3687 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1742,7 +1749,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3722 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1769,7 +1776,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3755 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3744 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1794,7 +1801,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3808 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3797 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1830,7 +1837,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L840 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L829 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1858,7 +1865,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1039 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1894,7 +1901,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1134 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1927,7 +1934,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1156 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1953,7 +1960,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L896 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L885 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1989,7 +1996,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2017,7 +2024,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2044,7 +2051,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1200 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2069,7 +2076,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1228 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1217 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2093,7 +2100,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L847 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2120,7 +2127,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1246 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2147,7 +2154,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1265 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2171,7 +2178,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1282 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2195,7 +2202,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1310 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1299 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2219,7 +2226,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1324 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2249,7 +2256,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1366 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2280,7 +2287,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1517 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2318,7 +2325,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1534 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2342,7 +2349,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1597 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2377,7 +2384,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1630 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1619 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2404,7 +2411,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1636 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2428,7 +2435,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1564 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2458,7 +2465,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1664 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2493,7 +2500,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1689 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2517,7 +2524,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1706 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2541,7 +2548,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1723 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2565,7 +2572,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L924 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2589,7 +2596,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1769 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1758 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2624,7 +2631,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1832 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2655,7 +2662,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1877 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1866 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2679,7 +2686,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1915 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2710,7 +2717,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1941 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2741,7 +2748,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3821 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2765,7 +2772,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2790,7 +2797,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3876 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3865 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2820,7 +2827,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3900 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2840,7 +2847,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3923 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3912 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2868,7 +2875,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3950 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2903,7 +2910,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4035 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2981,7 +2988,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4187 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3013,7 +3020,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4213 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4197 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3037,7 +3044,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3064,6 +3071,25 @@ _.uniqueId(); + + +## `Methods` + + + +### `_.templateSettings.imports._` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L348 "View in source") [Ⓣ][1] + +A reference to the `lodash` function. + +* * * + + + + + + + ## `Properties` @@ -3071,7 +3097,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4460 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4444 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3083,7 +3109,7 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L300 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3095,7 +3121,7 @@ _.uniqueId(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L329 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3107,7 +3133,7 @@ _.uniqueId(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L338 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L316 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3119,7 +3145,7 @@ _.uniqueId(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L324 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3131,7 +3157,7 @@ _.uniqueId(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L356 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L332 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3142,8 +3168,8 @@ _.uniqueId(); -### `_.templateSettings.templateImports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L299 "View in source") [Ⓣ][1] +### `_.templateSettings.imports` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L340 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. @@ -3152,18 +3178,6 @@ _.uniqueId(); - - -### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] - -*(Object)*: A reference to the `lodash` function. - -* * * - - - - diff --git a/lodash.js b/lodash.js index e58e0373cf..3cbe6aaa53 100644 --- a/lodash.js +++ b/lodash.js @@ -288,26 +288,6 @@ this.__wrapped__ = value; } - /** - * Used to import variables into the compiled template. - * - * @name imports - * @static - * @memberOf _.templateSettings - * @type Object - */ - var templateImports = { - - /** - * A reference to the `lodash` function. - * - * @static - * @memberOf _.templateSettings.imports - * @type Object - */ - '_': lodash - }; - /** * By default, the template delimiters used by Lo-Dash are similar to those in * embedded Ruby (ERB). Change the following template settings to use alternative @@ -322,7 +302,6 @@ /** * Used to detect `data` property values to be HTML-escaped. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -331,7 +310,6 @@ /** * Used to detect code to be evaluated. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -340,7 +318,6 @@ /** * Used to detect `data` property values to inject. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -349,13 +326,27 @@ /** * Used to reference the data object in the template text. * - * @static * @memberOf _.templateSettings * @type String */ 'variable': '', - 'imports': templateImports + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type Object + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type Function + */ + '_': lodash + } }; /*--------------------------------------------------------------------------*/ @@ -483,9 +474,7 @@ 'bottom': ' }\n}' }; - /** - * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. - */ + /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ var eachIteratorOptions = { 'arrays': true, 'args': 'collection, callback, thisArg', @@ -4048,21 +4037,27 @@ // http://ejohn.org/blog/javascript-micro-templating/ // and Laura Doktorova's doT.js // https://github.com/olado/doT + var settings = lodash.templateSettings; text || (text = ''); - options || (options = {}); - var isEvaluating, - index = 0, - settings = lodash.templateSettings, - interpolate = options.interpolate || settings.interpolate || reNoMatch, + // avoid missing dependencies when `iteratorTemplate` is not defined + options = iteratorTemplate ? defaults({}, options, settings) : settings; + + var imports = iteratorTemplate && defaults({}, options.imports, settings.imports), + importsKeys = iteratorTemplate ? keys(imports) : ['_'], + importsValues = iteratorTemplate ? values(imports) : [lodash]; + + var index = 0, + interpolate = options.interpolate || reNoMatch, + isEvaluating = !(importsKeys.length == 1 && importsKeys[0] == '_' && importsValues[0] === lodash), source = "__p += '"; // compile regexp to match each delimiter var reDelimiters = RegExp( - (options.escape || settings.escape || reNoMatch).source + '|' + + (options.escape || reNoMatch).source + '|' + interpolate.source + '|' + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + - (options.evaluate || settings.evaluate || reNoMatch).source + '|$' + (options.evaluate || reNoMatch).source + '|$' , 'g'); text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { @@ -4091,21 +4086,10 @@ source += "';\n"; - // resolve imported variables - var imports = options.imports, - importsKeys = ['_'], - importsValues = [lodash]; - - if (imports && imports != templateImports) { - isEvaluating = true; - imports = defaults({}, imports, settings.imports); - importsKeys = keys(imports); - importsValues = values(imports); - } // if `variable` is not specified and the template contains "evaluate" // delimiters, wrap a with-statement around the generated code to add the // data object to the top of the scope chain - var variable = options.variable || settings.variable, + var variable = options.variable, hasVariable = variable; if (!hasVariable) { diff --git a/lodash.min.js b/lodash.min.js index e6ebc78ecc..eee01f887f 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -6,35 +6,34 @@ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return yr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):pr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),pr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(dr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; -if(typeof o!="number")var f=hr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(dr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; +if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},ar={_:r}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:ar};var fr={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},mr=b(yr),_r=f(fr,{g:"if(t[i]==null)"+fr.g}),dr=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var br=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=sr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=hr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&dr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=hr(n),e=r.length,u=Array(e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var ar={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:hr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){n||(n=""),u||(u={});var o,i=0,a=r.templateSettings,f=u.interpolate||a.interpolate||_t,l="__p+='";n.replace(RegExp((u.escape||a.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||a.evaluate||_t).source+"|$","g"),function(t,r,e,u,a,f){return e||(e=u),l+=n.slice(i,f).replace(bt,c),r&&(l+="'+__e("+r+")+'"),a&&(l+="';"+a+";__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),o||(o=a||ft.test(r||e)),i=f+t.length,t -});var l=l+"';\n",p=u.imports,f=["_"],s=[r];p&&p!=ar&&(o=Q,p=_r({},p,a.imports),f=hr(p),s=S(p)),a=u=u.variable||a.variable,a||(u="obj",o?l="with("+u+"){"+l+"}":(p=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),l=l.replace(gt,"$&"+u+".").replace(p,"$1__d"))),l=(o?l.replace(lt,""):l).replace(pt,"$1").replace(st,"$1;"),l="function("+u+"){"+(a?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(a?"":",__d="+u+"."+u+"||"+u)+";")+l+"return __p}"; -try{var v=Function(f,"return "+l).apply(t,s)}catch(g){throw g.source=l,g}return e?v(e):(v.source=l,v)},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,gr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t)) -}},r.take=P,r.head=P,gr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,pr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),pr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this -}}),pr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Wt&&pr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r -})(this); \ No newline at end of file +},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,0r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=mr({},u,o),i=mr({},u.imports,o.imports),o=gr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +}),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); +return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) +}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 4de230df26..b883590b25 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -242,7 +242,6 @@ /** * Used to detect `data` property values to be HTML-escaped. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -251,7 +250,6 @@ /** * Used to detect code to be evaluated. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -260,7 +258,6 @@ /** * Used to detect `data` property values to inject. * - * @static * @memberOf _.templateSettings * @type RegExp */ @@ -269,7 +266,6 @@ /** * Used to reference the data object in the template text. * - * @static * @memberOf _.templateSettings * @type String */ @@ -289,9 +285,7 @@ 'bottom': ' }\n}' }; - /** - * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. - */ + /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ var eachIteratorOptions = { 'arrays': true, 'args': 'collection, callback, thisArg', From 316caf7e8cb7ca2d000380b967f2f458f74fba36 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 2 Jan 2013 23:35:38 -0800 Subject: [PATCH 044/176] Tweak UglifyJS "comments" option and update vendor/benchmark.js. Former-commit-id: 6f09f27936f9453c58138e216399a51732a00173 --- build/minify.js | 2 +- vendor/benchmark.js/benchmark.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/minify.js b/build/minify.js index 9cce7d13f7..fbd7494124 100755 --- a/build/minify.js +++ b/build/minify.js @@ -330,7 +330,7 @@ // restrict lines to 500 characters for consistency with the Closure Compiler var stream = uglifyJS.OutputStream({ 'ascii_only': true, - 'comments': /\* *@license/, + 'comments': /@cc_on|@license|@preserve/i, 'max_line_len': 500, }); diff --git a/vendor/benchmark.js/benchmark.js b/vendor/benchmark.js/benchmark.js index fe5ff3db06..2a39cb4fe4 100644 --- a/vendor/benchmark.js/benchmark.js +++ b/vendor/benchmark.js/benchmark.js @@ -1648,7 +1648,10 @@ function interpolate(string, object) { forOwn(object, function(value, key) { // escape regexp special characters in `key` - string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value); + string = string.replace( + RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), + value.replace(/\$/g, '$$$$') + ); }); return string; } From 7362dd1a7c054aaa280951e6f2560e94828d359c Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Fri, 4 Jan 2013 02:20:06 -0800 Subject: [PATCH 045/176] Update `_.range` docs to consistently reference 'end' Former-commit-id: a8ee760eb86e67eb898715ee9719fa8981eeda17 --- doc/README.md | 4 ++-- lodash.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/README.md b/doc/README.md index ec5f7117c9..0c8f8b5684 100644 --- a/doc/README.md +++ b/doc/README.md @@ -463,7 +463,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3135 "View in source") [Ⓣ][1] -Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. +Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. #### Arguments 1. `[start=0]` *(Number)*: The start of the range. @@ -3184,4 +3184,4 @@ A reference to the `lodash` function. - [1]: #Arrays "Jump back to the TOC." \ No newline at end of file + [1]: #Arrays "Jump back to the TOC." diff --git a/lodash.js b/lodash.js index 3cbe6aaa53..534ab7322c 100644 --- a/lodash.js +++ b/lodash.js @@ -3105,7 +3105,7 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to but not including `stop`. This method is a port of Python's + * `start` up to but not including `end`. This method is a port of Python's * `range()` function. See http://docs.python.org/library/functions.html#range. * * @static From e2c2a37221c46ea131f4c621890838dd8a75041c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 5 Jan 2013 00:12:33 -0800 Subject: [PATCH 046/176] Make `_.merge` assign `null` values. [closes #151] Former-commit-id: 5a839996db9475182d5957d2f8cb4b3c265b0d9f --- build/post-compile.js | 4 ++-- doc/README.md | 6 +++--- lodash.js | 6 +++--- lodash.min.js | 2 +- lodash.underscore.js | 4 ++-- test/test-build.js | 6 +++--- test/test.js | 10 ++++++++++ 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/build/post-compile.js b/build/post-compile.js index bcb4cc8bba..23d91afe8e 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -41,8 +41,8 @@ // flip `typeof` expressions to help optimize Safari and // correct the AMD module definition for AMD build optimizers // (e.g. from `"number" == typeof x` to `typeof x == "number") - source = source.replace(/(return)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[\w.]+))/g, function(match, ret, type, equality, expression) { - return (ret ? ret + ' ' : '') + expression + equality + type; + source = source.replace(/(\w)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[.\w[\]]+))/g, function(match, other, type, equality, expression) { + return (other ? other + ' ' : '') + expression + equality + type; }); // add trailing semicolon diff --git a/doc/README.md b/doc/README.md index 0c8f8b5684..94f6f03c44 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1738,7 +1738,7 @@ Creates a function that is restricted to execute `func` once. Repeat calls to th var initialize = _.once(createApplication); initialize(); initialize(); -// Application is only created once. +// `initialize` executes `createApplication` once ``` * * * @@ -2598,7 +2598,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1758 "View in source") [Ⓣ][1] -Recursively merges own enumerable properties of the source object(s), that don't resolve to `null`/`undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. #### Arguments 1. `object` *(Object)*: The destination object. @@ -3184,4 +3184,4 @@ A reference to the `lodash` function. - [1]: #Arrays "Jump back to the TOC." + [1]: #Arrays "Jump back to the TOC." \ No newline at end of file diff --git a/lodash.js b/lodash.js index 534ab7322c..4458143f01 100644 --- a/lodash.js +++ b/lodash.js @@ -1726,7 +1726,7 @@ /** * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `null`/`undefined`, into the `destination` object. Subsequent + * don't resolve to `undefined`, into the `destination` object. Subsequent * sources will overwrite propery assignments of previous sources. * * @static @@ -1796,7 +1796,7 @@ // recursively merge objects and arrays (susceptible to call stack limits) object[key] = merge(value, source, indicatorObject, stackA, stackB); } - } else if (source != null) { + } else if (typeof source != 'undefined') { object[key] = source; } }); @@ -3682,7 +3682,7 @@ * var initialize = _.once(createApplication); * initialize(); * initialize(); - * // Application is only created once. + * // `initialize` executes `createApplication` once */ function once(func) { var ran, diff --git a/lodash.min.js b/lodash.min.js index eee01f887f..7bec0348f9 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -11,7 +11,7 @@ var r=n.constructor;return!j(r)&&(!tr||!p(n))||r instanceof r?tt?(sr(n,function( }for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:vr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(Et.call(n,"index")&&(a.index=n.index),Et.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return sr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=gr(n),e=r.length,u={};++tr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++r Date: Sat, 5 Jan 2013 10:14:15 -0800 Subject: [PATCH 047/176] Remove `isKeysFast` guard. Former-commit-id: 38a63ed31d652fd198ebf30dbb0f1546160c30c1 --- build.js | 15 ++++------ build/post-compile.js | 2 +- build/pre-compile.js | 30 ++++++++++--------- lodash.js | 12 +++----- lodash.min.js | 62 ++++++++++++++++++++-------------------- lodash.underscore.js | 5 ++-- lodash.underscore.min.js | 2 +- 7 files changed, 61 insertions(+), 67 deletions(-) diff --git a/build.js b/build.js index 10a8e05228..db656ceb47 100755 --- a/build.js +++ b/build.js @@ -173,7 +173,7 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysFast', + 'isKeysNative', 'loop', 'nonEnumArgs', 'noCharByIndex', @@ -889,16 +889,14 @@ * @returns {String} Returns the modified source. */ function removeKeysOptimization(source) { - source = removeVar(source, 'isKeysFast'); - // remove optimized branch in `iteratorTemplate` source = source.replace(getIteratorTemplate(source), function(match) { - return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysFast[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); + return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysNative[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); }); // remove data object property assignment in `createIterator` source = source.replace(matchFunction(source, 'createIterator'), function(match) { - return match.replace(/ *'isKeysFast':.+\n/, ''); + return match.replace(/ *'isKeysNative':.+\n/, ''); }); return source; @@ -1382,7 +1380,7 @@ source = setUseStrictOption(source, isStrict); if (isLegacy) { - _.each(['getPrototypeOf', 'isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { + _.each(['getPrototypeOf', 'isBindFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { source = replaceVar(source, varName, 'false'); }); @@ -1401,9 +1399,10 @@ // remove `_.templateSettings.imports assignment source = source.replace(/,[^']*'imports':[^}]+}/, ''); - // remove large array optimizations + // remove large array and keys optimizations source = removeFunction(source, 'cachedContains'); source = removeVar(source, 'largeArraySize'); + source = removeKeysOptimization(source); // replace `_.assign` source = replaceFunction(source, 'assign', [ @@ -1700,8 +1699,6 @@ } } if (isMobile) { - source = replaceVar(source, 'isKeysFast', 'false'); - source = removeKeysOptimization(source); source = removeNoNodeClass(source); // remove `prototype` [[Enumerable]] fix from `_.keys` diff --git a/build/post-compile.js b/build/post-compile.js index 23d91afe8e..cbe27dd9e1 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -41,7 +41,7 @@ // flip `typeof` expressions to help optimize Safari and // correct the AMD module definition for AMD build optimizers // (e.g. from `"number" == typeof x` to `typeof x == "number") - source = source.replace(/(\w)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[.\w[\]]+))/g, function(match, other, type, equality, expression) { + source = source.replace(/(\w)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[.\w]+(?!\[)))/g, function(match, other, type, equality, expression) { return (other ? other + ' ' : '') + expression + equality + type; }); diff --git a/build/pre-compile.js b/build/pre-compile.js index 6ffee418e2..22a92ff0c9 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -39,7 +39,7 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysFast', + 'isKeysNative', 'loop', 'nonEnumArgs', 'noCharByIndex', @@ -275,14 +275,15 @@ // minify properties properties.forEach(function(property, index) { - var reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'), + var minName = minNames[index], + reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'), reDotProp = RegExp('\\.' + property + '\\b', 'g'), rePropColon = RegExp("([^?\\s])\\s*([\"'])?\\b" + property + "\\2 *:", 'g'); modified = modified - .replace(reBracketProp, "['" + minNames[index] + "']") - .replace(reDotProp, "['" + minNames[index] + "']") - .replace(rePropColon, "$1'" + minNames[index] + "':"); + .replace(reBracketProp, "['" + minName + "']") + .replace(reDotProp, "['" + minName + "']") + .replace(rePropColon, "$1'" + minName + "':"); }); // replace with modified snippet @@ -320,35 +321,36 @@ }); if (isCreateIterator) { - // replace with modified snippet early and clip snippet to the `factory` - // call so other arguments aren't minified + // replace with modified snippet early and clip snippet source = source.replace(snippet, modified); - snippet = modified = modified.replace(/factory\([\s\S]+$/, ''); + snippet = modified = modified.replace(/^[\s\S]+?data *= *{[^}]+}.+|return factory\([\s\S]+$/g, ''); } - // minify snippet variables / arguments compiledVars.forEach(function(variable, index) { + var minName = minNames[index]; + // ensure properties in compiled strings aren't minified - modified = modified.replace(RegExp('([^.]\\b)' + variable + '\\b(?!\' *[\\]:])', 'g'), '$1' + minNames[index]); + modified = modified.replace(RegExp('([^.]\\b)' + variable + '\\b(?!\' *[\\]:])', 'g'), '$1' + minName); // correct `typeof` values if (/^(?:boolean|function|object|number|string|undefined)$/.test(variable)) { - modified = modified.replace(RegExp("(typeof [^']+')" + minNames[index] + "'", 'g'), '$1' + variable + "'"); + modified = modified.replace(RegExp("(typeof [^']+')" + minName + "'", 'g'), '$1' + variable + "'"); } }); // minify `createIterator` option property names iteratorOptions.forEach(function(property, index) { + var minName = minNames[index]; if (isIteratorTemplate) { // minify property names as interpolated template variables - modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]); + modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minName); } else { // minify property name strings - modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'"); + modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minName + "'"); // minify property names in accessors if (isCreateIterator) { - modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minNames[index]); + modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minName); } } }); diff --git a/lodash.js b/lodash.js index 4458143f01..dadc7af57f 100644 --- a/lodash.js +++ b/lodash.js @@ -117,14 +117,10 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent, - isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); + var isIeOpera = !!window.attachEvent; /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && !isV8; - - /* Detect if `Object.keys` exists and is inferred to be fast (IE, Opera, V8) */ - var isKeysFast = nativeKeys && (isIeOpera || isV8); + var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); /** * Detect the JScript [[DontEnum]] bug: @@ -414,7 +410,7 @@ ' <% } %>' + // iterate own properties using `Object.keys` if it's fast - ' <% if (isKeysFast && useHas) { %>\n' + + ' <% if (isKeysNative && useHas) { %>\n' + ' var ownIndex = -1,\n' + ' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n' + ' length = ownProps.length;\n\n' + @@ -673,7 +669,7 @@ var data = { // support properties 'hasDontEnumBug': hasDontEnumBug, - 'isKeysFast': isKeysFast, + 'isKeysNative': nativeKeys, 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, diff --git a/lodash.min.js b/lodash.min.js index 7bec0348f9..7a06e217f7 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,36 +4,36 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; -if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var ar={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=mr({},u,o),i=mr({},u.imports,o.imports),o=gr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,er,Ft,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?Bt(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function B(n,t){return R(n,t+"")}function I(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; +if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),D(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?Bt(0,u+r):r||0)-1;else if(r)return e=H(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Gt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,qt=ht.test(qt=Array.isArray)&&qt,Dt=n.isFinite,Rt=n.isNaN,Ft=ht.test(Ft=Object.keys)&&Ft,Bt=Math.max,It=Math.min,Tt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Ht="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=Nt&&/\n|true/.test(Nt+Vt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Ht}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Ht]=tr[Lt]=tr[Ut]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Ht]=Object,rr[Kt]=Number,rr[Lt]=RegExp,rr[Ut]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=qt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=R,r.max=F,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?Bt(0,e+r):It(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Tt()*((+t||0)-n+1))},r.reduce=I,r.reduceRight=T,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=H,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); -return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) -}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=q,r.foldl=I,r.foldr=T,r.include=k,r.inject=I,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,Bt(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); +return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) +}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 7a40320f86..0467fe2807 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -115,11 +115,10 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent, - isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); + var isIeOpera = !!window.attachEvent; /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && !isV8; + var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); /** * Detect if `Array#shift` and `Array#splice` augment array-like objects diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index b6a76ba401..5790fb0da0 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -14,7 +14,7 @@ if(o!=At)return K;var o=n.constructor,a=t.constructor;if(o!=a&&(!b(o)||!(o insta });return i}function R(n,t,r){var e=-1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++ro&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=Rt(n),u=i.length; return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1; else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +}function V(n){return n}function G(n){N(_(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__];return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) }),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o) From 4e631c9e8fd5b7c4c74f897f17f95c9966eb55cd Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 5 Jan 2013 22:09:48 -0800 Subject: [PATCH 048/176] Flip `noNodeClass` check to avoid breaking when Firebug's "break on all errors" option is enabled. [closes #85] Former-commit-id: f98c3af700279cb688c5df6c696b141bf626e26b --- doc/README.md | 212 +++++++++++++++++++++++++------------------------- lodash.js | 4 +- lodash.min.js | 2 +- 3 files changed, 109 insertions(+), 109 deletions(-) diff --git a/doc/README.md b/doc/README.md index 94f6f03c44..e3bfcb0238 100644 --- a/doc/README.md +++ b/doc/README.md @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2783 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2817 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2813 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2852 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -273,7 +273,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2875 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -301,7 +301,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2917 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -333,7 +333,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2952 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -358,7 +358,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2980 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2976 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -382,7 +382,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3029 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -407,7 +407,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3056 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -436,7 +436,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3086 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -461,7 +461,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3135 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3131 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -499,7 +499,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3174 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3170 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -527,7 +527,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3218 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3214 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -571,7 +571,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3246 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -595,7 +595,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3280 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -634,7 +634,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3339 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -659,7 +659,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3374 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3370 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -690,7 +690,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -716,7 +716,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4245 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4241 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -746,7 +746,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4258 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -767,7 +767,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4275 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -798,7 +798,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1972 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -826,7 +826,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -864,7 +864,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2065 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2061 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -896,7 +896,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2091 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -925,7 +925,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2130 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -954,7 +954,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2174 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -983,7 +983,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2213 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1015,7 +1015,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2251 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1047,7 +1047,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2288 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2284 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1076,7 +1076,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2318 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1108,7 +1108,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1140,7 +1140,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2412 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2408 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1166,7 +1166,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2463 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2459 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1197,7 +1197,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2487 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2483 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1227,7 +1227,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1258,7 +1258,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1284,7 +1284,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2588 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2584 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1308,7 +1308,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2617 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1338,7 +1338,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2642 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1367,7 +1367,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2692 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2688 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1399,7 +1399,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2727 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2723 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1423,7 +1423,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2753 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1461,7 +1461,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3407 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3403 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1489,7 +1489,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3436 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1520,7 +1520,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1551,7 +1551,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3516 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3512 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1592,7 +1592,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3539 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3535 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1619,7 +1619,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3572 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3568 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1645,7 +1645,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3632 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1670,7 +1670,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1697,7 +1697,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3656 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1723,7 +1723,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3683 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1749,7 +1749,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3722 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1776,7 +1776,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3740 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1801,7 +1801,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3797 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3793 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1837,7 +1837,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L825 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1865,7 +1865,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1039 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1035 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1901,7 +1901,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1130 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1934,7 +1934,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1156 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1152 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1960,7 +1960,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L885 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L881 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1996,7 +1996,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L905 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2024,7 +2024,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1171 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2051,7 +2051,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1200 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1196 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2076,7 +2076,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1217 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1213 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2100,7 +2100,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L847 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2127,7 +2127,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2154,7 +2154,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1261 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2178,7 +2178,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1282 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1278 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2202,7 +2202,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1299 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1295 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2226,7 +2226,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1320 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2256,7 +2256,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1362 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2287,7 +2287,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1513 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2325,7 +2325,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1530 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2349,7 +2349,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1597 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1593 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2384,7 +2384,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1619 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1615 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2411,7 +2411,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1632 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2435,7 +2435,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1564 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1560 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2465,7 +2465,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2500,7 +2500,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1685 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2524,7 +2524,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1706 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1702 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2548,7 +2548,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1723 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1719 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2572,7 +2572,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L924 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2596,7 +2596,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1758 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1754 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2631,7 +2631,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1828 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2662,7 +2662,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1866 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1862 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2686,7 +2686,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1900 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2717,7 +2717,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1937 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2748,7 +2748,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3821 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3817 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2772,7 +2772,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3835 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2797,7 +2797,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3861 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2827,7 +2827,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3885 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2847,7 +2847,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3908 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2875,7 +2875,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3950 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3946 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2910,7 +2910,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4031 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2988,7 +2988,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4167 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3020,7 +3020,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4193 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3044,7 +3044,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4213 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3078,7 +3078,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L348 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L344 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3097,7 +3097,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4444 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4440 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3109,7 +3109,7 @@ A reference to the `lodash` function. ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L296 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3121,7 +3121,7 @@ A reference to the `lodash` function. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L304 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3133,7 +3133,7 @@ A reference to the `lodash` function. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L312 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3145,7 +3145,7 @@ A reference to the `lodash` function. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L320 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3157,7 +3157,7 @@ A reference to the `lodash` function. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L332 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L328 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3169,7 +3169,7 @@ A reference to the `lodash` function. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L340 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L336 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index dadc7af57f..1be044822e 100644 --- a/lodash.js +++ b/lodash.js @@ -177,10 +177,10 @@ /** * Detect if a node's [[Class]] is unresolvable (IE < 9) * and that the JS engine won't error when attempting to coerce an object to - * a string without a `toString` property value of `typeof` "function". + * a string without a `toString` function. */ try { - var noNodeClass = ({ 'toString': 0 } + '', toString.call(document) == objectClass); + var noNodeClass = toString.call(document) == objectClass && !({ 'toString': 0 } + ''); } catch(e) { } /** diff --git a/lodash.min.js b/lodash.min.js index 7a06e217f7..ae27771e66 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -18,7 +18,7 @@ if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));retu }function C(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?Bt(0,u+r):r||0)-1;else if(r)return e=H(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Gt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,qt=ht.test(qt=Array.isArray)&&qt,Dt=n.isFinite,Rt=n.isNaN,Ft=ht.test(Ft=Object.keys)&&Ft,Bt=Math.max,It=Math.min,Tt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Ht="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=Nt&&/\n|true/.test(Nt+Vt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Ht}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Ht]=tr[Lt]=tr[Ut]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Ht]=Object,rr[Kt]=Number,rr[Lt]=RegExp,rr[Ut]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Ht&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Ht]=tr[Lt]=tr[Ut]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Ht]=Object,rr[Kt]=Number,rr[Lt]=RegExp,rr[Ut]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=qt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 }},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++t Date: Tue, 8 Jan 2013 22:21:38 -0800 Subject: [PATCH 049/176] Correct `_#tap` doc example. [closes #156] Former-commit-id: d1f6982e824a97db73546b8594c074b735580f8e --- doc/README.md | 6 +++--- lodash.js | 6 +++--- lodash.underscore.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/README.md b/doc/README.md index e3bfcb0238..5e30bb5b96 100644 --- a/doc/README.md +++ b/doc/README.md @@ -729,13 +729,13 @@ Invokes `interceptor` with the `value` as the first argument, and then returns ` #### Example ```js -_.chain([1, 2, 3, 200]) +_([1, 2, 3, 4]) .filter(function(num) { return num % 2 == 0; }) .tap(alert) .map(function(num) { return num * num; }) .value(); -// => // [2, 200] (alerted) -// => [4, 40000] +// => // [2, 4] (alerted) +// => [4, 16] ``` * * * diff --git a/lodash.js b/lodash.js index 1be044822e..c98c69c77b 100644 --- a/lodash.js +++ b/lodash.js @@ -4230,13 +4230,13 @@ * @returns {Mixed} Returns `value`. * @example * - * _.chain([1, 2, 3, 200]) + * _([1, 2, 3, 4]) * .filter(function(num) { return num % 2 == 0; }) * .tap(alert) * .map(function(num) { return num * num; }) * .value(); - * // => // [2, 200] (alerted) - * // => [4, 40000] + * // => // [2, 4] (alerted) + * // => [4, 16] */ function tap(value, interceptor) { interceptor(value); diff --git a/lodash.underscore.js b/lodash.underscore.js index 0467fe2807..4eb97d25db 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -3633,13 +3633,13 @@ * @returns {Mixed} Returns `value`. * @example * - * _.chain([1, 2, 3, 200]) + * _([1, 2, 3, 4]) * .filter(function(num) { return num % 2 == 0; }) * .tap(alert) * .map(function(num) { return num * num; }) * .value(); - * // => // [2, 200] (alerted) - * // => [4, 40000] + * // => // [2, 4] (alerted) + * // => [4, 16] */ function tap(value, interceptor) { interceptor(value); From ce33af6bb5014039b33f36350b7c65aa76041762 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 13:47:13 -0800 Subject: [PATCH 050/176] Cleanup `_.merge`. Former-commit-id: 4227c403f89a1085ce88ca992106b7ed0a3c210c --- lodash.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lodash.js b/lodash.js index c98c69c77b..13e11ce1e0 100644 --- a/lodash.js +++ b/lodash.js @@ -1774,15 +1774,12 @@ // avoid merging previously merged cyclic sources var stackLength = stackA.length; while (stackLength--) { - found = stackA[stackLength] == source; - if (found) { + if ((found = stackA[stackLength] == source)) { + object[key] = stackB[stackLength]; break; } } - if (found) { - object[key] = stackB[stackLength]; - } - else { + if (!found) { // add `source` and associated `value` to the stack of traversed objects stackA.push(source); stackB.push(value = (value = object[key], isArr) From 1eff48a429370a5875a423fac08c3e99fbb82497 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 15:58:32 -0800 Subject: [PATCH 051/176] Ensure iterator options are minified correctly. Former-commit-id: ae7b617051d91d99bad899d82df195d3c41bf76a --- build/pre-compile.js | 36 +++++++++++++------------- lodash.min.js | 60 ++++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 22a92ff0c9..4951dd1c1d 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -321,9 +321,24 @@ }); if (isCreateIterator) { - // replace with modified snippet early and clip snippet + // clip before the `factory` call to avoid minifying its arguments source = source.replace(snippet, modified); - snippet = modified = modified.replace(/^[\s\S]+?data *= *{[^}]+}.+|return factory\([\s\S]+$/g, ''); + snippet = modified = modified.replace(/return factory\([\s\S]+$/, ''); + } + // minify `createIterator` option property names + iteratorOptions.forEach(function(property, index) { + var minName = minNames[index]; + + // minify variables in `iteratorTemplate` or property names in everything else + modified = isIteratorTemplate + ? modified.replace(RegExp('\\b' + property + '\\b', 'g'), minName) + : modified.replace(RegExp("'" + property + "'", 'g'), "'" + minName + "'"); + }); + + if (isCreateIterator) { + // clip after the `data` object assignment to avoid minifying its values + source = source.replace(snippet, modified); + snippet = modified = modified.replace(/^[\s\S]+?data *= *{[^}]+}.+/, ''); } // minify snippet variables / arguments compiledVars.forEach(function(variable, index) { @@ -338,23 +353,6 @@ } }); - // minify `createIterator` option property names - iteratorOptions.forEach(function(property, index) { - var minName = minNames[index]; - if (isIteratorTemplate) { - // minify property names as interpolated template variables - modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minName); - } - else { - // minify property name strings - modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minName + "'"); - // minify property names in accessors - if (isCreateIterator) { - modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minName); - } - } - }); - // replace with modified snippet source = source.replace(snippet, modified); }); diff --git a/lodash.min.js b/lodash.min.js index ae27771e66..93c7a08648 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,37 +3,37 @@ * Lo-Dash 1.0.0-rc.3 lodash.com/license * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(n=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,er,Ft,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?Bt(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function B(n,t){return R(n,t+"")}function I(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; -if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),D(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?Bt(0,u+r):r||0)-1;else if(r)return e=H(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Gt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,qt=ht.test(qt=Array.isArray)&&qt,Dt=n.isFinite,Rt=n.isNaN,Ft=ht.test(Ft=Object.keys)&&Ft,Bt=Math.max,It=Math.min,Tt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Ht="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=Nt&&/\n|true/.test(Nt+Vt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Ht&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Ht]=tr[Lt]=tr[Ut]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Ht]=Object,rr[Kt]=Number,rr[Lt]=RegExp,rr[Ut]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=qt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=R,r.max=F,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?Bt(0,e+r):It(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Tt()*((+t||0)-n+1))},r.reduce=I,r.reduceRight=T,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=H,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=q,r.foldl=I,r.foldr=T,r.include=k,r.inject=I,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,Bt(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) }}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file From 016391e44298ddcdb96054b9a021f179ab4d6aab Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 16:46:52 -0800 Subject: [PATCH 052/176] Add `capitalize` and `getCategoryDependencies` method to build.js Former-commit-id: d939fbb482926a1673c5841f0c08b280ddca18e5 --- build.js | 85 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 21 deletions(-) diff --git a/build.js b/build.js index db656ceb47..0db0b07c8b 100755 --- a/build.js +++ b/build.js @@ -511,6 +511,17 @@ return source.join('\n'); } + /** + * Capitalizes a given string. + * + * @private + * @param {String} string The string to capitalize. + * @returns {String} Returns the capitalized string. + */ + function capitalize(string) { + return string[0].toUpperCase() + string.toLowerCase().slice(1); + } + /** * Removes unnecessary comments, whitespace, and pseudo private properties. * @@ -592,21 +603,46 @@ } /** - * Gets the Lo-Dash method assignments snippet from `source`. + * Gets the category of the given method name. * * @private * @param {String} source The source to inspect. - * @returns {String} Returns the method assignments snippet. + * @param {String} methodName The method name. + * @returns {String} Returns the method name's category. */ - function getMethodAssignments(source) { - return (source.match(/\/\*-+\*\/\n(?:\s*\/\/.*)*\s*lodash\.\w+ *=[\s\S]+?lodash\.VERSION *=.+/) || [''])[0]; + function getCategory(source, methodName) { + var result = /@category *(\w+)/.exec(matchFunction(source, methodName)); + return result ? result[1] : ''; + } + + /** + * Gets an array of category dependencies for a given category. + * + * @private + * @param {String} source The source to inspect. + * @param {String} category The category. + * @returns {Array} Returns an array of cetegory dependants. + */ + function getCategoryDependencies(source, category) { + var methods = _.uniq(getMethodsByCategory(source, category).reduce(function(result, methodName) { + push.apply(result, getDependencies(methodName)); + return result; + }, [])); + + var categories = _.uniq(methods.map(function(methodName) { + return getCategory(source, methodName); + })); + + return categories.filter(function(other) { + return other != category; + }); } /** * Gets an array of depenants for a method by a given name. * * @private - * @param {String} methodName The name of the method to query. + * @param {String} methodName The method name. * @returns {Array} Returns an array of method dependants. */ function getDependants(methodName) { @@ -695,6 +731,17 @@ return (source.match(/^( *)var iteratorTemplate *= *[\s\S]+?\n\1.+?;\n/m) || [''])[0]; } + /** + * Gets the Lo-Dash method assignments snippet from `source`. + * + * @private + * @param {String} source The source to inspect. + * @returns {String} Returns the method assignments snippet. + */ + function getMethodAssignments(source) { + return (source.match(/\/\*-+\*\/\n(?:\s*\/\/.*)*\s*lodash\.\w+ *=[\s\S]+?lodash\.VERSION *=.+/) || [''])[0]; + } + /** * Gets the names of methods in `source` belonging to the given `category`. * @@ -705,7 +752,7 @@ */ function getMethodsByCategory(source, category) { return allMethods.filter(function(methodName) { - return category && RegExp('@category ' + category + '\\b').test(matchFunction(source, methodName)); + return getCategory(source, methodName) == category; }); } @@ -1228,6 +1275,11 @@ // constructed using the "use strict" directive var isStrict = options.indexOf('strict') > -1; + // used to specify methods of specific categories + var categories = options.reduce(function(result, value) { + return /category/.test(value) ? optionToArray(value) : result; + }, []); + // used to specify the ways to export the `lodash` function var exportsOptions = options.reduce(function(result, value) { return /exports/.test(value) ? optionToArray(value).sort() : result; @@ -1340,21 +1392,13 @@ if (isUnderscore && !result) { result = getDependencies(underscoreMethods); } - // add method names by category - options.some(function(value) { - if (!/category/.test(value)) { - return false; - } - // resolve method names belonging to each category (case-insensitive) - var methodNames = optionToArray(value).reduce(function(accumulator, category) { - var capitalized = category[0].toUpperCase() + category.toLowerCase().slice(1); - return accumulator.concat(getMethodsByCategory(source, capitalized)); - }, []); - - return (result = _.union(result || [], getDependencies(methodNames))); - }); - + if (categories.length) { + result = _.union(result || [], getDependencies(categories.reduce(function(accumulator, category) { + // resolve method names belonging to each category (case-insensitive) + return accumulator.concat(getMethodsByCategory(source, capitalize(category))); + }, []))); + } if (!result) { result = allMethods.slice(); } @@ -1983,7 +2027,6 @@ } else { source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}(?:\s*else *{([\s\S]+?) *})?\n/, '$1\n'); } - if ((source.match(/\bfreeExports\b/g) || []).length < 2) { source = removeVar(source, 'freeExports'); } From 2d202e90b7f2c67772c6ea0e82b81ccfcf40d67d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 19:02:06 -0800 Subject: [PATCH 053/176] Add unofficial `_.where` like support for methods like `_.find`. [closes #159] Former-commit-id: c6106035af3f3d676cbd3f0a5c785b2c00ad1e9d --- build.js | 39 ++++++++++++++++++++------------------- lodash.js | 30 +++++++++++++++++------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/build.js b/build.js index 0db0b07c8b..be622a684b 100755 --- a/build.js +++ b/build.js @@ -76,23 +76,23 @@ 'compact': [], 'compose': [], 'contains': ['indexOf', 'isString'], - 'countBy': ['forEach'], + 'countBy': ['forEach', 'keys'], 'debounce': [], 'defaults': ['isArguments'], 'defer': [], 'delay': [], 'difference': ['indexOf'], 'escape': [], - 'every': ['isArray'], - 'filter': ['isArray'], - 'find': ['forEach'], + 'every': ['isArray', 'keys'], + 'filter': ['isArray', 'keys'], + 'find': ['forEach', 'keys'], 'first': [], 'flatten': ['isArray'], 'forEach': ['identity', 'isArguments', 'isArray', 'isString'], 'forIn': ['identity', 'isArguments'], 'forOwn': ['identity', 'isArguments'], 'functions': ['forIn', 'isFunction'], - 'groupBy': ['forEach'], + 'groupBy': ['forEach', 'keys'], 'has': [], 'identity': [], 'indexOf': ['sortedIndex'], @@ -120,11 +120,11 @@ 'keys': ['forOwn', 'isArguments', 'isObject'], 'last': [], 'lastIndexOf': [], - 'map': ['isArray'], - 'max': ['isArray', 'isString'], + 'map': ['isArray', 'keys'], + 'max': ['isArray', 'isString', 'keys'], 'memoize': [], 'merge': ['forOwn', 'isArray', 'isPlainObject'], - 'min': ['isArray', 'isString'], + 'min': ['isArray', 'isString', 'keys'], 'mixin': ['forEach', 'forOwn', 'functions'], 'noConflict': [], 'object': [], @@ -136,16 +136,16 @@ 'pluck': ['map'], 'random': [], 'range': [], - 'reduce': ['isArray'], + 'reduce': ['isArray', 'keys'], 'reduceRight': ['forEach', 'isString', 'keys'], 'reject': ['filter'], 'rest': [], 'result': ['isFunction'], 'shuffle': ['forEach'], 'size': ['keys'], - 'some': ['isArray'], - 'sortBy': ['forEach'], - 'sortedIndex': ['identity'], + 'some': ['isArray', 'keys'], + 'sortBy': ['forEach', 'keys'], + 'sortedIndex': ['identity', 'keys'], 'tap': ['mixin'], 'template': ['defaults', 'escape', 'keys', 'values'], 'throttle': [], @@ -153,11 +153,11 @@ 'toArray': ['isString', 'values'], 'unescape': [], 'union': ['uniq'], - 'uniq': ['identity', 'indexOf'], + 'uniq': ['identity', 'indexOf', 'keys'], 'uniqueId': [], 'value': ['mixin'], 'values': ['keys'], - 'where': ['filter', 'keys'], + 'where': ['filter'], 'without': ['indexOf'], 'wrap': [], 'zip': ['max', 'pluck'], @@ -1336,6 +1336,12 @@ exposeForOwn = !isUnderscore, exposeIsPlainObject = !isUnderscore; + // flags used to specify export options + var isAMD = exportsOptions.indexOf('amd') > -1, + isCommonJS = exportsOptions.indexOf('commonjs') > -1, + isGlobal = exportsOptions.indexOf('global') > -1, + isNode = exportsOptions.indexOf('node') > -1; + /*------------------------------------------------------------------------*/ // names of methods to include in the build @@ -2004,11 +2010,6 @@ // customize Lo-Dash's export bootstrap (function() { - var isAMD = exportsOptions.indexOf('amd') > -1, - isCommonJS = exportsOptions.indexOf('commonjs') > -1, - isGlobal = exportsOptions.indexOf('global') > -1, - isNode = exportsOptions.indexOf('node') > -1; - if (!isAMD) { source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +define[\s\S]+?else /, '$1'); } diff --git a/lodash.js b/lodash.js index 13e11ce1e0..5c8780ba74 100644 --- a/lodash.js +++ b/lodash.js @@ -633,9 +633,23 @@ if (!func) { return identity; } - if (typeof func != 'function') { + var type = typeof func; + if (type != 'function') { + if (type != 'object') { + return function(object) { + return object[func]; + }; + } + var props = keys(func); return function(object) { - return object[func]; + var length = props.length; + while (length--) { + var result = object[props[length]] === func[props[length]]; + if (!result) { + break; + } + } + return !!result; }; } if (typeof thisArg != 'undefined') { @@ -2748,17 +2762,7 @@ * // => [{ 'name': 'moe', 'age': 40 }] */ function where(collection, properties) { - var props = keys(properties); - return filter(collection, function(object) { - var length = props.length; - while (length--) { - var result = object[props[length]] === properties[props[length]]; - if (!result) { - break; - } - } - return !!result; - }); + return filter(collection, properties); } /*--------------------------------------------------------------------------*/ From e4cb7112cf4f567d1cf6c90d11e56caede118cf5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 20:02:16 -0800 Subject: [PATCH 054/176] Update vendors, minified builds, and rebuild docs. Former-commit-id: 9be99ca3c78a1a35fd13138398c48ab4a4b35f11 --- doc/README.md | 196 ++++++++++++++-------------- lodash.js | 8 +- lodash.min.js | 14 +- lodash.underscore.js | 30 +++-- lodash.underscore.min.js | 42 +++--- vendor/backbone/backbone.js | 49 +++---- vendor/backbone/test/collection.js | 14 +- vendor/backbone/test/events.js | 14 ++ vendor/backbone/test/model.js | 7 + vendor/backbone/test/router.js | 13 ++ vendor/underscore/underscore-min.js | 2 +- vendor/underscore/underscore.js | 3 +- 12 files changed, 222 insertions(+), 170 deletions(-) diff --git a/doc/README.md b/doc/README.md index 5e30bb5b96..a933465cca 100644 --- a/doc/README.md +++ b/doc/README.md @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2783 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2784 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2813 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2814 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2849 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -273,7 +273,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2875 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2876 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -301,7 +301,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2918 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -333,7 +333,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2953 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -358,7 +358,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2977 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -382,7 +382,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3030 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -407,7 +407,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3056 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3057 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -436,7 +436,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3086 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -461,7 +461,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3131 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3132 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -499,7 +499,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3171 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -527,7 +527,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3215 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -571,7 +571,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -595,7 +595,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3281 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -634,7 +634,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3339 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3340 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -659,7 +659,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3371 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -716,7 +716,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4242 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -746,7 +746,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4259 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -767,7 +767,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4276 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -798,7 +798,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1972 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1983 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -826,7 +826,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2025 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -864,7 +864,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2061 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2072 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -896,7 +896,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2091 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2102 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -925,7 +925,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2130 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2141 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -954,7 +954,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2174 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2185 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -983,7 +983,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1015,7 +1015,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2262 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1047,7 +1047,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2295 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1076,7 +1076,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2329 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1108,7 +1108,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2371 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1140,7 +1140,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2408 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2419 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1166,7 +1166,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2459 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1197,7 +1197,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2483 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2494 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1227,7 +1227,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2536 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1258,7 +1258,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1284,7 +1284,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2584 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2595 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1308,7 +1308,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1338,7 +1338,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2642 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1367,7 +1367,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2699 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1399,7 +1399,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2723 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1423,7 +1423,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2753 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1461,7 +1461,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3403 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3404 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1489,7 +1489,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3436 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3437 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1520,7 +1520,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3467 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1551,7 +1551,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3512 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1592,7 +1592,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3535 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3536 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1619,7 +1619,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3569 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1645,7 +1645,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3632 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3633 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1670,7 +1670,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1697,7 +1697,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3656 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1723,7 +1723,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3683 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3684 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1749,7 +1749,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1776,7 +1776,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1801,7 +1801,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3793 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3794 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1837,7 +1837,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L825 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L839 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1865,7 +1865,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1049 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1901,7 +1901,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1130 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1144 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1934,7 +1934,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1166 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1960,7 +1960,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L881 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L895 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1996,7 +1996,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L905 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L919 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2024,7 +2024,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1185 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2051,7 +2051,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1196 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1210 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2076,7 +2076,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1213 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1227 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2100,7 +2100,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L857 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2127,7 +2127,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1256 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2154,7 +2154,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1275 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2178,7 +2178,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1292 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2202,7 +2202,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2226,7 +2226,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1334 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2256,7 +2256,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1362 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1376 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2287,7 +2287,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1527 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2325,7 +2325,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1530 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2349,7 +2349,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1607 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2384,7 +2384,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1615 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1629 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2411,7 +2411,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1632 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2435,7 +2435,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1560 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1574 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2465,7 +2465,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2500,7 +2500,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1685 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1699 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2524,7 +2524,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1702 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1716 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2548,7 +2548,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1733 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2572,7 +2572,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L934 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2596,7 +2596,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1754 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1768 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2631,7 +2631,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1839 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2662,7 +2662,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1873 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2686,7 +2686,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1900 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1911 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2717,7 +2717,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1937 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1948 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2748,7 +2748,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3817 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2772,7 +2772,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3835 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3836 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2797,7 +2797,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3861 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3862 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2827,7 +2827,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3885 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3886 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2847,7 +2847,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3909 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2875,7 +2875,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3946 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3947 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2910,7 +2910,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4032 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2988,7 +2988,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3020,7 +3020,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4194 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3044,7 +3044,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4213 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4214 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3097,7 +3097,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4441 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 5c8780ba74..f41b3c541e 100644 --- a/lodash.js +++ b/lodash.js @@ -642,14 +642,14 @@ } var props = keys(func); return function(object) { - var length = props.length; + var length = props.length, + result = false; while (length--) { - var result = object[props[length]] === func[props[length]]; - if (!result) { + if (!(result = object[props[length]] === func[props[length]])) { break; } } - return !!result; + return result; }; } if (typeof thisArg != 'undefined') { diff --git a/lodash.min.js b/lodash.min.js index 93c7a08648..5a7a47ee87 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,8 +4,8 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; +}return re;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++eC(o,r,1))&&(u[r]=n) }),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +},r.throttle=function(n,t){function r(){a=new Date,i=W,u=n.apply(o,e)}var e,u,o,i,a=0;return function(){var f=new Date,c=t-(f-a);return e=arguments,o=this,0r?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1)) +},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) },r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) diff --git a/lodash.underscore.js b/lodash.underscore.js index 4eb97d25db..7ca6b1f413 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -395,9 +395,23 @@ if (!func) { return identity; } - if (typeof func != 'function') { + var type = typeof func; + if (type != 'function') { + if (type != 'object') { + return function(object) { + return object[func]; + }; + } + var props = keys(func); return function(object) { - return object[func]; + var length = props.length, + result = false; + while (length--) { + if (!(result = object[props[length]] === func[props[length]])) { + break; + } + } + return result; }; } if (typeof thisArg != 'undefined') { @@ -2271,17 +2285,7 @@ * // => [{ 'name': 'moe', 'age': 40 }] */ function where(collection, properties) { - var props = keys(properties); - return filter(collection, function(object) { - var length = props.length; - while (length--) { - var result = object[props[length]] === properties[props[length]]; - if (!result) { - break; - } - } - return !!result; - }); + return filter(collection, properties); } /*--------------------------------------------------------------------------*/ diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 5790fb0da0..037f6445ba 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -5,28 +5,28 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&typeof r=="undefined"?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=Rt(n),u=i.length; -return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1; -else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) -}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1t||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length; +if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i +}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) +}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o) -}return u},o.filter=S,o.flatten=$,o.forEach=N,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return N(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,_t(yt(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return N(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J; -return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; -try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=k,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,yt(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this +for(var e=-1,t=yt(0,ot((t-n)/r)),u=Array(t);++eI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length +},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; +try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,yt(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this },o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o })(this); \ No newline at end of file diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index dd262c8359..07ed747b6e 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -142,7 +142,7 @@ // Remove one or many callbacks. If `context` is null, removes all // callbacks with that function. If `callback` is null, removes all - // callbacks for the event. If `events` is null, removes all bound + // callbacks for the event. If `name` is null, removes all bound // callbacks for all events. off: function(name, callback, context) { var list, ev, events, names, i, l, j, k; @@ -425,7 +425,7 @@ // If the server returns an attributes hash that differs, the model's // state will be `set` again. save: function(key, val, options) { - var attrs, model, success, method, xhr, attributes = this.attributes; + var attrs, success, method, xhr, attributes = this.attributes; // Handle both `"key", value` and `{key: value}` -style arguments. if (key == null || typeof key === 'object') { @@ -450,6 +450,7 @@ // After a successful server-side save, the client is (optionally) // updated with the server-side state. + if (options.parse === void 0) options.parse = true; success = options.success; options.success = function(model, resp, options) { // Ensure attributes are restored during synchronous saves. @@ -554,6 +555,7 @@ options || (options = {}); if (options.model) this.model = options.model; if (options.comparator !== void 0) this.comparator = options.comparator; + this.models = []; this._reset(); this.initialize.apply(this, arguments); if (models) this.reset(models, _.extend({silent: true}, options)); @@ -585,21 +587,19 @@ add: function(models, options) { models = _.isArray(models) ? models.slice() : [models]; options || (options = {}); - var i, l, model, attrs, existing, sort, doSort, sortAttr, at, add; + var i, l, model, attrs, existing, doSort, add, at, sort, sortAttr; add = []; at = options.at; - sort = this.comparator && (at == null) && (options.sort == null || options.sort); + sort = this.comparator && (at == null) && options.sort != false; sortAttr = _.isString(this.comparator) ? this.comparator : null; // Turn bare objects into model references, and prevent invalid models // from being added. for (i = 0, l = models.length; i < l; i++) { - attrs = models[i]; - if(!(model = this._prepareModel(attrs, options))) { + if (!(model = this._prepareModel(attrs = models[i], options))) { this.trigger('invalid', this, attrs, options); continue; } - models[i] = model; // If a duplicate is found, prevent it from being added and // optionally merge it into the existing model. @@ -796,7 +796,7 @@ for (var i = 0, l = this.models.length; i < l; i++) { this._removeReference(this.models[i]); } - options.previousModels = this.models; + options.previousModels = this.models.slice(); this._reset(); if (models) this.add(models, _.extend({silent: true}, options)); if (!options.silent) this.trigger('reset', this, options); @@ -804,8 +804,8 @@ }, // Fetch the default set of models for this collection, resetting the - // collection when they arrive. If `add: true` is passed, appends the - // models to the collection instead of resetting. + // collection when they arrive. If `update: true` is passed, the response + // data will be passed through the `update` method instead of `reset`. fetch: function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) options.parse = true; @@ -823,10 +823,9 @@ // wait for the server to agree. create: function(model, options) { options = options ? _.clone(options) : {}; - model = this._prepareModel(model, options); + if (!(model = this._prepareModel(model, options))) return false; + if (!options.wait) this.add(model, options); var collection = this; - if (!model) return false; - if (!options.wait) collection.add(model, options); var success = options.success; options.success = function(model, resp, options) { if (options.wait) collection.add(model, options); @@ -847,17 +846,10 @@ return new this.constructor(this.models); }, - // Proxy to _'s chain. Can't be proxied the same way the rest of the - // underscore methods are proxied because it relies on the underscore - // constructor. - chain: function() { - return _(this.models).chain(); - }, - // Reset all internal state. Called when the collection is reset. _reset: function() { this.length = 0; - this.models = []; + this.models.length = 0; this._byId = {}; }, @@ -892,6 +884,14 @@ if (model.id != null) this._byId[model.id] = model; } this.trigger.apply(this, arguments); + }, + + sortedIndex: function (model, value, context) { + value || (value = this.comparator); + var iterator = _.isFunction(value) ? value : function(model) { + return model.get(value); + }; + return _.sortedIndex(this.models, model, iterator, context); } }); @@ -900,9 +900,9 @@ var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', - 'max', 'min', 'sortedIndex', 'toArray', 'size', 'first', 'head', 'take', - 'initial', 'rest', 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', - 'lastIndexOf', 'isEmpty']; + 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', + 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf', + 'isEmpty', 'chain']; // Mix in each Underscore method as a proxy to `Collection#models`. _.each(methods, function(method) { @@ -965,6 +965,7 @@ var args = this._extractParameters(route, fragment); callback && callback.apply(this, args); this.trigger.apply(this, ['route:' + name].concat(args)); + this.trigger('route', name, args); Backbone.history.trigger('route', this, name, args); }, this)); return this; diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index 0bca07d945..167dad9fdb 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -497,9 +497,21 @@ $(document).ready(function() { [4, 0]); }); + test("sortedIndex", function () { + var model = new Backbone.Model({key: 2}); + var collection = new (Backbone.Collection.extend({ + comparator: 'key' + }))([model, {key: 1}]); + equal(collection.sortedIndex(model), 1); + equal(collection.sortedIndex(model, 'key'), 1); + equal(collection.sortedIndex(model, function (model) { + return model.get('key'); + }), 1); + }); + test("reset", 10, function() { var resetCount = 0; - var models = col.models; + var models = col.models.slice(); col.on('reset', function() { resetCount += 1; }); col.reset([]); equal(resetCount, 1); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index cf6c8f53a0..0d77328e53 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -86,6 +86,20 @@ $(document).ready(function() { b.trigger('change'); }); + test("listenTo yourself", 1, function(){ + var e = _.extend({}, Backbone.Events); + e.listenTo(e, "foo", function(){ ok(true); }); + e.trigger("foo"); + }); + + test("listenTo yourself cleans yourself up with stopListening", 1, function(){ + var e = _.extend({}, Backbone.Events); + e.listenTo(e, "foo", function(){ ok(true); }); + e.trigger("foo"); + e.stopListening(); + e.trigger("foo"); + }); + test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; _.extend(obj, Backbone.Events); diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index 8b8fe7109d..7bbb8337c7 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -734,6 +734,13 @@ $(document).ready(function() { model.save({x: 1}, {wait: true}); }); + test("save turns on parse flag", function () { + var Model = Backbone.Model.extend({ + sync: function(method, model, options) { ok(options.parse); } + }); + new Model().save(); + }); + test("nested `set` during `'change:attr'`", 2, function() { var events = []; var model = new Backbone.Model(); diff --git a/vendor/backbone/test/router.js b/vendor/backbone/test/router.js index b1c6a71a81..26d3800970 100644 --- a/vendor/backbone/test/router.js +++ b/vendor/backbone/test/router.js @@ -69,6 +69,7 @@ $(document).ready(function() { "contacts": "contacts", "contacts/new": "newContact", "contacts/:id": "loadContact", + "route-event/:arg": "routeEvent", "optional(/:item)": "optionalItem", "named/optional/(y:z)": "namedOptional", "splat/*args/end": "splat", @@ -132,6 +133,9 @@ $(document).ready(function() { namedOptional: function(z) { this.z = z; + }, + + routeEvent: function(arg) { } }); @@ -516,4 +520,13 @@ $(document).ready(function() { strictEqual(router.z, '123'); }); + test("#2062 - Trigger 'route' event on router instance.", 2, function() { + router.on('route', function(name, args) { + strictEqual(name, 'routeEvent'); + deepEqual(args, ['x']); + }); + location.replace('http://example.com#route-event/x'); + Backbone.history.checkUrl(); + }); + }); diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index 307393e73e..d2d3068c4d 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -2,4 +2,4 @@ // http://underscorejs.org // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var M=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=M(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&M(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return M(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var S={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};S.unescape=w.invert(S.escape);var T={escape:RegExp("["+w.keys(S.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(S.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return S[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var M=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=M(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&M(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return M(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var S={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};S.unescape=w.invert(S.escape);var T={escape:RegExp("["+w.keys(S.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(S.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return S[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index e228c95c4b..1105f60128 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -224,8 +224,9 @@ // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); return _.map(obj, function(value) { - return (_.isFunction(method) ? method : value[method]).apply(value, args); + return (isFunc ? method : value[method]).apply(value, args); }); }; From 9867d4bdc36dc812b4633241a1fe9fc96420da00 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 12 Jan 2013 20:42:54 -0800 Subject: [PATCH 055/176] Add unit test for passing an object as `callback` to `_.find`. Former-commit-id: 36da6e95473e85ac799180618e1a546d87f0686f --- test/test.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 0ce96fb215..a7aca801ee 100644 --- a/test/test.js +++ b/test/test.js @@ -556,14 +556,21 @@ QUnit.module('lodash.find'); (function() { - var array = [1, 2, 3]; + var array = [ + { 'a': 1, 'b': 2, 'c': 3 }, + { 'a': 2, 'b': 2, 'c': 3 } + ]; test('should return found `value`', function() { - equal(_.find(array, function(n) { return n > 2; }), 3); + equal(_.find(array, function(object) { return object.a == 1; }), array[0]); }); test('should return `undefined` if `value` is not found', function() { - equal(_.find(array, function(n) { return n == 4; }), undefined); + equal(_.find(array, function(object) { return object.a == 3; }), undefined); + }); + + test('should work with an object for `callback`', function() { + equal(_.find(array, { 'b': 2, 'c': 3 }), array[0]); }); }()); From e5e914282f529c43edfc8ec7c6b41d573920e3da Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 13 Jan 2013 14:58:53 -0800 Subject: [PATCH 056/176] Allow `_.first`, `_.last`, `_.initial`, and `_.rest` to accept `callback` and `thisArg` arguments. [closes #155] Former-commit-id: b921ae0ccc188c5544480f397216ce3b2479989e --- doc/README.md | 224 ++++++++++++++++++++++---------------- lodash.js | 226 +++++++++++++++++++++++++++------------ lodash.min.js | 35 +++--- lodash.underscore.js | 222 ++++++++++++++++++++++++++------------ lodash.underscore.min.js | 31 +++--- test/test.js | 163 +++++++++++++++++++++++++++- 6 files changed, 637 insertions(+), 264 deletions(-) diff --git a/doc/README.md b/doc/README.md index a933465cca..6fd1df3fd1 100644 --- a/doc/README.md +++ b/doc/README.md @@ -8,21 +8,21 @@ ## `Arrays` * [`_.compact`](#_compactarray) * [`_.difference`](#_differencearray--array1-array2-) -* [`_.drop`](#_restarray--n1) -* [`_.first`](#_firstarray--n) +* [`_.drop`](#_restarray--callbackn1-thisarg) +* [`_.first`](#_firstarray--callbackn-thisarg) * [`_.flatten`](#_flattenarray-shallow) -* [`_.head`](#_firstarray--n) +* [`_.head`](#_firstarray--callbackn-thisarg) * [`_.indexOf`](#_indexofarray-value--fromindex0) -* [`_.initial`](#_initialarray--n1) +* [`_.initial`](#_initialarray--callbackn1-thisarg) * [`_.intersection`](#_intersectionarray1-array2-) -* [`_.last`](#_lastarray--n) +* [`_.last`](#_lastarray--callbackn-thisarg) * [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1) * [`_.object`](#_objectkeys--values) * [`_.range`](#_rangestart0-end--step1) -* [`_.rest`](#_restarray--n1) +* [`_.rest`](#_restarray--callbackn1-thisarg) * [`_.sortedIndex`](#_sortedindexarray-value--callbackidentityproperty-thisarg) -* [`_.tail`](#_restarray--n1) -* [`_.take`](#_firstarray--n) +* [`_.tail`](#_restarray--callbackn1-thisarg) +* [`_.take`](#_firstarray--callbackn-thisarg) * [`_.union`](#_unionarray1-array2-) * [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg) * [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg) @@ -244,25 +244,34 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); -### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2849 "View in source") [Ⓣ][1] +### `_.first(array [, callback|n, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2858 "View in source") [Ⓣ][1] -Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. +Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. #### Aliases *head, take* #### Arguments 1. `array` *(Array)*: The array to query. -2. `[n]` *(Number)*: The number of elements to return. +2. `[callback|n]` *(Function|Number)*: The function called per element or the number of elements to return. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Mixed)*: Returns the first element, or an array of the first `n` elements, of `array`. +*(Mixed)*: Returns the first element(s) of `array`. #### Example ```js -_.first([5, 4, 3, 2, 1]); -// => 5 +_.first([1, 2, 3]); +// => 1 + +_.first([1, 2, 3], 2); +// => [1, 2] + +_.first([1, 2, 3], function(num) { + return num < 3; +}); +// => [1, 2] ``` * * * @@ -273,7 +282,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2876 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -301,7 +310,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2918 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2939 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -332,22 +341,31 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); -### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2953 "View in source") [Ⓣ][1] +### `_.initial(array [, callback|n=1, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2985 "View in source") [Ⓣ][1] -Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. +Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[n=1]` *(Number)*: The number of elements to exclude. +2. `[callback|n=1]` *(Function|Number)*: The function called per element or the number of elements to exclude. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Array)*: Returns all but the last element, or `n` elements, of `array`. +*(Array)*: Returns a slice of `array`. #### Example ```js -_.initial([3, 2, 1]); -// => [3, 2] +_.initial([1, 2, 3]); +// => [1, 2] + +_.initial([1, 2, 3], 2); +// => [1] + +_.initial([1, 2, 3], function(num) { + return num > 1; +}); +// => [1] ``` * * * @@ -358,7 +376,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2977 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3019 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -381,22 +399,31 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); -### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3030 "View in source") [Ⓣ][1] +### `_.last(array [, callback|n, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] -Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. +Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[n]` *(Number)*: The number of elements to return. +2. `[callback|n]` *(Function|Number)*: The function called per element or the number of elements to return. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Mixed)*: Returns the last element, or an array of the last `n` elements, of `array`. +*(Mixed)*: Returns the last element(s) of `array`. #### Example ```js -_.last([3, 2, 1]); -// => 1 +_.last([1, 2, 3]); +// => 3 + +_.last([1, 2, 3], 2); +// => [2, 3] + +_.last([1, 2, 3], function(num) { + return num > 1; +}); +// => [2, 3] ``` * * * @@ -407,7 +434,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3057 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3122 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -436,7 +463,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -461,7 +488,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3132 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3197 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -498,25 +525,34 @@ _.range(0); -### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3171 "View in source") [Ⓣ][1] +### `_.rest(array [, callback|n=1, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1] -The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. +The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. #### Aliases *drop, tail* #### Arguments 1. `array` *(Array)*: The array to query. -2. `[n=1]` *(Number)*: The number of elements to exclude. +2. `[callback|n=1]` *(Function|Number)*: The function called per element or the number of elements to exclude. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Array)*: Returns all but the first element, or `n` elements, of `array`. +*(Array)*: Returns a slice of `array`. #### Example ```js -_.rest([3, 2, 1]); -// => [2, 1] +_.rest([1, 2, 3]); +// => [2, 3] + +_.rest([1, 2, 3], 2); +// => [3] + +_.rest([1, 2, 3], function(num) { + return num < 3; +}); +// => [3] ``` * * * @@ -527,7 +563,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3215 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3303 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -571,7 +607,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3335 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -595,7 +631,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3281 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3369 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -634,7 +670,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3340 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3428 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -659,7 +695,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3459 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -716,7 +752,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4242 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4330 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -746,7 +782,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4259 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4347 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -767,7 +803,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4364 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1049,7 +1085,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2295 "View in source") [Ⓣ][1] -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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. +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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. @@ -1461,7 +1497,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3404 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1489,7 +1525,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3437 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3525 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1520,7 +1556,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3467 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3555 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1551,7 +1587,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1592,7 +1628,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3624 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1619,7 +1655,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3569 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1645,7 +1681,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3633 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1670,7 +1706,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3701 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1697,7 +1733,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1723,7 +1759,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3772 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1749,7 +1785,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3807 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1776,7 +1812,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3829 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1801,7 +1837,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2108,7 +2144,7 @@ Checks if `value` is an `arguments` object. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is an `arguments` object, else `false`. +*(Boolean)*: Returns `true`, if the `value` is an `arguments` object, else `false`. #### Example ```js @@ -2135,7 +2171,7 @@ Checks if `value` is an array. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is an array, else `false`. +*(Boolean)*: Returns `true`, if the `value` is an array, else `false`. #### Example ```js @@ -2156,13 +2192,13 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1275 "View in source") [Ⓣ][1] -Checks if `value` is a boolean *(`true` or `false`)* value. +Checks if `value` is a boolean value. #### Arguments 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a boolean value, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a boolean value, else `false`. #### Example ```js @@ -2186,7 +2222,7 @@ Checks if `value` is a date. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a date, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a date, else `false`. #### Example ```js @@ -2210,7 +2246,7 @@ Checks if `value` is a DOM element. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a DOM element, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a DOM element, else `false`. #### Example ```js @@ -2234,7 +2270,7 @@ Checks if `value` is empty. Arrays, strings, or `arguments` objects with a lengt 1. `value` *(Array|Object|String)*: The value to inspect. #### Returns -*(Boolean)*: Returns `true` if the `value` is empty, else `false`. +*(Boolean)*: Returns `true`, if the `value` is empty, else `false`. #### Example ```js @@ -2265,7 +2301,7 @@ Performs a deep comparison between two values to determine if they are equivalen 2. `b` *(Mixed)*: The other value to compare. #### Returns -*(Boolean)*: Returns `true` if the values are equvalent, else `false`. +*(Boolean)*: Returns `true`, if the values are equvalent, else `false`. #### Example ```js @@ -2297,7 +2333,7 @@ Note: This is not the same as native `isFinite`, which will return true for bool 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a finite number, else `false`. +*(Boolean)*: Returns `true`, if the `value` is finite, else `false`. #### Example ```js @@ -2333,7 +2369,7 @@ Checks if `value` is a function. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a function, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a function, else `false`. #### Example ```js @@ -2359,7 +2395,7 @@ Note: This is not the same as native `isNaN`, which will return `true` for `unde 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is `NaN`, else `false`. +*(Boolean)*: Returns `true`, if the `value` is `NaN`, else `false`. #### Example ```js @@ -2392,7 +2428,7 @@ Checks if `value` is `null`. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is `null`, else `false`. +*(Boolean)*: Returns `true`, if the `value` is `null`, else `false`. #### Example ```js @@ -2419,7 +2455,7 @@ Checks if `value` is a number. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a number, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a number, else `false`. #### Example ```js @@ -2443,7 +2479,7 @@ Checks if `value` is the language type of Object. *(e.g. arrays, functions, obje 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is an object, else `false`. +*(Boolean)*: Returns `true`, if the `value` is an object, else `false`. #### Example ```js @@ -2473,7 +2509,7 @@ Checks if a given `value` is an object created by the `Object` constructor. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if `value` is a plain object, else `false`. +*(Boolean)*: Returns `true`, if `value` is a plain object, else `false`. #### Example ```js @@ -2508,7 +2544,7 @@ Checks if `value` is a regular expression. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a regular expression, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a regular expression, else `false`. #### Example ```js @@ -2532,7 +2568,7 @@ Checks if `value` is a string. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is a string, else `false`. +*(Boolean)*: Returns `true`, if the `value` is a string, else `false`. #### Example ```js @@ -2556,7 +2592,7 @@ Checks if `value` is `undefined`. 1. `value` *(Mixed)*: The value to check. #### Returns -*(Boolean)*: Returns `true` if the `value` is `undefined`, else `false`. +*(Boolean)*: Returns `true`, if the `value` is `undefined`, else `false`. #### Example ```js @@ -2748,7 +2784,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3906 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2772,7 +2808,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3836 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3924 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2797,7 +2833,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3950 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2827,7 +2863,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3886 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2847,7 +2883,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3997 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2875,9 +2911,9 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3947 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4035 "View in source") [Ⓣ][1] -Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. +Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. #### Arguments 1. `object` *(Object)*: The object to inspect. @@ -2910,7 +2946,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4032 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4120 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2988,7 +3024,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4256 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3020,7 +3056,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4194 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4282 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3044,7 +3080,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4302 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3097,7 +3133,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4441 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4529 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index f41b3c541e..d137cd227e 100644 --- a/lodash.js +++ b/lodash.js @@ -494,7 +494,7 @@ * @param {Mixed} value The value to search for. * @param {Number} [fromIndex=0] The index to search from. * @param {Number} [largeSize=30] The length at which an array is considered large. - * @returns {Boolean} Returns `true` if `value` is found, else `false`. + * @returns {Boolean} Returns `true`, if `value` is found, else `false`. */ function cachedContains(array, fromIndex, largeSize) { fromIndex || (fromIndex = 0); @@ -845,7 +845,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an `arguments` object, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an `arguments` object, else `false`. * @example * * (function() { return _.isArguments(arguments); })(1, 2, 3); @@ -946,7 +946,7 @@ * * @private * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if `value` is a plain object, else `false`. + * @returns {Boolean} Returns `true`, if `value` is a plain object, else `false`. */ function shimIsPlainObject(value) { // avoid non-objects and false positives for `arguments` objects @@ -1244,7 +1244,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an array, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. * @example * * (function() { return _.isArray(arguments); })(); @@ -1260,13 +1260,13 @@ }; /** - * Checks if `value` is a boolean (`true` or `false`) value. + * Checks if `value` is a boolean value. * * @static * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a boolean value, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a boolean value, else `false`. * @example * * _.isBoolean(null); @@ -1283,7 +1283,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a date, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a date, else `false`. * @example * * _.isDate(new Date); @@ -1300,7 +1300,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a DOM element, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a DOM element, else `false`. * @example * * _.isElement(document.body); @@ -1319,7 +1319,7 @@ * @memberOf _ * @category Objects * @param {Array|Object|String} value The value to inspect. - * @returns {Boolean} Returns `true` if the `value` is empty, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is empty, else `false`. * @example * * _.isEmpty([1, 2, 3]); @@ -1361,7 +1361,7 @@ * @param {Mixed} b The other value to compare. * @param- {Object} [stackA=[]] Internally used track traversed `a` objects. * @param- {Object} [stackB=[]] Internally used track traversed `b` objects. - * @returns {Boolean} Returns `true` if the values are equvalent, else `false`. + * @returns {Boolean} Returns `true`, if the values are equvalent, else `false`. * @example * * var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; @@ -1506,7 +1506,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a finite number, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is finite, else `false`. * @example * * _.isFinite(-101); @@ -1535,7 +1535,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a function, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a function, else `false`. * @example * * _.isFunction(_); @@ -1559,7 +1559,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an object, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an object, else `false`. * @example * * _.isObject({}); @@ -1589,7 +1589,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `NaN`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `NaN`, else `false`. * @example * * _.isNaN(NaN); @@ -1617,7 +1617,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `null`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `null`, else `false`. * @example * * _.isNull(null); @@ -1637,7 +1637,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a number, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a number, else `false`. * @example * * _.isNumber(8.4 * 5); @@ -1654,7 +1654,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if `value` is a plain object, else `false`. + * @returns {Boolean} Returns `true`, if `value` is a plain object, else `false`. * @example * * function Stooge(name, age) { @@ -1690,7 +1690,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a regular expression, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a regular expression, else `false`. * @example * * _.isRegExp(/moe/); @@ -1707,7 +1707,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a string, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a string, else `false`. * @example * * _.isString('moe'); @@ -1724,7 +1724,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `undefined`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `undefined`, else `false`. * @example * * _.isUndefined(void 0); @@ -2273,7 +2273,7 @@ /** * 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 passed to each invoked method. If `methodName` is a function it will + * will be passed to each invoked method. If `methodName` is a function, it will * be invoked for, and `this` bound to, each element in the `collection`. * * @static @@ -2828,30 +2828,51 @@ } /** - * Gets the first element of the `array`. Pass `n` to return the first `n` - * elements of the `array`. + * Gets the first element of the `array`. If a number `n` is passed, the first + * `n` elements of the `array` are returned. If a `callback` function is passed, + * the first elements the `callback` returns truthy for are returned. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @alias head, take * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n] The number of elements to return. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Mixed} Returns the first element, or an array of the first `n` - * elements, of `array`. + * @param {Function|Number} [callback|n] The function called per element or + * the number of elements to return. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the first element(s) of `array`. * @example * - * _.first([5, 4, 3, 2, 1]); - * // => 5 + * _.first([1, 2, 3]); + * // => 1 + * + * _.first([1, 2, 3], 2); + * // => [1, 2] + * + * _.first([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [1, 2] */ - function first(array, n, guard) { + function first(array, callback, thisArg) { if (array) { - var length = array.length; - return (n == null || guard) - ? array[0] - : slice(array, 0, nativeMin(nativeMax(0, n), length)); + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = -1; + callback = createCallback(callback, thisArg); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array[0]; + } + } + return slice(array, 0, nativeMin(nativeMax(0, n), length)); } } @@ -2934,28 +2955,49 @@ } /** - * Gets all but the last element of `array`. Pass `n` to exclude the last `n` - * elements from the result. + * Gets all but the last element of `array`. If a number `n` is passed, the + * last `n` elements are excluded from the result. If a `callback` function + * is passed, the last elements the `callback` returns truthy for are excluded + * from the result. The `callback` is bound to `thisArg` and invoked with three + * arguments; (value, index, array). * * @static * @memberOf _ * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n=1] The number of elements to exclude. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the last element, or `n` elements, of `array`. + * @param {Function|Number} [callback|n=1] The function called per element or + * the number of elements to exclude. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. * @example * - * _.initial([3, 2, 1]); - * // => [3, 2] + * _.initial([1, 2, 3]); + * // => [1, 2] + * + * _.initial([1, 2, 3], 2); + * // => [1] + * + * _.initial([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [1] */ - function initial(array, n, guard) { + function initial(array, callback, thisArg) { if (!array) { return []; } - var length = array.length; - n = n == null || guard ? 1 : n || 0; + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = length; + callback = createCallback(callback, thisArg); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : callback || n; + } return slice(array, 0, nativeMin(nativeMax(0, length - n), length)); } @@ -3010,27 +3052,50 @@ } /** - * Gets the last element of the `array`. Pass `n` to return the last `n` - * elements of the `array`. + * Gets the last element of the `array`. If a number `n` is passed, the last + * `n` elements of the `array` are returned. If a `callback` function is passed, + * the last elements the `callback` returns truthy for are returned. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n] The number of elements to return. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Mixed} Returns the last element, or an array of the last `n` - * elements, of `array`. + * @param {Function|Number} [callback|n] The function called per element or + * the number of elements to return. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the last element(s) of `array`. * @example * - * _.last([3, 2, 1]); - * // => 1 + * _.last([1, 2, 3]); + * // => 3 + * + * _.last([1, 2, 3], 2); + * // => [2, 3] + * + * _.last([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [2, 3] */ - function last(array, n, guard) { + function last(array, callback, thisArg) { if (array) { - var length = array.length; - return (n == null || guard) ? array[length - 1] : slice(array, nativeMax(0, length - n)); + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = length; + callback = createCallback(callback, thisArg); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array[length - 1]; + } + } + return slice(array, nativeMax(0, length - n)); } } @@ -3151,25 +3216,48 @@ } /** - * The opposite of `_.initial`, this method gets all but the first value of - * `array`. Pass `n` to exclude the first `n` values from the result. + * The opposite of `_.initial`, this method gets all but the first value of `array`. + * If a number `n` is passed, the first `n` values are excluded from the result. + * If a `callback` function is passed, the first elements the `callback` returns + * truthy for are excluded from the result. The `callback` is bound to `thisArg` + * and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @alias drop, tail * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n=1] The number of elements to exclude. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the first element, or `n` elements, of `array`. + * @param {Function|Number} [callback|n=1] The function called per element or + * the number of elements to exclude. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. * @example * - * _.rest([3, 2, 1]); - * // => [2, 1] + * _.rest([1, 2, 3]); + * // => [2, 3] + * + * _.rest([1, 2, 3], 2); + * // => [3] + * + * _.rest([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [3] */ - function rest(array, n, guard) { - return slice(array, (n == null || guard) ? 1 : nativeMax(0, n)); + function rest(array, callback, thisArg) { + if (typeof callback == 'function') { + var n = 0, + index = -1, + length = array ? array.length : 0; + + callback = createCallback(callback, thisArg); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : nativeMax(0, callback); + } + return slice(array, n); } /** @@ -3919,7 +4007,7 @@ } /** - * Resolves the value of `property` on `object`. If `property` is a function + * Resolves the value of `property` on `object`. If `property` is a function, * it will be invoked and its result returned, else the property value is * returned. If `object` is falsey, then `null` is returned. * diff --git a/lodash.min.js b/lodash.min.js index 5a7a47ee87..85e74e785f 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -14,26 +14,27 @@ if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r if(t&&((u=yr(t))||mr(t))){for(var f=i.length;f--;)if(e=i[f]==t){n[r]=a[f];break}e||(i.push(t),a.push((o=n[r],o=u?yr(o)?o:[]:mr(o)?o:{})),n[r]=S(o,t,ot,i,a))}else typeof t!="undefined"&&(n[r]=t)});return n}function E(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +}else fr(n,function(n,e,o){r=u?(u=X,n):t(r,n,e,o)});return r}function B(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 }},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1)) -},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +},r)},r.difference=function(n){for(var t=-1,r=n?n.length:0,u=xt.apply(rt,arguments),u=e(u,r),o=[];++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={}; +return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); -return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) -}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) +}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r +})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 7ca6b1f413..c9cd2014ec 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -635,7 +635,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an `arguments` object, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an `arguments` object, else `false`. * @example * * (function() { return _.isArguments(arguments); })(1, 2, 3); @@ -752,7 +752,7 @@ * * @private * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if `value` is a plain object, else `false`. + * @returns {Boolean} Returns `true`, if `value` is a plain object, else `false`. */ function shimIsPlainObject(value) { // avoid non-objects and false positives for `arguments` objects @@ -960,7 +960,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an array, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. * @example * * (function() { return _.isArray(arguments); })(); @@ -976,13 +976,13 @@ }; /** - * Checks if `value` is a boolean (`true` or `false`) value. + * Checks if `value` is a boolean value. * * @static * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a boolean value, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a boolean value, else `false`. * @example * * _.isBoolean(null); @@ -999,7 +999,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a date, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a date, else `false`. * @example * * _.isDate(new Date); @@ -1016,7 +1016,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a DOM element, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a DOM element, else `false`. * @example * * _.isElement(document.body); @@ -1035,7 +1035,7 @@ * @memberOf _ * @category Objects * @param {Array|Object|String} value The value to inspect. - * @returns {Boolean} Returns `true` if the `value` is empty, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is empty, else `false`. * @example * * _.isEmpty([1, 2, 3]); @@ -1073,7 +1073,7 @@ * @param {Mixed} b The other value to compare. * @param- {Object} [stackA=[]] Internally used track traversed `a` objects. * @param- {Object} [stackB=[]] Internally used track traversed `b` objects. - * @returns {Boolean} Returns `true` if the values are equvalent, else `false`. + * @returns {Boolean} Returns `true`, if the values are equvalent, else `false`. * @example * * var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; @@ -1212,7 +1212,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a finite number, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is finite, else `false`. * @example * * _.isFinite(-101); @@ -1241,7 +1241,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a function, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a function, else `false`. * @example * * _.isFunction(_); @@ -1265,7 +1265,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is an object, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is an object, else `false`. * @example * * _.isObject({}); @@ -1295,7 +1295,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `NaN`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `NaN`, else `false`. * @example * * _.isNaN(NaN); @@ -1323,7 +1323,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `null`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `null`, else `false`. * @example * * _.isNull(null); @@ -1343,7 +1343,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a number, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a number, else `false`. * @example * * _.isNumber(8.4 * 5); @@ -1360,7 +1360,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a regular expression, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a regular expression, else `false`. * @example * * _.isRegExp(/moe/); @@ -1377,7 +1377,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a string, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is a string, else `false`. * @example * * _.isString('moe'); @@ -1394,7 +1394,7 @@ * @memberOf _ * @category Objects * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is `undefined`, else `false`. + * @returns {Boolean} Returns `true`, if the `value` is `undefined`, else `false`. * @example * * _.isUndefined(void 0); @@ -1804,7 +1804,7 @@ /** * 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 passed to each invoked method. If `methodName` is a function it will + * will be passed to each invoked method. If `methodName` is a function, it will * be invoked for, and `this` bound to, each element in the `collection`. * * @static @@ -2350,30 +2350,51 @@ } /** - * Gets the first element of the `array`. Pass `n` to return the first `n` - * elements of the `array`. + * Gets the first element of the `array`. If a number `n` is passed, the first + * `n` elements of the `array` are returned. If a `callback` function is passed, + * the first elements the `callback` returns truthy for are returned. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @alias head, take * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n] The number of elements to return. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Mixed} Returns the first element, or an array of the first `n` - * elements, of `array`. + * @param {Function|Number} [callback|n] The function called per element or + * the number of elements to return. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the first element(s) of `array`. * @example * - * _.first([5, 4, 3, 2, 1]); - * // => 5 + * _.first([1, 2, 3]); + * // => 1 + * + * _.first([1, 2, 3], 2); + * // => [1, 2] + * + * _.first([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [1, 2] */ - function first(array, n, guard) { + function first(array, callback, thisArg) { if (array) { - var length = array.length; - return (n == null || guard) - ? array[0] - : slice(array, 0, nativeMin(nativeMax(0, n), length)); + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = -1; + callback = createCallback(callback, thisArg); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array[0]; + } + } + return slice(array, 0, nativeMin(nativeMax(0, n), length)); } } @@ -2456,28 +2477,49 @@ } /** - * Gets all but the last element of `array`. Pass `n` to exclude the last `n` - * elements from the result. + * Gets all but the last element of `array`. If a number `n` is passed, the + * last `n` elements are excluded from the result. If a `callback` function + * is passed, the last elements the `callback` returns truthy for are excluded + * from the result. The `callback` is bound to `thisArg` and invoked with three + * arguments; (value, index, array). * * @static * @memberOf _ * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n=1] The number of elements to exclude. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the last element, or `n` elements, of `array`. + * @param {Function|Number} [callback|n=1] The function called per element or + * the number of elements to exclude. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. * @example * - * _.initial([3, 2, 1]); - * // => [3, 2] + * _.initial([1, 2, 3]); + * // => [1, 2] + * + * _.initial([1, 2, 3], 2); + * // => [1] + * + * _.initial([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [1] */ - function initial(array, n, guard) { + function initial(array, callback, thisArg) { if (!array) { return []; } - var length = array.length; - n = n == null || guard ? 1 : n || 0; + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = length; + callback = createCallback(callback, thisArg); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : callback || n; + } return slice(array, 0, nativeMin(nativeMax(0, length - n), length)); } @@ -2520,27 +2562,50 @@ } /** - * Gets the last element of the `array`. Pass `n` to return the last `n` - * elements of the `array`. + * Gets the last element of the `array`. If a number `n` is passed, the last + * `n` elements of the `array` are returned. If a `callback` function is passed, + * the last elements the `callback` returns truthy for are returned. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n] The number of elements to return. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Mixed} Returns the last element, or an array of the last `n` - * elements, of `array`. + * @param {Function|Number} [callback|n] The function called per element or + * the number of elements to return. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the last element(s) of `array`. * @example * - * _.last([3, 2, 1]); - * // => 1 + * _.last([1, 2, 3]); + * // => 3 + * + * _.last([1, 2, 3], 2); + * // => [2, 3] + * + * _.last([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [2, 3] */ - function last(array, n, guard) { + function last(array, callback, thisArg) { if (array) { - var length = array.length; - return (n == null || guard) ? array[length - 1] : slice(array, nativeMax(0, length - n)); + var n = 0, + length = array.length; + + if (typeof callback == 'function') { + var index = length; + callback = createCallback(callback, thisArg); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array[length - 1]; + } + } + return slice(array, nativeMax(0, length - n)); } } @@ -2661,25 +2726,48 @@ } /** - * The opposite of `_.initial`, this method gets all but the first value of - * `array`. Pass `n` to exclude the first `n` values from the result. + * The opposite of `_.initial`, this method gets all but the first value of `array`. + * If a number `n` is passed, the first `n` values are excluded from the result. + * If a `callback` function is passed, the first elements the `callback` returns + * truthy for are excluded from the result. The `callback` is bound to `thisArg` + * and invoked with three arguments; (value, index, array). * * @static * @memberOf _ * @alias drop, tail * @category Arrays * @param {Array} array The array to query. - * @param {Number} [n=1] The number of elements to exclude. - * @param- {Object} [guard] Internally used to allow this method to work with - * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the first element, or `n` elements, of `array`. + * @param {Function|Number} [callback|n=1] The function called per element or + * the number of elements to exclude. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. * @example * - * _.rest([3, 2, 1]); - * // => [2, 1] + * _.rest([1, 2, 3]); + * // => [2, 3] + * + * _.rest([1, 2, 3], 2); + * // => [3] + * + * _.rest([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [3] */ - function rest(array, n, guard) { - return slice(array, (n == null || guard) ? 1 : nativeMax(0, n)); + function rest(array, callback, thisArg) { + if (typeof callback == 'function') { + var n = 0, + index = -1, + length = array ? array.length : 0; + + callback = createCallback(callback, thisArg); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : nativeMax(0, callback); + } + return slice(array, n); } /** @@ -3362,7 +3450,7 @@ } /** - * Resolves the value of `property` on `object`. If `property` is a function + * Resolves the value of `property` on `object`. If `property` is a function, * it will be invoked and its result returned, else the property value is * returned. If `object` is falsey, then `null` is returned. * diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 037f6445ba..ffe2c0e53a 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -12,21 +12,22 @@ case wt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case xt:case Et:return n==t+""}if }),f&&e(t,function(n,t,r){return ft.call(r,t)?!(f=-1<--c)&&Y:void 0}),f}function b(n){return typeof n=="function"}function j(n){return n?kt[typeof n]:K}function w(n){return typeof n=="number"||lt.call(n)==wt}function A(n){return typeof n=="string"||lt.call(n)==Et}function x(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++to&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length; -if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i -}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) }),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o) -}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=n.length;return p(n,0,_t(yt(0,e-(t==J||r?1:t||0)),e))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n;o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1))},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length -},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}"; -try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=n.length;return t==J||r?n[e-1]:p(n,yt(0,e-t))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this -},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o -})(this); \ No newline at end of file +}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return p(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; +o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1)) +},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length +}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}";try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return p(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this +}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o})(this); \ No newline at end of file diff --git a/test/test.js b/test/test.js index a7aca801ee..23f53a1f64 100644 --- a/test/test.js +++ b/test/test.js @@ -576,6 +576,48 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.first'); + + (function() { + var array = [1, 2, 3]; + + test('should return the first element', function() { + strictEqual(_.first(array), 1); + }); + + test('should return the first two elements', function() { + deepEqual(_.first(array, 2), [1, 2]); + }); + + test('should work with a `callback`', function() { + var actual = _.first(array, function(num) { + return num < 3; + }); + + deepEqual(actual, [1, 2]); + }); + + test('should pass the correct `callback` arguments', function() { + var args; + + _.first(array, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [1, 0, array]); + }); + + test('supports the `thisArg` argument', function() { + var actual = _.first(array, function(value, index) { + return this[index] < 3; + }, array); + + deepEqual(actual, [1, 2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.flatten'); (function() { @@ -780,8 +822,9 @@ QUnit.module('lodash.initial'); (function() { - test('returns a full collection for `n` of `0`', function() { - var array = [1, 2, 3]; + var array = [1, 2, 3]; + + test('returns all elements for `n` of `0`', function() { deepEqual(_.initial(array, 0), [1, 2, 3]); }); @@ -793,6 +836,40 @@ deepEqual(actual, []); }) }); + + test('should exclude last element', function() { + deepEqual(_.initial(array), [1, 2]); + }); + + test('should exlcude the last two elements', function() { + deepEqual(_.initial(array, 2), [1]); + }); + + test('should work with a `callback`', function() { + var actual = _.initial(array, function(num) { + return num > 1; + }); + + deepEqual(actual, [1]); + }); + + test('should pass the correct `callback` arguments', function() { + var args; + + _.initial(array, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [3, 2, array]); + }); + + test('supports the `thisArg` argument', function() { + var actual = _.initial(array, function(value, index) { + return this[index] > 1; + }, array); + + deepEqual(actual, [1]); + }); }()); /*--------------------------------------------------------------------------*/ @@ -1051,6 +1128,48 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.last'); + + (function() { + var array = [1, 2, 3]; + + test('should return the last element', function() { + equal(_.last(array), 3); + }); + + test('should return the last two elements', function() { + deepEqual(_.last(array, 2), [2, 3]); + }); + + test('should work with a `callback`', function() { + var actual = _.last(array, function(num) { + return num > 1; + }); + + deepEqual(actual, [2, 3]); + }); + + test('should pass the correct `callback` arguments', function() { + var args; + + _.last(array, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [3, 2, array]); + }); + + test('supports the `thisArg` argument', function() { + var actual = _.last(array, function(value, index) { + return this[index] > 1; + }, array); + + deepEqual(actual, [2, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.lastIndexOf'); (function() { @@ -1548,6 +1667,12 @@ QUnit.module('lodash.rest'); (function() { + var array = [1, 2, 3]; + + test('returns all elements for `n` of `0`', function() { + deepEqual(_.rest(array, 0), [1, 2, 3]); + }); + test('should allow a falsey `array` argument', function() { _.each(falsey, function(index, value) { try { @@ -1556,6 +1681,40 @@ deepEqual(actual, []); }) }); + + test('should exclude the first element', function() { + deepEqual(_.rest(array), [2, 3]); + }); + + test('should exclude the first two elements', function() { + deepEqual(_.rest(array, 2), [3]); + }); + + test('should work with a `callback`', function() { + var actual = _.rest(array, function(num) { + return num < 3; + }); + + deepEqual(actual, [3]); + }); + + test('should pass the correct `callback` arguments', function() { + var args; + + _.rest(array, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [1, 0, array]); + }); + + test('supports the `thisArg` argument', function() { + var actual = _.rest(array, function(value, index) { + return this[index] < 3; + }, array); + + deepEqual(actual, [3]); + }); }()); /*--------------------------------------------------------------------------*/ From 0404c2266c9d5dd57aea32a6c7769b41069e70f7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 13 Jan 2013 15:12:02 -0800 Subject: [PATCH 057/176] Use `strictEqual` when the expected result is `0` or `1`. Former-commit-id: ff439b0e7252351663b754267056ad09e0f89838 --- test/test.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/test.js b/test/test.js index 23f53a1f64..38db0c2743 100644 --- a/test/test.js +++ b/test/test.js @@ -342,7 +342,7 @@ var array = /x/.exec('x'), actual = _.cloneDeep(array); - equal(actual.index, 0); + strictEqual(actual.index, 0); equal(actual.input, 'x'); }); @@ -421,7 +421,7 @@ return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor'; }); - equal(actual.constructor, 1); + strictEqual(actual.constructor, 1); equal(actual.hasOwnProperty, 2); }); }()); @@ -804,16 +804,16 @@ }); test('should work with a negative `fromIndex` <= `-array.length`', function() { - equal(_.indexOf(array, 1, -6), 0); - equal(_.indexOf(array, 2, -8), 1); + strictEqual(_.indexOf(array, 1, -6), 0); + strictEqual(_.indexOf(array, 2, -8), 1); }); test('should ignore non-number `fromIndex` values', function() { - equal(_.indexOf([1, 2, 3], 1, '1'), 0); + strictEqual(_.indexOf([1, 2, 3], 1, '1'), 0); }); test('should work with `isSorted`', function() { - equal(_.indexOf([1, 2, 3], 1, true), 0); + strictEqual(_.indexOf([1, 2, 3], 1, true), 0); }); }()); @@ -1176,7 +1176,7 @@ var array = [1, 2, 3, 1, 2, 3]; test('should work with a positive `fromIndex`', function() { - equal(_.lastIndexOf(array, 1, 2), 0); + strictEqual(_.lastIndexOf(array, 1, 2), 0); }); test('should work with `fromIndex` >= `array.length`', function() { @@ -1187,11 +1187,11 @@ }); test('should work with a negative `fromIndex`', function() { - equal(_.lastIndexOf(array, 2, -3), 1); + strictEqual(_.lastIndexOf(array, 2, -3), 1); }); test('should work with a negative `fromIndex` <= `-array.length`', function() { - equal(_.lastIndexOf(array, 1, -6), 0); + strictEqual(_.lastIndexOf(array, 1, -6), 0); equal(_.lastIndexOf(array, 2, -8), -1); }); @@ -1351,7 +1351,7 @@ test('should not assign `undefined` values', function() { var actual = _.merge({ 'a': 1 }, { 'a': undefined }); - equal(actual.a, 1); + strictEqual(actual.a, 1); }); }(1, 2, 3)); @@ -1437,7 +1437,7 @@ test('works without partially applying arguments, without additional arguments', function() { var func = function() { return arguments.length; }; - equal(_.partial(func)(), 0); + strictEqual(_.partial(func)(), 0); }); test('works without partially applying arguments, with additional arguments', function() { @@ -1744,7 +1744,7 @@ try { var actual = index ? _.size(value) : _.size(); } catch(e) { } - equal(actual, 0); + strictEqual(actual, 0); }) }); @@ -1832,7 +1832,7 @@ return this.sin(num); }, Math); - equal(actual, 0); + strictEqual(actual, 0); }); test('supports arrays with lengths larger than `Math.pow(2, 31) - 1`', function() { From 6ba4778c1b1ef99edc2e0266958085c4a3994dac Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 14 Jan 2013 01:11:46 -0800 Subject: [PATCH 058/176] Make methods capable of accepting unlimited arguments consistently accept either individual arguments or arrays of arguments. Former-commit-id: b9f0c744f79e74889323f4fd7f737d10acd32ada --- build/pre-compile.js | 3 + doc/README.md | 236 ++++++++++++++++++++------------------- lodash.js | 72 +++++++----- lodash.min.js | 52 ++++----- lodash.underscore.js | 42 ++++--- lodash.underscore.min.js | 28 ++--- test/test.js | 122 ++++++++++++++------ 7 files changed, 318 insertions(+), 237 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 4951dd1c1d..4d42831e26 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -7,10 +7,13 @@ /** Used to minify variables embedded in compiled strings */ var compiledVars = [ + 'args', 'argsIndex', 'argsLength', + 'arrayRef', 'callback', 'collection', + 'concat', 'createCallback', 'ctor', 'guard', diff --git a/doc/README.md b/doc/README.md index 6fd1df3fd1..ad4550d6a2 100644 --- a/doc/README.md +++ b/doc/README.md @@ -109,7 +109,7 @@ * [`_.assign`](#_assignobject--source1-source2-) * [`_.clone`](#_clonevalue-deep) * [`_.cloneDeep`](#_clonedeepvalue) -* [`_.defaults`](#_defaultsobject--default1-default2-) +* [`_.defaults`](#_defaultsobject--source1-source2-) * [`_.extend`](#_assignobject--source1-source2-) * [`_.forIn`](#_forinobject--callbackidentity-thisarg) * [`_.forOwn`](#_forownobject--callbackidentity-thisarg) @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2784 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2824 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2868 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -282,7 +282,7 @@ _.first([1, 2, 3], function(num) { ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -310,7 +310,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2939 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2949 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -342,7 +342,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2985 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2995 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -376,7 +376,7 @@ _.initial([1, 2, 3], function(num) { ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3029 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -400,7 +400,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3091 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -434,7 +434,7 @@ _.last([1, 2, 3], function(num) { ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3122 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3132 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -463,7 +463,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3162 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -488,7 +488,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3207 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -526,7 +526,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3257 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -563,7 +563,7 @@ _.rest([1, 2, 3], function(num) { ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3303 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3313 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -607,7 +607,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3345 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -631,7 +631,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3369 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3379 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -670,7 +670,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3438 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -695,7 +695,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3459 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -752,7 +752,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4342 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -782,7 +782,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4359 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -803,7 +803,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4376 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -834,7 +834,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1983 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1993 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -862,7 +862,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2025 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2035 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -900,7 +900,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2072 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2082 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -932,7 +932,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2102 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2112 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -961,7 +961,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2151 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -990,7 +990,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2195 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1019,7 +1019,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2230 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1051,7 +1051,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1083,7 +1083,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1112,7 +1112,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2329 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2339 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1144,7 +1144,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1176,7 +1176,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2429 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1202,7 +1202,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2480 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1233,7 +1233,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2504 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1263,7 +1263,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1294,7 +1294,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2584 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1320,7 +1320,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2595 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1344,7 +1344,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2638 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1374,7 +1374,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2663 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1403,7 +1403,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2709 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1435,7 +1435,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1459,7 +1459,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2774 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1497,7 +1497,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3502 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1525,7 +1525,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3525 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3535 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1556,9 +1556,9 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3555 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3566 "View in source") [Ⓣ][1] -Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. +Binds methods on `object` to `object`, 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 the function properties of `object` will be bound. #### Arguments 1. `object` *(Object)*: The object to bind and assign the bound methods to. @@ -1587,7 +1587,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1628,9 +1628,9 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] -Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. +Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. Functions may be specified as individual arguments or as arrays of functions. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. #### Arguments 1. `[func1, func2, ...]` *(Function)*: Functions to compose. @@ -1655,7 +1655,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3669 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1681,7 +1681,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1706,7 +1706,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3701 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3713 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1733,7 +1733,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3757 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1759,7 +1759,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3784 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1785,7 +1785,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3807 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3819 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1812,7 +1812,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1837,7 +1837,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3894 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1873,9 +1873,9 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L842 "View in source") [Ⓣ][1] -Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. +Assigns own enumerable properties of source object(s) to the `destination` object. Source objects may be specified as individual arguments or as arrays of source objects. Subsequent sources will overwrite propery assignments of previous sources. #### Aliases *extend* @@ -1901,7 +1901,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1049 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1052 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1937,7 +1937,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1144 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1147 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1969,14 +1969,14 @@ deep[0] === stooges[0]; -### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1166 "View in source") [Ⓣ][1] +### `_.defaults(object [, source1, source2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1170 "View in source") [Ⓣ][1] -Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. +Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Source objects may be specified as individual arguments or as arrays of source objects. Once a property is set, additional defaults of the same property will be ignored. #### Arguments 1. `object` *(Object)*: The destination object. -2. `[default1, default2, ...]` *(Object)*: The default objects. +2. `[source1, source2, ...]` *(Object)*: The source objects. #### Returns *(Object)*: Returns the destination object. @@ -1996,7 +1996,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L895 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L898 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2032,7 +2032,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L919 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L922 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2060,7 +2060,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1189 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2087,7 +2087,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1214 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2112,7 +2112,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1227 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2136,7 +2136,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L857 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L860 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2163,7 +2163,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1256 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1260 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2190,7 +2190,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1279 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2214,7 +2214,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1292 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1296 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2238,7 +2238,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1313 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2262,7 +2262,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1338 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2292,7 +2292,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1376 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1380 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2323,7 +2323,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1527 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1531 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2361,7 +2361,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1548 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2385,7 +2385,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1607 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1611 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2420,7 +2420,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1633 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2447,7 +2447,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1650 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2471,7 +2471,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1578 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2501,7 +2501,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1678 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2536,7 +2536,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1703 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2560,7 +2560,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1716 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1720 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2584,7 +2584,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1737 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2608,7 +2608,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L934 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L937 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2632,9 +2632,9 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1777 "View in source") [Ⓣ][1] -Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Source objects may be specified as individual arguments or as arrays of source objects. Subsequent sources will overwrite propery assignments of previous sources. #### Arguments 1. `object` *(Object)*: The destination object. @@ -2645,18 +2645,22 @@ Recursively merges own enumerable properties of the source object(s), that don't #### Example ```js -var stooges = [ - { 'name': 'moe' }, - { 'name': 'larry' } -]; +var names = { + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] +}; -var ages = [ - { 'age': 40 }, - { 'age': 50 } -]; +var ages = { + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] +}; -_.merge(stooges, ages); -// => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] +_.merge(names, ages); +// => { 'stooges': [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] } ``` * * * @@ -2667,7 +2671,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1849 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2698,7 +2702,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1873 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1883 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2722,7 +2726,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1911 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1921 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2753,7 +2757,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1948 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1958 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2784,7 +2788,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3906 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3918 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2808,7 +2812,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3924 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3936 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2833,7 +2837,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3950 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3962 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2863,7 +2867,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3986 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2883,7 +2887,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3997 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4009 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2911,7 +2915,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2946,7 +2950,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4132 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3024,7 +3028,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4256 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4268 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3056,7 +3060,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4282 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4294 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3080,7 +3084,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4302 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4314 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3133,7 +3137,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4541 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index d137cd227e..06824a6ff1 100644 --- a/lodash.js +++ b/lodash.js @@ -463,9 +463,11 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - "var argsIndex = 0, argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'var args = concat.apply(arrayRef, arguments),\n' + + ' argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + 'while (++argsIndex < argsLength) {\n' + - ' if ((iteratee = arguments[argsIndex])) {', + ' if ((iteratee = args[argsIndex])) {', 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -707,14 +709,14 @@ // create the function factory var factory = Function( - 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' + - 'nativeKeys, propertyIsEnumerable', + 'arrayRef, concat, createCallback, hasOwnProperty, isArguments, isString, ' + + 'objectTypes, nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' ); // return the compiled function return factory( - createCallback, hasOwnProperty, isArguments, isString, objectTypes, - nativeKeys, propertyIsEnumerable + arrayRef, concat, createCallback, hasOwnProperty, isArguments, isString, + objectTypes, nativeKeys, propertyIsEnumerable ); } @@ -821,8 +823,9 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` - * object. Subsequent sources will overwrite propery assignments of previous - * sources. + * object. Source objects may be specified as individual arguments or as arrays + * of source objects. Subsequent sources will overwrite propery assignments of + * previous sources. * * @static * @memberOf _ @@ -1148,14 +1151,15 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` * object for all `destination` properties that resolve to `null`/`undefined`. - * Once a property is set, additional defaults of the same property will be - * ignored. + * Source objects may be specified as individual arguments or as arrays of source + * objects. Once a property is set, additional defaults of the same property will + * be ignored. * * @static * @memberOf _ * @category Objects * @param {Object} object The destination object. - * @param {Object} [default1, default2, ...] The default objects. + * @param {Object} [source1, source2, ...] The source objects. * @returns {Object} Returns the destination object. * @example * @@ -1736,8 +1740,9 @@ /** * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined`, into the `destination` object. Subsequent - * sources will overwrite propery assignments of previous sources. + * don't resolve to `undefined`, into the `destination` object. Source objects + * may be specified as individual arguments or as arrays of source objects. + * Subsequent sources will overwrite propery assignments of previous sources. * * @static * @memberOf _ @@ -1752,18 +1757,22 @@ * @returns {Object} Returns the destination object. * @example * - * var stooges = [ - * { 'name': 'moe' }, - * { 'name': 'larry' } - * ]; + * var names = { + * 'stooges': [ + * { 'name': 'moe' }, + * { 'name': 'larry' } + * ] + * }; * - * var ages = [ - * { 'age': 40 }, - * { 'age': 50 } - * ]; + * var ages = { + * 'stooges': [ + * { 'age': 40 }, + * { 'age': 50 } + * ] + * }; * - * _.merge(stooges, ages); - * // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] + * _.merge(names, ages); + * // => { 'stooges': [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] } */ function merge(object, source, indicator) { var args = arguments, @@ -1773,6 +1782,7 @@ stackB = args[4]; if (indicator !== indicatorObject) { + args = concat.apply(arrayRef, args); stackA = []; stackB = []; @@ -1885,10 +1895,10 @@ /** * 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 `callback` is passed, it will be executed for each property - * in the `object`, picking the properties `callback` returns truthy for. The - * `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object). + * Property names may be specified as individual arguments or as arrays of property + * names. If `callback` is passed, it will be executed for each property in the + * `object`, picking the properties `callback` returns truthy for. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, key, object). * * @static * @memberOf _ @@ -3532,7 +3542,8 @@ /** * Binds methods on `object` to `object`, overwriting the existing method. - * If no method names are provided, all the function properties of `object` + * Method names may be specified as individual arguments or as arrays of method + * names. If no method names are provided, all the function properties of `object` * will be bound. * * @static @@ -3553,7 +3564,7 @@ * // => When the button is clicked, `this.label` will have the correct value */ function bindAll(object) { - var funcs = arguments, + var funcs = concat.apply(arrayRef, arguments), index = funcs.length > 1 ? 0 : (funcs = functions(object), -1), length = funcs.length; @@ -3605,6 +3616,7 @@ /** * Creates a function that is the composition of the passed functions, * where each function consumes the return value of the function that follows. + * Functions may be specified as individual arguments or as arrays of functions. * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. * Each function is executed with the `this` binding of the composed function. * @@ -3622,7 +3634,7 @@ * // => 'hi: moe!' */ function compose() { - var funcs = arguments; + var funcs = concat.apply(arrayRef, arguments); return function() { var args = arguments, length = funcs.length; diff --git a/lodash.min.js b/lodash.min.js index 85e74e785f..8371c4af82 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -5,36 +5,36 @@ */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++ee;e++)r+="l='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(i&&i.prototype===o)&&"),r+="k.call(o,l)){"+t.g+"}"; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return w",Function("d,g,h,k,m,n,s,q,v","return function("+n+"){"+r+"}")(rt,xt,a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={}; +if(yr(n))for(var r=-1,u=n.length;++ro&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return q(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),F(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function B(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,Rt=ht.test(Rt=Array.isArray)&&Rt,Ft=n.isFinite,qt=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,zt=Math.random,Bt="[object Arguments]",Mt="[object Array]",Pt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=Nt&&/\n|true/.test(Nt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Bt]=tr[Mt]=tr[Pt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Mt]=Array,rr[Pt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"r,y,j",k:"var a=g.apply(d,arguments),b=0,c=typeof j=='number'?2:a.length;while(++b":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(w[l]==null)"+or.g}),yr=Rt||function(n){return Wt&&n instanceof Array||$t.call(n)==Mt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=q,r.max=D,r.memoize=function(n,t){var r={}; return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +},r.uniq=U,r.values=E,r.where=function(n,t){return N(n,t)},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(zt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=z,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=B,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) -}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=B,r.detect=R,r.foldl=T,r.foldr=z,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) +}},r.take=M,r.head=M,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this }}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r })(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index c9cd2014ec..5d938cf9d0 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -277,9 +277,11 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - "var argsIndex = 0, argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'var args = concat.apply(arrayRef, arguments),\n' + + ' argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + 'while (++argsIndex < argsLength) {\n' + - ' if ((iteratee = arguments[argsIndex])) {', + ' if ((iteratee = args[argsIndex])) {', 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -468,14 +470,14 @@ // create the function factory var factory = Function( - 'createCallback, hasOwnProperty, isString, objectTypes, ' + - 'nativeKeys, propertyIsEnumerable', + 'arrayRef, concat, createCallback, hasOwnProperty, isString, ' + + 'objectTypes, nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + (data) + '\n}' ); // return the compiled function return factory( - createCallback, hasOwnProperty, isString, objectTypes, - nativeKeys, propertyIsEnumerable + arrayRef, concat, createCallback, hasOwnProperty, isString, + objectTypes, nativeKeys, propertyIsEnumerable ); } @@ -599,8 +601,9 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` - * object. Subsequent sources will overwrite propery assignments of previous - * sources. + * object. Source objects may be specified as individual arguments or as arrays + * of source objects. Subsequent sources will overwrite propery assignments of + * previous sources. * * @static * @memberOf _ @@ -851,14 +854,15 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` * object for all `destination` properties that resolve to `null`/`undefined`. - * Once a property is set, additional defaults of the same property will be - * ignored. + * Source objects may be specified as individual arguments or as arrays of source + * objects. Once a property is set, additional defaults of the same property will + * be ignored. * * @static * @memberOf _ * @category Objects * @param {Object} object The destination object. - * @param {Object} [default1, default2, ...] The default objects. + * @param {Object} [source1, source2, ...] The source objects. * @returns {Object} Returns the destination object. * @example * @@ -1470,10 +1474,10 @@ /** * 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 `callback` is passed, it will be executed for each property - * in the `object`, picking the properties `callback` returns truthy for. The - * `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object). + * Property names may be specified as individual arguments or as arrays of property + * names. If `callback` is passed, it will be executed for each property in the + * `object`, picking the properties `callback` returns truthy for. The `callback` + * is bound to `thisArg` and invoked with three arguments; (value, key, object). * * @static * @memberOf _ @@ -3029,7 +3033,8 @@ /** * Binds methods on `object` to `object`, overwriting the existing method. - * If no method names are provided, all the function properties of `object` + * Method names may be specified as individual arguments or as arrays of method + * names. If no method names are provided, all the function properties of `object` * will be bound. * * @static @@ -3050,7 +3055,7 @@ * // => When the button is clicked, `this.label` will have the correct value */ function bindAll(object) { - var funcs = arguments, + var funcs = concat.apply(arrayRef, arguments), index = funcs.length > 1 ? 0 : (funcs = functions(object), -1), length = funcs.length; @@ -3064,6 +3069,7 @@ /** * Creates a function that is the composition of the passed functions, * where each function consumes the return value of the function that follows. + * Functions may be specified as individual arguments or as arrays of functions. * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. * Each function is executed with the `this` binding of the composed function. * @@ -3081,7 +3087,7 @@ * // => 'hi: moe!' */ function compose() { - var funcs = arguments; + var funcs = concat.apply(arrayRef, arguments); return function() { var args = arguments, length = funcs.length; diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index ffe2c0e53a..72613d67e5 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -5,29 +5,29 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&typeof r=="undefined"?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++et||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length; -if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) -}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o) -}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return p(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; -o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||pt&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,pt=tt.test(pt=s.bind)&&pt,st=tt.test(st=Array.isArray)&&st,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=pt&&/\n|true/.test(pt+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=st||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) +}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=it.apply(W,arguments),r=1I(e,o,r)&&u.push(o)}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return s(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; +o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=s(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1)) },o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length }),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}";try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return p(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this +if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return s(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this }}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o})(this); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 38db0c2743..ffbd7c892e 100644 --- a/test/test.js +++ b/test/test.js @@ -189,15 +189,14 @@ }); test('should work with `_.reduce`', function() { - var actual = { 'a': 1}, + var actual = { 'a': 1 }, array = [{ 'b': 2 }, { 'c': 3 }]; _.reduce(array, _.assign, actual); - deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3}); + deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); }); }()); - /*--------------------------------------------------------------------------*/ QUnit.module('lodash.at'); @@ -256,6 +255,33 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.bindAll'); + + (function() { + test('should accept arrays of method names', function() { + var object = { + '_a': 1, + '_b': 2, + '_c': 3, + '_d': 4, + 'a': function() { return this._a; }, + 'b': function() { return this._b; }, + 'c': function() { return this._c; }, + 'd': function() { return this._d; } + }; + + _.bindAll(object, ['a', 'b'], ['c']); + + var actual = _.map(_.functions(object), function(methodName) { + return object[methodName].call({}); + }); + + deepEqual(actual, [1, 2, 3, undefined]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.bindKey'); (function() { @@ -369,6 +395,23 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.compose'); + + (function() { + test('should accept arrays of functions', function() { + var composed = _.compose([ + function(c) { return c + 'd'; }, + function(b) { return b + 'c'; } + ], [ + function(a) { return a + 'b'; } + ]); + + equal(composed('a'), 'abcd'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.contains'); (function() { @@ -497,7 +540,7 @@ QUnit.module('source property checks'); - _.each(['assign', 'defaults'], function(methodName) { + _.each(['assign', 'defaults', 'merge'], function(methodName) { var func = _[methodName]; test('lodash.' + methodName + ' should not assign inherited `source` properties', function() { @@ -505,6 +548,11 @@ Foo.prototype = { 'a': 1 }; deepEqual(func({}, new Foo), {}); }); + + test('lodash.' + methodName + ' should accept arrays of source objects', function() { + var actual = func({}, [{ 'a': 1 }, { 'b': 2 }], [{ 'c': 3 }]); + deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); + }); }); /*--------------------------------------------------------------------------*/ @@ -1260,27 +1308,35 @@ var args = arguments; test('should merge `source` into the destination object', function() { - var stooges = [ - { 'name': 'moe' }, - { 'name': 'larry' } - ]; + var names = { + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] + }; - var ages = [ - { 'age': 40 }, - { 'age': 50 } - ]; + var ages = { + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] + }; - var heights = [ - { 'height': '5\'4"' }, - { 'height': '5\'5"' }, - ]; + var heights = { + 'stooges': [ + { 'height': '5\'4"' }, + { 'height': '5\'5"' }, + ] + }; - var expected = [ - { 'name': 'moe', 'age': 40, 'height': '5\'4"' }, - { 'name': 'larry', 'age': 50, 'height': '5\'5"' } - ]; + var expected = { + 'stooges': [ + { 'name': 'moe', 'age': 40, 'height': '5\'4"' }, + { 'name': 'larry', 'age': 50, 'height': '5\'5"' } + ] + }; - deepEqual(_.merge(stooges, ages, heights), expected); + deepEqual(_.merge(names, ages, heights), expected); }); test('should merge sources containing circular references', function() { @@ -1302,20 +1358,20 @@ }); test('should merge problem JScript properties (test in IE < 9)', function() { - var object = [{ + var object = { 'constructor': 1, 'hasOwnProperty': 2, 'isPrototypeOf': 3 - }]; + }; - var source = [{ + var source = { 'propertyIsEnumerable': 4, 'toLocaleString': 5, 'toString': 6, 'valueOf': 7 - }]; + }; - deepEqual(_.merge(object, source), [shadowed]); + deepEqual(_.merge(object, source), shadowed); }); test('should not treat `arguments` objects as plain objects', function() { @@ -1361,25 +1417,25 @@ (function() { var object = { 'a': 1, 'b': 2 }, - actual = { 'b': 2 }; + expected = { 'b': 2 }; test('should accept individual property names', function() { - deepEqual(_.omit(object, 'a'), actual); + deepEqual(_.omit(object, 'a'), expected); }); test('should accept an array of property names', function() { - deepEqual(_.omit(object, ['a', 'c']), actual); + deepEqual(_.omit(object, ['a', 'c']), expected); }); test('should accept mixes of individual and arrays of property names', function() { - deepEqual(_.omit(object, ['a'], 'c'), actual); + deepEqual(_.omit(object, ['a'], 'c'), expected); }); test('should iterate over inherited properties', function() { function Foo() {} Foo.prototype = object; - deepEqual(_.omit(new Foo, 'a'), actual); + deepEqual(_.omit(new Foo, 'a'), expected); }); test('should work with a `callback` argument', function() { @@ -1387,7 +1443,7 @@ return value == 1; }); - deepEqual(actual, { 'b': 2 }); + deepEqual(actual, expected); }); test('should pass the correct `callback` arguments', function() { @@ -1410,7 +1466,7 @@ return value == this.a; }, { 'a': 1 }); - deepEqual(actual, { 'b': 2 }); + deepEqual(actual, expected); }); }()); From 0a53f762fe6d85b4f2f690cf8549ab79e198b259 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 14 Jan 2013 01:28:39 -0800 Subject: [PATCH 059/176] Update tested environments in README.md. Former-commit-id: 9ce4d74e664acdd3acee27b7a127a6d7d4577ac4 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19924c1c7c..df82854465 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ For more information check out these screencasts over Lo-Dash: ## Support -Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~17, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.16, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. +Lo-Dash has been tested in at least Chrome 5~24, Firefox 1~18, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.17, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. ## Custom builds From 16a204335ec1e7e1f1dee5ae37d10b675c9d6e48 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2013 01:32:21 -0800 Subject: [PATCH 060/176] Ensure `_.merge` produces dense arrays and revert accepting arrays of arguments for `_.compose`, `_.defaults`, `_.extend`, and `_.merge`. Former-commit-id: a02772f8be04e187cbbfeb324cd4fb4318098162 --- build/pre-compile.js | 3 - doc/README.md | 204 +++++++++++++++++++-------------------- lodash.js | 51 +++++----- lodash.min.js | 54 +++++------ lodash.underscore.js | 30 +++--- lodash.underscore.min.js | 28 +++--- test/test.js | 37 +++---- 7 files changed, 194 insertions(+), 213 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 4d42831e26..4951dd1c1d 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -7,13 +7,10 @@ /** Used to minify variables embedded in compiled strings */ var compiledVars = [ - 'args', 'argsIndex', 'argsLength', - 'arrayRef', 'callback', 'collection', - 'concat', 'createCallback', 'ctor', 'guard', diff --git a/doc/README.md b/doc/README.md index ad4550d6a2..9f1c06f357 100644 --- a/doc/README.md +++ b/doc/README.md @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2790 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2824 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -282,7 +282,7 @@ _.first([1, 2, 3], function(num) { ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2903 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -310,7 +310,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2949 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2945 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -342,7 +342,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2995 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2991 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -376,7 +376,7 @@ _.initial([1, 2, 3], function(num) { ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3025 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -400,7 +400,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3091 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -434,7 +434,7 @@ _.last([1, 2, 3], function(num) { ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3132 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3128 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -463,7 +463,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3158 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -488,7 +488,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3203 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -526,7 +526,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3253 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -563,7 +563,7 @@ _.rest([1, 2, 3], function(num) { ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3309 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -607,7 +607,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3341 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -631,7 +631,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3375 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -670,7 +670,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3438 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3434 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -695,7 +695,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3465 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -752,7 +752,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4342 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4337 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -782,7 +782,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4359 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4354 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -803,7 +803,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4376 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4371 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -834,7 +834,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1989 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -862,7 +862,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2031 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -900,7 +900,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2082 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2078 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -932,7 +932,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2108 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -961,7 +961,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2147 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -990,7 +990,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2191 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1019,7 +1019,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2230 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2226 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1051,7 +1051,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2268 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1083,7 +1083,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2301 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1112,7 +1112,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2339 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2335 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1144,7 +1144,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2377 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1176,7 +1176,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2429 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2425 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1202,7 +1202,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2480 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2476 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1233,7 +1233,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2504 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2500 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1263,7 +1263,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2542 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1294,7 +1294,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2584 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2580 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1320,7 +1320,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2601 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1344,7 +1344,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2638 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1374,7 +1374,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2659 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1403,7 +1403,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2709 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2705 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1435,7 +1435,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2740 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1459,7 +1459,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2774 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2770 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1497,7 +1497,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3502 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3498 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1525,7 +1525,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3535 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3531 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1556,7 +1556,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3562 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, 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 the function properties of `object` will be bound. @@ -1587,7 +1587,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3608 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1628,9 +1628,9 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3631 "View in source") [Ⓣ][1] -Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. Functions may be specified as individual arguments or as arrays of functions. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. +Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. #### Arguments 1. `[func1, func2, ...]` *(Function)*: Functions to compose. @@ -1655,7 +1655,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3669 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1681,7 +1681,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3728 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1706,7 +1706,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3713 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3708 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1733,7 +1733,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3752 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1759,7 +1759,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3784 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3779 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1785,7 +1785,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1812,7 +1812,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3836 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1837,7 +1837,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1873,9 +1873,9 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L840 "View in source") [Ⓣ][1] -Assigns own enumerable properties of source object(s) to the `destination` object. Source objects may be specified as individual arguments or as arrays of source objects. Subsequent sources will overwrite propery assignments of previous sources. +Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. #### Aliases *extend* @@ -1901,7 +1901,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1052 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1050 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1937,7 +1937,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1147 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1970,9 +1970,9 @@ deep[0] === stooges[0]; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] -Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Source objects may be specified as individual arguments or as arrays of source objects. Once a property is set, additional defaults of the same property will be ignored. +Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. #### Arguments 1. `object` *(Object)*: The destination object. @@ -1996,7 +1996,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L898 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L896 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2032,7 +2032,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L922 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2060,7 +2060,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2087,7 +2087,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1211 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2112,7 +2112,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1228 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2136,7 +2136,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L860 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L858 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2163,7 +2163,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1257 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2190,7 +2190,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2214,7 +2214,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1296 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1293 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2238,7 +2238,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1310 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2262,7 +2262,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1338 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1335 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2292,7 +2292,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1380 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1377 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2323,7 +2323,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1528 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2361,7 +2361,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2385,7 +2385,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1608 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2420,7 +2420,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1633 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1630 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2447,7 +2447,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2471,7 +2471,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1578 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2501,7 +2501,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1678 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1675 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2536,7 +2536,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2560,7 +2560,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1720 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2584,7 +2584,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1737 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1734 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2608,7 +2608,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L937 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L935 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2632,9 +2632,9 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1777 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1773 "View in source") [Ⓣ][1] -Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Source objects may be specified as individual arguments or as arrays of source objects. Subsequent sources will overwrite propery assignments of previous sources. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. #### Arguments 1. `object` *(Object)*: The destination object. @@ -2671,7 +2671,7 @@ _.merge(names, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1849 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1845 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2702,7 +2702,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2726,7 +2726,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1917 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2757,7 +2757,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1958 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1954 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2788,7 +2788,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3918 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3913 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2812,7 +2812,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3936 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3931 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2837,7 +2837,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3962 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3957 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2867,7 +2867,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3986 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2887,7 +2887,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4009 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4004 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2915,7 +2915,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4042 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2950,7 +2950,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4132 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4127 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3028,7 +3028,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4268 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4263 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3060,7 +3060,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4294 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4289 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3084,7 +3084,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4309 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3137,7 +3137,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4541 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4536 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 06824a6ff1..50896fc81d 100644 --- a/lodash.js +++ b/lodash.js @@ -463,11 +463,10 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - 'var args = concat.apply(arrayRef, arguments),\n' + - ' argsIndex = 0,\n' + - " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + + 'var argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + 'while (++argsIndex < argsLength) {\n' + - ' if ((iteratee = args[argsIndex])) {', + ' if ((iteratee = arguments[argsIndex])) {', 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -709,14 +708,14 @@ // create the function factory var factory = Function( - 'arrayRef, concat, createCallback, hasOwnProperty, isArguments, isString, ' + - 'objectTypes, nativeKeys, propertyIsEnumerable', + 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' + + 'nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' ); // return the compiled function return factory( - arrayRef, concat, createCallback, hasOwnProperty, isArguments, isString, - objectTypes, nativeKeys, propertyIsEnumerable + createCallback, hasOwnProperty, isArguments, isString, objectTypes, + nativeKeys, propertyIsEnumerable ); } @@ -823,9 +822,8 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` - * object. Source objects may be specified as individual arguments or as arrays - * of source objects. Subsequent sources will overwrite propery assignments of - * previous sources. + * object. Subsequent sources will overwrite propery assignments of previous + * sources. * * @static * @memberOf _ @@ -1151,9 +1149,8 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` * object for all `destination` properties that resolve to `null`/`undefined`. - * Source objects may be specified as individual arguments or as arrays of source - * objects. Once a property is set, additional defaults of the same property will - * be ignored. + * Once a property is set, additional defaults of the same property will be + * ignored. * * @static * @memberOf _ @@ -1740,9 +1737,8 @@ /** * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined`, into the `destination` object. Source objects - * may be specified as individual arguments or as arrays of source objects. - * Subsequent sources will overwrite propery assignments of previous sources. + * don't resolve to `undefined`, into the `destination` object. Subsequent + * sources will overwrite propery assignments of previous sources. * * @static * @memberOf _ @@ -1782,7 +1778,6 @@ stackB = args[4]; if (indicator !== indicatorObject) { - args = concat.apply(arrayRef, args); stackA = []; stackB = []; @@ -1792,9 +1787,10 @@ } } while (++index < length) { - forOwn(args[index], function(source, key) { - var found, isArr, value; - if (source && ((isArr = isArray(source)) || isPlainObject(source))) { + var isArr = isArray(args[index]); + (isArr ? forEach : forOwn)(args[index], function(source, key) { + var found, isObj, value; + if (source && ((isObj = isPlainObject(source)) || isArray(source))) { // avoid merging previously merged cyclic sources var stackLength = stackA.length; while (stackLength--) { @@ -1806,14 +1802,14 @@ if (!found) { // add `source` and associated `value` to the stack of traversed objects stackA.push(source); - stackB.push(value = (value = object[key], isArr) - ? (isArray(value) ? value : []) - : (isPlainObject(value) ? value : {}) + stackB.push(value = (value = object[key], isObj) + ? (isPlainObject(value) ? value : {}) + : (isArray(value) ? value : []) ); // recursively merge objects and arrays (susceptible to call stack limits) object[key] = merge(value, source, indicatorObject, stackA, stackB); } - } else if (typeof source != 'undefined') { + } else if (isArr || typeof source != 'undefined') { object[key] = source; } }); @@ -3616,8 +3612,7 @@ /** * Creates a function that is the composition of the passed functions, * where each function consumes the return value of the function that follows. - * Functions may be specified as individual arguments or as arrays of functions. - * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. + * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. * Each function is executed with the `this` binding of the composed function. * * @static @@ -3634,7 +3629,7 @@ * // => 'hi: moe!' */ function compose() { - var funcs = concat.apply(arrayRef, arguments); + var funcs = arguments; return function() { var args = arguments, length = funcs.length; diff --git a/lodash.min.js b/lodash.min.js index 8371c4af82..bde205a341 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -5,36 +5,36 @@ */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="l='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(i&&i.prototype===o)&&"),r+="k.call(o,l)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return w",Function("d,g,h,k,m,n,s,q,v","return function("+n+"){"+r+"}")(rt,xt,a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return q(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),F(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function B(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,Rt=ht.test(Rt=Array.isArray)&&Rt,Ft=n.isFinite,qt=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,zt=Math.random,Bt="[object Arguments]",Mt="[object Array]",Pt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=Nt&&/\n|true/.test(Nt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Bt]=tr[Mt]=tr[Pt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Mt]=Array,rr[Pt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"r,y,j",k:"var a=g.apply(d,arguments),b=0,c=typeof j=='number'?2:a.length;while(++b":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(w[l]==null)"+or.g}),yr=Rt||function(n){return Wt&&n instanceof Array||$t.call(n)==Mt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=q,r.max=D,r.memoize=function(n,t){var r={}; +}:function(r,e,u){return n.call(t,r,e,u)}:n}function f(){for(var n,t={e:nt,f:Dt,h:Qt,i:Yt,j:wt,b:X,c:"",g:"",k:"",l:Q},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e];if(n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var i,l="+t.d+",t="+t.d+";if(!"+t.d+")return t;"+t.k+";",t.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",t.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++ie;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={}; return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(zt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=z,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=B,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +},r.uniq=U,r.values=E,r.where=function(n,t){return q(n,t)},r.without=function(n){for(var t=-1,r=n?n.length:0,u=e(arguments,1,20),o=[];++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=B,r.detect=R,r.foldl=T,r.foldr=z,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) -}},r.take=M,r.head=M,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) +}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this }}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r })(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 5d938cf9d0..44028daad3 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -277,11 +277,10 @@ var assignIteratorOptions = { 'args': 'object, source, guard', 'top': - 'var args = concat.apply(arrayRef, arguments),\n' + - ' argsIndex = 0,\n' + - " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + + 'var argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + 'while (++argsIndex < argsLength) {\n' + - ' if ((iteratee = args[argsIndex])) {', + ' if ((iteratee = arguments[argsIndex])) {', 'loop': 'result[index] = iteratee[index]', 'bottom': ' }\n}' }; @@ -470,14 +469,14 @@ // create the function factory var factory = Function( - 'arrayRef, concat, createCallback, hasOwnProperty, isString, ' + - 'objectTypes, nativeKeys, propertyIsEnumerable', + 'createCallback, hasOwnProperty, isString, objectTypes, ' + + 'nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + (data) + '\n}' ); // return the compiled function return factory( - arrayRef, concat, createCallback, hasOwnProperty, isString, - objectTypes, nativeKeys, propertyIsEnumerable + createCallback, hasOwnProperty, isString, objectTypes, + nativeKeys, propertyIsEnumerable ); } @@ -601,9 +600,8 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` - * object. Source objects may be specified as individual arguments or as arrays - * of source objects. Subsequent sources will overwrite propery assignments of - * previous sources. + * object. Subsequent sources will overwrite propery assignments of previous + * sources. * * @static * @memberOf _ @@ -854,9 +852,8 @@ /** * Assigns own enumerable properties of source object(s) to the `destination` * object for all `destination` properties that resolve to `null`/`undefined`. - * Source objects may be specified as individual arguments or as arrays of source - * objects. Once a property is set, additional defaults of the same property will - * be ignored. + * Once a property is set, additional defaults of the same property will be + * ignored. * * @static * @memberOf _ @@ -3069,8 +3066,7 @@ /** * Creates a function that is the composition of the passed functions, * where each function consumes the return value of the function that follows. - * Functions may be specified as individual arguments or as arrays of functions. - * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. + * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. * Each function is executed with the `this` binding of the composed function. * * @static @@ -3087,7 +3083,7 @@ * // => 'hi: moe!' */ function compose() { - var funcs = concat.apply(arrayRef, arguments); + var funcs = arguments; return function() { var args = arguments, length = funcs.length; diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 72613d67e5..c93c5b2fd5 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -5,29 +5,29 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&typeof r=="undefined"?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++et||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length; -if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||pt&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,pt=tt.test(pt=s.bind)&&pt,st=tt.test(st=Array.isArray)&&st,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=pt&&/\n|true/.test(pt+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=st||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) -}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=it.apply(W,arguments),r=1I(e,o,r)&&u.push(o)}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return s(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; -o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=s(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) +}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=it.apply(W,arguments),r=1I(e,o,r)&&u.push(o)}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return p(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; +o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1)) },o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length }),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}";try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return s(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this +if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return p(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this }}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o})(this); \ No newline at end of file diff --git a/test/test.js b/test/test.js index ffbd7c892e..2e8b4e1c55 100644 --- a/test/test.js +++ b/test/test.js @@ -395,23 +395,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.compose'); - - (function() { - test('should accept arrays of functions', function() { - var composed = _.compose([ - function(c) { return c + 'd'; }, - function(b) { return b + 'c'; } - ], [ - function(a) { return a + 'b'; } - ]); - - equal(composed('a'), 'abcd'); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.contains'); (function() { @@ -548,11 +531,6 @@ Foo.prototype = { 'a': 1 }; deepEqual(func({}, new Foo), {}); }); - - test('lodash.' + methodName + ' should accept arrays of source objects', function() { - var actual = func({}, [{ 'a': 1 }, { 'b': 2 }], [{ 'c': 3 }]); - deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); - }); }); /*--------------------------------------------------------------------------*/ @@ -1406,9 +1384,24 @@ }); test('should not assign `undefined` values', function() { + var a var actual = _.merge({ 'a': 1 }, { 'a': undefined }); strictEqual(actual.a, 1); }); + + test('should treat sparse arrays as dense', function() { + var array = Array(3); + array[0] = 1; + array[2] = 3; + + var actual = _.merge([], array), + expected = array.slice(); + + expected[1] = undefined; + + ok(1 in actual); + deepEqual(actual, expected); + }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/ From 64e8d6ae99a1ecacfe904bad63f47c267a8c6a22 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2013 02:18:40 -0800 Subject: [PATCH 061/176] Update .travis.yml with git and branch options. Former-commit-id: 51abc02eb378332b15d525fdab62d82f8d70b62b --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index b478dee6be..ce1f1fb8ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ language: node_js node_js: - 0.6 - 0.8 +git: + depth: 1 +branches: + only: + - master before_script: - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor" - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/505f1be36ef60fd25a992a522f116d5179ab317f | tar xvz -C vendor" From 21a90f8f8f5fcfad74c455501d22ac782e76fa25 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2013 08:49:59 -0800 Subject: [PATCH 062/176] Avoid travis-ci downloading the included minifiers. Former-commit-id: d8558ea8295a9c7e7d28c1a1740edf63daa81933 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce1f1fb8ba..667213d2e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ branches: only: - master before_script: - - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor" - - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/505f1be36ef60fd25a992a522f116d5179ab317f | tar xvz -C vendor" + - "tar -xzvf vendor/closure-compiler.tar.gz -C vendor" + - "tar -xzvf vendor/uglifyjs.tar.gz -C vendor" From 25efa294708e3bf7aefbb6fdb8f05754d0817bf5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2013 21:14:48 -0800 Subject: [PATCH 063/176] Remove metadata from tar.gz files. Former-commit-id: 2cd702d72e9f2ff441fc7f8c8e22bef3f2784cbe --- build/minify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/minify.js b/build/minify.js index fbd7494124..f53762946c 100755 --- a/build/minify.js +++ b/build/minify.js @@ -15,10 +15,10 @@ postprocess = require('./post-compile.js'); /** The Git object ID of `closure-compiler.tar.gz` */ - var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; + var closureId = 'd29ccc8d738f4c46621e8982bbf1bef7cf0ebd9a'; /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '505f1be36ef60fd25a992a522f116d5179ab317f'; + var uglifyId = '71532e2f79b681f2940ea78d43778b43c805c084'; /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); From 677503dbf11bb490d1fabf09e793827e68ae9e0a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2013 21:28:14 -0800 Subject: [PATCH 064/176] Remove Travis-CI build status until they resolve their issues. Former-commit-id: 2d5607771e148b3010906452a9dc86f25f18ed3f --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index df82854465..ec971bab91 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Lo-Dash v1.0.0-rc.3 -[![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) An alternative to Underscore.js, delivering [consistency](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), [customization](https://github.com/bestiejs/lodash#custom-builds), [performance](http://lodash.com/benchmarks), and [extra features](https://github.com/bestiejs/lodash#features). From b60d0cdb17639ba3d3e47a7bb8e4e5fa4940adb4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Jan 2013 01:11:39 -0800 Subject: [PATCH 065/176] Added support for `_.merge` to accept `callback` and `thisArg` arguments. [closes #154] Former-commit-id: 5d641ae4ba1d120d776a895f8bc9b8c1a7def0b6 --- doc/README.md | 150 +++++++++++++++++++++++++------------------------- lodash.js | 59 ++++++++++++++------ lodash.min.js | 16 +++--- test/test.js | 26 +++++++++ 4 files changed, 152 insertions(+), 99 deletions(-) diff --git a/doc/README.md b/doc/README.md index 9f1c06f357..b44e247cff 100644 --- a/doc/README.md +++ b/doc/README.md @@ -134,7 +134,7 @@ * [`_.isString`](#_isstringvalue) * [`_.isUndefined`](#_isundefinedvalue) * [`_.keys`](#_keysobject) -* [`_.merge`](#_mergeobject--source1-source2-) +* [`_.merge`](#_mergeobject--source1-source2--callback-thisarg) * [`_.methods`](#_functionsobject) * [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg) * [`_.pairs`](#_pairsobject) @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2790 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2815 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2845 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2889 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -282,7 +282,7 @@ _.first([1, 2, 3], function(num) { ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2903 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2928 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -310,7 +310,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2970 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -342,7 +342,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2991 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3016 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -376,7 +376,7 @@ _.initial([1, 2, 3], function(num) { ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3025 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3050 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -400,7 +400,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -434,7 +434,7 @@ _.last([1, 2, 3], function(num) { ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3153 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -463,7 +463,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3183 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -488,7 +488,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3203 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3228 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -526,7 +526,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3253 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3278 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -563,7 +563,7 @@ _.rest([1, 2, 3], function(num) { ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -607,7 +607,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3341 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3366 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -631,7 +631,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3400 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -670,7 +670,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3434 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3459 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -695,7 +695,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3465 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -752,7 +752,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4362 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -782,7 +782,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4379 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -803,7 +803,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4396 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -834,7 +834,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1989 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -862,7 +862,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2056 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -900,7 +900,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2078 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2103 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -932,7 +932,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2108 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2133 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -961,7 +961,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2147 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2172 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -990,7 +990,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2216 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1019,7 +1019,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2251 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1051,7 +1051,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2268 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2293 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1083,7 +1083,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2326 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1112,7 +1112,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1144,7 +1144,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2402 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1176,7 +1176,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2425 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2450 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1202,7 +1202,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2476 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2501 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1233,7 +1233,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2500 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1263,7 +1263,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2542 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1294,7 +1294,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2580 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1320,7 +1320,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2626 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1344,7 +1344,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2659 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1374,7 +1374,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2659 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1403,7 +1403,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2705 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2730 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1435,7 +1435,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2765 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1459,7 +1459,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2770 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2795 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1497,7 +1497,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3498 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3523 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1525,7 +1525,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3556 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1556,7 +1556,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3562 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, 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 the function properties of `object` will be bound. @@ -1587,7 +1587,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3633 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1628,7 +1628,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3631 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3656 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1655,7 +1655,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3689 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1681,7 +1681,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3728 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3753 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1706,7 +1706,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1733,7 +1733,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3752 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3777 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1759,7 +1759,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3804 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1785,7 +1785,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1812,7 +1812,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3836 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3861 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1837,7 +1837,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3914 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2631,14 +2631,16 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); -### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1773 "View in source") [Ⓣ][1] +### `_.merge(object [, source1, source2, ..., callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1778 "View in source") [Ⓣ][1] -Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source object properties. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. #### Arguments 1. `object` *(Object)*: The destination object. 2. `[source1, source2, ...]` *(Object)*: The source objects. +3. `[callback]` *(Function)*: The function called for each property to merge. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns *(Object)*: Returns the destination object. @@ -2671,7 +2673,7 @@ _.merge(names, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1845 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1870 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2702,7 +2704,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2726,7 +2728,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1942 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2757,7 +2759,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1954 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2788,7 +2790,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3938 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2812,7 +2814,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3931 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3956 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2837,7 +2839,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3957 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3982 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2867,7 +2869,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4006 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2887,7 +2889,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4004 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4029 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2915,7 +2917,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4042 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4067 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2950,7 +2952,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4152 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3028,7 +3030,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4288 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3060,7 +3062,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4289 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4314 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3084,7 +3086,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4334 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3137,7 +3139,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4561 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 50896fc81d..718edbdfe5 100644 --- a/lodash.js +++ b/lodash.js @@ -1737,14 +1737,19 @@ /** * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined`, into the `destination` object. Subsequent - * sources will overwrite propery assignments of previous sources. + * don't resolve to `undefined`, into the `destination` object. Subsequent sources + * will overwrite propery assignments of previous sources. If a `callback` function + * is passed, it will be executed to produce the merged values of the destination + * and source object properties. The `callback` is bound to `thisArg` and invoked + * with two arguments; (objectValue, sourceValue). * * @static * @memberOf _ * @category Objects * @param {Object} object The destination object. * @param {Object} [source1, source2, ...] The source objects. + * @param {Function} [callback] The function called for each property to merge. + * @param {Mixed} [thisArg] The `this` binding of `callback`. * @param- {Object} [indicator] Internally used to indicate that the `stack` * argument is an array of traversed objects instead of another source object. * @param- {Array} [stackA=[]] Internally used to track traversed source objects. @@ -1773,45 +1778,65 @@ function merge(object, source, indicator) { var args = arguments, index = 0, - length = 2, - stackA = args[3], - stackB = args[4]; + length = 2; - if (indicator !== indicatorObject) { + if (!object) { + return object; + } + if (indicator === indicatorObject) { + var callback = args[3], + stackA = args[4], + stackB = args[5]; + } + else { stackA = []; stackB = []; - - // work with `_.reduce` by only using its callback `accumulator` and `value` arguments if (typeof indicator != 'number') { length = args.length; + callback = typeof (callback = args[length - 2]) == 'function' + ? createCallback(callback, args[--length]) + : (typeof (callback = args[length - 1]) == 'function' && callback); } } while (++index < length) { var isArr = isArray(args[index]); (isArr ? forEach : forOwn)(args[index], function(source, key) { - var found, isObj, value; + var found, + isObj, + value = object[key]; + if (source && ((isObj = isPlainObject(source)) || isArray(source))) { // avoid merging previously merged cyclic sources var stackLength = stackA.length; while (stackLength--) { if ((found = stackA[stackLength] == source)) { - object[key] = stackB[stackLength]; + value = stackB[stackLength]; break; } } if (!found) { + value = isObj + ? (isPlainObject(value) ? value : {}) + : (isArray(value) ? value : []); + + if (callback) { + value = callback(value, source); + } // add `source` and associated `value` to the stack of traversed objects stackA.push(source); - stackB.push(value = (value = object[key], isObj) - ? (isPlainObject(value) ? value : {}) - : (isArray(value) ? value : []) - ); + stackB.push(value); + // recursively merge objects and arrays (susceptible to call stack limits) - object[key] = merge(value, source, indicatorObject, stackA, stackB); + value = value && merge(value, source, indicatorObject, callback, stackA, stackB); } - } else if (isArr || typeof source != 'undefined') { - object[key] = source; } + else if (callback) { + value = callback(value, source); + } + else if (isArr || typeof source != 'undefined') { + value = source; + } + object[key] = value; }); } return object; diff --git a/lodash.min.js b/lodash.min.js index bde205a341..f3df3bc198 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -10,14 +10,14 @@ return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return f var r=n.constructor;return!j(r)&&(!Zt||!p(n))||r instanceof r?tt?(lr(n,function(n,r,e){return t=!St.call(e,r),X}),t===X):(lr(n,function(n,r){t=r}),t===X||St.call(n,t)):t}function m(n){var t=[];return pr(n,function(n,r){t.push(r)}),t}function _(n,t,r,e,u){if(n==W)return n;if(r&&(t=X),r=x(n)){var o=$t.call(n);if(!tr[o]||Zt&&p(n))return n;var i=yr(n)}if(!r||!t)return r?i?v(n):cr({},n):n;switch(r=rr[o],o){case zt:case Ct:return new r(+n);case Kt:case Vt:return new r(n);case Ut:return r(n.source,vt.exec(n)) }for(e||(e=[]),u||(u=[]),o=e.length;o--;)if(e[o]==n)return u[o];var a=i?r(n.length):{};return e.push(n),u.push(a),(i?R:pr)(n,function(n,r){a[r]=_(n,t,W,e,u)}),i&&(St.call(n,"index")&&(a.index=n.index),St.call(n,"input")&&(a.input=n.input)),a}function d(n){var t=[];return lr(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=sr(n),e=r.length,u={};++tr?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +if(r.push(n),e.push(t),o){if(f=n.length,a=f==t.length)for(;f--&&(a=w(n[f],t[f],r,e)););return a}return lr(n,function(n,u,o){return St.call(o,u)?(f++,a=St.call(t,u)&&w(n,t[u],r,e)):void 0}),a&&lr(t,function(n,t,r){return St.call(r,t)?a=-1<--f:void 0}),a}function j(n){return typeof n=="function"}function x(n){return n?er[typeof n]:X}function O(n){return typeof n=="number"||$t.call(n)==Kt}function A(n){return typeof n=="string"||$t.call(n)==Vt}function S(n,t,r){var e=arguments,u=0,o=2;if(!n)return n;if(r===ot)var i=e[3],f=e[4],c=e[5]; +else f=[],c=[],typeof r!="number"&&(o=e.length,i=typeof(i=e[o-2])=="function"?a(i,e[--o]):typeof(i=e[o-1])=="function"&&i);for(;++ur?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n) +});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 diff --git a/test/test.js b/test/test.js index 2e8b4e1c55..2978a38a51 100644 --- a/test/test.js +++ b/test/test.js @@ -1402,6 +1402,32 @@ ok(1 in actual); deepEqual(actual, expected); }); + + test('should pass the correct `callback` arguments', function() { + var args; + + _.merge({ 'a': 1 }, { 'a': 2 }, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [1, 2]); + }); + + test('should correct set the `this` binding', function() { + var actual = _.merge({}, { 'a': 0 }, function(a, b) { + return this[b]; + }, [2]); + + deepEqual(actual, { 'a': 2 }); + }); + + test('should work as a deep `_.defaults`', function() { + var object = { 'a': { 'b': 1 } }, + source = { 'a': { 'b': 2, 'c': 3 } }, + expected = { 'a': { 'b': 1, 'c': 3 } }; + + deepEqual(_.merge(object, source, _.defaults), expected); + }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/ From ab83f2d5e2326da587eda2c5e37c02ad19503359 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Jan 2013 01:39:58 -0800 Subject: [PATCH 066/176] Ensure `_.first` and `_.last` have the correct chaining behavior when passing a `callback` and `thisArg`. Former-commit-id: 4d54fd677fa48bf8de033696c58ee66babd77a81 --- doc/README.md | 2 +- lodash.js | 8 +++++--- lodash.min.js | 2 +- test/test.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/doc/README.md b/doc/README.md index b44e247cff..4f513e0f6d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -3139,7 +3139,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4561 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4563 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 718edbdfe5..e10ebd5025 100644 --- a/lodash.js +++ b/lodash.js @@ -4542,9 +4542,11 @@ forOwn(lodash, function(func, methodName) { if (!lodash.prototype[methodName]) { - lodash.prototype[methodName]= function(n, guard) { - var result = func(this.__wrapped__, n, guard); - return (n == null || guard) ? result : new lodash(result); + lodash.prototype[methodName]= function(callback, thisArg) { + var result = func(this.__wrapped__, callback, thisArg); + return callback == null || (thisArg && typeof callback != 'function') + ? result + : new lodash(result); }; } }); diff --git a/lodash.min.js b/lodash.min.js index f3df3bc198..ad9ab88dd8 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -35,6 +35,6 @@ return lr(n,function(n,r,i){(e?!t(n,r,i):0>C(o,r,1))&&(u[r]=n)}),u},r.once=funct },r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) },r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) -}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this }}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r })(this); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 2978a38a51..532003bfc6 100644 --- a/test/test.js +++ b/test/test.js @@ -640,6 +640,29 @@ deepEqual(actual, [1, 2]); }); + + test('should chain when passing `n`, `callback`, or `thisArg`', function() { + var actual = _(array).first(2); + + ok(actual instanceof _); + + actual = _(array).first(function(num) { + return num < 3; + }); + + ok(actual instanceof _); + + actual = _(array).first(function(value, index) { + return this[index] < 3; + }, array); + + ok(actual instanceof _); + }); + + test('should not chain when no arguments are passed', function() { + var actual = _(array).first(); + strictEqual(actual, 1); + }); }()); /*--------------------------------------------------------------------------*/ @@ -1192,6 +1215,29 @@ deepEqual(actual, [2, 3]); }); + + test('should chain when passing `n`, `callback`, or `thisArg`', function() { + var actual = _(array).last(2); + + ok(actual instanceof _); + + actual = _(array).last(function(num) { + return num > 1; + }); + + ok(actual instanceof _); + + actual = _(array).last(function(value, index) { + return this[index] > 1; + }, array); + + ok(actual instanceof _); + }); + + test('should not chain when no arguments are passed', function() { + var actual = _(array).last(); + equal(actual, 3); + }); }()); /*--------------------------------------------------------------------------*/ From 769e03e7f269f3d7dbbe916980881378534b3355 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Jan 2013 23:21:08 -0800 Subject: [PATCH 067/176] Update Closure Compiler and UglifyJS. Former-commit-id: 8e20f30f84b01ed6df593136c2d081e9d05acbca --- build/minify.js | 4 ++-- lodash.js | 3 +-- lodash.min.js | 2 +- lodash.underscore.js | 3 +-- lodash.underscore.min.js | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/build/minify.js b/build/minify.js index f53762946c..94b3f31d3d 100755 --- a/build/minify.js +++ b/build/minify.js @@ -15,10 +15,10 @@ postprocess = require('./post-compile.js'); /** The Git object ID of `closure-compiler.tar.gz` */ - var closureId = 'd29ccc8d738f4c46621e8982bbf1bef7cf0ebd9a'; + var closureId = '7bbcf0c118f006fb095ece7c3a11c90b6f0215ad'; /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '71532e2f79b681f2940ea78d43778b43c805c084'; + var uglifyId = '577c2dfdf72c0310d2a560976696c07894943079'; /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); diff --git a/lodash.js b/lodash.js index e10ebd5025..e72db4c367 100644 --- a/lodash.js +++ b/lodash.js @@ -19,8 +19,7 @@ /** Used for array and object method references */ var arrayRef = [], - // avoid a Closure Compiler bug by creatively creating an object - objectRef = new function(){}; + objectRef = {}; /** Used to generate unique IDs */ var idCounter = 0; diff --git a/lodash.min.js b/lodash.min.js index ad9ab88dd8..b576d09dbd 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -17,7 +17,7 @@ return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;re });return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +}function G(n){return n}function H(n){R(d(n),function(t){var e=r[t]=n[t];r.prototype[t]=function(){var n=[this.__wrapped__];return Et.apply(n,arguments),new r(e.apply(r,n))}})}function J(){return this.__wrapped__}var Q=!0,W=null,X=!1,Y=typeof exports=="object"&&exports,Z=typeof global=="object"&&global;Z.global===Z&&(n=Z);var nt,tt,rt=[],et={},ut=0,ot=et,it=30,at=n._,ft=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 diff --git a/lodash.underscore.js b/lodash.underscore.js index 44028daad3..eaf3114d4b 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -20,8 +20,7 @@ /** Used for array and object method references */ var arrayRef = [], - // avoid a Closure Compiler bug by creatively creating an object - objectRef = new function(){}; + objectRef = {}; /** Used to generate unique IDs */ var idCounter = 0; diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index c93c5b2fd5..5590d3c132 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -15,7 +15,7 @@ else u(n,function(n,r,u){i[++e]=t(n,r,u)});return i}function R(n,t,r){var e=-1/0 if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +Q.global===Q&&(n=Q);var W=[],Q={},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) }),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=it.apply(W,arguments),r=1 Date: Wed, 16 Jan 2013 23:22:07 -0800 Subject: [PATCH 068/176] Fix typo in `_.merge` unit test. Former-commit-id: 15b2389bca12cb1655a07a51525624f7af9caa6c --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 532003bfc6..b8b0e8edbf 100644 --- a/test/test.js +++ b/test/test.js @@ -1349,7 +1349,7 @@ var heights = { 'stooges': [ { 'height': '5\'4"' }, - { 'height': '5\'5"' }, + { 'height': '5\'5"' } ] }; From 96fbd7c7ba734eaeceaf6301a0758474f6ebdf62 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Jan 2013 23:59:24 -0800 Subject: [PATCH 069/176] Fix closure compiler bug. Former-commit-id: 6b61f095fa26d2dee0d70b666e630e4ca0fa7be6 --- build/post-compile.js | 4 +- doc/README.md | 212 +++++++++++++++++++++--------------------- lodash.min.js | 24 ++--- 3 files changed, 121 insertions(+), 119 deletions(-) diff --git a/build/post-compile.js b/build/post-compile.js index cbe27dd9e1..6cf17fadd9 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -31,7 +31,9 @@ source = source.replace(/^((?:(['"])use strict\2;)?(?:var (?:[a-z]+=(?:!0|!1|null)[,;])+)?)([\s\S]*?function[^)]+\){)/, '$3$1'); // correct overly aggressive Closure Compiler advanced optimizations - source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}'); + source = source + .replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}') + .replace(/(document[^&]+&&)\s*\w+/, '$1!({toString:0}+"")'); // unescape properties (e.g. foo["bar"] => foo.bar) source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) { diff --git a/doc/README.md b/doc/README.md index 4f513e0f6d..b50472574f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -196,7 +196,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2815 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2814 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -220,7 +220,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2845 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2844 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -245,7 +245,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2888 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -282,7 +282,7 @@ _.first([1, 2, 3], function(num) { ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2927 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -310,7 +310,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2970 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2969 "View in source") [Ⓣ][1] 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, passing `true` for `fromIndex` will run a faster binary search. @@ -342,7 +342,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3016 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -376,7 +376,7 @@ _.initial([1, 2, 3], function(num) { ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3049 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -400,7 +400,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3111 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -434,7 +434,7 @@ _.last([1, 2, 3], function(num) { ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3153 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -463,7 +463,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3183 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3182 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -488,7 +488,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3228 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3227 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -526,7 +526,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3277 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -563,7 +563,7 @@ _.rest([1, 2, 3], function(num) { ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3333 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -607,7 +607,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3365 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -631,7 +631,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3399 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -670,7 +670,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3459 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3458 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -695,7 +695,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3489 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -726,7 +726,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L274 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -752,7 +752,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4362 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4361 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -782,7 +782,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4378 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -803,7 +803,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4395 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -834,7 +834,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2013 "View in source") [Ⓣ][1] Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -862,7 +862,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2056 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2055 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -900,7 +900,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2103 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2102 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -932,7 +932,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2133 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2132 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -961,7 +961,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2172 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2171 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -990,7 +990,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2216 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2215 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1019,7 +1019,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2250 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1051,7 +1051,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2292 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1083,7 +1083,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2326 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2325 "View in source") [Ⓣ][1] 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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1112,7 +1112,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2359 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1144,7 +1144,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2402 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2401 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1176,7 +1176,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2449 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1202,7 +1202,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2501 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2500 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1233,7 +1233,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2524 "View in source") [Ⓣ][1] Reduces a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with four arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1263,7 +1263,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2566 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1294,7 +1294,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2604 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1320,7 +1320,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2626 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2625 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1344,7 +1344,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2659 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2658 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1374,7 +1374,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2683 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1403,7 +1403,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2730 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2729 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1435,7 +1435,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2765 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1459,7 +1459,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1497,7 +1497,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3523 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3522 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1525,7 +1525,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3555 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1556,7 +1556,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3586 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, 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 the function properties of `object` will be bound. @@ -1587,7 +1587,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3633 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3632 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1628,7 +1628,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3656 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3655 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1655,7 +1655,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3688 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1681,7 +1681,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3753 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3752 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1706,7 +1706,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3732 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1733,7 +1733,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3777 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3776 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1759,7 +1759,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3803 "View in source") [Ⓣ][1] 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 with the `this` binding of the created function. @@ -1785,7 +1785,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3838 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1812,7 +1812,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3861 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3860 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1837,7 +1837,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3913 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1873,7 +1873,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L840 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L839 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1901,7 +1901,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1049 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. @@ -1937,7 +1937,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1144 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. @@ -1970,7 +1970,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1166 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1996,7 +1996,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L896 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L895 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2032,7 +2032,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L919 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2060,7 +2060,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1185 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2087,7 +2087,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1210 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2112,7 +2112,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1228 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1227 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2136,7 +2136,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L857 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2163,7 +2163,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1256 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2190,7 +2190,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1275 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2214,7 +2214,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1292 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2238,7 +2238,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1310 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2262,7 +2262,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1334 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2292,7 +2292,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1376 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2323,7 +2323,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1527 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2361,7 +2361,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2385,7 +2385,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1607 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2420,7 +2420,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1630 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1629 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2447,7 +2447,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2471,7 +2471,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1574 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2501,7 +2501,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1674 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2536,7 +2536,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1699 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2560,7 +2560,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1716 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2584,7 +2584,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1733 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2608,7 +2608,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L934 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2632,7 +2632,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1777 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source object properties. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2673,7 +2673,7 @@ _.merge(names, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1869 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2704,7 +2704,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1903 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2728,7 +2728,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1942 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1941 "View in source") [Ⓣ][1] 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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2759,7 +2759,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1978 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2790,7 +2790,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3938 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3937 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2814,7 +2814,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3956 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3955 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2839,7 +2839,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3982 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2869,7 +2869,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4006 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4005 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2889,7 +2889,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4028 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2917,7 +2917,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4066 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2952,7 +2952,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4151 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3030,7 +3030,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4288 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4287 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3062,7 +3062,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4313 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3086,7 +3086,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4333 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3120,7 +3120,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L344 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L343 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3139,7 +3139,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4562 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3151,7 +3151,7 @@ A reference to the `lodash` function. ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L296 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L295 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3163,7 +3163,7 @@ A reference to the `lodash` function. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L303 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3175,7 +3175,7 @@ A reference to the `lodash` function. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L312 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L311 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3187,7 +3187,7 @@ A reference to the `lodash` function. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L319 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3199,7 +3199,7 @@ A reference to the `lodash` function. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L328 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L327 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3211,7 +3211,7 @@ A reference to the `lodash` function. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L336 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L335 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.min.js b/lodash.min.js index b576d09dbd..3ea315d9f3 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -18,18 +18,18 @@ return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X,r=(0>r?It(0,u+r):r)||0;re });return!!e}function P(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=-1,t=a(t,r);++or?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&X}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={}; -return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r); +return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this },r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t From 62fb440de2f3d78a7918a4a9983c902cd7852a4e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 17 Jan 2013 00:18:41 -0800 Subject: [PATCH 070/176] Update closure compiler. Former-commit-id: 20934c3606c88b0c108f89a01bcc7703dfbe2179 --- build/minify.js | 2 +- lodash.min.js | 33 +++++++++++++------------ lodash.underscore.min.js | 53 ++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/build/minify.js b/build/minify.js index 94b3f31d3d..543dfaabb5 100755 --- a/build/minify.js +++ b/build/minify.js @@ -15,7 +15,7 @@ postprocess = require('./post-compile.js'); /** The Git object ID of `closure-compiler.tar.gz` */ - var closureId = '7bbcf0c118f006fb095ece7c3a11c90b6f0215ad'; + var closureId = 'c92fd8f7f2b2096eb910c99d10ede0ec25d3c3cc'; /** The Git object ID of `uglifyjs.tar.gz` */ var uglifyId = '577c2dfdf72c0310d2a560976696c07894943079'; diff --git a/lodash.min.js b/lodash.min.js index 3ea315d9f3..fb12083f06 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,38 +3,39 @@ * Lo-Dash 1.0.0-rc.3 lodash.com/license * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(n=(r||it);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,St,h,A,er,Dt,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n) -});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +return u}function k(n,t,r){var e=-1,u=n?n.length:0,o=X;return r=(0>r?It(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f) +}}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,ot),yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a) +}),r}function M(n,t,r){var e;if(t=a(t,r),yr(n)){r=-1;for(var u=n.length;++rr?It(0,u+r):r||0)-1; +else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Ht||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,St=et.hasOwnProperty,Et=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&/\n|true/.test(qt+Gt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Lt&&!({toString:0}+"")}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Lt]=tr[Ut]=tr[Vt]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Lt]=Object,rr[Kt]=Number,rr[Ut]=RegExp,rr[Vt]=String; var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=Nt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r); return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n)){r=-1;for(var i=n.length;++rC(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=hr({},u,o);var i=hr({},u.imports,o.imports),o=sr(i),i=E(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=a(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t=="function"){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==W||r)return n[u-1];return v(n,It(0,u-e)) }},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this }}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r })(this); \ No newline at end of file diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 5590d3c132..a152947c3e 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,29 @@ * Build: `lodash underscore -m -o ./lodash.underscore.min.js` * Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=V),n)if(ft.call(n,r)&&t(n[r],r,n)===Y)break}function e(n,t){var r;if(n)for(r in t||(t=V),n)if(t(n[r],r,n)===Y)break}function u(n,t,r){if(n){var t=t&&typeof r=="undefined"?t:f(t,r),e=n.length,r=-1;if(typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length; -if(typeof u!="number")var i=Rt(n),u=i.length;return t=f(t,e,Y),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),Nt=arguments.constructor==Object,kt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return Nt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) -}),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=it.apply(W,arguments),r=1I(e,o,r)&&u.push(o)}return u},o.filter=S,o.flatten=$,o.forEach=k,o.functions=_,o.groupBy=function(n,t,r){var e={},t=f(t,r);return k(n,function(n,r,u){r=t(n,r,u)+"",(ft.call(e,r)?e[r]:e[r]=[]).push(n)}),e},o.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else e=t==J||r?1:t||e;return p(n,0,_t(yt(0,u-e),u))},o.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eI(o,i)){for(var a=r;--a;)if(0>I(t[a],i))continue n; -o.push(i)}}return o},o.invert=m,o.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return k(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=Rt,o.map=F,o.max=R,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.min=function(n,t,r){var e=1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++rI(t,e,1)&&(r[e]=n)}),r},o.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},o.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tI(arguments,u,1)&&e.push(u)}return e},o.wrap=function(n,t){return function(){var r=[n];return ct.apply(r,arguments),t.apply(this,r)}},o.zip=function(n){for(var t=-1,r=n?R(T(arguments,"length")):0,e=Array(r);++tr?yt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=G,o.noConflict=function(){return n._=Z,this},o.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+at(mt()*((+t||0)-n+1)) -},o.reduce=q,o.reduceRight=B,o.result=function(n,t){var r=n?n[t]:J;return b(r)?n[t]():r},o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length},o.some=D,o.sortedIndex=C,o.template=function(n,t,r){n||(n="");var r=y({},r,o.templateSettings),e=0,u="__p+='",i=r.variable;n.replace(RegExp((r.escape||rt).source+"|"+(r.interpolate||rt).source+"|"+(r.evaluate||rt).source+"|$","g"),function(t,r,o,i,a){u+=n.slice(e,a).replace(ut,c),u+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":o?"'+((__t=("+o+"))==null?'':__t)+'":"",e=a+t.length -}),u+="';\n",i||(i="obj",u="with("+i+"||{}){"+u+"}"),u="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+u+"return __p}";try{var a=Function("_","return "+u)(o)}catch(f){throw f.source=u,f}return t?a(t):(a.source=u,a)},o.unescape=function(n){return n==J?"":(n+"").replace(nt,v)},o.uniqueId=function(n){var t=++X+"";return n?n+t:t},o.all=O,o.any=D,o.detect=N,o.foldl=q,o.foldr=B,o.include=E,o.inject=q,o.first=M,o.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t=="function")for(var o=u,t=f(t,r);o--&&t(n[o],o,n);)e++;else if(e=t,e==J||r)return n[u-1];return p(n,yt(0,u-e))}},o.take=M,o.head=M,o.chain=function(n){return n=new o(n),n.__chain__=H,n},o.VERSION="1.0.0-rc.3",G(o),o.prototype.chain=function(){return this.__chain__=H,this},o.prototype.value=function(){return this.__wrapped__},u("pop push reverse shift sort splice unshift".split(" "),function(n){var t=W[n];o.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),St&&0===n.length&&delete n[0],this -}}),u(["concat","join","slice"],function(n){var t=W[n];o.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=o)._=o:L._=o:n._=o})(this); \ No newline at end of file +;(function(n,t){function r(n,t){var r;if(n)for(r in t||(t=P),n)if(t(n[r],r,n)===W)break}function e(n,t,r){if(n){t=t&&typeof r=="undefined"?t:i(t,r);var e=n.length;if(r=-1,typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=f)}}else t=i(t,r),e(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function F(n,t){return N(n,t+"") +}function R(n,t,r,u){var o=3>arguments.length;if(t=i(t,u,W),Tt(n)){var a=-1,f=n.length;for(o&&(r=n[++a]);++aarguments.length;if(typeof u!="number")var a=kt(n),u=a.length;return t=i(t,e,W),S(n,function(e,i,f){i=a?a[--u]:--u,r=o?(o=H,n[i]):t(r,n[i],i,f)}),r}function q(n,t,r){var u;if(t=i(t,r),Tt(n)){r=-1;for(var o=n.length;++rr?gt(0,u+r):r||0)-1;else if(r)return e=I(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])M(f,c))&&(r&&f.push(c),a.push(e))}return a}function C(n,t){var r;if(xt||ct&&2"']/g,rt=/['\n\r\t\u2028\u2029\\]/g,et=Math.ceil,ut=L.concat,ot=Math.floor,it=K.hasOwnProperty,at=L.push,ft=K.toString,ct=Z.test(ct=l.bind)&&ct,lt=Z.test(lt=Array.isArray)&<,st=n.isFinite,pt=n.isNaN,vt=Z.test(vt=Object.keys)&&vt,gt=Math.max,ht=Math.min,yt=Math.random,_t="[object Array]",mt="[object Boolean]",dt="[object Date]",bt="[object Number]",jt="[object Object]",wt="[object RegExp]",At="[object String]",K=!!n.attachEvent,xt=ct&&/\n|true/.test(ct+K),Et=(Et={0:1,length:1},L.splice.call(Et,0,1),Et[0]),Ot=arguments.constructor==Object,St={"boolean":H,"function":V,object:V,number:H,string:H,undefined:H},Nt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},u.isArguments=function(n){return"[object Arguments]"==ft.call(n)},u.isArguments(arguments)||(u.isArguments=function(n){return n?it.call(n,"callee"):H});var kt=vt?function(n){return d(n)?vt(n):[]}:v,Ft={"&":"&","<":"<",">":">",'"':""","'":"'"},Rt=y(Ft),Tt=lt||function(n){return Ot&&n instanceof Array||ft.call(n)==_t};m(/x/)&&(m=function(n){return n instanceof Function||"[object Function]"==ft.call(n) +}),u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=C,u.bindAll=function(n){for(var t=ut.apply(L,arguments),r=1M(e,o,r)&&u.push(o)}return u},u.filter=E,u.flatten=D,u.forEach=S,u.functions=h,u.groupBy=function(n,t,r){var e={};return t=i(t,r),S(n,function(n,r,u){r=t(n,r,u)+"",(it.call(e,r)?e[r]:e[r]=[]).push(n)}),e},u.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t=="function"){var o=u;for(t=i(t,r);o--&&t(n[o],o,n);)e++}else e=t==G||r?1:t||e;return l(n,0,ht(gt(0,u-e),u))},u.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++eM(o,i)){for(var a=r;--a;)if(0>M(t[a],i))continue n; +o.push(i)}}return o},u.invert=y,u.invoke=function(n,t){var r=l(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return S(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=kt,u.map=N,u.max=k,u.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return it.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var u=1/0,o=u;if(!t&&Tt(n)){r=-1;for(var a=n.length;++rM(t,r,1)&&(e[r]=n)}),e},u.once=function(n){var t,r;return function(){return t?r:(t=V,r=n.apply(this,arguments),n=G,r)}},u.pairs=function(n){for(var t=-1,r=kt(n),e=r.length,u=Array(e);++tM(arguments,u,1)&&e.push(u)}return e},u.wrap=function(n,t){return function(){var r=[n];return at.apply(r,arguments),t.apply(this,r)}},u.zip=function(n){for(var t=-1,r=n?k(F(arguments,"length")):0,e=Array(r);++tr?gt(0,e+r):ht(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=U,u.noConflict=function(){return n._=X,this},u.random=function(n,t){return n==G&&t==G&&(t=1),n=+n||0,t==G&&(t=n,n=0),n+ot(yt()*((+t||0)-n+1)) +},u.reduce=R,u.reduceRight=T,u.result=function(n,t){var r=n?n[t]:G;return m(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:kt(n).length},u.some=q,u.sortedIndex=I,u.template=function(n,t,r){n||(n=""),r=g({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||nt).source+"|"+(r.interpolate||nt).source+"|"+(r.evaluate||nt).source+"|$","g"),function(t,r,u,i,f){o+=n.slice(e,f).replace(rt,a),o+=r?"'+_['escape']("+r+")+'":i?"';"+i+";__p+='":u?"'+((__t=("+u+"))==null?'':__t)+'":"",e=f+t.length +}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var f=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return t?f(t):(f.source=o,f)},u.unescape=function(n){return n==G?"":(n+"").replace(Y,s)},u.uniqueId=function(n){var t=++Q+"";return n?n+t:t},u.all=x,u.any=q,u.detect=O,u.foldl=R,u.foldr=T,u.include=A,u.inject=R,u.first=B,u.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t=="function"){var o=u;for(t=i(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==G||r)return n[u-1];return l(n,gt(0,u-e))}},u.take=B,u.head=B,u.chain=function(n){return n=new u(n),n.__chain__=V,n},u.VERSION="1.0.0-rc.3",U(u),u.prototype.chain=function(){return this.__chain__=V,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=L[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),Et&&0===n.length&&delete n[0],this +}}),e(["concat","join","slice"],function(n){var t=L[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=V),n}}),J?typeof module=="object"&&module&&module.exports==J?(module.exports=u)._=u:J._=u:n._=u})(this); \ No newline at end of file From 5fe7ca5e7060bab83d6ba15f6266aee16469f5a8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 17 Jan 2013 00:40:49 -0800 Subject: [PATCH 071/176] Update vendor/backbone. Former-commit-id: faf9ed71356e1ae8b5c4f65e7084243571cb7d82 --- test/backbone.html | 3 ++- vendor/backbone/backbone.js | 42 +++++++++++++++--------------- vendor/backbone/test/collection.js | 21 ++++++++++++--- vendor/backbone/test/events.js | 32 +++++++++++++++++++---- 4 files changed, 68 insertions(+), 30 deletions(-) diff --git a/test/backbone.html b/test/backbone.html index 0392a66eb7..a186eb32c3 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -36,7 +36,8 @@

Test

- + - + - +