Make _.times return an array of the results of each callback execution. [Closes #73]

Former-commit-id: 808af6b9eb07bf1fada8221ca659558d82e6eb57
This commit is contained in:
John-David Dalton
2012-09-17 21:48:14 -07:00
parent 10064c046c
commit 93b89a93c1
4 changed files with 208 additions and 178 deletions

View File

@@ -173,7 +173,7 @@ The `lodash` function.
<!-- div -->
### <a id="_version"></a>`_.VERSION`
<a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4245 "View in source") [&#x24C9;][1]
<a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4259 "View in source") [&#x24C9;][1]
*(String)*: The semantic version number.
@@ -185,9 +185,9 @@ The `lodash` function.
<!-- div -->
### <a id="_aftern-func"></a>`_.after(n, func)`
<a href="#_aftern-func">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3321 "View in source") [&#x24C9;][1]
<a href="#_aftern-func">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3327 "View in source") [&#x24C9;][1]
Creates a new function that is restricted to executing only after it is called `n` times.
Creates a function that is restricted to executing only after it is called `n` times.
#### Arguments
1. `n` *(Number)*: The number of times the function must be called before it is executed.
@@ -213,9 +213,9 @@ _.forEach(notes, function(note) {
<!-- div -->
### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])`
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3354 "View in source") [&#x24C9;][1]
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3360 "View in source") [&#x24C9;][1]
Creates a new 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.
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.
#### Arguments
1. `func` *(Function)*: The function to bind.
@@ -244,7 +244,7 @@ func();
<!-- div -->
### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])`
<a href="#_bindallobject--methodname1-methodname2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [&#x24C9;][1]
<a href="#_bindallobject--methodname1-methodname2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3390 "View in source") [&#x24C9;][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.
@@ -275,7 +275,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick);
<!-- div -->
### <a id="_chainvalue"></a>`_.chain(value)`
<a href="#_chainvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [&#x24C9;][1]
<a href="#_chainvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4184 "View in source") [&#x24C9;][1]
Wraps the value in a `lodash` wrapper object.
@@ -351,9 +351,9 @@ shallow[0] === stooges[0];
<!-- div -->
### <a id="_compactarray"></a>`_.compact(array)`
<a href="#_compactarray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2553 "View in source") [&#x24C9;][1]
<a href="#_compactarray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2557 "View in source") [&#x24C9;][1]
Creates a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
#### Arguments
1. `array` *(Array)*: The array to compact.
@@ -375,9 +375,9 @@ _.compact([0, 1, false, 2, '', 3]);
<!-- div -->
### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])`
<a href="#_composefunc1-func2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3422 "View in source") [&#x24C9;][1]
<a href="#_composefunc1-func2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3428 "View in source") [&#x24C9;][1]
Creates a new 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()))`.
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()))`.
#### Arguments
1. `[func1, func2, ...]` *(Function)*: Functions to compose.
@@ -438,7 +438,7 @@ _.contains('curly', 'ur');
### <a id="_countbycollection-callbackproperty--thisarg"></a>`_.countBy(collection, callback|property [, thisArg])`
<a href="#_countbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2050 "View in source") [&#x24C9;][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 `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*.
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')*.
#### Arguments
1. `collection` *(Array|Object|String)*: The collection to iterate over.
@@ -468,9 +468,9 @@ _.countBy(['one', 'two', 'three'], 'length');
<!-- div -->
### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)`
<a href="#_debouncefunc-wait-immediate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3455 "View in source") [&#x24C9;][1]
<a href="#_debouncefunc-wait-immediate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3461 "View in source") [&#x24C9;][1]
Creates a new 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.
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.
#### Arguments
1. `func` *(Function)*: The function to debounce.
@@ -520,7 +520,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' });
<!-- div -->
### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])`
<a href="#_deferfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3520 "View in source") [&#x24C9;][1]
<a href="#_deferfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3526 "View in source") [&#x24C9;][1]
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked.
@@ -545,7 +545,7 @@ _.defer(function() { alert('deferred'); });
<!-- div -->
### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])`
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3500 "View in source") [&#x24C9;][1]
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3506 "View in source") [&#x24C9;][1]
Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked.
@@ -572,9 +572,9 @@ _.delay(log, 1000, 'logged later');
<!-- div -->
### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])`
<a href="#_differencearray--array1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2585 "View in source") [&#x24C9;][1]
<a href="#_differencearray--array1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2589 "View in source") [&#x24C9;][1]
Creates a new array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`.
Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `array` *(Array)*: The array to process.
@@ -597,7 +597,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
<!-- div -->
### <a id="_escapestring"></a>`_.escape(string)`
<a href="#_escapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3739 "View in source") [&#x24C9;][1]
<a href="#_escapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "View in source") [&#x24C9;][1]
Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities.
@@ -621,9 +621,9 @@ _.escape('Moe, Larry & Curly');
<!-- div -->
### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])`
<a href="#_everycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2070 "View in source") [&#x24C9;][1]
<a href="#_everycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2071 "View in source") [&#x24C9;][1]
Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
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)*.
#### Aliases
*all*
@@ -634,7 +634,7 @@ Checks if the `callback` returns a truthy value for **all** elements of a `colle
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Boolean)*: Returns `true` if all elements pass the callback check, else `false`.
*(Boolean)*: Returns `true` if all elements pass the callback check, else `false`.
#### Example
```js
@@ -675,9 +675,9 @@ _.extend({ 'name': 'moe' }, { 'age': 40 });
<!-- div -->
### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])`
<a href="#_filtercollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [&#x24C9;][1]
<a href="#_filtercollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2091 "View in source") [&#x24C9;][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 `3` arguments; *(value, index|key, collection)*.
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)*.
#### Aliases
*select*
@@ -688,7 +688,7 @@ Examines each element in a `collection`, returning an array of all elements the
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: Returns a new array of elements that passed callback check.
*(Array)*: Returns a new array of elements that passed the callback check.
#### Example
```js
@@ -704,9 +704,9 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; })
<!-- div -->
### <a id="_findcollection-callback--thisarg"></a>`_.find(collection, callback [, thisArg])`
<a href="#_findcollection-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2111 "View in source") [&#x24C9;][1]
<a href="#_findcollection-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [&#x24C9;][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 `3` arguments; *(value, index|key, collection)*.
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)*.
#### Aliases
*detect*
@@ -717,7 +717,7 @@ Examines each element in a `collection`, returning the first one the `callback`
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Mixed)*: Returns the element that passed the callback check, else `undefined`.
*(Mixed)*: Returns the element that passed the callback check, else `undefined`.
#### Example
```js
@@ -733,7 +733,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
<!-- div -->
### <a id="_firstarray--n-guard"></a>`_.first(array [, n, guard])`
<a href="#_firstarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2622 "View in source") [&#x24C9;][1]
<a href="#_firstarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2626 "View in source") [&#x24C9;][1]
Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`.
@@ -762,7 +762,7 @@ _.first([5, 4, 3, 2, 1]);
<!-- div -->
### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
<a href="#_flattenarray-shallow">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2646 "View in source") [&#x24C9;][1]
<a href="#_flattenarray-shallow">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2650 "View in source") [&#x24C9;][1]
Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level.
@@ -790,9 +790,9 @@ _.flatten([1, [2], [3, [[4]]]], true);
<!-- div -->
### <a id="_foreachcollection-callback--thisarg"></a>`_.forEach(collection, callback [, thisArg])`
<a href="#_foreachcollection-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2138 "View in source") [&#x24C9;][1]
<a href="#_foreachcollection-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2140 "View in source") [&#x24C9;][1]
Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`.
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`.
#### Aliases
*each*
@@ -803,7 +803,7 @@ Iterates over a `collection`, executing the `callback` for each element in the `
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array, Object)*: Returns `collection`.
*(Array, Object, String)*: Returns `collection`.
#### Example
```js
@@ -824,7 +824,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
### <a id="_forinobject-callback--thisarg"></a>`_.forIn(object, callback [, thisArg])`
<a href="#_forinobject-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [&#x24C9;][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 `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
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`.
#### Arguments
1. `object` *(Object)*: The object to iterate over.
@@ -860,7 +860,7 @@ _.forIn(new Dog('Dagny'), function(value, key) {
### <a id="_forownobject-callback--thisarg"></a>`_.forOwn(object, callback [, thisArg])`
<a href="#_forownobject-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1307 "View in source") [&#x24C9;][1]
Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
Iterates over `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`.
#### Arguments
1. `object` *(Object)*: The object to iterate over.
@@ -913,9 +913,9 @@ _.functions(_);
<!-- div -->
### <a id="_groupbycollection-callbackproperty--thisarg"></a>`_.groupBy(collection, callback|property [, thisArg])`
<a href="#_groupbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2166 "View in source") [&#x24C9;][1]
<a href="#_groupbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2168 "View in source") [&#x24C9;][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 `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*.
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 count by *(e.g. 'length')*.
#### Arguments
1. `collection` *(Array|Object|String)*: The collection to iterate over.
@@ -970,7 +970,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
<!-- div -->
### <a id="_identityvalue"></a>`_.identity(value)`
<a href="#_identityvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3759 "View in source") [&#x24C9;][1]
<a href="#_identityvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3765 "View in source") [&#x24C9;][1]
This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback.
@@ -995,7 +995,7 @@ moe === _.identity(moe);
<!-- div -->
### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
<a href="#_indexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2690 "View in source") [&#x24C9;][1]
<a href="#_indexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2696 "View in source") [&#x24C9;][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 `isSorted` will run a faster binary search.
@@ -1027,7 +1027,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
<!-- div -->
### <a id="_initialarray--n-guard"></a>`_.initial(array [, n, guard])`
<a href="#_initialarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2730 "View in source") [&#x24C9;][1]
<a href="#_initialarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2736 "View in source") [&#x24C9;][1]
Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result.
@@ -1053,7 +1053,7 @@ _.initial([3, 2, 1]);
<!-- div -->
### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
<a href="#_intersectionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2752 "View in source") [&#x24C9;][1]
<a href="#_intersectionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "View in source") [&#x24C9;][1]
Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`.
@@ -1101,9 +1101,9 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });
<!-- div -->
### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])`
<a href="#_invokecollection-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2194 "View in source") [&#x24C9;][1]
<a href="#_invokecollection-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2196 "View in source") [&#x24C9;][1]
Invokes the method named by `methodName` on each element in the `collection`. 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.
@@ -1111,7 +1111,7 @@ Invokes the method named by `methodName` on each element in the `collection`. Ad
3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
#### Returns
*(Array)*: Returns a new array of values returned from each invoked method.
*(Array)*: Returns a new array of the results of each invoked method.
#### Example
```js
@@ -1445,7 +1445,7 @@ Checks if `value` is a number.
#### Example
```js
_.isNumber(8.4 * 5;
_.isNumber(8.4 * 5);
// => true
```
@@ -1580,7 +1580,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 });
<!-- div -->
### <a id="_lastarray--n-guard"></a>`_.last(array [, n, guard])`
<a href="#_lastarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2795 "View in source") [&#x24C9;][1]
<a href="#_lastarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2801 "View in source") [&#x24C9;][1]
Gets the last element of the `array`. Pass `n` to return the lasy `n` elementsvof the `array`.
@@ -1606,7 +1606,7 @@ _.last([3, 2, 1]);
<!-- div -->
### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [&#x24C9;][1]
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "View in source") [&#x24C9;][1]
Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`.
@@ -1635,9 +1635,9 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
<!-- div -->
### <a id="_latebindobject-methodname--arg1-arg2-"></a>`_.lateBind(object, methodName [, arg1, arg2, ...])`
<a href="#_latebindobject-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [&#x24C9;][1]
<a href="#_latebindobject-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [&#x24C9;][1]
Creates a new function that, when called, invokes `object[methodName]` and prepends any additional `lateBind` arguments to those passed to the bound function. This method
Creates a function that, when called, invokes `object[methodName]` and prepends any additional `lateBind` arguments to those passed to the bound function. This method
#### Arguments
1. `object` *(Object)*: The object the method belongs to.
@@ -1676,9 +1676,9 @@ func();
<!-- div -->
### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])`
<a href="#_mapcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2229 "View in source") [&#x24C9;][1]
<a href="#_mapcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2231 "View in source") [&#x24C9;][1]
Creates a new array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
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)*.
#### Aliases
*collect*
@@ -1689,7 +1689,7 @@ Creates a new array of values by running each element in the `collection` throug
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: Returns a new array of elements returned by the callback.
*(Array)*: Returns a new array of the results of each `callback`.
#### Example
```js
@@ -1708,9 +1708,9 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
<!-- div -->
### <a id="_maxarray--callback-thisarg"></a>`_.max(array [, callback, thisArg])`
<a href="#_maxarray--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2861 "View in source") [&#x24C9;][1]
<a href="#_maxarray--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2867 "View in source") [&#x24C9;][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 `3` arguments; *(value, index, array)*.
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, array)*.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
@@ -1740,9 +1740,9 @@ _.max(stooges, function(stooge) { return stooge.age; });
<!-- div -->
### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])`
<a href="#_memoizefunc--resolver">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3579 "View in source") [&#x24C9;][1]
<a href="#_memoizefunc--resolver">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3585 "View in source") [&#x24C9;][1]
Creates a new 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.
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.
#### Arguments
1. `func` *(Function)*: The function to have its output memoized.
@@ -1804,9 +1804,9 @@ _.merge(stooges, ages);
<!-- div -->
### <a id="_minarray--callback-thisarg"></a>`_.min(array [, callback, thisArg])`
<a href="#_minarray--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2911 "View in source") [&#x24C9;][1]
<a href="#_minarray--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2917 "View in source") [&#x24C9;][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 `3` arguments; *(value, index, array)*.
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, array)*.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
@@ -1830,7 +1830,7 @@ _.min([10, 5, 100, 2, 1000]);
<!-- div -->
### <a id="_mixinobject"></a>`_.mixin(object)`
<a href="#_mixinobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3785 "View in source") [&#x24C9;][1]
<a href="#_mixinobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3791 "View in source") [&#x24C9;][1]
Adds functions properties of `object` to the `lodash` function and chainable wrapper.
@@ -1860,7 +1860,7 @@ _('curly').capitalize();
<!-- div -->
### <a id="_noconflict"></a>`_.noConflict()`
<a href="#_noconflict">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [&#x24C9;][1]
<a href="#_noconflict">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3822 "View in source") [&#x24C9;][1]
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
@@ -1880,7 +1880,7 @@ var lodash = _.noConflict();
<!-- div -->
### <a id="_objectkeys--values"></a>`_.object(keys [, values=[]])`
<a href="#_objectkeys--values">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [&#x24C9;][1]
<a href="#_objectkeys--values">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2966 "View in source") [&#x24C9;][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`.
@@ -1907,7 +1907,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
### <a id="_omitobject-callback-prop1-prop2--thisarg"></a>`_.omit(object, callback|[prop1, prop2, ..., thisArg])`
<a href="#_omitobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1907 "View in source") [&#x24C9;][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 `3` arguments; *(value, key, object)*.
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)*.
#### Arguments
1. `object` *(Object)*: The source object.
@@ -1936,9 +1936,9 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va
<!-- div -->
### <a id="_oncefunc"></a>`_.once(func)`
<a href="#_oncefunc">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3605 "View in source") [&#x24C9;][1]
<a href="#_oncefunc">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [&#x24C9;][1]
Creates a new function that is restricted to one execution. Repeat calls to the function will return the value of the first call.
Creates a function that is restricted to one execution. Repeat calls to the function will return the value of the first call.
#### Arguments
1. `func` *(Function)*: The function to restrict.
@@ -1986,9 +1986,9 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 });
<!-- div -->
### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])`
<a href="#_partialfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3640 "View in source") [&#x24C9;][1]
<a href="#_partialfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3646 "View in source") [&#x24C9;][1]
Creates a new 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.
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.
#### Arguments
1. `func` *(Function)*: The function to partially apply arguments to.
@@ -2015,7 +2015,7 @@ hi('moe');
### <a id="_pickobject-callback-prop1-prop2--thisarg"></a>`_.pick(object, callback|[prop1, prop2, ..., thisArg])`
<a href="#_pickobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1954 "View in source") [&#x24C9;][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 `3` arguments; *(value, key, object)*.
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)*.
#### Arguments
1. `object` *(Object)*: The source object.
@@ -2044,7 +2044,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va
<!-- div -->
### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)`
<a href="#_pluckcollection-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2252 "View in source") [&#x24C9;][1]
<a href="#_pluckcollection-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2254 "View in source") [&#x24C9;][1]
Retrieves the value of a specified property from all elements in the `collection`.
@@ -2075,7 +2075,7 @@ _.pluck(stooges, 'name');
<!-- div -->
### <a id="_randommin-max"></a>`_.random(min, max)`
<a href="#_randommin-max">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3843 "View in source") [&#x24C9;][1]
<a href="#_randommin-max">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3849 "View in source") [&#x24C9;][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. If no arguments are passed `_.random` will act as `Math.random`.
@@ -2106,7 +2106,7 @@ _.random();
<!-- div -->
### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
<a href="#_rangestart0-end--step1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3007 "View in source") [&#x24C9;][1]
<a href="#_rangestart0-end--step1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3013 "View in source") [&#x24C9;][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.
@@ -2144,7 +2144,7 @@ _.range(0);
<!-- div -->
### <a id="_reducecollection-callback--accumulator-thisarg"></a>`_.reduce(collection, callback [, accumulator, thisArg])`
<a href="#_reducecollection-callback--accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2280 "View in source") [&#x24C9;][1]
<a href="#_reducecollection-callback--accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2282 "View in source") [&#x24C9;][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)*.
@@ -2174,7 +2174,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });
<!-- div -->
### <a id="_reducerightcollection-callback--accumulator-thisarg"></a>`_.reduceRight(collection, callback [, accumulator, thisArg])`
<a href="#_reducerightcollection-callback--accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2317 "View in source") [&#x24C9;][1]
<a href="#_reducerightcollection-callback--accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2319 "View in source") [&#x24C9;][1]
The right-associative version of `_.reduce`.
@@ -2205,7 +2205,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
<!-- div -->
### <a id="_rejectcollection--callbackidentity-thisarg"></a>`_.reject(collection [, callback=identity, thisArg])`
<a href="#_rejectcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2372 "View in source") [&#x24C9;][1]
<a href="#_rejectcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2375 "View in source") [&#x24C9;][1]
The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for.
@@ -2215,7 +2215,7 @@ The opposite of `_.filter`, this method returns the values of a `collection` tha
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: Returns a new array of elements that did **not** pass the callback check.
*(Array)*: Returns a new array of elements that did **not** pass the callback check.
#### Example
```js
@@ -2231,7 +2231,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
<!-- div -->
### <a id="_restarray--n-guard"></a>`_.rest(array [, n, guard])`
<a href="#_restarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3046 "View in source") [&#x24C9;][1]
<a href="#_restarray--n-guard">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3052 "View in source") [&#x24C9;][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.
@@ -2260,7 +2260,7 @@ _.rest([3, 2, 1]);
<!-- div -->
### <a id="_resultobject-property"></a>`_.result(object, property)`
<a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [&#x24C9;][1]
<a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3888 "View in source") [&#x24C9;][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.
@@ -2295,9 +2295,9 @@ _.result(object, 'stuff');
<!-- div -->
### <a id="_shufflearray"></a>`_.shuffle(array)`
<a href="#_shufflearray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [&#x24C9;][1]
<a href="#_shufflearray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3073 "View in source") [&#x24C9;][1]
Creates a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
#### Arguments
1. `array` *(Array)*: The array to shuffle.
@@ -2319,7 +2319,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]);
<!-- div -->
### <a id="_sizecollection"></a>`_.size(collection)`
<a href="#_sizecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2396 "View in source") [&#x24C9;][1]
<a href="#_sizecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2399 "View in source") [&#x24C9;][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.
@@ -2349,9 +2349,9 @@ _.size('curly');
<!-- div -->
### <a id="_somecollection--callbackidentity-thisarg"></a>`_.some(collection [, callback=identity, thisArg])`
<a href="#_somecollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [&#x24C9;][1]
<a href="#_somecollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2427 "View in source") [&#x24C9;][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 `3` arguments; *(value, index|key, collection)*.
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)*.
#### Aliases
*any*
@@ -2362,7 +2362,7 @@ Checks if the `callback` returns a truthy value for **any** element of a `collec
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Boolean)*: Returns `true` if any element passes the callback check, else `false`.
*(Boolean)*: Returns `true` if any element passes the callback check, else `false`.
#### Example
```js
@@ -2378,9 +2378,9 @@ _.some([null, 0, 'yes', false]);
<!-- div -->
### <a id="_sortbycollection-callbackproperty--thisarg"></a>`_.sortBy(collection, callback|property [, thisArg])`
<a href="#_sortbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2453 "View in source") [&#x24C9;][1]
<a href="#_sortbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2457 "View in source") [&#x24C9;][1]
Creates a new 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 `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*.
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')*.
#### Arguments
1. `collection` *(Array|Object|String)*: The collection to iterate over.
@@ -2410,9 +2410,9 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length');
<!-- div -->
### <a id="_sortedindexarray-value--callbackidentity-thisarg"></a>`_.sortedIndex(array, value [, callback=identity, thisArg])`
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3119 "View in source") [&#x24C9;][1]
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3125 "View in source") [&#x24C9;][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 `1` argument; *(value)*.
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)*.
#### Arguments
1. `array` *(Array)*: The array to iterate over.
@@ -2451,7 +2451,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) {
<!-- div -->
### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
<a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4197 "View in source") [&#x24C9;][1]
<a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4211 "View in source") [&#x24C9;][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.
@@ -2464,7 +2464,7 @@ Invokes `interceptor` with the `value` as the first argument, and then returns `
#### Example
```js
_.chain([1,2,3,200])
_.chain([1, 2, 3, 200])
.filter(function(num) { return num % 2 == 0; })
.tap(alert)
.map(function(num) { return num * num })
@@ -2481,7 +2481,7 @@ _.chain([1,2,3,200])
<!-- div -->
### <a id="_templatetext-data-options"></a>`_.template(text, data, options)`
<a href="#_templatetext-data-options">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3955 "View in source") [&#x24C9;][1]
<a href="#_templatetext-data-options">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3961 "View in source") [&#x24C9;][1]
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html
@@ -2546,9 +2546,9 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\
<!-- div -->
### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)`
<a href="#_throttlefunc-wait">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3662 "View in source") [&#x24C9;][1]
<a href="#_throttlefunc-wait">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3668 "View in source") [&#x24C9;][1]
Creates a new 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.
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.
#### Arguments
1. `func` *(Function)*: The function to throttle.
@@ -2571,22 +2571,28 @@ jQuery(window).on('scroll', throttled);
<!-- div -->
### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])`
<a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [&#x24C9;][1]
<a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4106 "View in source") [&#x24C9;][1]
Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*.
Executes the `callback` function `n` times, returning an array of the results of each `callback`. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*.
#### Arguments
1. `n` *(Number)*: The number of times to execute the callback.
2. `callback` *(Function)*: The function called per iteration.
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
#### Returns
*(Array)*: Returns a new array of the results of each `callback`.
#### Example
```js
_.times(3, function(n) { genie.grantWish(n); });
// => calls `genie.grantWish(n)` three times, passing `n` of `0`, `1`, and `2` respectively
var diceRolls = _.times(3, _.partial(_.random, 1, 6));
// => [3, 6, 4]
_.times(3, function(n) { this.grantWish(n); }, genie);
// => also calls `genie.grantWish(n)` three times
_.times(3, function(n) { mage.castSpell(n); });
// => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
_.times(3, function(n) { this.cast(n); }, mage);
// => also calls `mage.castSpell(n)` three times
```
* * *
@@ -2597,7 +2603,7 @@ _.times(3, function(n) { this.grantWish(n); }, genie);
<!-- div -->
### <a id="_toarraycollection"></a>`_.toArray(collection)`
<a href="#_toarraycollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2489 "View in source") [&#x24C9;][1]
<a href="#_toarraycollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2493 "View in source") [&#x24C9;][1]
Converts the `collection`, to an array.
@@ -2621,7 +2627,7 @@ Converts the `collection`, to an array.
<!-- div -->
### <a id="_unescapestring"></a>`_.unescape(string)`
<a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4122 "View in source") [&#x24C9;][1]
<a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4136 "View in source") [&#x24C9;][1]
Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#x27;` in `string` to their corresponding characters.
@@ -2645,7 +2651,7 @@ _.unescape('Moe, Larry &amp; Curly');
<!-- div -->
### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
<a href="#_unionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3160 "View in source") [&#x24C9;][1]
<a href="#_unionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3166 "View in source") [&#x24C9;][1]
Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`.
@@ -2669,9 +2675,9 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
<!-- div -->
### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3204 "View in source") [&#x24C9;][1]
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3210 "View in source") [&#x24C9;][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 `3` arguments; *(value, index, array)*.
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)*.
#### Aliases
*unique*
@@ -2708,7 +2714,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
<!-- div -->
### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
<a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "View in source") [&#x24C9;][1]
<a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4154 "View in source") [&#x24C9;][1]
Generates a unique id. If `prefix` is passed, the id will be appended to it.
@@ -2756,7 +2762,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
<!-- div -->
### <a id="_wherecollection-properties"></a>`_.where(collection, properties)`
<a href="#_wherecollection-properties">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2523 "View in source") [&#x24C9;][1]
<a href="#_wherecollection-properties">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2527 "View in source") [&#x24C9;][1]
Examines each element in a `collection`, returning an array of all elements that contain the given `properties`.
@@ -2787,9 +2793,9 @@ _.where(stooges, { 'age': 40 });
<!-- div -->
### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
<a href="#_withoutarray--value1-value2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3253 "View in source") [&#x24C9;][1]
<a href="#_withoutarray--value1-value2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3259 "View in source") [&#x24C9;][1]
Creates a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `array` *(Array)*: The array to filter.
@@ -2812,9 +2818,9 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
<!-- div -->
### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)`
<a href="#_wrapvalue-wrapper">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3713 "View in source") [&#x24C9;][1]
<a href="#_wrapvalue-wrapper">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [&#x24C9;][1]
Creates a new function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the new function are appended to those passed to the `wrapper` function.
Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the new function are appended to those passed to the `wrapper` function.
#### Arguments
1. `value` *(Mixed)*: The value to wrap.
@@ -2841,7 +2847,7 @@ hello();
<!-- div -->
### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
<a href="#_ziparray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3286 "View in source") [&#x24C9;][1]
<a href="#_ziparray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3292 "View in source") [&#x24C9;][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.
@@ -2872,7 +2878,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
<!-- div -->
### <a id="_prototypechain"></a>`_.prototype.chain()`
<a href="#_prototypechain">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4215 "View in source") [&#x24C9;][1]
<a href="#_prototypechain">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4229 "View in source") [&#x24C9;][1]
Enables method chaining on the wrapper object.
@@ -2893,7 +2899,7 @@ _([1, 2, 3]).value();
<!-- div -->
### <a id="_prototypevalue"></a>`_.prototype.value()`
<a href="#_prototypevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4232 "View in source") [&#x24C9;][1]
<a href="#_prototypevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4246 "View in source") [&#x24C9;][1]
Extracts the wrapped value.

138
lodash.js
View File

@@ -609,7 +609,7 @@
}
/**
* Creates a new function optimized for searching large arrays for a given `value`,
* Creates a function optimized for searching large arrays for a given `value`,
* starting at `fromIndex`, using strict equality for comparisons, i.e. `===`.
*
* @private
@@ -677,7 +677,7 @@
}
/**
* Creates a new function that, when called, invokes `func` with the `this`
* Creates a function that, when called, invokes `func` with the `this`
* binding of `thisArg` and prepends any `partailArgs` to the arguments passed
* to the bound function.
*
@@ -1255,7 +1255,7 @@
/**
* Iterates over `object`'s own and inherited enumerable properties, executing
* the `callback` for each property. The `callback` is bound to `thisArg` and
* invoked with 3 arguments; (value, key, object). Callbacks may exit iteration
* invoked with three arguments; (value, key, object). Callbacks may exit iteration
* early by explicitly returning `false`.
*
* @static
@@ -1286,9 +1286,9 @@
/**
* Iterates over `object`'s own enumerable properties, executing the `callback`
* for each property. The `callback` is bound to `thisArg` and invoked with 3
* arguments; (value, key, object). Callbacks may exit iteration early by
* explicitly returning `false`.
* 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`.
*
* @static
* @memberOf _
@@ -1727,7 +1727,7 @@
* @returns {Boolean} Returns `true` if the `value` is a number, else `false`.
* @example
*
* _.isNumber(8.4 * 5;
* _.isNumber(8.4 * 5);
* // => true
*/
function isNumber(value) {
@@ -1884,7 +1884,7 @@
* 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 3 arguments; (value, key, object).
* `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).
*
* @static
* @memberOf _
@@ -1931,7 +1931,7 @@
* 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 3 arguments; (value, key, object).
* `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).
*
* @static
* @memberOf _
@@ -2025,7 +2025,7 @@
* 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 3 arguments; (value, index|key, collection).
* 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').
*
* @static
@@ -2051,7 +2051,7 @@
/**
* Checks if the `callback` returns a truthy value for **all** elements of a
* `collection`. The `callback` is bound to `thisArg` and invoked with 3
* `collection`. The `callback` is bound to `thisArg` and invoked with three
* arguments; (value, index|key, collection).
*
* @static
@@ -2061,7 +2061,8 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Boolean} Returns `true` if all elements pass the callback check, else `false`.
* @returns {Boolean} Returns `true` if all elements pass the callback check,
* else `false`.
* @example
*
* _.every([true, 1, null, 'yes'], Boolean);
@@ -2072,7 +2073,7 @@
/**
* 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 3 arguments; (value, index|key, collection).
* invoked with three arguments; (value, index|key, collection).
*
* @static
* @memberOf _
@@ -2081,7 +2082,7 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Array} Returns a new array of elements that passed callback check.
* @returns {Array} Returns a new array of elements that passed the callback check.
* @example
*
* var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
@@ -2093,7 +2094,7 @@
* 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 3 arguments; (value, index|key, collection).
* bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
*
* @static
* @memberOf _
@@ -2102,7 +2103,8 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} callback The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Mixed} Returns the element that passed the callback check, else `undefined`.
* @returns {Mixed} Returns the element that passed the callback check,
* else `undefined`.
* @example
*
* var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
@@ -2115,9 +2117,9 @@
/**
* Iterates over a `collection`, executing the `callback` for each element in
* the `collection`. The `callback` is bound to `thisArg` and invoked with 3
* arguments; (value, index|key, collection). Callbacks may exit iteration
* early by explicitly returning `false`.
* 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`.
*
* @static
* @memberOf _
@@ -2126,7 +2128,7 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} callback The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Array|Object} Returns `collection`.
* @returns {Array|Object|String} Returns `collection`.
* @example
*
* _([1, 2, 3]).forEach(alert).join(',');
@@ -2141,7 +2143,7 @@
* 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 3 arguments; (value, index|key, collection).
* 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').
*
* @static
@@ -2170,10 +2172,10 @@
});
/**
* Invokes the method named by `methodName` on each element in the `collection`.
* 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`.
*
* @static
* @memberOf _
@@ -2182,7 +2184,7 @@
* @param {Function|String} methodName The name of the method to invoke or
* the function invoked per iteration.
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with.
* @returns {Array} Returns a new array of values returned from each invoked method.
* @returns {Array} Returns a new array of the results of each invoked method.
* @example
*
* _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
@@ -2206,9 +2208,9 @@
});
/**
* Creates a new array of values by running each element in the `collection`
* Creates an array of values by running each element in the `collection`
* through a `callback`. The `callback` is bound to `thisArg` and invoked with
* 3 arguments; (value, index|key, collection).
* three arguments; (value, index|key, collection).
*
* @static
* @memberOf _
@@ -2217,7 +2219,7 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Array} Returns a new array of elements returned by the callback.
* @returns {Array} Returns a new array of the results of each `callback` execution.
* @example
*
* _.map([1, 2, 3], function(num) { return num * 3; });
@@ -2363,7 +2365,8 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Array} Returns a new array of elements that did **not** pass the callback check.
* @returns {Array} Returns a new array of elements that did **not** pass the
* callback check.
* @example
*
* var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
@@ -2405,7 +2408,7 @@
* 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 3 arguments; (value, index|key, collection).
* `thisArg` and invoked with three arguments; (value, index|key, collection).
*
* @static
* @memberOf _
@@ -2414,7 +2417,8 @@
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Boolean} Returns `true` if any element passes the callback check, else `false`.
* @returns {Boolean} Returns `true` if any element passes the callback check,
* else `false`.
* @example
*
* _.some([null, 0, 'yes', false]);
@@ -2426,9 +2430,9 @@
});
/**
* Creates a new array, stable sorted in ascending order by the results of
* 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 3 arguments; (value, index|key, collection).
* 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').
*
* @static
@@ -2537,7 +2541,7 @@
/*--------------------------------------------------------------------------*/
/**
* Creates a new array with all falsey values of `array` removed. The values
* Creates an array with all falsey values of `array` removed. The values
* `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
*
* @static
@@ -2567,7 +2571,7 @@
}
/**
* Creates a new array of `array` elements not present in the other arrays
* Creates an array of `array` elements not present in the other arrays
* using strict equality for comparisons, i.e. `===`.
*
* @static
@@ -2654,6 +2658,8 @@
while (++index < length) {
value = array[index];
// recursively flatten arrays (susceptible to call stack limits)
if (isArray(value)) {
push.apply(result, shallow ? value : flatten(value));
} else {
@@ -2838,7 +2844,7 @@
* 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 3 arguments; (value, index, array).
* `thisArg` and invoked with three arguments; (value, index, array).
*
* @static
* @memberOf _
@@ -2894,7 +2900,7 @@
* 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 3 arguments; (value, index, array).
* and invoked with three arguments; (value, index, array).
*
* @static
* @memberOf _
@@ -3051,7 +3057,7 @@
}
/**
* Creates a new array of shuffled `array` values, using a version of the
* Creates an array of shuffled `array` values, using a version of the
* Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
*
* @static
@@ -3086,7 +3092,7 @@
* 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 1 argument; (value).
* bound to `thisArg` and invoked with one argument; (value).
*
* @static
* @memberOf _
@@ -3176,7 +3182,7 @@
* 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 3 arguments; (value, index, array).
* The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array).
*
* @static
* @memberOf _
@@ -3236,7 +3242,7 @@
}
/**
* Creates a new array with all occurrences of the passed values removed using
* Creates an array with all occurrences of the passed values removed using
* strict equality for comparisons, i.e. `===`.
*
* @static
@@ -3300,7 +3306,7 @@
/*--------------------------------------------------------------------------*/
/**
* Creates a new function that is restricted to executing only after it is
* Creates a function that is restricted to executing only after it is
* called `n` times.
*
* @static
@@ -3330,7 +3336,7 @@
}
/**
* Creates a new function that, when called, invokes `func` with the `this`
* 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.
*
@@ -3402,7 +3408,7 @@
});
/**
* Creates a new function that is the composition of the passed functions,
* 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()))`.
*
@@ -3433,7 +3439,7 @@
}
/**
* Creates a new function that will delay the execution of `func` until after
* 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
@@ -3523,7 +3529,7 @@
}
/**
* Creates a new function that, when called, invokes `object[methodName]` and
* Creates a function that, when called, invokes `object[methodName]` and
* prepends any additional `lateBind` arguments to those passed to the bound
* function. This method
*
@@ -3559,7 +3565,7 @@
}
/**
* Creates a new function that memoizes the result of `func`. If `resolver` is
* 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.
@@ -3587,7 +3593,7 @@
}
/**
* Creates a new function that is restricted to one execution. Repeat calls to
* Creates a function that is restricted to one execution. Repeat calls to
* the function will return the value of the first call.
*
* @static
@@ -3620,7 +3626,7 @@
}
/**
* Creates a new function that, when called, invokes `func` with any additional
* 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.
*
@@ -3642,7 +3648,7 @@
}
/**
* Creates a new function that, when executed, will only call the `func`
* 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
@@ -3691,7 +3697,7 @@
}
/**
* Creates a new function that passes `value` to the `wrapper` function as its
* Creates a function that passes `value` to the `wrapper` function as its
* first argument. Additional arguments passed to the new function are appended
* to those passed to the `wrapper` function.
*
@@ -4075,8 +4081,9 @@
}
/**
* Executes the `callback` function `n` times. The `callback` is bound to
* `thisArg` and invoked with 1 argument; (index).
* 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).
*
* @static
* @memberOf _
@@ -4084,25 +4091,32 @@
* @param {Number} n The number of times to execute the callback.
* @param {Function} callback The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding for the callback.
* @returns {Array} Returns a new array of the results of each `callback` execution.
* @example
*
* _.times(3, function(n) { genie.grantWish(n); });
* // => calls `genie.grantWish(n)` three times, passing `n` of `0`, `1`, and `2` respectively
* var diceRolls = _.times(3, _.partial(_.random, 1, 6));
* // => [3, 6, 4]
*
* _.times(3, function(n) { this.grantWish(n); }, genie);
* // => also calls `genie.grantWish(n)` three times
* _.times(3, function(n) { mage.castSpell(n); });
* // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
*
* _.times(3, function(n) { this.cast(n); }, mage);
* // => also calls `mage.castSpell(n)` three times
*/
function times(n, callback, thisArg) {
var index = -1;
var index = -1,
result = Array(n || 0);
if (thisArg) {
while (++index < n) {
callback.call(thisArg, index);
result[index] = callback.call(thisArg, index);
}
} else {
while (++index < n) {
callback(index);
result[index] = callback(index);
}
}
return result;
}
/**
@@ -4186,7 +4200,7 @@
* @returns {Mixed} Returns `value`.
* @example
*
* _.chain([1,2,3,200])
* _.chain([1, 2, 3, 200])
* .filter(function(num) { return num % 2 == 0; })
* .tap(alert)
* .map(function(num) { return num * num })

10
lodash.min.js vendored
View File

@@ -34,8 +34,8 @@ r},s.isObject=function(e){return e?$t[typeof e]:i},s.isUndefined=function(e){ret
t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=yn,s.partial=function(e){return l(e,ct.call(arguments,1))},s.pick=bn,s.pluck=On,s.random=function(e,t){return e==r&&t==r?wt():(e=+e||0,t==r&&(t=e,e=0),e+dt(wt()*((+t||0)-e+1)))},s.range=function(e,t,n){e=+e||0,n=+n||1,t==r&&(t=e,e=0);for(var i=-1,t=yt(0,Math.ceil((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=Mn,s.reduceRight=N,s.reject=_n,s.rest=O,s.result=function(e,t){if(!e)return r;var n=e[t];return E(n)?e[t]():n},s.shuffle=function(
e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++n<r;)t=dt(wt()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){if(!e)return 0;var t=e.length;return t===+t?t:vn(e).length},s.some=Dn,s.sortBy=Pn,s.sortedIndex=M,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var e=e+"",o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,l=s.templateSettings,c=n=n.variable||l.variable;o==r&&(o=l.escape),a==r&&(a=l.evaluate||i),f==r&&(f=l.interpolate),o&&(e=e.replace(o,m)),f&&(e=e
.replace(f,y)),a!=B&&(B=a,I=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(a?"|"+a.source:""),"g")),o=ot.length,e=e.replace(I,g),o=o!=ot.length,e="__p += '"+e.replace(nt,p).replace(et,h)+"';",ot.length=0,c||(n=j||"obj",o?e="with("+n+"){"+e+"}":(n!=j&&(j=n,F=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(Y,"$&"+n+".").replace(F,"$1__d"))),e=(o?e.replace(J,""):e).replace(K,"$1").replace(Q,"$1;"),e="function("+n+"){"+(c?"":n+"||("+n+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"
:(c?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(d){throw d.source=e,d}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,s=e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Ot(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];var t=e.length;return t===+t?(Bt?ht.
call(e)==Lt:"string"==typeof e)?e.split(""):ct.call(e):wn(e)},s.unescape=function(e){return e==r?"":(e+"").replace($,b)},s.union=function(){for(var e=-1,t=[],n=ut.apply(t,arguments),r=n.length;++e<r;)0>L(t,n[e])&&t.push(n[e]);return t},s.uniq=_,s.uniqueId=function(e){var t=z++;return e?e+t:t},s.values=wn,s.where=Hn,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=a(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments
.length&&ft.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=A(On(arguments,"length")),r=Array(n);++t<n;)r[t]=On(arguments,t);return r},s.all=xn,s.any=Dn,s.collect=An,s.detect=Nn,s.drop=O,s.each=Cn,s.foldl=Mn,s.foldr=N,s.head=C,s.include=En,s.inject=Mn,s.methods=hn,s.select=Tn,s.tail=O,s.take=C,s.unique=_,Cn({Date:Tt,Number:Nt,RegExp:kt,String:Lt},function(e,t){s["is"+t]=function(t){return ht.call(t)==e}}),o.prototype=s.prototype,H(s),o.prototype.chain=function(
){return this.__chain__=n,this},o.prototype.value=function(){return this.__wrapped__},Cn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=R[e];o.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),_t&&e.length===0&&delete e[0],this.__chain__&&(e=new o(e),e.__chain__=n),e}}),Cn(["concat","join","slice"],function(e){var t=R[e];o.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new o(e),e.__chain__=n),e}}),typeof
define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):q?"object"==typeof module&&module&&module.exports==q?(module.exports=s)._=s:q._=s:e._=s})(this);
:(c?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(d){throw d.source=e,d}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,s=e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Ot(n,f)),s}},s.times=function(e,t,n){var r=-1,i=Array(e||0);if(n)for(;++r<e;)i[r]=t.call(n,r);else for(;++r<e;)i[r]=t(r);return i},s.toArray=function(e){if(!e)return[];var t=
e.length;return t===+t?(Bt?ht.call(e)==Lt:"string"==typeof e)?e.split(""):ct.call(e):wn(e)},s.unescape=function(e){return e==r?"":(e+"").replace($,b)},s.union=function(){for(var e=-1,t=[],n=ut.apply(t,arguments),r=n.length;++e<r;)0>L(t,n[e])&&t.push(n[e]);return t},s.uniq=_,s.uniqueId=function(e){var t=z++;return e?e+t:t},s.values=wn,s.where=Hn,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=a(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(
){var n=[e];return arguments.length&&ft.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=A(On(arguments,"length")),r=Array(n);++t<n;)r[t]=On(arguments,t);return r},s.all=xn,s.any=Dn,s.collect=An,s.detect=Nn,s.drop=O,s.each=Cn,s.foldl=Mn,s.foldr=N,s.head=C,s.include=En,s.inject=Mn,s.methods=hn,s.select=Tn,s.tail=O,s.take=C,s.unique=_,Cn({Date:Tt,Number:Nt,RegExp:kt,String:Lt},function(e,t){s["is"+t]=function(t){return ht.call(t)==e}}),o.prototype=s.prototype,H(s
),o.prototype.chain=function(){return this.__chain__=n,this},o.prototype.value=function(){return this.__wrapped__},Cn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=R[e];o.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),_t&&e.length===0&&delete e[0],this.__chain__&&(e=new o(e),e.__chain__=n),e}}),Cn(["concat","join","slice"],function(e){var t=R[e];o.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new
o(e),e.__chain__=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):q?"object"==typeof module&&module&&module.exports==q?(module.exports=s)._=s:q._=s:e._=s})(this);

View File

@@ -1544,6 +1544,16 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.times');
(function() {
test('should return an array of the results of each `callback` execution', function() {
deepEqual(_.times(3, function(n) { return n * 2; }), [0, 2, 4]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.unescape');
(function() {