diff --git a/build.js b/build.js index ab610f6b7..ce5ee6a09 100755 --- a/build.js +++ b/build.js @@ -174,14 +174,13 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysNative', + 'isKeysFast', 'loop', 'nonEnumArgs', 'noCharByIndex', 'shadowed', 'top', - 'useHas', - 'useStrict' + 'useHas' ]; /** List of all Lo-Dash methods */ @@ -945,14 +944,16 @@ * @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 *\(isKeysNative[\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` source = source.replace(matchFunction(source, 'createIterator'), function(match) { - return match.replace(/ *'isKeysNative':.+\n/, ''); + return match.replace(/ *'isKeysFast':.+\n/, ''); }); return source; @@ -1448,7 +1449,7 @@ source = setUseStrictOption(source, isStrict); if (isLegacy) { - _.each(['getPrototypeOf', 'isBindFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { + _.each(['getPrototypeOf', 'isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { source = replaceVar(source, varName, 'false'); }); @@ -1467,10 +1468,9 @@ // remove `_.templateSettings.imports assignment source = source.replace(/,[^']*'imports':[^}]+}/, ''); - // remove large array and keys optimizations + // remove large array optimizations source = removeFunction(source, 'cachedContains'); source = removeVar(source, 'largeArraySize'); - source = removeKeysOptimization(source); // replace `_.assign` source = replaceFunction(source, 'assign', [ @@ -1769,6 +1769,7 @@ } } if (isMobile) { + source = removeKeysOptimization(source); source = removeNoNodeClass(source); // remove `prototype` [[Enumerable]] fix from `_.keys` diff --git a/build/pre-compile.js b/build/pre-compile.js index 44efa4749..790bac3ce 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -7,23 +7,29 @@ /** Used to minify variables embedded in compiled strings */ var compiledVars = [ + 'argsIndex', + 'argsLength', 'callback', 'collection', 'createCallback', 'ctor', + 'guard', 'hasOwnProperty', 'index', 'isArguments', + 'isArray', 'isString', 'iteratee', 'length', 'nativeKeys', + 'object', 'objectTypes', 'ownIndex', 'ownProps', 'propertyIsEnumerable', 'result', 'skipProto', + 'source', 'thisArg' ]; @@ -34,14 +40,13 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysNative', + 'isKeysFast', 'loop', 'nonEnumArgs', 'noCharByIndex', 'shadowed', 'top', - 'useHas', - 'useStrict' + 'useHas' ]; /** Used to minify variables and string values to a single character */ @@ -328,11 +333,6 @@ : 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) { var minName = minNames[index]; diff --git a/doc/README.md b/doc/README.md index 8f2b5c928..8850c78cd 100644 --- a/doc/README.md +++ b/doc/README.md @@ -197,7 +197,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2808 "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. @@ -221,7 +221,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2844 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2838 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -246,7 +246,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2888 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2882 "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)*. @@ -283,7 +283,7 @@ _.first([1, 2, 3], function(num) { ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2927 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "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. @@ -311,7 +311,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2963 "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. @@ -343,7 +343,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#L3015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3009 "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)*. @@ -377,7 +377,7 @@ _.initial([1, 2, 3], function(num) { ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3049 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3043 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -401,7 +401,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#L3111 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3105 "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)*. @@ -435,7 +435,7 @@ _.last([1, 2, 3], function(num) { ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "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. @@ -464,7 +464,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3182 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3176 "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`. @@ -489,7 +489,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3220 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -527,7 +527,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "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)*. @@ -564,7 +564,7 @@ _.rest([1, 2, 3], function(num) { ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3332 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3326 "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. @@ -608,7 +608,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3358 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -632,7 +632,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#L3398 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3392 "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)*. @@ -671,7 +671,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#L3457 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -696,7 +696,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3488 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3482 "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. @@ -727,7 +727,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L265 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -756,7 +756,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#L4393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4387 "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. @@ -786,7 +786,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4410 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4404 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -807,7 +807,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4427 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4421 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -838,7 +838,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2012 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2006 "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. @@ -866,7 +866,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2054 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "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. @@ -904,7 +904,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "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')*. @@ -936,7 +936,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2131 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "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)*. @@ -965,7 +965,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2164 "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)*. @@ -994,7 +994,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#L2214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2208 "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)*. @@ -1023,7 +1023,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#L2249 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2243 "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`. @@ -1055,7 +1055,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2291 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2285 "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')*. @@ -1087,7 +1087,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2318 "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`. @@ -1116,7 +1116,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2358 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2352 "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)*. @@ -1148,7 +1148,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#L2400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2394 "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)*. @@ -1180,7 +1180,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2448 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "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)*. @@ -1206,7 +1206,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2493 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1237,7 +1237,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2523 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "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)*. @@ -1267,7 +1267,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#L2566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2560 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1298,7 +1298,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#L2604 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2598 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1324,7 +1324,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#L2625 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2619 "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. @@ -1348,7 +1348,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2652 "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. @@ -1378,7 +1378,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2683 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2677 "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)*. @@ -1407,7 +1407,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2729 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2723 "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')*. @@ -1439,7 +1439,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1463,7 +1463,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2788 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1501,7 +1501,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3521 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3515 "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. @@ -1529,7 +1529,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3554 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "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. @@ -1560,7 +1560,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3585 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3579 "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. @@ -1591,7 +1591,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3631 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3625 "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. @@ -1632,7 +1632,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3654 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3648 "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. @@ -1659,7 +1659,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3681 "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. @@ -1685,7 +1685,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3751 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "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. @@ -1710,7 +1710,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3725 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1737,7 +1737,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3775 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3769 "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. @@ -1763,7 +1763,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3796 "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. @@ -1789,7 +1789,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3831 "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. @@ -1816,7 +1816,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3864 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -1855,7 +1855,7 @@ options.imports ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3886 "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. @@ -1880,7 +1880,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3939 "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. @@ -1916,7 +1916,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L991 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1029 "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. @@ -1944,7 +1944,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#L1062 "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. @@ -1980,7 +1980,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#L1157 "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. @@ -2013,7 +2013,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1154 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1181 "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. @@ -2039,7 +2039,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L849 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L865 "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`. @@ -2075,7 +2075,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L873 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L889 "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`. @@ -2103,7 +2103,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1184 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1200 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2130,7 +2130,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1225 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2155,7 +2155,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2179,7 +2179,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L827 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2206,7 +2206,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L907 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2233,7 +2233,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1274 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1268 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2257,7 +2257,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1291 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1285 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2281,7 +2281,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1302 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2305,7 +2305,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1327 "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". @@ -2335,7 +2335,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1369 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2366,7 +2366,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1526 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1520 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2404,7 +2404,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1537 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2428,7 +2428,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1606 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1600 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2463,7 +2463,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1622 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2490,7 +2490,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1645 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1639 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2514,7 +2514,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1567 "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('')`)* @@ -2544,7 +2544,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1673 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1667 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2579,7 +2579,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1692 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2603,7 +2603,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1715 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1709 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2627,7 +2627,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1726 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2651,7 +2651,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L888 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L926 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2675,7 +2675,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1776 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1770 "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)*. @@ -2716,7 +2716,7 @@ _.merge(names, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1862 "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)*. @@ -2747,7 +2747,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1902 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1896 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2771,7 +2771,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1940 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1934 "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)*. @@ -2802,7 +2802,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1977 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1971 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2833,7 +2833,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3963 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2857,7 +2857,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2882,7 +2882,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4007 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2912,7 +2912,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4031 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2932,7 +2932,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4054 "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. @@ -2960,7 +2960,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4092 "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. @@ -2995,7 +2995,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4183 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4177 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3073,7 +3073,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4319 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4313 "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)*. @@ -3105,7 +3105,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4339 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3129,7 +3129,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4359 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3163,7 +3163,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L334 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3182,7 +3182,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4595 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4589 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3194,7 +3194,7 @@ A reference to the `lodash` function. ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L282 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L286 "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. @@ -3206,7 +3206,7 @@ A reference to the `lodash` function. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L290 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L294 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3218,7 +3218,7 @@ A reference to the `lodash` function. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L298 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L302 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3230,7 +3230,7 @@ A reference to the `lodash` function. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L306 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L310 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3242,7 +3242,7 @@ A reference to the `lodash` function. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L318 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3254,7 +3254,7 @@ A reference to the `lodash` function. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L326 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index a90858dd2..19441eea0 100644 --- a/lodash.js +++ b/lodash.js @@ -116,10 +116,14 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent; + var isIeOpera = !!window.attachEvent, + isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); + var isBindFast = nativeBind && !isV8; + + /* Detect if `Object.keys` exists and is inferred to be fast (IE, Opera, V8) */ + var isKeysFast = nativeKeys && (isIeOpera || isV8); /** * Detect the JScript [[DontEnum]] bug: @@ -353,7 +357,7 @@ // array-like iteration: '<% if (arrays) { %>' + 'var length = iteratee.length; index = -1;\n' + - "if (typeof length == 'number') {" + + "if (<%= arrays %>) {" + // add support for accessing string characters by index if needed ' <% if (noCharByIndex) { %>\n' + @@ -393,7 +397,7 @@ ' <% } %>' + // iterate own properties using `Object.keys` if it's fast - ' <% if (isKeysNative && useHas) { %>\n' + + ' <% if (isKeysFast && useHas) { %>\n' + ' var ownIndex = -1,\n' + ' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n' + ' length = ownProps.length;\n\n' + @@ -442,11 +446,23 @@ 'return result' ); + /** Reusable iterator options for `assign` and `defaults` */ + var assignIteratorOptions = { + 'args': 'object, source, guard', + 'top': + 'var argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'while (++argsIndex < argsLength) {\n' + + ' if ((iteratee = arguments[argsIndex])) {', + 'loop': 'result[index] = iteratee[index]', + 'bottom': ' }\n}' + }; + /** 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)", + 'arrays': "typeof length == 'number'", 'loop': 'if (callback(iteratee[index], index, collection) === false) return result' }; @@ -656,13 +672,13 @@ var data = { // support properties 'hasDontEnumBug': hasDontEnumBug, - 'isKeysNative': nativeKeys, + 'isKeysFast': isKeysFast, 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, // iterator options - 'arrays': false, + 'arrays': "isArray(iteratee)", 'bottom': '', 'loop': '', 'top': '', @@ -680,14 +696,14 @@ // create the function factory var factory = Function( - 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' + - 'nativeKeys, propertyIsEnumerable', + 'createCallback, hasOwnProperty, isArguments, isArray, isString, ' + + 'objectTypes, nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' ); // return the compiled function return factory( - createCallback, hasOwnProperty, isArguments, isString, objectTypes, - nativeKeys, propertyIsEnumerable + createCallback, hasOwnProperty, isArguments, isArray, isString, + objectTypes, nativeKeys, propertyIsEnumerable ); } @@ -872,6 +888,28 @@ */ var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + // `instanceof` may cause a memory leak in IE 7 if `value` is a host object + // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak + return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; + }; + /** * Creates an array composed of the own enumerable property names of `object`. * @@ -988,18 +1026,7 @@ * _.assign({ 'name': 'moe' }, { 'age': 40 }); * // => { 'name': 'moe', 'age': 40 } */ - function assign(object, source, guard) { - var args = arguments, - index = 0, - length = typeof guard == 'number' ? 2 : args.length; - - while (++index < length) { - (isArray(args[index]) ? forEach : forOwn)(args[index], function(value, key) { - object[key] = value; - }); - } - return object; - } + var assign = createIterator(assignIteratorOptions); /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also @@ -1151,20 +1178,9 @@ * _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); * // => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' } */ - function defaults(object, source, guard) { - var args = arguments, - index = 0, - length = typeof guard == 'number' ? 2 : args.length; - - while (++index < length) { - (isArray(args[index]) ? forEach : forOwn)(args[index], function(value, key) { - if (object[key] == null) { - object[key] = value; - } - }); - } - return object; - } + var defaults = createIterator(assignIteratorOptions, { + 'loop': 'if (result[index] == null) ' + assignIteratorOptions.loop + }); /** * Creates a sorted array of all enumerable properties, own and inherited, @@ -1236,28 +1252,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - var isArray = nativeIsArray || function(value) { - // `instanceof` may cause a memory leak in IE 7 if `value` is a host object - // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; - }; - /** * Checks if `value` is a boolean value. * @@ -3457,7 +3451,7 @@ function without(array) { var index = -1, length = array ? array.length : 0, - contains = cachedContains(arguments, 1, 20), + contains = cachedContains(arguments, 1), result = []; while (++index < length) { diff --git a/lodash.min.js b/lodash.min.js index 690cff12b..c90045bf2 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,39 +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||ot);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(nu;u++)e+="f='"+t.j[u]+"';if(","constructor"==t.j[u]&&(e+="!(d&&d.prototype===i)&&"),e+="e.call(i,f)){"+t.g+"}"}return(t.b||t.h)&&(e+="}"),e+=t.c+";return p",r("c,e,g,h,l,k,o","return function("+n+"){"+e+"}")(a,At,h,E,rr,Ft,Et)}function c(n){return"\\"+er[n]}function l(n){return lr[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);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++er?Dt(0,u+r):r)||0,typeof u=="number"?o=-1<(E(n)?n.indexOf(t,r):L(n,t,r)):ir(n,function(n){return++eo&&(o=f)}}else t=!t&&E(n)?u:a(t,r),ir(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function B(n,t){return I(n,t+"")}function M(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,ut),sr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=cr(n),o=f.length;else Xt&&E(n)&&(u=n.split(""));return t=a(t,e,ut),D(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function z(n,t,r){var e;if(t=a(t,r),sr(n)){r=-1;for(var u=n.length;++rr?Dt(0,u+r):r||0)-1;else if(r)return e=V(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])L(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function H(n,t){return Gt||$t&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ft=/&(?:amp|lt|gt|quot|#x27);/g,ct=/\b__p\+='';/g,lt=/\b(__p\+=)''\+/g,pt=/(__e\(.*?\)|\b__t\))\+'';/g,st=/\w*$/,vt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,gt=RegExp("^"+(rt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ht=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,yt=/<%=([\s\S]+?)%>/g,mt=/($^)/,_t=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,wt=tt.concat,xt=Math.floor,Ot=gt.test(Ot=Object.getPrototypeOf)&&Ot,At=rt.hasOwnProperty,St=tt.push,Et=rt.propertyIsEnumerable,kt=rt.toString,$t=gt.test($t=v.bind)&&$t,Rt=gt.test(Rt=Array.isArray)&&Rt,qt=n.isFinite,Nt=n.isNaN,Ft=gt.test(Ft=Object.keys)&&Ft,Dt=Math.max,It=Math.min,Tt=Math.random,Bt="[object Arguments]",Mt="[object Array]",Pt="[object Boolean]",zt="[object Date]",Ct="[object Number]",Kt="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=$t&&/\n|true/.test($t+Vt),Ht=(Ht={0:1,length:1},tt.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;Z=!/valueOf/.test(t),nt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!h(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=kt.call(document)==Kt&&!1}catch(Zt){}var nr={"[object Function]":!1};nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=nr[Lt]=nr[Ut]=!0;var tr={};tr[Mt]=Array,tr[Pt]=Boolean,tr[zt]=Date,tr[Kt]=Object,tr[Ct]=Number,tr[Lt]=RegExp,tr[Ut]=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:yt,variable:"",imports:{_:r}};var ur={b:!0,a:"b,a,r",k:"a=a&&typeof r=='undefined'?a:c(a,r)",g:"if(a(i[f],f,b)===false)return p"},or={b:!1},ir=f(ur);Wt&&(h=function(n){return n?At.call(n,"callee"):!1});var ar=f(ur,or,{l:!1}),fr=f(ur,or),cr=Ft?function(n){return typeof n=="function"&&Et.call(n,"prototype")?m(n):A(n)?Ft(n):[]}:m,lr={"&":"&","<":"<",">":">",'"':""","'":"'"},pr=w(lr),sr=Rt||function(n){return Qt&&n instanceof Array||kt.call(n)==Mt -};O(/x/)&&(O=function(n){return n instanceof Function||"[object Function]"==kt.call(n)});var vr=Ot?function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,r=typeof t=="function"&&(r=Ot(t))&&Ot(r);return r?n==r||Ot(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=_,r.at=function(n){var t=-1,r=wt.apply(tt,v(arguments,1)),e=r.length,u=Array(e);for(Xt&&E(n)&&(n=n.split(""));++tL(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=w,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=cr,r.map=I,r.max=T,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return At.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=k,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&sr(n)){r=-1;for(var i=n.length;++rL(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},r.pairs=function(n){for(var t=-1,r=cr(n),e=r.length,u=Array(e);++tr?Dt(0,e+r):It(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=Q,r.noConflict=function(){return n._=it,this},r.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+xt(Tt()*((+t||0)-n+1))},r.reduce=M,r.reduceRight=P,r.result=function(n,t){var r=n?n[t]:null;return O(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:cr(n).length -},r.some=z,r.sortedIndex=V,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=b({},u,o);var i=b({},u.imports,o.imports),o=cr(i),i=$(i),a=0,f=u.interpolate||mt,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||mt).source+"|"+f.source+"|"+(f===yt?ht:mt).source+"|"+(u.evaluate||mt).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||at.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(vt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$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 null==n?"":(n+"").replace(ft,g)},r.uniqueId=function(n){var t=++et;return(null==n?"":n+"")+t},r.all=q,r.any=z,r.detect=F,r.foldl=M,r.foldr=P,r.include=R,r.inject=M,fr(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=C,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,null==e||r)return n[u-1];return v(n,Dt(0,u-e)) -}},r.take=C,r.head=C,fr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return null==t||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=W,r.prototype.valueOf=W,ir(["join","pop","shift"],function(n){var t=tt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ir(["push","reverse","sort","unshift"],function(n){var t=tt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this -}}),ir(["concat","slice","splice"],function(n){var t=tt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Ht&&ir(["pop","shift","splice"],function(n){var t=tt[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})):X?typeof module=="object"&&module&&module.exports==X?(module.exports=r)._=r:X._=r:n._=r +;(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){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(nu;u++)e+="i='"+t.j[u]+"';if(","constructor"==t.j[u]&&(e+="!(f&&f.prototype===m)&&"),e+="h.call(m,i)){"+t.g+"}"}return(t.b||t.h)&&(e+="}"),e+=t.c+";return u",r("e,h,j,k,l,q,o,t","return function("+n+"){"+e+"}")(a,xt,h,lr,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),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++er?Ft(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):ar(n,function(n){return++eo&&(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 q(n,t+"")}function T(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,rt),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.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),F(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;if(t=a(t,r),lr(n)){r=-1;for(var u=n.length;++rr?Ft(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 Vt||Et&&2|{(\/]|\[\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,St=nt.toString,Et=st.test(Et=v.bind)&&Et,kt=st.test(kt=Array.isArray)&&kt,$t=n.isFinite,Rt=n.isNaN,Nt=st.test(Nt=Object.keys)&&Nt,Ft=Math.max,qt=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=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!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=St.call(document)==zt&&!1}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:"",imports:{_:r}};var ur={a:"p,w,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},vr=b(sr),gr=f(ur),hr=f(ur,{g:"if(u[i]==null)"+ur.g});j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==St.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=gr,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(""));++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=pr,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 xt.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&&lr(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=!0,r=n.apply(this,arguments),n=null,r)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);++tr?Ft(0,e+r):qt(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,e,u){var o=r.templateSettings;n||(n=""),u=hr({},u,o);var i=hr({},u.imports,o.imports),o=pr(i),i=E(i),a=0,f=u.interpolate||ht,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||ht).source+"|"+f.source+"|"+(f===gt?vt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(mt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ot.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(pt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(at,""):p).replace(ft,"$1").replace(ct,"$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 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,cr(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=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,null==e||r)return n[u-1];return v(n,Ft(0,u-e)) +}},r.take=P,r.head=P,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return null==t||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,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 05768bb37..d330c8466 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -114,10 +114,11 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent; + var isIeOpera = !!window.attachEvent, + isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); + var isBindFast = nativeBind && !isV8; /** * Detect if `Array#shift` and `Array#splice` augment array-like objects @@ -167,8 +168,12 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object, that wraps the given `value`, to enable - * method chaining. + * Creates a `lodash` object, that wraps the given `value`, to enable method + * chaining. + * + * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: + * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, + * and `unshift` * * The chainable wrapper functions are: * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, @@ -255,11 +260,23 @@ /*--------------------------------------------------------------------------*/ + /** Reusable iterator options for `assign` and `defaults` */ + var assignIteratorOptions = { + 'args': 'object, source, guard', + 'top': + 'var argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" + + 'while (++argsIndex < argsLength) {\n' + + ' if ((iteratee = arguments[argsIndex])) {', + 'loop': 'result[index] = iteratee[index]', + 'bottom': ' }\n}' + }; + /** 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)", + 'arrays': "typeof length == 'number'", 'loop': 'if (callback(iteratee[index], index, collection) === false) return result' }; @@ -422,7 +439,7 @@ 'shadowed': shadowed, // iterator options - 'arrays': false, + 'arrays': "isArray(iteratee)", 'bottom': '', 'loop': '', 'top': '', @@ -440,14 +457,14 @@ // create the function factory var factory = Function( - 'createCallback, hasOwnProperty, isString, objectTypes, ' + - 'nativeKeys, propertyIsEnumerable', + 'createCallback, hasOwnProperty, isArray, isString, ' + + 'objectTypes, nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + (data) + '\n}' ); // return the compiled function return factory( - createCallback, hasOwnProperty, isString, objectTypes, - nativeKeys, propertyIsEnumerable + createCallback, hasOwnProperty, isArray, isString, + objectTypes, nativeKeys, propertyIsEnumerable ); } @@ -667,6 +684,28 @@ return result }; + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + // `instanceof` may cause a memory leak in IE 7 if `value` is a host object + // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak + return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; + }; + /** * Creates an array composed of the own enumerable property names of `object`. * @@ -929,28 +968,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - var isArray = nativeIsArray || function(value) { - // `instanceof` may cause a memory leak in IE 7 if `value` is a host object - // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; - }; - /** * Checks if `value` is a boolean value. * diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 7ab2e0b1c..0e0e73e27 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=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);++er?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(;++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),kt(n)){var a=-1,f=n.length;for(o&&(r=n[++a]);++aarguments.length;if(typeof u!="number")var a=Ft(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),kt(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):[]}:p,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) +return o.length&&(n=n.length?o.concat(l(n)):o),this instanceof i?(c.prototype=e.prototype,t=new c,c.prototype=G,n=e.apply(t,n),d(n)?n:t):e.apply(t,n)};r=i}return r}function P(n){return n}function U(n){S(h(n),function(t){var r=u[t]=n[t];u.prototype[t]=function(){var n=[this.__wrapped__];return at.apply(n,arguments),n=r.apply(u,n),this.__chain__&&(n=new u(n),n.__chain__=V),n}})}var V=!0,G=null,H=!1,J=typeof exports=="object"&&exports,K=typeof global=="object"&&global;K.global===K&&(n=K);var L=[],K={},Q=0,W=K,X=n._,Y=/&(?:amp|lt|gt|quot|#x27);/g,Z=RegExp("^"+(K.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),nt=/($^)/,tt=/[&<>"']/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,K=ct&&!/\n|true/.test(ct+K),xt=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=lt||function(n){return Ot&&n instanceof Array||ft.call(n)==_t},Ft=vt?function(n){return d(n)?vt(n):[]}:p,Rt={"&":"&","<":"<",">":">",'"':""","'":"'"},Tt=y(Rt);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(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=Ft(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);++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 +},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:Ft(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 diff --git a/perf/perf.js b/perf/perf.js index 625e9ee9e..affddb4a9 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -1733,13 +1733,13 @@ ); suites.push( - Benchmark.Suite('`_.without` iterating an array of 20 elements') + Benchmark.Suite('`_.without` iterating an array of 30 elements') .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [twentyValues].concat(twentyValues2));', + 'fn': 'lodash.without.apply(lodash, [thirtyValues].concat(thirtyValues2));', 'teardown': 'function multiArrays(){}' }) .add(otherName, { - 'fn': '_.without.apply(_, [twentyValues].concat(twentyValues2));', + 'fn': '_.without.apply(_, [thirtyValues].concat(thirtyValues2));', 'teardown': 'function multiArrays(){}' }) );