/slider/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/doc/README.md
Markdown | 3590 lines | 2375 code | 1215 blank | 0 comment | 0 complexity | a71626c79bf93a5ff610106e395bc913 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT
Large files files are truncated, but you can click here to view the full file
- # Lo-Dash <sup>v1.0.1</sup>
- <!-- div -->
- <!-- div -->
- ## <a id="Arrays"></a>`Arrays`
- * [`_.compact`](#_compactarray)
- * [`_.difference`](#_differencearray--array1-array2-)
- * [`_.drop`](#_restarray--callbackn1-thisarg)
- * [`_.first`](#_firstarray--callbackn-thisarg)
- * [`_.flatten`](#_flattenarray-shallow)
- * [`_.head`](#_firstarray--callbackn-thisarg)
- * [`_.indexOf`](#_indexofarray-value--fromindex0)
- * [`_.initial`](#_initialarray--callbackn1-thisarg)
- * [`_.intersection`](#_intersectionarray1-array2-)
- * [`_.last`](#_lastarray--callbackn-thisarg)
- * [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1)
- * [`_.object`](#_objectkeys--values)
- * [`_.range`](#_rangestart0-end--step1)
- * [`_.rest`](#_restarray--callbackn1-thisarg)
- * [`_.sortedIndex`](#_sortedindexarray-value--callbackidentity-thisarg)
- * [`_.tail`](#_restarray--callbackn1-thisarg)
- * [`_.take`](#_firstarray--callbackn-thisarg)
- * [`_.union`](#_unionarray1-array2-)
- * [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg)
- * [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg)
- * [`_.without`](#_withoutarray--value1-value2-)
- * [`_.zip`](#_ziparray1-array2-)
- <!-- /div -->
- <!-- div -->
- ## `Chaining`
- * [`_`](#_value)
- * [`_.tap`](#_tapvalue-interceptor)
- * [`_.prototype.toString`](#_prototypetostring)
- * [`_.prototype.value`](#_prototypevalueof)
- * [`_.prototype.valueOf`](#_prototypevalueof)
- <!-- /div -->
- <!-- div -->
- ## `Collections`
- * [`_.all`](#_everycollection--callbackidentity-thisarg)
- * [`_.any`](#_somecollection--callbackidentity-thisarg)
- * [`_.at`](#_atcollection--index1-index2-)
- * [`_.collect`](#_mapcollection--callbackidentity-thisarg)
- * [`_.contains`](#_containscollection-target--fromindex0)
- * [`_.countBy`](#_countbycollection--callbackidentity-thisarg)
- * [`_.detect`](#_findcollection--callbackidentity-thisarg)
- * [`_.each`](#_foreachcollection--callbackidentity-thisarg)
- * [`_.every`](#_everycollection--callbackidentity-thisarg)
- * [`_.filter`](#_filtercollection--callbackidentity-thisarg)
- * [`_.find`](#_findcollection--callbackidentity-thisarg)
- * [`_.foldl`](#_reducecollection--callbackidentity-accumulator-thisarg)
- * [`_.foldr`](#_reducerightcollection--callbackidentity-accumulator-thisarg)
- * [`_.forEach`](#_foreachcollection--callbackidentity-thisarg)
- * [`_.groupBy`](#_groupbycollection--callbackidentity-thisarg)
- * [`_.include`](#_containscollection-target--fromindex0)
- * [`_.inject`](#_reducecollection--callbackidentity-accumulator-thisarg)
- * [`_.invoke`](#_invokecollection-methodname--arg1-arg2-)
- * [`_.map`](#_mapcollection--callbackidentity-thisarg)
- * [`_.max`](#_maxcollection--callbackidentity-thisarg)
- * [`_.min`](#_mincollection--callbackidentity-thisarg)
- * [`_.pluck`](#_pluckcollection-property)
- * [`_.reduce`](#_reducecollection--callbackidentity-accumulator-thisarg)
- * [`_.reduceRight`](#_reducerightcollection--callbackidentity-accumulator-thisarg)
- * [`_.reject`](#_rejectcollection--callbackidentity-thisarg)
- * [`_.select`](#_filtercollection--callbackidentity-thisarg)
- * [`_.shuffle`](#_shufflecollection)
- * [`_.size`](#_sizecollection)
- * [`_.some`](#_somecollection--callbackidentity-thisarg)
- * [`_.sortBy`](#_sortbycollection--callbackidentity-thisarg)
- * [`_.toArray`](#_toarraycollection)
- * [`_.where`](#_wherecollection-properties)
- <!-- /div -->
- <!-- div -->
- ## `Functions`
- * [`_.after`](#_aftern-func)
- * [`_.bind`](#_bindfunc--thisarg-arg1-arg2-)
- * [`_.bindAll`](#_bindallobject--methodname1-methodname2-)
- * [`_.bindKey`](#_bindkeyobject-key--arg1-arg2-)
- * [`_.compose`](#_composefunc1-func2-)
- * [`_.debounce`](#_debouncefunc-wait-immediate)
- * [`_.defer`](#_deferfunc--arg1-arg2-)
- * [`_.delay`](#_delayfunc-wait--arg1-arg2-)
- * [`_.memoize`](#_memoizefunc--resolver)
- * [`_.once`](#_oncefunc)
- * [`_.partial`](#_partialfunc--arg1-arg2-)
- * [`_.partialRight`](#_partialrightfunc--arg1-arg2-)
- * [`_.throttle`](#_throttlefunc-wait)
- * [`_.wrap`](#_wrapvalue-wrapper)
- <!-- /div -->
- <!-- div -->
- ## `Objects`
- * [`_.assign`](#_assignobject--source1-source2--callback-thisarg)
- * [`_.clone`](#_clonevalue--deepfalse-callback-thisarg)
- * [`_.cloneDeep`](#_clonedeepvalue--callback-thisarg)
- * [`_.defaults`](#_defaultsobject--source1-source2-)
- * [`_.extend`](#_assignobject--source1-source2--callback-thisarg)
- * [`_.forIn`](#_forinobject--callbackidentity-thisarg)
- * [`_.forOwn`](#_forownobject--callbackidentity-thisarg)
- * [`_.functions`](#_functionsobject)
- * [`_.has`](#_hasobject-property)
- * [`_.invert`](#_invertobject)
- * [`_.isArguments`](#_isargumentsvalue)
- * [`_.isArray`](#_isarrayvalue)
- * [`_.isBoolean`](#_isbooleanvalue)
- * [`_.isDate`](#_isdatevalue)
- * [`_.isElement`](#_iselementvalue)
- * [`_.isEmpty`](#_isemptyvalue)
- * [`_.isEqual`](#_isequala-b--callback-thisarg)
- * [`_.isFinite`](#_isfinitevalue)
- * [`_.isFunction`](#_isfunctionvalue)
- * [`_.isNaN`](#_isnanvalue)
- * [`_.isNull`](#_isnullvalue)
- * [`_.isNumber`](#_isnumbervalue)
- * [`_.isObject`](#_isobjectvalue)
- * [`_.isPlainObject`](#_isplainobjectvalue)
- * [`_.isRegExp`](#_isregexpvalue)
- * [`_.isString`](#_isstringvalue)
- * [`_.isUndefined`](#_isundefinedvalue)
- * [`_.keys`](#_keysobject)
- * [`_.merge`](#_mergeobject--source1-source2--callback-thisarg)
- * [`_.methods`](#_functionsobject)
- * [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg)
- * [`_.pairs`](#_pairsobject)
- * [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg)
- * [`_.values`](#_valuesobject)
- <!-- /div -->
- <!-- div -->
- ## `Utilities`
- * [`_.escape`](#_escapestring)
- * [`_.identity`](#_identityvalue)
- * [`_.mixin`](#_mixinobject)
- * [`_.noConflict`](#_noconflict)
- * [`_.random`](#_randommin0-max1)
- * [`_.result`](#_resultobject-property)
- * [`_.template`](#_templatetext-data-options)
- * [`_.times`](#_timesn-callback--thisarg)
- * [`_.unescape`](#_unescapestring)
- * [`_.uniqueId`](#_uniqueidprefix)
- <!-- /div -->
- <!-- div -->
- ## `Methods`
- * [`_.templateSettings.imports._`](#_templatesettingsimports_)
- <!-- /div -->
- <!-- div -->
- ## `Properties`
- * [`_.VERSION`](#_version)
- * [`_.templateSettings`](#_templatesettings)
- * [`_.templateSettings.escape`](#_templatesettingsescape)
- * [`_.templateSettings.evaluate`](#_templatesettingsevaluate)
- * [`_.templateSettings.interpolate`](#_templatesettingsinterpolate)
- * [`_.templateSettings.variable`](#_templatesettingsvariable)
- * [`_.templateSettings.imports`](#_templatesettingsimports)
- <!-- /div -->
- <!-- /div -->
- <!-- div -->
- <!-- div -->
- ## `“Arrays” Methods`
- <!-- div -->
- ### <a id="_compactarray"></a>`_.compact(array)`
- <a href="#_compactarray">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3166 "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.
- #### Arguments
- 1. `array` *(Array)*: The array to compact.
- #### Returns
- *(Array)*: Returns a new filtered array.
- #### Example
- ```js
- _.compact([0, 1, false, 2, '', 3]);
- // => [1, 2, 3]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])`
- <a href="#_differencearray--array1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3196 "View in source") [Ⓣ][1]
- 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.
- 2. `[array1, array2, ...]` *(Array)*: Arrays to check.
- #### Returns
- *(Array)*: Returns a new array of `array` elements not present in the other arrays.
- #### Example
- ```js
- _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
- // => [1, 3, 4]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_firstarray--callbackn-thisarg"></a>`_.first(array [, callback|n, thisArg])`
- <a href="#_firstarray--callbackn-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3268 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *head, take*
- #### Arguments
- 1. `array` *(Array)*: The array to query.
- 2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Mixed)*: Returns the first element(s) of `array`.
- #### Example
- ```js
- _.first([1, 2, 3]);
- // => 1
- _.first([1, 2, 3], 2);
- // => [1, 2]
- _.first([1, 2, 3], function(num) {
- return num < 3;
- });
- // => [1, 2]
- var food = [
- { 'name': 'banana', 'organic': true },
- { 'name': 'beet', 'organic': false },
- ];
- // using "_.pluck" callback shorthand
- _.first(food, 'organic');
- // => [{ 'name': 'banana', 'organic': true }]
- var food = [
- { 'name': 'apple', 'type': 'fruit' },
- { 'name': 'banana', 'type': 'fruit' },
- { 'name': 'beet', 'type': 'vegetable' }
- ];
- // using "_.where" callback shorthand
- _.first(food, { 'type': 'fruit' });
- // => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
- <a href="#_flattenarray-shallow">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "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.
- #### Arguments
- 1. `array` *(Array)*: The array to compact.
- 2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level.
- #### Returns
- *(Array)*: Returns a new flattened array.
- #### Example
- ```js
- _.flatten([1, [2], [3, [[4]]]]);
- // => [1, 2, 3, 4];
- _.flatten([1, [2], [3, [[4]]]], true);
- // => [1, 2, 3, [[4]]];
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
- <a href="#_indexofarray-value--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "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.
- #### Arguments
- 1. `array` *(Array)*: The array to search.
- 2. `value` *(Mixed)*: The value to search for.
- 3. `[fromIndex=0]` *(Boolean|Number)*: The index to search from or `true` to perform a binary search on a sorted `array`.
- #### Returns
- *(Number)*: Returns the index of the matched value or `-1`.
- #### Example
- ```js
- _.indexOf([1, 2, 3, 1, 2, 3], 2);
- // => 1
- _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
- // => 4
- _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
- // => 2
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_initialarray--callbackn1-thisarg"></a>`_.initial(array [, callback|n=1, thisArg])`
- <a href="#_initialarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `array` *(Array)*: The array to query.
- 2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array)*: Returns a slice of `array`.
- #### Example
- ```js
- _.initial([1, 2, 3]);
- // => [1, 2]
- _.initial([1, 2, 3], 2);
- // => [1]
- _.initial([1, 2, 3], function(num) {
- return num > 1;
- });
- // => [1]
- var food = [
- { 'name': 'beet', 'organic': false },
- { 'name': 'carrot', 'organic': true }
- ];
- // using "_.pluck" callback shorthand
- _.initial(food, 'organic');
- // => [{ 'name': 'beet', 'organic': false }]
- var food = [
- { 'name': 'banana', 'type': 'fruit' },
- { 'name': 'beet', 'type': 'vegetable' },
- { 'name': 'carrot', 'type': 'vegetable' }
- ];
- // using "_.where" callback shorthand
- _.initial(food, { 'type': 'vegetable' });
- // => [{ 'name': 'banana', 'type': 'fruit' }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
- <a href="#_intersectionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1]
- Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`.
- #### Arguments
- 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
- #### Returns
- *(Array)*: Returns a new array of unique elements that are present in **all** of the arrays.
- #### Example
- ```js
- _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
- // => [1, 2]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_lastarray--callbackn-thisarg"></a>`_.last(array [, callback|n, thisArg])`
- <a href="#_lastarray--callbackn-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `array` *(Array)*: The array to query.
- 2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Mixed)*: Returns the last element(s) of `array`.
- #### Example
- ```js
- _.last([1, 2, 3]);
- // => 3
- _.last([1, 2, 3], 2);
- // => [2, 3]
- _.last([1, 2, 3], function(num) {
- return num > 1;
- });
- // => [2, 3]
- var food = [
- { 'name': 'beet', 'organic': false },
- { 'name': 'carrot', 'organic': true }
- ];
- // using "_.pluck" callback shorthand
- _.last(food, 'organic');
- // => [{ 'name': 'carrot', 'organic': true }]
- var food = [
- { 'name': 'banana', 'type': 'fruit' },
- { 'name': 'beet', 'type': 'vegetable' },
- { 'name': 'carrot', 'type': 'vegetable' }
- ];
- // using "_.where" callback shorthand
- _.last(food, { 'type': 'vegetable' });
- // => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
- <a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "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.
- #### Arguments
- 1. `array` *(Array)*: The array to search.
- 2. `value` *(Mixed)*: The value to search for.
- 3. `[fromIndex=array.length-1]` *(Number)*: The index to search from.
- #### Returns
- *(Number)*: Returns the index of the matched value or `-1`.
- #### Example
- ```js
- _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
- // => 4
- _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
- // => 1
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_objectkeys--values"></a>`_.object(keys [, values=[]])`
- <a href="#_objectkeys--values">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "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`.
- #### Arguments
- 1. `keys` *(Array)*: The array of keys.
- 2. `[values=[]]` *(Array)*: The array of values.
- #### Returns
- *(Object)*: Returns an object composed of the given keys and corresponding values.
- #### Example
- ```js
- _.object(['moe', 'larry'], [30, 40]);
- // => { 'moe': 30, 'larry': 40 }
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
- <a href="#_rangestart0-end--step1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1]
- Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`.
- #### Arguments
- 1. `[start=0]` *(Number)*: The start of the range.
- 2. `end` *(Number)*: The end of the range.
- 3. `[step=1]` *(Number)*: The value to increment or descrement by.
- #### Returns
- *(Array)*: Returns a new range array.
- #### Example
- ```js
- _.range(10);
- // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- _.range(1, 11);
- // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- _.range(0, 30, 5);
- // => [0, 5, 10, 15, 20, 25]
- _.range(0, -10, -1);
- // => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
- _.range(0);
- // => []
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_restarray--callbackn1-thisarg"></a>`_.rest(array [, callback|n=1, thisArg])`
- <a href="#_restarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *drop, tail*
- #### Arguments
- 1. `array` *(Array)*: The array to query.
- 2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array)*: Returns a slice of `array`.
- #### Example
- ```js
- _.rest([1, 2, 3]);
- // => [2, 3]
- _.rest([1, 2, 3], 2);
- // => [3]
- _.rest([1, 2, 3], function(num) {
- return num < 3;
- });
- // => [3]
- var food = [
- { 'name': 'banana', 'organic': true },
- { 'name': 'beet', 'organic': false },
- ];
- // using "_.pluck" callback shorthand
- _.rest(food, 'organic');
- // => [{ 'name': 'beet', 'organic': false }]
- var food = [
- { 'name': 'apple', 'type': 'fruit' },
- { 'name': 'banana', 'type': 'fruit' },
- { 'name': 'beet', 'type': 'vegetable' }
- ];
- // using "_.where" callback shorthand
- _.rest(food, { 'type': 'fruit' });
- // => [{ 'name': 'beet', 'type': 'vegetable' }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_sortedindexarray-value--callbackidentity-thisarg"></a>`_.sortedIndex(array, value [, callback=identity, thisArg])`
- <a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3805 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `array` *(Array)*: The array to iterate over.
- 2. `value` *(Mixed)*: The value to evaluate.
- 3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Number)*: Returns the index at which the value should be inserted into `array`.
- #### Example
- ```js
- _.sortedIndex([20, 30, 50], 40);
- // => 2
- // using "_.pluck" callback shorthand
- _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
- // => 2
- var dict = {
- 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
- };
- _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
- return dict.wordToNumber[word];
- });
- // => 2
- _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
- return this.wordToNumber[word];
- }, dict);
- // => 2
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
- <a href="#_unionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [Ⓣ][1]
- Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`.
- #### Arguments
- 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
- #### Returns
- *(Array)*: Returns a new array of unique values, in order, that are present in one or more of the arrays.
- #### Example
- ```js
- _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
- // => [1, 2, 3, 101, 10]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
- <a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3884 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *unique*
- #### Arguments
- 1. `array` *(Array)*: The array to process.
- 2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted.
- 3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array)*: Returns a duplicate-value-free array.
- #### Example
- ```js
- _.uniq([1, 2, 1, 3, 1]);
- // => [1, 2, 3]
- _.uniq([1, 1, 2, 2, 3], true);
- // => [1, 2, 3]
- _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); });
- // => [1, 2, 3]
- _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
- // => [1, 2, 3]
- // using "_.pluck" callback shorthand
- _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
- // => [{ 'x': 1 }, { 'x': 2 }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
- <a href="#_withoutarray--value1-value2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3943 "View in source") [Ⓣ][1]
- 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.
- 2. `[value1, value2, ...]` *(Mixed)*: Values to remove.
- #### Returns
- *(Array)*: Returns a new filtered array.
- #### Example
- ```js
- _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
- // => [2, 3, 4]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
- <a href="#_ziparray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "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.
- #### Arguments
- 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
- #### Returns
- *(Array)*: Returns a new array of grouped elements.
- #### Example
- ```js
- _.zip(['moe', 'larry'], [30, 40], [true, false]);
- // => [['moe', 30, true], ['larry', 40, false]]
- ```
- * * *
- <!-- /div -->
- <!-- /div -->
- <!-- div -->
- ## `“Chaining” Methods`
- <!-- div -->
- ### <a id="_value"></a>`_(value)`
- <a href="#_value">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L272 "View in source") [Ⓣ][1]
- 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:<br>
- `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, and `unshift`
- The chainable wrapper functions are:<br>
- `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
- The non-chainable wrapper functions are:<br>
- `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId`
- The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values.
- #### Arguments
- 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance.
- #### Returns
- *(Object)*: Returns a `lodash` instance.
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
- <a href="#_tapvalue-interceptor">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4874 "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.
- #### Arguments
- 1. `value` *(Mixed)*: The value to pass to `interceptor`.
- 2. `interceptor` *(Function)*: The function to invoke.
- #### Returns
- *(Mixed)*: Returns `value`.
- #### Example
- ```js
- _([1, 2, 3, 4])
- .filter(function(num) { return num % 2 == 0; })
- .tap(alert)
- .map(function(num) { return num * num; })
- .value();
- // => // [2, 4] (alerted)
- // => [4, 16]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_prototypetostring"></a>`_.prototype.toString()`
- <a href="#_prototypetostring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4891 "View in source") [Ⓣ][1]
- Produces the `toString` result of the wrapped value.
- #### Returns
- *(String)*: Returns the string result.
- #### Example
- ```js
- _([1, 2, 3]).toString();
- // => '1,2,3'
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_prototypevalueof"></a>`_.prototype.valueOf()`
- <a href="#_prototypevalueof">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4908 "View in source") [Ⓣ][1]
- Extracts the wrapped value.
- #### Aliases
- *value*
- #### Returns
- *(Mixed)*: Returns the wrapped value.
- #### Example
- ```js
- _([1, 2, 3]).valueOf();
- // => [1, 2, 3]
- ```
- * * *
- <!-- /div -->
- <!-- /div -->
- <!-- div -->
- ## `“Collections” Methods`
- <!-- div -->
- ### <a id="_atcollection--index1-index2-"></a>`_.at(collection [, index1, index2, ...])`
- <a href="#_atcollection--index1-index2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2167 "View in source") [Ⓣ][1]
- Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[index1, index2, ...]` *(Array|Number|String)*: The indexes of `collection` to retrieve, either as individual arguments or arrays.
- #### Returns
- *(Array)*: Returns a new array of elements corresponding to the provided indexes.
- #### Example
- ```js
- _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
- // => ['a', 'c', 'e']
- _.at(['moe', 'larry', 'curly'], 0, 2);
- // => ['moe', 'curly']
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_containscollection-target--fromindex0"></a>`_.contains(collection, target [, fromIndex=0])`
- <a href="#_containscollection-target--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "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.
- #### Aliases
- *include*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `target` *(Mixed)*: The value to check for.
- 3. `[fromIndex=0]` *(Number)*: The index to search from.
- #### Returns
- *(Boolean)*: Returns `true` if the `target` element is found, else `false`.
- #### Example
- ```js
- _.contains([1, 2, 3], 1);
- // => true
- _.contains([1, 2, 3], 1, 2);
- // => false
- _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
- // => true
- _.contains('curly', 'ur');
- // => true
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_countbycollection--callbackidentity-thisarg"></a>`_.countBy(collection [, callback=identity, thisArg])`
- <a href="#_countbycollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2263 "View in source") [Ⓣ][1]
- Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Object)*: Returns the composed aggregate object.
- #### Example
- ```js
- _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
- // => { '4': 1, '6': 2 }
- _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
- // => { '4': 1, '6': 2 }
- _.countBy(['one', 'two', 'three'], 'length');
- // => { '3': 2, '5': 1 }
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])`
- <a href="#_everycollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2315 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *all*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Boolean)*: Returns `true` if all elements pass the callback check, else `false`.
- #### Example
- ```js
- _.every([true, 1, null, 'yes'], Boolean);
- // => false
- var stooges = [
- { 'name': 'moe', 'age': 40 },
- { 'name': 'larry', 'age': 50 }
- ];
- // using "_.pluck" callback shorthand
- _.every(stooges, 'age');
- // => true
- // using "_.where" callback shorthand
- _.every(stooges, { 'age': 50 });
- // => false
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])`
- <a href="#_filtercollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2376 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *select*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array)*: Returns a new array of elements that passed the callback check.
- #### Example
- ```js
- var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
- // => [2, 4, 6]
- var food = [
- { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
- ];
- // using "_.pluck" callback shorthand
- _.filter(food, 'organic');
- // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
- // using "_.where" callback shorthand
- _.filter(food, { 'type': 'fruit' });
- // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_findcollection--callbackidentity-thisarg"></a>`_.find(collection [, callback=identity, thisArg])`
- <a href="#_findcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2443 "View in source") [Ⓣ][1]
- Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *detect*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Mixed)*: Returns the element that passed the callback check, else `undefined`.
- #### Example
- ```js
- var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
- // => 2
- var food = [
- { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- { 'name': 'banana', 'organic': true, 'type': 'fruit' },
- { 'name': 'beet', 'organic': false, 'type': 'vegetable' },
- { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
- ];
- // using "_.where" callback shorthand
- var veggie = _.find(food, { 'type': 'vegetable' });
- // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
- // using "_.pluck" callback shorthand
- var healthy = _.find(food, 'organic');
- // => { 'name': 'banana', 'organic': true, 'type': 'fruit' }
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_foreachcollection--callbackidentity-thisarg"></a>`_.forEach(collection [, callback=identity, thisArg])`
- <a href="#_foreachcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "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`.
- #### Aliases
- *each*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function)*: The function called per iteration.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array, Object, String)*: Returns `collection`.
- #### Example
- ```js
- _([1, 2, 3]).forEach(alert).join(',');
- // => alerts each number and returns '1,2,3'
- _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
- // => alerts each number value (order is not guaranteed)
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_groupbycollection--callbackidentity-thisarg"></a>`_.groupBy(collection [, callback=identity, thisArg])`
- <a href="#_groupbycollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1]
- Creates an object composed of keys returned from running each element of the `collection` through the `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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Object)*: Returns the composed aggregate object.
- #### Example
- ```js
- _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
- // => { '4': [4.2], '6': [6.1, 6.4] }
- _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
- // => { '4': [4.2], '6': [6.1, 6.4] }
- // using "_.pluck" callback shorthand
- _.groupBy(['one', 'two', 'three'], 'length');
- // => { '3': ['one', 'two'], '5': ['three'] }
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])`
- <a href="#_invokecollection-methodname--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2561 "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`.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `methodName` *(Function|String)*: The name of the method to invoke or the function invoked per iteration.
- 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
- #### Returns
- *(Array)*: Returns a new array of the results of each invoked method.
- #### Example
- ```js
- _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
- // => [[1, 5, 7], [1, 2, 3]]
- _.invoke([123, 456], String.prototype.split, '');
- // => [['1', '2', '3'], ['4', '5', '6']]
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])`
- <a href="#_mapcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2613 "View in source") [Ⓣ][1]
- Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Aliases
- *collect*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Array)*: Returns a new array of the results of each `callback` execution.
- #### Example
- ```js
- _.map([1, 2, 3], function(num) { return num * 3; });
- // => [3, 6, 9]
- _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
- // => [3, 6, 9] (order is not guaranteed)
- var stooges = [
- { 'name': 'moe', 'age': 40 },
- { 'name': 'larry', 'age': 50 }
- ];
- // using "_.pluck" callback shorthand
- _.map(stooges, 'name');
- // => ['moe', 'larry']
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_maxcollection--callbackidentity-thisarg"></a>`_.max(collection [, callback=identity, thisArg])`
- <a href="#_maxcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Mixed)*: Returns the maximum value.
- #### Example
- ```js
- _.max([4, 2, 8, 6]);
- // => 8
- var stooges = [
- { 'name': 'moe', 'age': 40 },
- { 'name': 'larry', 'age': 50 }
- ];
- _.max(stooges, function(stooge) { return stooge.age; });
- // => { 'name': 'larry', 'age': 50 };
- // using "_.pluck" callback shorthand
- _.max(stooges, 'age');
- // => { 'name': 'larry', 'age': 50 };
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_mincollection--callbackidentity-thisarg"></a>`_.min(collection [, callback=identity, thisArg])`
- <a href="#_mincollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2739 "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)*.
- If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
- If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
- 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
- #### Returns
- *(Mixed)*: Returns the minimum value.
- #### Example
- ```js
- _.min([4, 2, 8, 6]);
- // => 2
- var stooges = [
- { 'name': 'moe', 'age': 40 },
- { 'name': 'larry', 'age': 50 }
- ];
- _.min(stooges, function(stooge) { return stooge.age; });
- // => { 'name': 'moe', 'age': 40 };
- // using "_.pluck" callback shorthand
- _.min(stooges, 'age');
- // => { 'name': 'moe', 'age': 40 };
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)`
- <a href="#_pluckcollection-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2789 "View in source") [Ⓣ][1]
- Retrieves the value of a specified property from all elements in the `collection`.
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `property` *(String)*: The property to pluck.
- #### Returns
- *(Array)*: Returns a new array of property values.
- #### Example
- ```js
- var stooges = [
- { 'name': 'moe', 'age': 40 },
- { 'name': 'larry', 'age': 50 }
- ];
- _.pluck(stooges, 'name');
- // => ['moe', 'larry']
- ```
- * * *
- <!-- /div -->
- <!-- div -->
- ### <a id="_reducecollection--callbackidentity-accumulator-thisarg"></a>`_.reduce(collection [, callback=identity, accumulator, thisArg])`
- <a href="#_reducecollection--callbackidentity-accumulator-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [Ⓣ][1]
- Reduces a `collection` to a value that is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*.
- #### Aliases
- *foldl, inject*
- #### Arguments
- 1. `collection` *(Array|Object|String)*: The collection to iterate over.
- 2. `[callback=identity]` *(Function)*: The function called per iteration.
- 3. `[accumulator]` *(Mixed)*: Ini…
Large files files are truncated, but you can click here to view the full file