diff --git a/doc/README.md b/doc/README.md index f69e72e0a..b624f979a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# lodash v3.1.0 +# lodash v3.2.0 @@ -12,6 +12,7 @@ * `_.dropRight` * `_.dropRightWhile` * `_.dropWhile` +* `_.fill` * `_.findIndex` * `_.findLastIndex` * `_.first` @@ -55,7 +56,10 @@ * `_.tap` * `_.thru` * `_.prototype.chain` +* `_.prototype.commit` +* `_.prototype.plant` * `_.prototype.reverse` +* `_.prototype.run` -> `value` * `_.prototype.toJSON` -> `value` * `_.prototype.toString` * `_.prototype.value` @@ -140,6 +144,7 @@ * `_.partial` * `_.partialRight` * `_.rearg` +* `_.spread` * `_.throttle` * `_.wrap` @@ -160,7 +165,7 @@ * `_.isError` * `_.isFinite` * `_.isFunction` -* `_.isMatch` +* `_.isMatch` * `_.isNaN` * `_.isNative` * `_.isNull` @@ -251,6 +256,7 @@ * `_.identity` * `_.iteratee` -> `callback` * `_.matches` +* `_.matchesProperty` * `_.mixin` * `_.noConflict` * `_.noop` @@ -306,7 +312,7 @@ ### `_.chunk(array, [size=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4103 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4167 "View in source") [Ⓣ][1] Creates an array of elements split into groups the length of `size`. If `collection` can't be split evenly, the final chunk will be the remaining @@ -314,7 +320,7 @@ elements. #### Arguments 1. `array` *(Array)*: The array to process. -2. `[size=1]` *(numer)*: The length of each chunk. +2. `[size=1]` *(number)*: The length of each chunk. #### Returns *(Array)*: Returns the new array containing chunks. @@ -334,7 +340,7 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4198 "View in source") [Ⓣ][1] Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsey. @@ -357,7 +363,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4233 "View in source") [Ⓣ][1] Creates an array excluding all values of the provided arrays using `SameValueZero` for equality comparisons. @@ -387,7 +393,7 @@ _.difference([1, 2, 3], [5, 2, 10]); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4270 "View in source") [Ⓣ][1] Creates a slice of `array` with `n` elements dropped from the beginning. @@ -419,7 +425,7 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4243 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4305 "View in source") [Ⓣ][1] Creates a slice of `array` with `n` elements dropped from the end. @@ -451,24 +457,29 @@ _.dropRight([1, 2, 3], 0); ### `_.dropRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4364 "View in source") [Ⓣ][1] Creates a slice of `array` excluding elements dropped from the end. Elements are dropped until `predicate` returns falsey. The predicate is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style -callback returns `true` for elements that have the properties of the given +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style +callback returns `true` for elements that match the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per element. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -480,18 +491,22 @@ _.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); // => [1] var users = [ - { 'user': 'barney', 'status': 'busy', 'active': false }, - { 'user': 'fred', 'status': 'busy', 'active': true }, - { 'user': 'pebbles', 'status': 'away', 'active': true } + { 'user': 'barney', 'active': true }, + { 'user': 'fred', 'active': false }, + { 'user': 'pebbles', 'active': false } ]; -// using the "_.property" callback shorthand -_.pluck(_.dropRightWhile(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user'); +// => ['barney', 'fred'] + +// using the `_.matchesProperty` callback shorthand +_.pluck(_.dropRightWhile(users, 'active', false), 'user'); // => ['barney'] -// using the "_.matches" callback shorthand -_.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user'); -// => ['barney', 'fred'] +// using the `_.property` callback shorthand +_.pluck(_.dropRightWhile(users, 'active'), 'user'); +// => ['barney', 'fred', 'pebbles'] ``` * * * @@ -500,24 +515,29 @@ _.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user'); ### `_.dropWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4421 "View in source") [Ⓣ][1] Creates a slice of `array` excluding elements dropped from the beginning. Elements are dropped until `predicate` returns falsey. The predicate is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per element. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -529,18 +549,22 @@ _.dropWhile([1, 2, 3], function(n) { return n < 3; }); // => [3] var users = [ - { 'user': 'barney', 'status': 'busy', 'active': true }, - { 'user': 'fred', 'status': 'busy', 'active': false }, - { 'user': 'pebbles', 'status': 'away', 'active': true } + { 'user': 'barney', 'active': false }, + { 'user': 'fred', 'active': false }, + { 'user': 'pebbles', 'active': true } ]; -// using the "_.property" callback shorthand -_.pluck(_.dropWhile(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); // => ['fred', 'pebbles'] -// using the "_.matches" callback shorthand -_.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user'); +// using the `_.matchesProperty` callback shorthand +_.pluck(_.dropWhile(users, 'active', false), 'user'); // => ['pebbles'] + +// using the `_.property` callback shorthand +_.pluck(_.dropWhile(users, 'active'), 'user'); +// => ['barney', 'fred', 'pebbles'] ``` * * * @@ -548,24 +572,53 @@ _.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user'); +### `_.fill(array, value, [start=0], [end=array.length])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4447 "View in source") [Ⓣ][1] + +Fills elements of `array` with `value` from `start` up to, but not +including, `end`. +
+
+**Note:** This method mutates `array`. + +#### Arguments +1. `array` *(Array)*: The array to fill. +2. `value` *(*)*: The value to fill `array` with. +3. `[start=0]` *(number)*: The start position. +4. `[end=array.length]` *(number)*: The end position. + +#### Returns +*(Array)*: Returns `array`. + +* * * + + + + + ### `_.findIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4395 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4505 "View in source") [Ⓣ][1] This method is like `_.find` except that it returns the index of the first element `predicate` returns truthy for, instead of the element itself.

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -574,21 +627,25 @@ object, else `false`. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36, 'active': false }, - { 'user': 'fred', 'age': 40, 'active': true }, - { 'user': 'pebbles', 'age': 1, 'active': false } + { 'user': 'barney', 'active': false }, + { 'user': 'fred', 'active': false }, + { 'user': 'pebbles', 'active': true } ]; -_.findIndex(users, function(chr) { return chr.age < 40; }); +_.findIndex(users, function(chr) { return chr.user == 'barney'; }); // => 0 -// using the "_.matches" callback shorthand -_.findIndex(users, { 'age': 1 }); -// => 2 - -// using the "_.property" callback shorthand -_.findIndex(users, 'active'); +// using the `_.matches` callback shorthand +_.findIndex(users, { 'user': 'fred', 'active': false }); // => 1 + +// using the `_.matchesProperty` callback shorthand +_.findIndex(users, 'active', false); +// => 0 + +// using the `_.property` callback shorthand +_.findIndex(users, 'active'); +// => 2 ``` * * * @@ -597,23 +654,28 @@ _.findIndex(users, 'active'); ### `_.findLastIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4564 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it iterates over elements of `collection` from right to left.

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -622,19 +684,23 @@ object, else `false`. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36, 'active': true }, - { 'user': 'fred', 'age': 40, 'active': false }, - { 'user': 'pebbles', 'age': 1, 'active': false } + { 'user': 'barney', 'active': true }, + { 'user': 'fred', 'active': false }, + { 'user': 'pebbles', 'active': false } ]; -_.findLastIndex(users, function(chr) { return chr.age < 40; }); +_.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; }); // => 2 -// using the "_.matches" callback shorthand -_.findLastIndex(users, { 'age': 40 }); +// using the `_.matches` callback shorthand +_.findLastIndex(users, { user': 'barney', 'active': true }); +// => 0 + +// using the `_.matchesProperty` callback shorthand +_.findLastIndex(users, 'active', false); // => 1 -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.findLastIndex(users, 'active'); // => 0 ``` @@ -645,7 +711,7 @@ _.findLastIndex(users, 'active'); ### `_.first(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4475 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4592 "View in source") [Ⓣ][1] Gets the first element of `array`. @@ -670,7 +736,7 @@ _.first([]); ### `_.flatten(array, [isDeep])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4616 "View in source") [Ⓣ][1] Flattens a nested array. If `isDeep` is `true` the array is recursively flattened, otherwise it is only flattened a single level. @@ -698,7 +764,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4637 "View in source") [Ⓣ][1] Recursively flattens a nested array. @@ -720,7 +786,7 @@ _.flattenDeep([1, [2], [3, [[4]]]]); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4674 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found in `array` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, @@ -761,7 +827,7 @@ _.indexOf([4, 4, 5, 5, 6, 6], 5, true); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4703 "View in source") [Ⓣ][1] Gets all but the last element of `array`. @@ -783,7 +849,7 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4609 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4726 "View in source") [Ⓣ][1] Creates an array of unique values in all provided arrays using `SameValueZero` for equality comparisons. @@ -812,7 +878,7 @@ _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4781 "View in source") [Ⓣ][1] Gets the last element of `array`. @@ -834,7 +900,7 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4694 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4811 "View in source") [Ⓣ][1] This method is like `_.indexOf` except that it iterates over elements of `array` from right to left. @@ -867,7 +933,7 @@ _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4741 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4858 "View in source") [Ⓣ][1] Removes all provided values from `array` using `SameValueZero` for equality comparisons. @@ -902,7 +968,7 @@ console.log(array); ### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4903 "View in source") [Ⓣ][1] Removes elements from `array` corresponding to the given indexes and returns an array of the removed elements. Indexes may be specified as an array of @@ -936,18 +1002,23 @@ console.log(evens); ### `_.remove(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4824 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4944 "View in source") [Ⓣ][1] Removes all elements from `array` that `predicate` returns truthy for and returns an array of the removed elements. The predicate is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`.
@@ -956,7 +1027,7 @@ object, else `false`. #### Arguments 1. `array` *(Array)*: The array to modify. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -980,7 +1051,7 @@ console.log(evens); ### `_.rest(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4975 "View in source") [Ⓣ][1] Gets all but the first element of `array`. @@ -1002,7 +1073,7 @@ _.rest([1, 2, 3]); ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4873 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4993 "View in source") [Ⓣ][1] Creates a slice of `array` from `start` up to, but not including, `end`.
@@ -1025,7 +1096,7 @@ lists in IE < 9 and to ensure dense arrays are returned. ### `_.sortedIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5053 "View in source") [Ⓣ][1] Uses a binary search to determine the lowest index at which `value` should be inserted into `array` in order to maintain its sort order. If an iteratee @@ -1034,18 +1105,23 @@ to compute their sort ranking. The iteratee is bound to `thisArg` and invoked with one argument; (value).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -1068,7 +1144,7 @@ _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { }, dict); // => 1 -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); // => 1 ``` @@ -1079,7 +1155,7 @@ _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); ### `_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4958 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5080 "View in source") [Ⓣ][1] This method is like `_.sortedIndex` except that it returns the highest index at which `value` should be inserted into `array` in order to @@ -1088,7 +1164,7 @@ maintain its sort order. #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -1107,7 +1183,7 @@ _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L4990 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5111 "View in source") [Ⓣ][1] Creates a slice of `array` with `n` elements taken from the beginning. @@ -1139,7 +1215,7 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5026 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5146 "View in source") [Ⓣ][1] Creates a slice of `array` with `n` elements taken from the end. @@ -1171,24 +1247,29 @@ _.takeRight([1, 2, 3], 0); ### `_.takeRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5078 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5205 "View in source") [Ⓣ][1] Creates a slice of `array` with elements taken from the end. Elements are taken until `predicate` returns falsey. The predicate is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per element. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -1200,18 +1281,22 @@ _.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); // => [2, 3] var users = [ - { 'user': 'barney', 'status': 'busy', 'active': false }, - { 'user': 'fred', 'status': 'busy', 'active': true }, - { 'user': 'pebbles', 'status': 'away', 'active': true } + { 'user': 'barney', 'active': true }, + { 'user': 'fred', 'active': false }, + { 'user': 'pebbles', 'active': false } ]; -// using the "_.property" callback shorthand -_.pluck(_.takeRightWhile(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); +// => ['pebbles'] + +// using the `_.matchesProperty` callback shorthand +_.pluck(_.takeRightWhile(users, 'active', false), 'user'); // => ['fred', 'pebbles'] -// using the "_.matches" callback shorthand -_.pluck(_.takeRightWhile(users, { 'status': 'away' }), 'user'); -// => ['pebbles'] +// using the `_.property` callback shorthand +_.pluck(_.takeRightWhile(users, 'active'), 'user'); +// => [] ``` * * * @@ -1220,24 +1305,29 @@ _.pluck(_.takeRightWhile(users, { 'status': 'away' }), 'user'); ### `_.takeWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5262 "View in source") [Ⓣ][1] Creates a slice of `array` with elements taken from the beginning. Elements are taken until `predicate` returns falsey. The predicate is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per element. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -1249,18 +1339,22 @@ _.takeWhile([1, 2, 3], function(n) { return n < 3; }); // => [1, 2] var users = [ - { 'user': 'barney', 'status': 'busy', 'active': true }, - { 'user': 'fred', 'status': 'busy', 'active': false }, - { 'user': 'pebbles', 'status': 'away', 'active': true } + { 'user': 'barney', 'active': false }, + { 'user': 'fred', 'active': false}, + { 'user': 'pebbles', 'active': true } ]; -// using the "_.property" callback shorthand -_.pluck(_.takeWhile(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); // => ['barney'] -// using the "_.matches" callback shorthand -_.pluck(_.takeWhile(users, { 'status': 'busy' }), 'user'); +// using the `_.matchesProperty` callback shorthand +_.pluck(_.takeWhile(users, 'active', false), 'user'); // => ['barney', 'fred'] + +// using the `_.property` callback shorthand +_.pluck(_.takeWhile(users, 'active'), 'user'); +// => [] ``` * * * @@ -1269,7 +1363,7 @@ _.pluck(_.takeWhile(users, { 'status': 'busy' }), 'user'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5292 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the provided arrays using `SameValueZero` for equality comparisons. @@ -1298,7 +1392,7 @@ _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); ### `_.uniq(array, [isSorted], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5346 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of an array using `SameValueZero` for equality comparisons. Providing `true` for `isSorted` performs a faster @@ -1308,11 +1402,16 @@ uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index, array).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`.
@@ -1325,7 +1424,7 @@ for more details. #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[isSorted]` *(boolean)*: Specify the array is sorted. -3. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +3. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. 4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -1344,7 +1443,7 @@ _.uniq([1, 1, 2], true); _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); // => [1, 2.5] -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }, { 'x': 2 }] ``` @@ -1355,7 +1454,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5248 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5384 "View in source") [Ⓣ][1] This method is like `_.zip` except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-`_.zip` @@ -1382,7 +1481,7 @@ _.unzip(zipped); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5415 "View in source") [Ⓣ][1] Creates an array excluding all provided values using `SameValueZero` for equality comparisons. @@ -1412,7 +1511,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5437 "View in source") [Ⓣ][1] Creates an array that is the symmetric difference of the provided arrays. See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for @@ -1439,7 +1538,7 @@ _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5331 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5467 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements @@ -1463,7 +1562,7 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); ### `_.zipObject(props, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5358 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5494 "View in source") [Ⓣ][1] Creates an object composed from arrays of property names and values. Provide either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]` @@ -1494,9 +1593,9 @@ _.zipObject(['fred', 'barney'], [30, 40]); ### `._(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L919 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L920 "View in source") [Ⓣ][1] -Creates a `lodash` object which wraps `value` to enable intuitive chaining. +Creates a `lodash` object which wraps `value` to enable implicit chaining. Methods that operate on and return arrays, collections, and functions can be chained together. Methods that return a boolean or single value will automatically end the chain returning the unwrapped value. Explicit chaining @@ -1519,31 +1618,33 @@ In addition to lodash methods, wrappers also have the following `Array` methods: and `unshift`

-The wrapper functions that support shortcut fusion are:
-`drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`, -`initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`, -`take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where` +The wrapper methods that support shortcut fusion are:
+`compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, +`first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, +`slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, +and `where`

-The chainable wrapper functions are:
+The chainable wrapper methods are:
`after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, -`callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`, -`create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, -`drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `flatten`, -`flattenDeep`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`, -`forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`, -`initial`, `intersection`, `invert`, `invoke`, `keys`, `keysIn`, `map`, -`mapValues`, `matches`, `memoize`, `merge`, `mixin`, `negate`, `noop`, -`omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`, -`pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, -`rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, -`sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`, -`takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, -`transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, -`where`, `without`, `wrap`, `xor`, `zip`, and `zipObject` +`callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, +`countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, +`difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`, +`filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, +`forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, +`groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, +`keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, +`mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, +`partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, +`pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, +`shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, +`take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, +`thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, +`unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, +`zip`, and `zipObject`

-The wrapper functions that are **not** chainable by default are:
+The wrapper methods that are **not** chainable by default are:
`attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, @@ -1559,14 +1660,14 @@ The wrapper functions that are **not** chainable by default are:
`trunc`, `unescape`, `uniqueId`, `value`, and `words`

-The wrapper function `sample` will return a wrapped value when `n` is provided, +The wrapper method `sample` will return a wrapped value when `n` is provided, otherwise an unwrapped value is returned. #### Arguments 1. `value` *(*)*: The value to wrap in a `lodash` instance. #### Returns -*(Object)*: Returns a `lodash` instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -1592,7 +1693,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5403 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5539 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps `value` with explicit method chaining enabled. @@ -1601,7 +1702,7 @@ chaining enabled. 1. `value` *(*)*: The value to wrap. #### Returns -*(Object)*: Returns the new `lodash` object. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -1625,7 +1726,7 @@ var youngest = _.chain(users) ### `_.tap(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5430 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5566 "View in source") [Ⓣ][1] This method invokes `interceptor` and returns `value`. The interceptor is bound to `thisArg` and invoked with one argument; (value). The purpose of @@ -1655,7 +1756,7 @@ _([1, 2, 3]) ### `_.thru(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5453 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5589 "View in source") [Ⓣ][1] This method is like `_.tap` except that it returns the result of `interceptor`. @@ -1682,12 +1783,12 @@ _([1, 2, 3]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5482 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5618 "View in source") [Ⓣ][1] Enables explicit method chaining on the wrapper object. #### Returns -*(*)*: Returns the `lodash` object. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -1713,8 +1814,70 @@ _(users).chain() +### `_.prototype.commit()` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5647 "View in source") [Ⓣ][1] + +Executes the chained sequence and returns the wrapped result. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var array = [1, 2]; +var wrapper = _(array).push(3); + +console.log(array); +// => [1, 2] + +wrapper = wrapper.commit(); +console.log(array); +// => [1, 2, 3] + +wrapper.last(); +// => 3 + +console.log(array); +// => [1, 2, 3] +``` +* * * + + + + + +### `_.prototype.plant()` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5674 "View in source") [Ⓣ][1] + +Creates a clone of the chained sequence planting `value` as the wrapped value. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var array = [1, 2]; +var wrapper = _(array).map(function(value) { + return Math.pow(value, 2); +}); + +var other = [3, 4]; +var otherWrapper = wrapper.plant(other); + +otherWrapper.value(); +// => [9, 16] + +wrapper.value(); +// => [1, 4] +``` +* * * + + + + + ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5506 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5712 "View in source") [Ⓣ][1] Reverses the wrapped array so the first element becomes the last, the second element becomes the second to last, and so on. @@ -1723,7 +1886,7 @@ second element becomes the second to last, and so on. **Note:** This method mutates the wrapped array. #### Returns -*(Object)*: Returns the new reversed `lodash` object. +*(Object)*: Returns the new reversed `lodash` wrapper instance. #### Example ```js @@ -1742,7 +1905,7 @@ console.log(array); ### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5737 "View in source") [Ⓣ][1] Produces the result of coercing the unwrapped value to a string. @@ -1761,7 +1924,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5754 "View in source") [Ⓣ][1] Executes the chained sequence to extract the unwrapped value. @@ -1786,7 +1949,7 @@ _([1, 2, 3]).value(); ### `_.at(collection, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5780 "View in source") [Ⓣ][1] Creates an array of elements corresponding to the given keys, or indexes, of `collection`. Keys may be specified as individual arguments or as arrays @@ -1814,7 +1977,7 @@ _.at(['fred', 'barney', 'pebbles'], 0, 2); ### `_.countBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5876 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -1823,17 +1986,22 @@ The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -1857,24 +2025,29 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5712 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5928 "View in source") [Ⓣ][1] Checks if `predicate` returns truthy for **all** elements of `collection`. The predicate is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -1883,20 +2056,24 @@ else `false`. #### Example ```js -_.every([true, 1, null, 'yes']); +_.every([true, 1, null, 'yes'], Boolean); // => false var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } + { 'user': 'barney', 'active': false }, + { 'user': 'fred', 'active': false } ]; -// using the "_.property" callback shorthand -_.every(users, 'age'); +// using the `_.matches` callback shorthand +_.every(users, { 'user': 'barney', 'active': false }); +// => false + +// using the `_.matchesProperty` callback shorthand +_.every(users, 'active', false); // => true -// using the "_.matches" callback shorthand -_.every(users, { 'age': 36 }); +// using the `_.property` callback shorthand +_.every(users, 'active'); // => false ``` * * * @@ -1906,24 +2083,29 @@ _.every(users, { 'age': 36 }); ### `_.filter(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5983 "View in source") [Ⓣ][1] Iterates over elements of `collection`, returning an array of all elements `predicate` returns truthy for. The predicate is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -1935,16 +2117,20 @@ var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); // => [2, 4] var users = [ - { 'user': 'barney', 'age': 36, 'active': false }, - { 'user': 'fred', 'age': 40, 'active': true } + { 'user': 'barney', 'age': 36, 'active': true }, + { 'user': 'fred', 'age': 40, 'active': false } ]; -// using the "_.property" callback shorthand -_.pluck(_.filter(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); +// => ['barney'] + +// using the `_.matchesProperty` callback shorthand +_.pluck(_.filter(users, 'active', false), 'user'); // => ['fred'] -// using the "_.matches" callback shorthand -_.pluck(_.filter(users, { 'age': 36 }), 'user'); +// using the `_.property` callback shorthand +_.pluck(_.filter(users, 'active'), 'user'); // => ['barney'] ``` * * * @@ -1954,24 +2140,29 @@ _.pluck(_.filter(users, { 'age': 36 }), 'user'); ### `_.find(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5807 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6037 "View in source") [Ⓣ][1] Iterates over elements of `collection`, returning the first element `predicate` returns truthy for. The predicate is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -1980,21 +2171,25 @@ object, else `false`. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36, 'active': false }, - { 'user': 'fred', 'age': 40, 'active': true }, - { 'user': 'pebbles', 'age': 1, 'active': false } + { 'user': 'barney', 'age': 36, 'active': true }, + { 'user': 'fred', 'age': 40, 'active': false }, + { 'user': 'pebbles', 'age': 1, 'active': true } ]; _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user'); // => 'barney' -// using the "_.matches" callback shorthand -_.result(_.find(users, { 'age': 1 }), 'user'); +// using the `_.matches` callback shorthand +_.result(_.find(users, { 'age': 1, 'active': true }), 'user'); // => 'pebbles' -// using the "_.property" callback shorthand -_.result(_.find(users, 'active'), 'user'); +// using the `_.matchesProperty` callback shorthand +_.result(_.find(users, 'active', false), 'user'); // => 'fred' + +// using the `_.property` callback shorthand +_.result(_.find(users, 'active'), 'user'); +// => 'barney' ``` * * * @@ -2003,14 +2198,14 @@ _.result(_.find(users, 'active'), 'user'); ### `_.findLast(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5834 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6063 "View in source") [Ⓣ][1] This method is like `_.find` except that it iterates over elements of `collection` from right to left. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -2028,11 +2223,17 @@ _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); ### `_.findWhere(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5863 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6097 "View in source") [Ⓣ][1] Performs a deep comparison between each element in `collection` and the source object, returning the first element that has equivalent property values. +
+
+**Note:** This method supports comparing arrays, booleans, `Date` objects, +numbers, `Object` objects, regexes, and strings. Objects are compared by +their own, not inherited, enumerable properties. For comparing a single +own or inherited property value see `_.matchesProperty`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. @@ -2044,14 +2245,14 @@ values. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36, 'status': 'busy' }, - { 'user': 'fred', 'age': 40, 'status': 'busy' } + { 'user': 'barney', 'age': 36, 'active': true }, + { 'user': 'fred', 'age': 40, 'active': false } ]; -_.result(_.findWhere(users, { 'status': 'busy' }), 'user'); +_.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); // => 'barney' -_.result(_.findWhere(users, { 'age': 40 }), 'user'); +_.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); // => 'fred' ``` * * * @@ -2061,7 +2262,7 @@ _.result(_.findWhere(users, { 'age': 40 }), 'user'); ### `_.forEach(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6127 "View in source") [Ⓣ][1] Iterates over elements of `collection` invoking `iteratee` for each element. The `iteratee` is bound to `thisArg` and invoked with three arguments; @@ -2096,7 +2297,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, ### `_.forEachRight(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5916 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6150 "View in source") [Ⓣ][1] This method is like `_.forEach` except that it iterates over elements of `collection` from right to left. @@ -2121,7 +2322,7 @@ _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); ### `_.groupBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5957 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6194 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -2130,17 +2331,22 @@ The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2154,7 +2360,7 @@ _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); // => { '4': [4.2], '6': [6.1, 6.4] } -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] } ``` @@ -2165,7 +2371,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.includes(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L5614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5820 "View in source") [Ⓣ][1] Checks if `value` is in `collection` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, it is used as the offset from @@ -2206,7 +2412,7 @@ _.includes('pebbles', 'eb'); ### `_.indexBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6004 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6244 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -2215,17 +2421,22 @@ iteratee function is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2254,7 +2465,7 @@ _.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, ### `_.invoke(collection, methodName, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6270 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in `collection`, returning an array of the results of each invoked method. Any additional @@ -2284,24 +2495,40 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6326 "View in source") [Ⓣ][1] Creates an array of values by running each element in `collection` through `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. +
+
+Many lodash methods are guarded to work as interatees for methods like +`_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. +
+
+The guarded methods are:
+`ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, +`dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`, +`sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, +`trunc`, `random`, `range`, `sample`, `uniq`, and `words` #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. create a `_.property` or `_.matches` style callback respectively. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2320,7 +2547,7 @@ var users = [ { 'user': 'fred' } ]; -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.map(users, 'user'); // => ['barney', 'fred'] ``` @@ -2331,7 +2558,7 @@ _.map(users, 'user'); ### `_.max(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6122 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6377 "View in source") [Ⓣ][1] Gets the maximum value of `collection`. If `collection` is empty or falsey `-Infinity` is returned. If an iteratee function is provided it is invoked @@ -2340,17 +2567,22 @@ is ranked. The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2372,7 +2604,7 @@ var users = [ _.max(users, function(chr) { return chr.age; }); // => { 'user': 'fred', 'age': 40 }; -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.max(users, 'age'); // => { 'user': 'fred', 'age': 40 }; ``` @@ -2383,7 +2615,7 @@ _.max(users, 'age'); ### `_.min(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6424 "View in source") [Ⓣ][1] Gets the minimum value of `collection`. If `collection` is empty or falsey `Infinity` is returned. If an iteratee function is provided it is invoked @@ -2392,17 +2624,22 @@ is ranked. The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2424,7 +2661,7 @@ var users = [ _.min(users, function(chr) { return chr.age; }); // => { 'user': 'barney', 'age': 36 }; -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.min(users, 'age'); // => { 'user': 'barney', 'age': 36 }; ``` @@ -2435,7 +2672,7 @@ _.min(users, 'age'); ### `_.partition(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6213 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6479 "View in source") [Ⓣ][1] Creates an array of elements split into two groups, the first of which contains elements `predicate` returns truthy for, while the second of which @@ -2443,17 +2680,22 @@ contains elements `predicate` returns falsey for. The predicate is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -2473,12 +2715,18 @@ var users = [ { 'user': 'pebbles', 'age': 1, 'active': false } ]; -// using the "_.matches" callback shorthand -_.map(_.partition(users, { 'age': 1 }), function(array) { return _.pluck(array, 'user'); }); +var mapper = function(array) { return _.pluck(array, 'user'); }; + +// using the `_.matches` callback shorthand +_.map(_.partition(users, { 'age': 1, 'active': false }), mapper); // => [['pebbles'], ['barney', 'fred']] -// using the "_.property" callback shorthand -_.map(_.partition(users, 'active'), function(array) { return _.pluck(array, 'user'); }); +// using the `_.matchesProperty` callback shorthand +_.map(_.partition(users, 'active', false), mapper); +// => [['barney', 'pebbles'], ['fred']] + +// using the `_.property` callback shorthand +_.map(_.partition(users, 'active'), mapper); // => [['fred'], ['barney', 'pebbles']] ``` * * * @@ -2488,7 +2736,7 @@ _.map(_.partition(users, 'active'), function(array) { return _.pluck(array, 'use ### `_.pluck(collection, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6506 "View in source") [Ⓣ][1] Gets the value of `key` from all elements in `collection`. @@ -2520,7 +2768,7 @@ _.pluck(userIndex, 'age'); ### `_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6272 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6544 "View in source") [Ⓣ][1] Reduces `collection` to a value which is the accumulated result of running each element in `collection` through `iteratee`, where each successive @@ -2528,6 +2776,14 @@ invocation is supplied the return value of the previous. If `accumulator` is not provided the first element of `collection` is used as the initial value. The `iteratee` is bound to `thisArg`and invoked with four arguments; (accumulator, value, index|key, collection). +
+
+Many lodash methods are guarded to work as interatees for methods like +`_.reduce`, `_.reduceRight`, and `_.transform`. +
+
+The guarded methods are:
+`assign`, `defaults`, `merge`, and `sortAllBy` #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. @@ -2556,7 +2812,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { ### `_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6296 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6568 "View in source") [Ⓣ][1] This method is like `_.reduce` except that it iterates over elements of `collection` from right to left. @@ -2583,23 +2839,28 @@ _.reduceRight(array, function(flattened, other) { return flattened.concat(other) ### `_.reject(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6339 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6618 "View in source") [Ⓣ][1] The opposite of `_.filter`; this method returns the elements of `collection` that `predicate` does **not** return truthy for.

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -2615,13 +2876,17 @@ var users = [ { 'user': 'fred', 'age': 40, 'active': true } ]; -// using the "_.property" callback shorthand -_.pluck(_.reject(users, 'active'), 'user'); +// using the `_.matches` callback shorthand +_.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); // => ['barney'] -// using the "_.matches" callback shorthand -_.pluck(_.reject(users, { 'age': 36 }), 'user'); +// using the `_.matchesProperty` callback shorthand +_.pluck(_.reject(users, 'active', false), 'user'); // => ['fred'] + +// using the `_.property` callback shorthand +_.pluck(_.reject(users, 'active'), 'user'); +// => ['barney'] ``` * * * @@ -2630,7 +2895,7 @@ _.pluck(_.reject(users, { 'age': 36 }), 'user'); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6644 "View in source") [Ⓣ][1] Gets a random element or `n` random elements from a collection. @@ -2656,7 +2921,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6391 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6670 "View in source") [Ⓣ][1] Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) @@ -2680,7 +2945,7 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6707 "View in source") [Ⓣ][1] Gets the size of `collection` by returning `collection.length` for array-like values or the number of own enumerable properties for objects. @@ -2709,7 +2974,7 @@ _.size('pebbles'); ### `_.some(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6475 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6761 "View in source") [Ⓣ][1] Checks if `predicate` returns truthy for **any** element of `collection`. The function returns as soon as it finds a passing value and does not iterate @@ -2717,17 +2982,22 @@ over the entire collection. The predicate is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -2740,17 +3010,21 @@ _.some([null, 0, 'yes', false], Boolean); // => true var users = [ - { 'user': 'barney', 'age': 36, 'active': false }, - { 'user': 'fred', 'age': 40, 'active': true } + { 'user': 'barney', 'active': true }, + { 'user': 'fred', 'active': false } ]; -// using the "_.property" callback shorthand -_.some(users, 'active'); +// using the `_.matches` callback shorthand +_.some(users, { user': 'barney', 'active': false }); +// => false + +// using the `_.matchesProperty` callback shorthand +_.some(users, 'active', false); // => true -// using the "_.matches" callback shorthand -_.some(users, { 'age': 1 }); -// => false +// using the `_.property` callback shorthand +_.some(users, 'active'); +// => true ``` * * * @@ -2759,7 +3033,7 @@ _.some(users, { 'age': 1 }); ### `_.sortBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6524 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6814 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in a collection through `iteratee`. This method performs @@ -2768,17 +3042,22 @@ The `iteratee` is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. If a property name or an object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. If a property name or an object is provided it is used to create a `_.property` or `_.matches` style callback respectively. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -2798,7 +3077,7 @@ var users = [ { 'user': 'barney' } ]; -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.pluck(_.sortBy(users, 'user'), 'user'); // => ['barney', 'fred', 'pebbles'] ``` @@ -2809,7 +3088,7 @@ _.pluck(_.sortBy(users, 'user'), 'user'); ### `_.sortByAll(collection, props)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6562 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6852 "View in source") [Ⓣ][1] This method is like `_.sortBy` except that it sorts by property names instead of an iteratee function. @@ -2840,11 +3119,17 @@ _.map(_.sortByAll(users, ['user', 'age']), _.values); ### `_.where(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6903 "View in source") [Ⓣ][1] Performs a deep comparison between each element in `collection` and the source object, returning an array of all elements that have equivalent property values. +
+
+**Note:** This method supports comparing arrays, booleans, `Date` objects, +numbers, `Object` objects, regexes, and strings. Objects are compared by +their own, not inherited, enumerable properties. For comparing a single +own or inherited property value see `_.matchesProperty`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. @@ -2856,18 +3141,15 @@ property values. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36, 'status': 'busy', 'pets': ['hoppy'] }, - { 'user': 'fred', 'age': 40, 'status': 'busy', 'pets': ['baby puss', 'dino'] } + { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, + { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } ]; -_.pluck(_.where(users, { 'age': 36 }), 'user'); +_.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); // => ['barney'] _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); // => ['fred'] - -_.pluck(_.where(users, { 'status': 'busy' }), 'user'); -// => ['barney', 'fred'] ``` * * * @@ -2882,7 +3164,7 @@ _.pluck(_.where(users, { 'status': 'busy' }), 'user'); ### `_.now` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6921 "View in source") [Ⓣ][1] Gets the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC). @@ -2905,7 +3187,7 @@ _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6950 "View in source") [Ⓣ][1] The opposite of `_.before`; this method creates a function that invokes `func` once it is called `n` or more times. @@ -2937,7 +3219,7 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6692 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6984 "View in source") [Ⓣ][1] Creates a function that accepts up to `n` arguments ignoring any additional arguments. @@ -2961,7 +3243,7 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6716 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7008 "View in source") [Ⓣ][1] Creates a function that invokes `func`, with the `this` binding and arguments of the created function, while it is called less than `n` times. Subsequent @@ -2986,7 +3268,7 @@ jQuery('#add').on('click', _.before(5, addContactToList)); ### `_.bind(func, thisArg, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7064 "View in source") [Ⓣ][1] Creates a function that invokes `func` with the `this` binding of `thisArg` and prepends any additional `_.bind` arguments to those provided to the @@ -3032,7 +3314,7 @@ bound('hi'); ### `_.bindAll(object, [methodNames])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6809 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7101 "View in source") [Ⓣ][1] Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays @@ -3067,7 +3349,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6861 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7153 "View in source") [Ⓣ][1] Creates a function that invokes the method at `object[key]` and prepends any additional `_.bindKey` arguments to those provided to the bound function. @@ -3122,7 +3404,7 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7204 "View in source") [Ⓣ][1] Creates a function that accepts one or more arguments of `func` that when called either invokes `func` returning its result, if all `func` arguments @@ -3172,7 +3454,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L6958 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7250 "View in source") [Ⓣ][1] This method is like `_.curry` except that arguments are applied to `func` in the manner of `_.partialRight` instead of `_.partial`. @@ -3219,7 +3501,7 @@ curried(3)(1, _)(2); ### `_.debounce(func, wait, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7321 "View in source") [Ⓣ][1] Creates a function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time it was invoked. The created function comes @@ -3289,7 +3571,7 @@ delete models.todo; ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7450 "View in source") [Ⓣ][1] Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to `func` when it is invoked. @@ -3313,7 +3595,7 @@ _.defer(function(text) { console.log(text); }, 'deferred'); ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7470 "View in source") [Ⓣ][1] Invokes `func` after `wait` milliseconds. Any additional arguments are provided to `func` when it is invoked. @@ -3338,7 +3620,7 @@ _.delay(function(text) { console.log(text); }, 1000, 'later'); ### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7498 "View in source") [Ⓣ][1] Creates a function that returns the result of invoking the provided functions with the `this` binding of the created function, where each @@ -3371,7 +3653,7 @@ addSquare(1, 2); ### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7543 "View in source") [Ⓣ][1] This method is like `_.flow` except that it creates a function that invokes the provided functions from right to left. @@ -3403,7 +3685,7 @@ addSquare(1, 2); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7617 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is provided it determines the cache key for storing the result based on the @@ -3466,7 +3748,7 @@ identity(other); ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7363 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7655 "View in source") [Ⓣ][1] Creates a function that negates the result of the predicate `func`. The `func` predicate is invoked with the `this` binding and arguments of the @@ -3494,7 +3776,7 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7390 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7681 "View in source") [Ⓣ][1] Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first call. The `func` is invoked @@ -3520,7 +3802,7 @@ initialize(); ### `_.partial(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7426 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7717 "View in source") [Ⓣ][1] Creates a function that invokes `func` with `partial` arguments prepended to those provided to the new function. This method is like `_.bind` except @@ -3563,7 +3845,7 @@ greetFred('hi'); ### `_.partialRight(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7755 "View in source") [Ⓣ][1] This method is like `_.partial` except that partially applied arguments are appended to those provided to the new function. @@ -3605,7 +3887,7 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7497 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7788 "View in source") [Ⓣ][1] Creates a function that invokes `func` with arguments arranged according to the specified indexes where the argument value at the first index is @@ -3638,8 +3920,47 @@ map(function(n) { return n * 3; }, [1, 2, 3]); +### `_.spread(func)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7823 "View in source") [Ⓣ][1] + +Creates a function that invokes `func` with the `this` binding of the +created function and the array of arguments provided to the created +function much like [Function#apply](http://es5.github.io/#x15.3.4.3). + +#### Arguments +1. `func` *(Function)*: The function to spread arguments over. + +#### Returns +*(*)*: Returns the new function. + +#### Example +```js +var spread = _.spread(function(who, what) { + return who + ' says ' + what; +}); + +spread(['Fred', 'hello']); +// => 'Fred says hello' + +// with a Promise +var numbers = Promise.all([ + Promise.resolve(40), + Promise.resolve(36) +]); + +numbers.then(_.spread(function(x, y) { + return x + y; +})); +// => a Promise of 76 +``` +* * * + + + + + ### `_.throttle(func, wait, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7540 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7870 "View in source") [Ⓣ][1] Creates a function that only invokes `func` at most once per every `wait` milliseconds. The created function comes with a `cancel` method to cancel @@ -3686,7 +4007,7 @@ jQuery(window).on('popstate', throttled.cancel); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7580 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7910 "View in source") [Ⓣ][1] Creates a function that provides `value` to the wrapper function as its first argument. Any additional arguments provided to the function are @@ -3722,7 +4043,7 @@ p('fred, barney, & pebbles'); ### `_.clone(value, [isDeep], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7966 "View in source") [Ⓣ][1] Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, otherwise they are assigned by reference. If `customizer` is provided it is @@ -3781,7 +4102,7 @@ body.childNodes.length; ### `_.cloneDeep(value, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7690 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8020 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If `customizer` is provided it is invoked to produce the cloned values. If `customizer` returns `undefined` cloning @@ -3834,7 +4155,7 @@ body.childNodes.length; ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7711 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8041 "View in source") [Ⓣ][1] Checks if `value` is classified as an `arguments` object. @@ -3859,7 +4180,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8070 "View in source") [Ⓣ][1] Checks if `value` is classified as an `Array` object. @@ -3884,7 +4205,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8090 "View in source") [Ⓣ][1] Checks if `value` is classified as a boolean primitive or object. @@ -3909,7 +4230,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7780 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8110 "View in source") [Ⓣ][1] Checks if `value` is classified as a `Date` object. @@ -3934,7 +4255,7 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7800 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8130 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -3959,7 +4280,7 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7838 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8168 "View in source") [Ⓣ][1] Checks if a value is empty. A value is considered empty unless it is an `arguments` object, array, string, or jQuery-like collection with a length @@ -3995,7 +4316,7 @@ _.isEmpty({ 'a': 1 }); ### `_.isEqual(value, other, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7890 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8221 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent. If `customizer` is provided it is invoked to compare values. @@ -4005,7 +4326,8 @@ arguments; (value, other [, index|key]).

**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Functions and DOM nodes +numbers, `Object` objects, regexes, and strings. Objects are compared by +their own, not inherited, enumerable properties. Functions and DOM nodes are **not** supported. Provide a customizer function to extend support for comparing other values. @@ -4045,7 +4367,7 @@ _.isEqual(array, other, function(value, other) { ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7916 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8247 "View in source") [Ⓣ][1] Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, `SyntaxError`, `TypeError`, or `URIError` object. @@ -4071,7 +4393,7 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7949 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8280 "View in source") [Ⓣ][1] Checks if `value` is a finite primitive number.
@@ -4110,7 +4432,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L7969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8300 "View in source") [Ⓣ][1] Checks if `value` is classified as a `Function` object. @@ -4134,8 +4456,8 @@ _.isFunction(/abc/); -### `_.isMatch(source, source, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8052 "View in source") [Ⓣ][1] +### `_.isMatch(object, source, [customizer], [thisArg])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8383 "View in source") [Ⓣ][1] Performs a deep comparison between `object` and `source` to determine if `object` contains equivalent property values. If `customizer` is provided @@ -4150,7 +4472,7 @@ and DOM nodes are **not** supported. Provide a customizer function to extend support for comparing other values. #### Arguments -1. `source` *(Object)*: The object to inspect. +1. `object` *(Object)*: The object to inspect. 2. `source` *(Object)*: The object of property values to match. 3. `[customizer]` *(Function)*: The function to customize comparing values. 4. `[thisArg]` *(*)*: The `this` binding of `customizer`. @@ -4184,7 +4506,7 @@ _.isMatch(object, source, function(value, other) { ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8432 "View in source") [Ⓣ][1] Checks if `value` is `NaN`.
@@ -4220,7 +4542,7 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8123 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8454 "View in source") [Ⓣ][1] Checks if `value` is a native function. @@ -4245,7 +4567,7 @@ _.isNative(_); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8150 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8481 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -4270,7 +4592,7 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8176 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8507 "View in source") [Ⓣ][1] Checks if `value` is classified as a `Number` primitive or object.
@@ -4302,7 +4624,7 @@ _.isNumber('8.4'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8006 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8337 "View in source") [Ⓣ][1] Checks if `value` is the language type of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) @@ -4334,7 +4656,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8541 "View in source") [Ⓣ][1] Checks if `value` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`. @@ -4374,7 +4696,7 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8238 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8569 "View in source") [Ⓣ][1] Checks if `value` is classified as a `RegExp` object. @@ -4399,7 +4721,7 @@ _.isRegExp('/abc/'); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8589 "View in source") [Ⓣ][1] Checks if `value` is classified as a `String` primitive or object. @@ -4424,7 +4746,7 @@ _.isString(1); ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8609 "View in source") [Ⓣ][1] Checks if `value` is classified as a typed array. @@ -4449,7 +4771,7 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8298 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8629 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -4474,7 +4796,7 @@ _.isUndefined(null); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8315 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8646 "View in source") [Ⓣ][1] Converts `value` to an array. @@ -4496,7 +4818,7 @@ Converts `value` to an array. ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8682 "View in source") [Ⓣ][1] Converts `value` to a plain object flattening inherited enumerable properties of `value` to own properties of the plain object. @@ -4534,7 +4856,7 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); ### `_.random([min=0], [max=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9238 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9586 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` (inclusive). If only one argument is provided a number between `0` and the given number is returned. @@ -4576,7 +4898,7 @@ _.random(1.2, 5.2); ### `_.assign(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8386 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8717 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources overwrite property assignments of previous sources. @@ -4613,7 +4935,7 @@ defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8751 "View in source") [Ⓣ][1] Creates an object that inherits from the given `prototype` object. If a `properties` object is provided its own enumerable properties are assigned @@ -4653,7 +4975,7 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8444 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8775 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a @@ -4678,23 +5000,28 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.findKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8492 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8830 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it returns the key of the first element `predicate` returns truthy for, instead of the element itself.

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `object` *(Object)*: The object to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -4711,11 +5038,15 @@ var users = { _.findKey(users, function(chr) { return chr.age < 40; }); // => 'barney' (iteration order is not guaranteed) -// using the "_.matches" callback shorthand -_.findKey(users, { 'age': 1 }); +// using the `_.matches` callback shorthand +_.findKey(users, { 'age': 1, 'active': true }); // => 'pebbles' -// using the "_.property" callback shorthand +// using the `_.matchesProperty` callback shorthand +_.findKey(users, 'active', false); +// => 'fred' + +// using the `_.property` callback shorthand _.findKey(users, 'active'); // => 'barney' ``` @@ -4726,23 +5057,28 @@ _.findKey(users, 'active'); ### `_.findLastKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8881 "View in source") [Ⓣ][1] This method is like `_.findKey` except that it iterates over elements of a collection in the opposite order.

-If a property name is provided for `predicate` the created "_.property" +If a property name is provided for `predicate` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `predicate` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `object` *(Object)*: The object to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns @@ -4759,11 +5095,15 @@ var users = { _.findLastKey(users, function(chr) { return chr.age < 40; }); // => returns `pebbles` assuming `_.findKey` returns `barney` -// using the "_.matches" callback shorthand -_.findLastKey(users, { 'age': 36 }); +// using the `_.matches` callback shorthand +_.findLastKey(users, { 'age': 36, 'active': true }); // => 'barney' -// using the "_.property" callback shorthand +// using the `_.matchesProperty` callback shorthand +_.findLastKey(users, 'active', false); +// => 'fred' + +// using the `_.property` callback shorthand _.findLastKey(users, 'active'); // => 'pebbles' ``` @@ -4774,7 +5114,7 @@ _.findLastKey(users, 'active'); ### `_.forIn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8913 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of an object invoking `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked @@ -4810,7 +5150,7 @@ _.forIn(new Foo, function(value, key) { ### `_.forInRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8600 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8945 "View in source") [Ⓣ][1] This method is like `_.forIn` except that it iterates over properties of `object` in the opposite order. @@ -4844,7 +5184,7 @@ _.forInRight(new Foo, function(value, key) { ### `_.forOwn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8625 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8970 "View in source") [Ⓣ][1] Iterates over own enumerable properties of an object invoking `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked with @@ -4873,7 +5213,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { ### `_.forOwnRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8995 "View in source") [Ⓣ][1] This method is like `_.forOwn` except that it iterates over properties of `object` in the opposite order. @@ -4900,7 +5240,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9015 "View in source") [Ⓣ][1] Creates an array of function property names from all enumerable properties, own and inherited, of `object`. @@ -4923,7 +5263,7 @@ _.functions(_); ### `_.has(object, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9034 "View in source") [Ⓣ][1] Checks if `key` exists as a direct property of `object` instead of an inherited property. @@ -4947,7 +5287,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object, [multiValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9063 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of `object`. If `object` contains duplicate values, subsequent values overwrite property @@ -4980,7 +5320,7 @@ _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9117 "View in source") [Ⓣ][1] Creates an array of the own enumerable property names of `object`.
@@ -5017,7 +5357,7 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9151 "View in source") [Ⓣ][1] Creates an array of the own and inherited enumerable property names of `object`.
@@ -5049,7 +5389,7 @@ _.keysIn(new Foo); ### `_.mapValues(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8900 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9248 "View in source") [Ⓣ][1] Creates an object with the same keys as `object` and values generated by running each own enumerable property of `object` through `iteratee`. The @@ -5057,17 +5397,22 @@ iteratee function is bound to `thisArg` and invoked with three arguments; (value, key, object).

-If a property name is provided for `iteratee` the created "_.property" +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

-If an object is provided for `iteratee` the created "_.matches" style +If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `iteratee` the created `_.matches` style callback returns `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `object` *(Object)*: The object to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. If a property name or object is provided it is used to create a "_.property" or "_.matches" style callback respectively. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. 3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns @@ -5083,7 +5428,7 @@ var users = { 'pebbles': { 'user': 'pebbles', 'age': 1 } }; -// using the "_.property" callback shorthand +// using the `_.property` callback shorthand _.mapValues(users, 'age'); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) ``` @@ -5094,7 +5439,7 @@ _.mapValues(users, 'age'); ### `_.merge(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8956 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9304 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined` into the destination object. Subsequent sources @@ -5149,7 +5494,7 @@ _.merge(object, other, function(a, b) { ### `_.omit(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L8986 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9334 "View in source") [Ⓣ][1] The opposite of `_.pick`; this method creates an object composed of the own and inherited enumerable properties of `object` that are not omitted. @@ -5184,7 +5529,7 @@ _.omit(object, _.isNumber); ### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9014 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9362 "View in source") [Ⓣ][1] Creates a two dimensional array of the key-value pairs for `object`, e.g. `[[key1, value1], [key2, value2]]`. @@ -5207,7 +5552,7 @@ _.pairs({ 'barney': 36, 'fred': 40 }); ### `_.pick(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9053 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9401 "View in source") [Ⓣ][1] Creates an object composed of the picked `object` properties. Property names may be specified as individual arguments or as arrays of property @@ -5240,7 +5585,7 @@ _.pick(object, _.isString); ### `_.result(object, key, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9092 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9440 "View in source") [Ⓣ][1] Resolves the value of property `key` on `object`. If the value of `key` is a function it is invoked with the `this` binding of `object` and its result @@ -5278,7 +5623,7 @@ _.result(object, 'status', _.constant('busy')); ### `_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9131 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9479 "View in source") [Ⓣ][1] An alternative to `_.reduce`; this method transforms `object` to a new `accumulator` object which is the result of running each of its own enumerable @@ -5318,7 +5663,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9526 "View in source") [Ⓣ][1] Creates an array of the own enumerable property values of `object`.
@@ -5353,7 +5698,7 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9553 "View in source") [Ⓣ][1] Creates an array of the own and inherited enumerable property values of `object`. @@ -5392,7 +5737,7 @@ _.valuesIn(new Foo); ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9643 "View in source") [Ⓣ][1] Converts `string` to camel case. See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details. @@ -5421,7 +5766,7 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9661 "View in source") [Ⓣ][1] Capitalizes the first character of `string`. @@ -5443,7 +5788,7 @@ _.capitalize('fred'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9681 "View in source") [Ⓣ][1] Deburrs `string` by converting latin-1 supplementary letters to basic latin letters. See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) @@ -5467,7 +5812,7 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9359 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9707 "View in source") [Ⓣ][1] Checks if `string` ends with the given target string. @@ -5497,7 +5842,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9748 "View in source") [Ⓣ][1] Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to their corresponding HTML entities. @@ -5542,7 +5887,7 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9422 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9770 "View in source") [Ⓣ][1] Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. @@ -5565,7 +5910,7 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9798 "View in source") [Ⓣ][1] Converts `string` to kebab case (a.k.a. spinal case). See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for @@ -5595,7 +5940,7 @@ _.kebabCase('__foo_bar__'); ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9825 "View in source") [Ⓣ][1] Pads `string` on the left and right sides if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -5627,7 +5972,7 @@ _.pad('abc', 3); ### `_.padLeft([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9516 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9864 "View in source") [Ⓣ][1] Pads `string` on the left side if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -5659,7 +6004,7 @@ _.padLeft('abc', 3); ### `_.padRight([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9892 "View in source") [Ⓣ][1] Pads `string` on the right side if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -5691,7 +6036,7 @@ _.padRight('abc', 3); ### `_.parseInt(string, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9572 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9920 "View in source") [Ⓣ][1] Converts `string` to an integer of the specified radix. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, @@ -5723,7 +6068,7 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9962 "View in source") [Ⓣ][1] Repeats the given string `n` times. @@ -5752,7 +6097,7 @@ _.repeat('abc', 0); ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9654 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10002 "View in source") [Ⓣ][1] Converts `string` to snake case. See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. @@ -5781,7 +6126,7 @@ _.snakeCase('--foo-bar'); ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9679 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10027 "View in source") [Ⓣ][1] Converts `string` to start case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) @@ -5811,7 +6156,7 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9704 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10052 "View in source") [Ⓣ][1] Checks if `string` starts with the given target string. @@ -5841,7 +6186,7 @@ _.startsWith('abc', 'b', 1); ### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10154 "View in source") [Ⓣ][1] Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, HTML-escape interpolated data properties in @@ -5948,7 +6293,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10281 "View in source") [Ⓣ][1] Removes leading and trailing whitespace or specified characters from `string`. @@ -5977,7 +6322,7 @@ _.map([' foo ', ' bar '], _.trim); ### `_.trimLeft([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10312 "View in source") [Ⓣ][1] Removes leading whitespace or specified characters from `string`. @@ -6003,7 +6348,7 @@ _.trimLeft('-_-abc-_-', '_-'); ### `_.trimRight([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L9994 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10342 "View in source") [Ⓣ][1] Removes trailing whitespace or specified characters from `string`. @@ -6029,7 +6374,7 @@ _.trimRight('-_-abc-_-', '_-'); ### `_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10038 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10386 "View in source") [Ⓣ][1] Truncates `string` if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the omission @@ -6069,7 +6414,7 @@ _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10108 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10456 "View in source") [Ⓣ][1] The inverse of `_.escape`; this method converts the HTML entities `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their @@ -6097,7 +6442,7 @@ _.unescape('fred, barney, & pebbles'); ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10133 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10481 "View in source") [Ⓣ][1] Splits `string` into an array of its words. @@ -6129,10 +6474,10 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); ### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10511 "View in source") [Ⓣ][1] -Attempts to invoke `func`, returning either the result or the caught -error object. +Attempts to invoke `func`, returning either the result or the caught error +object. Any additional arguments are provided to `func` when it is invoked. #### Arguments 1. `func` *(*)*: The function to attempt. @@ -6143,9 +6488,9 @@ error object. #### Example ```js // avoid throwing errors for invalid selectors -var elements = _.attempt(function() { +var elements = _.attempt(function(selector) { return document.querySelectorAll(selector); -}); +}, '>_>'); if (_.isError(elements)) { elements = []; @@ -6158,12 +6503,13 @@ if (_.isError(elements)) { ### `_.callback([func=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10555 "View in source") [Ⓣ][1] -Creates a function bound to an optional `thisArg`. If `func` is a property -name the created callback returns the property value for a given element. -If `func` is an object the created callback returns `true` for elements -that contain the equivalent object properties, otherwise it returns `false`. +Creates a function that invokes `func` with the `this` binding of `thisArg` +and arguments of the created function. If `func` is a property name the +created callback returns the property value for a given element. If `func` +is an object the created callback returns `true` for elements that contain +the equivalent object properties, otherwise it returns `false`. #### Arguments 1. `[func=_.identity]` *(*)*: The value to convert to a callback. @@ -6200,7 +6546,7 @@ _.filter(users, 'age__gt36'); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10230 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10579 "View in source") [Ⓣ][1] Creates a function that returns `value`. @@ -6224,7 +6570,7 @@ getter() === object; ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10599 "View in source") [Ⓣ][1] This method returns the first argument provided to it. @@ -6247,11 +6593,17 @@ _.identity(object) === object; ### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10628 "View in source") [Ⓣ][1] Creates a function which performs a deep comparison between a given object and `source`, returning `true` if the given object has equivalent property values, else `false`. +
+
+**Note:** This method supports comparing arrays, booleans, `Date` objects, +numbers, `Object` objects, regexes, and strings. Objects are compared by +their own, not inherited, enumerable properties. For comparing a single +own or inherited property value see `_.matchesProperty`. #### Arguments 1. `source` *(Object)*: The object of property values to match. @@ -6262,17 +6614,47 @@ values, else `false`. #### Example ```js var users = [ - { 'user': 'fred', 'age': 40 }, - { 'user': 'barney', 'age': 36 } + { 'user': 'barney', 'age': 36, 'active': true }, + { 'user': 'fred', 'age': 40, 'active': false } ]; -var matchesAge = _.matches({ 'age': 36 }); +_.filter(users, _.matches({ 'age': 40, 'active': false })); +// => [{ 'user': 'fred', 'age': 40, 'active': false }] +``` +* * * -_.filter(users, matchesAge); -// => [{ 'user': 'barney', 'age': 36 }] + -_.find(users, matchesAge); -// => { 'user': 'barney', 'age': 36 } + + +### `_.matchesProperty(key, value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10657 "View in source") [Ⓣ][1] + +Creates a function which compares the property value of `key` on a given +object to `value`. +
+
+**Note:** This method supports comparing arrays, booleans, `Date` objects, +numbers, `Object` objects, regexes, and strings. Objects are compared by +their own, not inherited, enumerable properties. + +#### Arguments +1. `key` *(string)*: The key of the property to get. +2. `value` *(*)*: The value to compare. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var users = [ + { 'user': 'barney' }, + { 'user': 'fred' }, + { 'user': 'pebbles' } +]; + +_.find(users, _.matchesProperty('user', 'fred')); +// => { 'user': 'fred', 'age': 40 } ``` * * * @@ -6281,7 +6663,7 @@ _.find(users, matchesAge); ### `_.mixin([object=this], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10697 "View in source") [Ⓣ][1] Adds all own enumerable function properties of a source object to the destination object. If `object` is a function then methods are added to @@ -6304,6 +6686,9 @@ function vowels(string) { }); } +// use `_.runInContext` to avoid potential conflicts (esp. in Node.js) +var _ = require('lodash').runInContext(); + _.mixin({ 'vowels': vowels }); _.vowels('fred'); // => ['e'] @@ -6322,7 +6707,7 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10760 "View in source") [Ⓣ][1] Reverts the `_` variable to its previous value and returns a reference to the `lodash` function. @@ -6341,7 +6726,7 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10777 "View in source") [Ⓣ][1] A no-operation function. @@ -6358,7 +6743,7 @@ _.noop(object) === undefined; ### `_.property(key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10804 "View in source") [Ⓣ][1] Creates a function which returns the property value of `key` on a given object. @@ -6390,7 +6775,7 @@ _.pluck(_.sortBy(users, getName), 'user'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10827 "View in source") [Ⓣ][1] The inverse of `_.property`; this method creates a function which returns the property value of a given key on `object`. @@ -6418,7 +6803,7 @@ _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10484 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10865 "View in source") [Ⓣ][1] Creates an array of numbers (positive and/or negative) progressing from `start` up to, but not including, `end`. If `start` is less than `end` a @@ -6459,7 +6844,7 @@ _.range(0); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L689 "View in source") [Ⓣ][1] Create a new pristine `lodash` function using the given `context` object. @@ -6503,7 +6888,7 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; ### `_.times(n, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10533 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10914 "View in source") [Ⓣ][1] Invokes the iteratee function `n` times, returning an array of the results of each invocation. The `iteratee` is bound to `thisArg` and invoked with @@ -6535,7 +6920,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10571 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10952 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is provided the ID is appended to it. @@ -6566,7 +6951,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1164 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -6583,7 +6968,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L10832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L11220 "View in source") [Ⓣ][1] (string): The semantic version number. @@ -6594,7 +6979,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L953 "View in source") [Ⓣ][1] (Object): An object environment feature flags. @@ -6605,7 +6990,7 @@ A reference to the `lodash` function. ### `_.support.argsTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L970 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of `arguments` objects is resolvable (all but Firefox < 4, IE < 9). @@ -6617,7 +7002,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L978 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L979 "View in source") [Ⓣ][1] (boolean): Detect if `name` or `message` properties of `Error.prototype` are enumerable by default (IE < 9, Safari < 5.1). @@ -6629,7 +7014,7 @@ enumerable by default (IE < 9, Safari < 5.1). ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L992 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L993 "View in source") [Ⓣ][1] (boolean): Detect if `prototype` properties are enumerable by default.
@@ -6646,7 +7031,7 @@ property to `true`. ### `_.support.funcDecomp` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1002 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1003 "View in source") [Ⓣ][1] (boolean): Detect if functions can be decompiled by `Function#toString` (all but Firefox OS certified apps, older Opera mobile browsers, and @@ -6659,7 +7044,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.funcNames` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1010 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1011 "View in source") [Ⓣ][1] (boolean): Detect if `Function#name` is supported (all but IE). @@ -6670,7 +7055,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nodeTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1019 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9). @@ -6681,7 +7066,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1039 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1040 "View in source") [Ⓣ][1] (boolean): Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -6697,7 +7082,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.nonEnumStrings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1028 "View in source") [Ⓣ][1] (boolean): Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal). @@ -6709,7 +7094,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1048 "View in source") [Ⓣ][1] (boolean): Detect if own properties are iterated after inherited properties (IE < 9). @@ -6720,7 +7105,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1063 "View in source") [Ⓣ][1] (boolean): Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -6739,7 +7124,7 @@ is buggy regardless of mode in IE < 9. ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1074 "View in source") [Ⓣ][1] (boolean): Detect lack of support for accessing string characters by index.
@@ -6754,7 +7139,7 @@ by index on string literals, not string objects. ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1116 "View in source") [Ⓣ][1] (Object): By default, the template delimiters used by lodash are like those in embedded Ruby (ERB). Change the following template settings to use @@ -6767,7 +7152,7 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1123 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1124 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to be HTML-escaped. @@ -6778,7 +7163,7 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1131 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1132 "View in source") [Ⓣ][1] (RegExp): Used to detect code to be evaluated. @@ -6789,7 +7174,7 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1156 "View in source") [Ⓣ][1] (Object): Used to import variables into the compiled template. @@ -6800,7 +7185,7 @@ alternative delimiters. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1139 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1140 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to inject. @@ -6811,7 +7196,7 @@ alternative delimiters. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.1.0/lodash.src.js#L1147 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1148 "View in source") [Ⓣ][1] (string): Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 052424f99..40ab9b793 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.1.0 (Custom Build) + * lodash 3.2.0 (Custom Build) * Build: `lodash modern -o ./lodash.js` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.7.0 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.1.0'; + var VERSION = '3.2.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -798,12 +798,13 @@ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, * and `unshift` * - * The wrapper functions that support shortcut fusion are: - * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`, - * `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`, - * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where` + * The wrapper methods that support shortcut fusion are: + * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, + * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, + * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, + * and `where` * - * The chainable wrapper functions are: + * The chainable wrapper methods are: * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, @@ -811,8 +812,8 @@ * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, - * `keysIn`, `map`, `mapValues`, `matches`, `memoize`, `merge`, `mixin`, - * `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, + * `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, + * `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, @@ -821,7 +822,7 @@ * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, * `zip`, and `zipObject` * - * The wrapper functions that are **not** chainable by default are: + * The wrapper methods that are **not** chainable by default are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, @@ -836,7 +837,7 @@ * `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, * `trunc`, `unescape`, `uniqueId`, `value`, and `words` * - * The wrapper function `sample` will return a wrapped value when `n` is provided, + * The wrapper method `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. * * @name _ @@ -1091,7 +1092,7 @@ end = view.end, length = end - start, dropCount = this.__dropCount__, - takeCount = nativeMin(length, this.__takeCount__ - dropCount), + takeCount = nativeMin(length, this.__takeCount__), index = isRight ? end : start - 1, iteratees = this.__iteratees__, iterLength = iteratees ? iteratees.length : 0, @@ -1538,7 +1539,7 @@ return baseCopy(source, object, props); } var index = -1, - length = props.length + length = props.length; while (++index < length) { var key = props[index], @@ -1645,10 +1646,12 @@ if (func == null) { return identity; } - // Handle "_.property" and "_.matches" style callback shorthands. - return type == 'object' - ? baseMatches(func) - : baseProperty(func + ''); + if (type == 'object') { + return baseMatches(func); + } + return typeof thisArg == 'undefined' + ? baseProperty(func + '') + : baseMatchesProperty(func + '', thisArg); } /** @@ -2293,8 +2296,7 @@ } /** - * The base implementation of `_.matches` which supports specifying whether - * `source` should be cloned. + * The base implementation of `_.matches` which does not clone `source`. * * @private * @param {Object} source The object of property values to match. @@ -2310,7 +2312,7 @@ if (isStrictComparable(value)) { return function(object) { - return object != null && value === object[key] && hasOwnProperty.call(object, key); + return object != null && object[key] === value && hasOwnProperty.call(object, key); }; } } @@ -2327,6 +2329,26 @@ }; } + /** + * The base implementation of `_.matchesProperty` which does not coerce `key` + * to a string. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} value The value to compare. + * @returns {Function} Returns the new function. + */ + function baseMatchesProperty(key, value) { + if (isStrictComparable(value)) { + return function(object) { + return object != null && object[key] === value; + }; + } + return function(object) { + return object != null && baseIsEqual(value, object[key], null, true); + }; + } + /** * The base implementation of `_.merge` without support for argument juggling, * multiple sources, and `this` binding `customizer` functions. @@ -2489,7 +2511,7 @@ eachFunc(collection, function(value, index, collection) { accumulator = initFromCollection ? (initFromCollection = false, value) - : iteratee(accumulator, value, index, collection) + : iteratee(accumulator, value, index, collection); }); return accumulator; } @@ -2865,8 +2887,7 @@ /** * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection - * through an iteratee. The `setter` sets the keys and values of the accumulator - * object. If `initializer` is provided initializes the accumulator object. + * through an iteratee. * * @private * @param {Function} setter The function to set keys and values of the accumulator object. @@ -4113,11 +4134,15 @@ * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style - * callback returns `true` for elements that have the properties of the given + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that match the properties of the given * object, else `false`. * * @static @@ -4125,7 +4150,7 @@ * @category Array * @param {Array} array The array to query. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per element. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the slice of `array`. * @example @@ -4134,18 +4159,22 @@ * // => [1] * * var users = [ - * { 'user': 'barney', 'status': 'busy', 'active': false }, - * { 'user': 'fred', 'status': 'busy', 'active': true }, - * { 'user': 'pebbles', 'status': 'away', 'active': true } + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.dropRightWhile(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user'); + * // => ['barney', 'fred'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active', false), 'user'); * // => ['barney'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user'); - * // => ['barney', 'fred'] + * // using the `_.property` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] */ function dropRightWhile(array, predicate, thisArg) { var length = array ? array.length : 0; @@ -4162,10 +4191,14 @@ * Elements are dropped until `predicate` returns falsey. The predicate is * bound to `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4174,7 +4207,7 @@ * @category Array * @param {Array} array The array to query. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per element. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the slice of `array`. * @example @@ -4183,18 +4216,22 @@ * // => [3] * * var users = [ - * { 'user': 'barney', 'status': 'busy', 'active': true }, - * { 'user': 'fred', 'status': 'busy', 'active': false }, - * { 'user': 'pebbles', 'status': 'away', 'active': true } + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.dropWhile(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); * // => ['fred', 'pebbles'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user'); + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropWhile(users, 'active', false), 'user'); * // => ['pebbles'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.dropWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] */ function dropWhile(array, predicate, thisArg) { var length = array ? array.length : 0; @@ -4213,7 +4250,9 @@ * * **Note:** This method mutates `array`. * - * @private + * @static + * @memberOf _ + * @category Array * @param {Array} array The array to fill. * @param {*} value The value to fill `array` with. * @param {number} [start=0] The start position. @@ -4236,10 +4275,14 @@ * This method is like `_.find` except that it returns the index of the first * element `predicate` returns truthy for, instead of the element itself. * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4248,28 +4291,31 @@ * @category Array * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } * ]; * - * _.findIndex(users, function(chr) { return chr.age < 40; }); + * _.findIndex(users, function(chr) { return chr.user == 'barney'; }); * // => 0 * - * // using the "_.matches" callback shorthand - * _.findIndex(users, { 'age': 1 }); - * // => 2 - * - * // using the "_.property" callback shorthand - * _.findIndex(users, 'active'); + * // using the `_.matches` callback shorthand + * _.findIndex(users, { 'user': 'fred', 'active': false }); * // => 1 + * + * // using the `_.matchesProperty` callback shorthand + * _.findIndex(users, 'active', false); + * // => 0 + * + * // using the `_.property` callback shorthand + * _.findIndex(users, 'active'); + * // => 2 */ function findIndex(array, predicate, thisArg) { var index = -1, @@ -4288,10 +4334,14 @@ * This method is like `_.findIndex` except that it iterates over elements * of `collection` from right to left. * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4300,26 +4350,29 @@ * @category Array * @param {Array} array The array to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {number} Returns the index of the found element, else `-1`. * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': false } + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } * ]; * - * _.findLastIndex(users, function(chr) { return chr.age < 40; }); + * _.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; }); * // => 2 * - * // using the "_.matches" callback shorthand - * _.findLastIndex(users, { 'age': 40 }); + * // using the `_.matches` callback shorthand + * _.findLastIndex(users, { user': 'barney', 'active': true }); + * // => 0 + * + * // using the `_.matchesProperty` callback shorthand + * _.findLastIndex(users, 'active', false); * // => 1 * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.findLastIndex(users, 'active'); * // => 0 */ @@ -4671,10 +4724,14 @@ * and returns an array of the removed elements. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4685,8 +4742,7 @@ * @category Array * @param {Array} array The array to modify. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new array of removed elements. * @example @@ -4768,10 +4824,14 @@ * to compute their sort ranking. The iteratee is bound to `thisArg` and * invoked with one argument; (value). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4781,8 +4841,7 @@ * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. @@ -4802,7 +4861,7 @@ * }, dict); * // => 1 * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ @@ -4824,8 +4883,7 @@ * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. @@ -4917,10 +4975,14 @@ * taken until `predicate` returns falsey. The predicate is bound to `thisArg` * and invoked with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4929,7 +4991,7 @@ * @category Array * @param {Array} array The array to query. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per element. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the slice of `array`. * @example @@ -4938,18 +5000,22 @@ * // => [2, 3] * * var users = [ - * { 'user': 'barney', 'status': 'busy', 'active': false }, - * { 'user': 'fred', 'status': 'busy', 'active': true }, - * { 'user': 'pebbles', 'status': 'away', 'active': true } + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.takeRightWhile(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); + * // => ['pebbles'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active', false), 'user'); * // => ['fred', 'pebbles'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.takeRightWhile(users, { 'status': 'away' }), 'user'); - * // => ['pebbles'] + * // using the `_.property` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active'), 'user'); + * // => [] */ function takeRightWhile(array, predicate, thisArg) { var length = array ? array.length : 0; @@ -4966,10 +5032,14 @@ * are taken until `predicate` returns falsey. The predicate is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -4978,7 +5048,7 @@ * @category Array * @param {Array} array The array to query. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per element. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the slice of `array`. * @example @@ -4987,18 +5057,22 @@ * // => [1, 2] * * var users = [ - * { 'user': 'barney', 'status': 'busy', 'active': true }, - * { 'user': 'fred', 'status': 'busy', 'active': false }, - * { 'user': 'pebbles', 'status': 'away', 'active': true } + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false}, + * { 'user': 'pebbles', 'active': true } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.takeWhile(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); * // => ['barney'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.takeWhile(users, { 'status': 'busy' }), 'user'); + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeWhile(users, 'active', false), 'user'); * // => ['barney', 'fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.takeWhile(users, 'active'), 'user'); + * // => [] */ function takeWhile(array, predicate, thisArg) { var length = array ? array.length : 0; @@ -5042,10 +5116,14 @@ * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, index, array). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5061,8 +5139,6 @@ * @param {Array} array The array to inspect. * @param {boolean} [isSorted] Specify the array is sorted. * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * If a property name or object is provided it is used to create a "_.property" - * or "_.matches" style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new duplicate-value-free array. * @example @@ -5078,7 +5154,7 @@ * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); * // => [1, 2.5] * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ @@ -5384,7 +5460,7 @@ * // => [1, 2, 3] */ function wrapperCommit() { - return new LodashWrapper(this.value()); + return new LodashWrapper(this.value(), this.__chain__); } /** @@ -5397,7 +5473,9 @@ * @example * * var array = [1, 2]; - * var wrapper = _(array).map(_.partial(Math.pow, _, 2)); + * var wrapper = _(array).map(function(value) { + * return Math.pow(value, 2); + * }); * * var other = [3, 4]; * var otherWrapper = wrapper.plant(other); @@ -5452,7 +5530,7 @@ if (this.__actions__.length) { value = new LazyWrapper(this); } - return new LodashWrapper(value.reverse()); + return new LodashWrapper(value.reverse(), this.__chain__); } return this.thru(function(value) { return value.reverse(); @@ -5580,10 +5658,14 @@ * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5592,8 +5674,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example @@ -5616,10 +5697,14 @@ * The predicate is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5629,27 +5714,30 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. * @example * - * _.every([true, 1, null, 'yes']); + * _.every([true, 1, null, 'yes'], Boolean); * // => false * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false } * ]; * - * // using the "_.property" callback shorthand - * _.every(users, 'age'); + * // using the `_.matches` callback shorthand + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.every(users, 'active', false); * // => true * - * // using the "_.matches" callback shorthand - * _.every(users, { 'age': 36 }); + * // using the `_.property` callback shorthand + * _.every(users, 'active'); * // => false */ function every(collection, predicate, thisArg) { @@ -5665,10 +5753,14 @@ * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5678,8 +5770,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example @@ -5688,16 +5779,20 @@ * // => [2, 4] * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.filter(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.filter(users, 'active', false), 'user'); * // => ['fred'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.filter(users, { 'age': 36 }), 'user'); + * // using the `_.property` callback shorthand + * _.pluck(_.filter(users, 'active'), 'user'); * // => ['barney'] */ function filter(collection, predicate, thisArg) { @@ -5711,10 +5806,14 @@ * `predicate` returns truthy for. The predicate is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5724,28 +5823,31 @@ * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * * _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user'); * // => 'barney' * - * // using the "_.matches" callback shorthand - * _.result(_.find(users, { 'age': 1 }), 'user'); + * // using the `_.matches` callback shorthand + * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); * // => 'pebbles' * - * // using the "_.property" callback shorthand - * _.result(_.find(users, 'active'), 'user'); + * // using the `_.matchesProperty` callback shorthand + * _.result(_.find(users, 'active', false), 'user'); * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.result(_.find(users, 'active'), 'user'); + * // => 'barney' */ function find(collection, predicate, thisArg) { if (isArray(collection)) { @@ -5765,8 +5867,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -5784,6 +5885,11 @@ * source object, returning the first element that has equivalent property * values. * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * * @static * @memberOf _ * @category Collection @@ -5793,14 +5899,14 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'status': 'busy' }, - * { 'user': 'fred', 'age': 40, 'status': 'busy' } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * _.result(_.findWhere(users, { 'status': 'busy' }), 'user'); + * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); * // => 'barney' * - * _.result(_.findWhere(users, { 'age': 40 }), 'user'); + * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); * // => 'fred' */ function findWhere(collection, source) { @@ -5869,10 +5975,14 @@ * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5881,8 +5991,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example @@ -5893,7 +6002,7 @@ * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ @@ -5912,10 +6021,14 @@ * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -5924,8 +6037,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example @@ -5979,21 +6091,34 @@ * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * + * Many lodash methods are guarded to work as interatees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, + * `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`, + * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, + * `trunc`, `random`, `range`, `sample`, `uniq`, and `words` + * * @static * @memberOf _ * @alias collect * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. + * create a `_.property` or `_.matches` style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new mapped array. * @example @@ -6009,7 +6134,7 @@ * { 'user': 'fred' } * ]; * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.map(users, 'user'); * // => ['barney', 'fred'] */ @@ -6026,10 +6151,14 @@ * is ranked. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6038,8 +6167,6 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * If a property name or object is provided it is used to create a "_.property" - * or "_.matches" style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the maximum value. * @example @@ -6058,7 +6185,7 @@ * _.max(users, function(chr) { return chr.age; }); * // => { 'user': 'fred', 'age': 40 }; * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.max(users, 'age'); * // => { 'user': 'fred', 'age': 40 }; */ @@ -6071,10 +6198,14 @@ * is ranked. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6083,8 +6214,6 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * If a property name or object is provided it is used to create a "_.property" - * or "_.matches" style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the minimum value. * @example @@ -6103,7 +6232,7 @@ * _.min(users, function(chr) { return chr.age; }); * // => { 'user': 'barney', 'age': 36 }; * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.min(users, 'age'); * // => { 'user': 'barney', 'age': 36 }; */ @@ -6115,10 +6244,14 @@ * contains elements `predicate` returns falsey for. The predicate is bound * to `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6127,8 +6260,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the array of grouped elements. * @example @@ -6145,12 +6277,18 @@ * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * - * // using the "_.matches" callback shorthand - * _.map(_.partition(users, { 'age': 1 }), function(array) { return _.pluck(array, 'user'); }); + * var mapper = function(array) { return _.pluck(array, 'user'); }; + * + * // using the `_.matches` callback shorthand + * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); * // => [['pebbles'], ['barney', 'fred']] * - * // using the "_.property" callback shorthand - * _.map(_.partition(users, 'active'), function(array) { return _.pluck(array, 'user'); }); + * // using the `_.matchesProperty` callback shorthand + * _.map(_.partition(users, 'active', false), mapper); + * // => [['barney', 'pebbles'], ['fred']] + * + * // using the `_.property` callback shorthand + * _.map(_.partition(users, 'active'), mapper); * // => [['fred'], ['barney', 'pebbles']] */ var partition = createAggregator(function(result, value, key) { @@ -6181,7 +6319,7 @@ * // => [36, 40] (iteration order is not guaranteed) */ function pluck(collection, key) { - return map(collection, baseProperty(key + '')); + return map(collection, baseProperty(key)); } /** @@ -6192,6 +6330,12 @@ * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * + * Many lodash methods are guarded to work as interatees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `merge`, and `sortAllBy` + * * @static * @memberOf _ * @alias foldl, inject @@ -6245,10 +6389,14 @@ * The opposite of `_.filter`; this method returns the elements of `collection` * that `predicate` does **not** return truthy for. * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6257,8 +6405,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {Array} Returns the new filtered array. * @example @@ -6271,13 +6418,17 @@ * { 'user': 'fred', 'age': 40, 'active': true } * ]; * - * // using the "_.property" callback shorthand - * _.pluck(_.reject(users, 'active'), 'user'); + * // using the `_.matches` callback shorthand + * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); * // => ['barney'] * - * // using the "_.matches" callback shorthand - * _.pluck(_.reject(users, { 'age': 36 }), 'user'); + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.reject(users, 'active', false), 'user'); * // => ['fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.reject(users, 'active'), 'user'); + * // => ['barney'] */ function reject(collection, predicate, thisArg) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -6379,10 +6530,14 @@ * over the entire collection. The predicate is bound to `thisArg` and invoked * with three arguments; (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6392,8 +6547,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. @@ -6403,17 +6557,21 @@ * // => true * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } * ]; * - * // using the "_.property" callback shorthand - * _.some(users, 'active'); + * // using the `_.matches` callback shorthand + * _.some(users, { user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.some(users, 'active', false); * // => true * - * // using the "_.matches" callback shorthand - * _.some(users, { 'age': 1 }); - * // => false + * // using the `_.property` callback shorthand + * _.some(users, 'active'); + * // => true */ function some(collection, predicate, thisArg) { var func = isArray(collection) ? arraySome : baseSome; @@ -6430,10 +6588,14 @@ * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -6443,7 +6605,7 @@ * @param {Array|Object|string} collection The collection to iterate over. * @param {Array|Function|Object|string} [iteratee=_.identity] The function * invoked per iteration. If a property name or an object is provided it is - * used to create a "_.property" or "_.matches" style callback respectively. + * used to create a `_.property` or `_.matches` style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example @@ -6460,7 +6622,7 @@ * { 'user': 'barney' } * ]; * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.pluck(_.sortBy(users, 'user'), 'user'); * // => ['barney', 'fred', 'pebbles'] */ @@ -6512,7 +6674,7 @@ props = baseFlatten(args, false, false, 1), result = isLength(length) ? Array(length) : []; - baseEach(collection, function(value, key, collection) { + baseEach(collection, function(value) { var length = props.length, criteria = Array(length); @@ -6529,6 +6691,11 @@ * source object, returning an array of all elements that have equivalent * property values. * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * * @static * @memberOf _ * @category Collection @@ -6538,18 +6705,15 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'status': 'busy', 'pets': ['hoppy'] }, - * { 'user': 'fred', 'age': 40, 'status': 'busy', 'pets': ['baby puss', 'dino'] } + * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, + * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } * ]; * - * _.pluck(_.where(users, { 'age': 36 }), 'user'); + * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); * // => ['barney'] * * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); * // => ['fred'] - * - * _.pluck(_.where(users, { 'status': 'busy' }), 'user'); - * // => ['barney', 'fred'] */ function where(collection, source) { return filter(collection, baseMatches(source)); @@ -7442,15 +7606,14 @@ } /** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and the array of arguments provided to the created function much like - * [Function#apply](http://es5.github.io/#x15.3.4.3). + * Creates a function that invokes `func` with the `this` binding of the + * created function and the array of arguments provided to the created + * function much like [Function#apply](http://es5.github.io/#x15.3.4.3). * * @static * @memberOf _ * @category Function - * @param {Function} The function to spread arguments over. - * @param {*} [thisArg] The `this` binding of `func`. + * @param {Function} func The function to spread arguments over. * @returns {*} Returns the new function. * @example * @@ -7467,19 +7630,17 @@ * Promise.resolve(36) * ]); * - * var add = function(x, y) { + * numbers.then(_.spread(function(x, y) { * return x + y; - * }; - * - * numbers.then(_.spread(add)); + * })); * // => a Promise of 76 */ - function spread(func, thisArg) { + function spread(func) { if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } return function(array) { - return func.apply(thisArg, array); + return func.apply(this, array); }; } @@ -7831,7 +7992,8 @@ * arguments; (value, other [, index|key]). * * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. Functions and DOM nodes * are **not** supported. Provide a customizer function to extend support * for comparing other values. * @@ -8427,10 +8589,14 @@ * This method is like `_.findIndex` except that it returns the key of the * first element `predicate` returns truthy for, instead of the element itself. * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -8439,8 +8605,7 @@ * @category Object * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -8454,11 +8619,15 @@ * _.findKey(users, function(chr) { return chr.age < 40; }); * // => 'barney' (iteration order is not guaranteed) * - * // using the "_.matches" callback shorthand - * _.findKey(users, { 'age': 1 }); + * // using the `_.matches` callback shorthand + * _.findKey(users, { 'age': 1, 'active': true }); * // => 'pebbles' * - * // using the "_.property" callback shorthand + * // using the `_.matchesProperty` callback shorthand + * _.findKey(users, 'active', false); + * // => 'fred' + * + * // using the `_.property` callback shorthand * _.findKey(users, 'active'); * // => 'barney' */ @@ -8471,10 +8640,14 @@ * This method is like `_.findKey` except that it iterates over elements of * a collection in the opposite order. * - * If a property name is provided for `predicate` the created "_.property" + * If a property name is provided for `predicate` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `predicate` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -8483,8 +8656,7 @@ * @category Object * @param {Object} object The object to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `predicate`. * @returns {string|undefined} Returns the key of the matched element, else `undefined`. * @example @@ -8498,11 +8670,15 @@ * _.findLastKey(users, function(chr) { return chr.age < 40; }); * // => returns `pebbles` assuming `_.findKey` returns `barney` * - * // using the "_.matches" callback shorthand - * _.findLastKey(users, { 'age': 36 }); + * // using the `_.matches` callback shorthand + * _.findLastKey(users, { 'age': 36, 'active': true }); * // => 'barney' * - * // using the "_.property" callback shorthand + * // using the `_.matchesProperty` callback shorthand + * _.findLastKey(users, 'active', false); + * // => 'fred' + * + * // using the `_.property` callback shorthand * _.findLastKey(users, 'active'); * // => 'pebbles' */ @@ -8811,10 +8987,14 @@ * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, key, object). * - * If a property name is provided for `iteratee` the created "_.property" + * If a property name is provided for `iteratee` the created `_.property` * style callback returns the property value of the given element. * - * If an object is provided for `iteratee` the created "_.matches" style + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style * callback returns `true` for elements that have the properties of the given * object, else `false`. * @@ -8823,8 +9003,7 @@ * @category Object * @param {Object} object The object to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. If a property name or object is provided it is used to - * create a "_.property" or "_.matches" style callback respectively. + * per iteration. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the new mapped object. * @example @@ -8837,7 +9016,7 @@ * 'pebbles': { 'user': 'pebbles', 'age': 1 } * }; * - * // using the "_.property" callback shorthand + * // using the `_.property` callback shorthand * _.mapValues(users, 'age'); * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) */ @@ -9912,7 +10091,7 @@ return string; } if (guard ? isIterateeCall(value, chars, guard) : chars == null) { - return string.slice(trimmedLeftIndex(string)) + return string.slice(trimmedLeftIndex(string)); } return string.slice(charsLeftIndex(string, (chars + ''))); } @@ -9942,7 +10121,7 @@ return string; } if (guard ? isIterateeCall(value, chars, guard) : chars == null) { - return string.slice(0, trimmedRightIndex(string) + 1) + return string.slice(0, trimmedRightIndex(string) + 1); } return string.slice(0, charsRightIndex(string, (chars + '')) + 1); } @@ -10108,7 +10287,7 @@ try { return func.apply(undefined, baseSlice(arguments, 1)); } catch(e) { - return isError(e) ? e : Error(e); + return isError(e) ? e : new Error(e); } } @@ -10201,6 +10380,11 @@ * and `source`, returning `true` if the given object has equivalent property * values, else `false`. * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * * @static * @memberOf _ * @category Utility @@ -10209,22 +10393,46 @@ * @example * * var users = [ - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * var matchesAge = _.matches({ 'age': 36 }); - * - * _.filter(users, matchesAge); - * // => [{ 'user': 'barney', 'age': 36 }] - * - * _.find(users, matchesAge); - * // => { 'user': 'barney', 'age': 36 } + * _.filter(users, _.matches({ 'age': 40, 'active': false })); + * // => [{ 'user': 'fred', 'age': 40, 'active': false }] */ function matches(source) { return baseMatches(baseClone(source, true)); } + /** + * Creates a function which compares the property value of `key` on a given + * object to `value`. + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. + * + * @static + * @memberOf _ + * @category Utility + * @param {string} key The key of the property to get. + * @param {*} value The value to compare. + * @returns {Function} Returns the new function. + * @example + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' }, + * { 'user': 'pebbles' } + * ]; + * + * _.find(users, _.matchesProperty('user', 'fred')); + * // => { 'user': 'fred', 'age': 40 } + */ + function matchesProperty(key, value) { + return baseMatchesProperty(key + '', baseClone(value, true)); + } + /** * Adds all own enumerable function properties of a source object to the * destination object. If `object` is a function then methods are added to @@ -10593,6 +10801,7 @@ lodash.map = map; lodash.mapValues = mapValues; lodash.matches = matches; + lodash.matchesProperty = matchesProperty; lodash.memoize = memoize; lodash.merge = merge; lodash.mixin = mixin; @@ -10812,7 +11021,7 @@ whileName = methodName + 'While'; LazyWrapper.prototype[methodName] = function(n) { - n = n == null ? 1 : nativeMax(+n || 0, 0); + n = n == null ? 1 : nativeMax(floor(n) || 0, 0); var result = this.clone(); if (result.__filtered__) { @@ -10836,7 +11045,7 @@ // Add `LazyWrapper` methods for `_.first` and `_.last`. arrayEach(['first', 'last'], function(methodName, index) { - var takeName = 'take' + (index ? 'Right': ''); + var takeName = 'take' + (index ? 'Right' : ''); LazyWrapper.prototype[methodName] = function() { return this[takeName](1).value()[0]; @@ -10858,22 +11067,26 @@ createCallback = index ? baseMatches : baseProperty; LazyWrapper.prototype[methodName] = function(value) { - return this[operationName](createCallback(index ? value : (value + ''))); + return this[operationName](createCallback(value)); }; }); - LazyWrapper.prototype.dropWhile = function(iteratee, thisArg) { + LazyWrapper.prototype.compact = function() { + return this.filter(identity); + }; + + LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { var done; - iteratee = getCallback(iteratee, thisArg, 3); + predicate = getCallback(predicate, thisArg, 3); return this.filter(function(value, index, array) { - return done || (done = !iteratee(value, index, array)); + return done || (done = !predicate(value, index, array)); }); }; - LazyWrapper.prototype.reject = function(iteratee, thisArg) { - iteratee = getCallback(iteratee, thisArg, 3); + LazyWrapper.prototype.reject = function(predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); return this.filter(function(value, index, array) { - return !iteratee(value, index, array); + return !predicate(value, index, array); }); }; @@ -10888,6 +11101,10 @@ return result; }; + LazyWrapper.prototype.toArray = function() { + return this.drop(0); + }; + // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName], diff --git a/lodash.min.js b/lodash.min.js index 7592d76e3..e29d33a98 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,88 +1,88 @@ /** * @license - * lodash 3.1.0 (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE + * lodash 3.2.0 (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE * Build: `lodash modern -o ./lodash.js` */ ;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n) -}function g(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++ui(r,a)&&u.push(a);return u}function or(n,t){var r=n?n.length:0;if(!ue(r))return _r(n,t);for(var e=-1,u=se(n);++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=mu(u);++eu(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Or(n,t){for(var r=-1,e=t.length,u=mu(e);++r>>1,i=n[o]; -(r?i<=t:it||null==r)return r;if(3=o&&f<=i&&(e=O&&t>u||e>u&&t>=O)||o)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Ur(u,e,p[4]):zt(e),r[4]=u?g(r[3],B):zt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Fr(u,e,p[6]):zt(e),r[6]=u?g(r[5],B):zt(p[6])),(e=p[7])&&(r[7]=zt(e)),t&C&&(r[8]=null==r[8]?p[8]:uo(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9]}return r[9]=null==f?a?0:n.length:eo(f-c,0)||0,(p?wo:Ao)(t==x?Br(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?qr.apply(w,r):Kr.apply(w,r),r)}function Yr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true; -if(a!=c&&(!u||c<=a))return false;for(;l&&++fu)||i===e&&i===o)&&(u=i,o=n)}),o}function Xr(n,t,r){var e=Wt.callback||hu,e=e===hu?tr:e; -return r?e(n,t,r):e}function Hr(n,r,e){var u=Wt.indexOf||ye,u=u===ye?t:u;return n?u(n,r,e):u}function Qr(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Nu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ne(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=ku),new n}function te(n,t,r){var e=n.constructor;switch(t){case J:return Nr(n);case M:case q:return new e(+n);case X:case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:return t=n.buffer,new e(r?Nr(t):t,n.byteOffset,n.length); -case V:case G:return new e(n);case Z:var u=new e(n.source,yt.exec(n));u.lastIndex=n.lastIndex}return u}function re(n,t){return n=+n,t=null==t?go:t,-1t?0:t)):[]}function _e(n,t,r){var e=n?n.length:0;return e?((r?ee(n,t,r):null==t)&&(t=1),t=e-(+t||0),Er(n,0,0>t?0:t)):[]}function ge(n,t,r){var e=-1,u=n?n.length:0;for(t=Xr(t,r,3);++ee?eo(u+e,0):e||0;else if(e)return e=Tr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function de(n){return he(n,1)}function me(n,r,e,u){if(!n||!n.length)return[];typeof r!="boolean"&&null!=r&&(u=e,e=ee(n,r,u)?null:r,r=false);var o=Xr();if((o!==tr||null!=e)&&(e=o(e,u,3)),r&&Hr()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=mu(r);++tr?eo(e+r,0):r||0:0,typeof n=="string"||!To(n)&&nu(n)?rarguments.length,or) -}function Se(n,t,r,e){return(To(n)?Zt:kr)(n,Xr(t,e,4),r,3>arguments.length,ir)}function We(n,t,r){return(r?ee(n,t,r):null==t)?(n=le(n),t=n.length,0t?0:+t||0,n.length),n)}function Ne(n){n=le(n);for(var t=-1,r=n.length,e=mu(r);++t=r||r>t?(f&&Mu(f),r=p,f=s=p=w,r&&(h=Co(),a=n.apply(l,i),s||f||(i=l=null))):s=Zu(e,r)}function u(){s&&Mu(s),f=s=p=w,(g||_!==t)&&(h=Co(),a=n.apply(l,i),s||f||(i=l=null))}function o(){if(i=arguments,c=Co(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Mu(f)),h=c,a=n.apply(l,i)):f||(f=Zu(u,o))}return y&&s?s=Mu(s):s||t===_||(s=Zu(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true; -if(typeof n!="function")throw new Iu($);if(t=0>t?0:t,true===r)var v=true,g=false;else Je(r)&&(v=r.leading,_="maxWait"in r&&eo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Mu(s),f&&Mu(f),f=s=p=w},o}function Me(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!qt(n,Ge))throw new Iu($);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function qe(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0]; -if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Iu($);return r.cache=new qe.Cache,r}function Pe(n){var t=Er(arguments,1),r=g(t,Pe.placeholder);return Vr(n,R,null,t,r)}function Ke(n){var t=Er(arguments,1),r=g(t,Ke.placeholder);return Vr(n,I,null,t,r)}function Ve(n){return ue(h(n)?n.length:w)&&Fu.call(n)==z||false}function Ye(n){return n&&1===n.nodeType&&h(n)&&-1t||!n||!to(t))return r;do t%2&&(r+=n),t=qu(t/2),n+=n;while(t);return r}function lu(n,t,r){var u=n;return(n=e(n))?(r?ee(u,t,r):null==t)?n.slice(v(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function su(n,t,r){return r&&ee(n,t,r)&&(t=null),n=e(n),n.match(t||Rt)||[]}function pu(n){try{return n.apply(w,Er(arguments,1))}catch(t){return Ze(t)?t:bu(t)}}function hu(n,t,r){return r&&ee(n,t,r)&&(t=null),h(n)?vu(n):tr(n,t)}function _u(n){return function(){return n}}function gu(n){return n -}function vu(n){return br(rr(n,true))}function yu(n,t,r){if(null==r){var e=Je(t),u=e&&Uo(t);((u=u&&u.length&&vr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=vr(t,Uo(t)));var o=true,e=-1,i=Ge(n),f=u.length;false===r?o=false:Je(r)&&"chain"in r&&(o=r.chain);for(;++e>>1,_o=Hu?Hu.BYTES_PER_ELEMENT:0,go=Au.pow(2,53)-1,vo=Xu&&new Xu,yo=Wt.support={};!function(n){yo.funcDecomp=!Xe(_.WinRTError)&&kt.test(m),yo.funcNames=typeof xu.name=="string";try{yo.dom=11===Tu.createDocumentFragment().nodeType -}catch(t){yo.dom=false}try{yo.nonEnumArgs=!Vu.call(arguments,1)}catch(r){yo.nonEnumArgs=true}}(0,0),Wt.templateSettings={escape:ht,evaluate:_t,interpolate:gt,variable:"",imports:{_:Wt}};var mo=function(){function n(){}return function(t){if(Je(t)){n.prototype=t;var r=new n;n.prototype=null}return r||_.Object()}}(),wo=vo?function(n,t){return vo.set(n,t),n}:gu;zu||(Nr=Bu&&Ju?function(n){var t=n.byteLength,r=Hu?qu(t/_o):0,e=r*_o,u=new Bu(t);if(r){var o=new Hu(u,0,r);o.set(new Hu(n,0,r))}return t!=e&&(o=new Ju(u,e),o.set(new Ju(n,e))),u -}:_u(null));var bo=no&&Yu?function(n){return new Lt(n)}:_u(null),xo=vo?function(n){return vo.get(n)}:du,Ao=function(){var n=0,t=0;return function(r,e){var u=Co(),o=N-(u-t);if(t=u,0=W)return r}else n=0;return wo(r,e)}}(),jo=Lr(function(n,t,r){Nu.call(n,r)?++n[r]:n[r]=1}),ko=Lr(function(n,t,r){Nu.call(n,r)?n[r].push(t):n[r]=[t]}),Eo=Lr(function(n,t,r){n[r]=t}),Ro=Mr(Vt),Io=Mr(function(n){for(var t=-1,r=n.length,e=lo;++t--n?t.apply(this,arguments):void 0}},Wt.ary=function(n,t,r){return r&&ee(n,t,r)&&(t=null),t=n&&null==t?n.length:eo(+t||0,0),Vr(n,C,null,null,null,null,t)},Wt.assign=No,Wt.at=function(n){return ue(n?n.length:0)&&(n=le(n)),Qt(n,lr(arguments,false,false,1))},Wt.before=Fe,Wt.bind=Le,Wt.bindAll=function(n){for(var t=n,r=1r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(s?Bt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Bt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Wt.invert=function(n,t,r){r&&ee(n,t,r)&&(t=null),r=-1; -for(var e=Uo(n),u=e.length,o={};++rt?0:t)):[]},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ee(n,t,r):null==t)&&(t=1),t=e-(+t||0),Er(n,0>t?0:t)):[]},Wt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=Xr(t,r,3);e--&&t(n[e],e,n););return Er(n,e+1)},Wt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=Xr(t,r,3);++un||!to(n))return[];var e=-1,u=mu(uo(n,so));for(t=Wr(t,r,1);++er?0:+r||0,u))-t.length,0<=r&&n.indexOf(t,r)==r},Wt.escape=function(n){return(n=e(n))&&pt.test(n)?n.replace(lt,l):n},Wt.escapeRegExp=fu,Wt.every=ke,Wt.find=Re,Wt.findIndex=ge,Wt.findKey=function(n,t,r){return t=Xr(t,r,3),cr(n,t,_r,true)},Wt.findLast=function(n,t,r){return t=Xr(t,r,3),cr(n,t,ir)},Wt.findLastIndex=function(n,t,r){var e=n?n.length:0; -for(t=Xr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Wt.findLastKey=function(n,t,r){return t=Xr(t,r,3),cr(n,t,gr,true)},Wt.findWhere=function(n,t){return Re(n,br(t))},Wt.first=ve,Wt.has=function(n,t){return n?Nu.call(n,t):false},Wt.identity=gu,Wt.includes=je,Wt.indexOf=ye,Wt.isArguments=Ve,Wt.isArray=To,Wt.isBoolean=function(n){return true===n||false===n||h(n)&&Fu.call(n)==M||false},Wt.isDate=function(n){return h(n)&&Fu.call(n)==q||false},Wt.isElement=Ye,Wt.isEmpty=function(n){if(null==n)return true;var t=n.length; -return ue(t)&&(To(n)||nu(n)||Ve(n)||h(n)&&Ge(n.splice))?!t:!Uo(n).length},Wt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Wr(r,e,3),!r&&oe(n)&&oe(t)?n===t:(e=r?r(n,t):w,typeof e=="undefined"?dr(n,t,r):!!e)},Wt.isError=Ze,Wt.isFinite=So,Wt.isFunction=Ge,Wt.isMatch=function(n,t,r,e){var u=Uo(t),o=u.length;if(r=typeof r=="function"&&Wr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],oe(e))return null!=n&&e===n[i]&&Nu.call(n,i)}for(var i=mu(o),f=mu(o);o--;)e=i[o]=t[u[o]],f[o]=oe(e);return mr(n,u,i,f,r) -},Wt.isNaN=function(n){return He(n)&&n!=+n},Wt.isNative=Xe,Wt.isNull=function(n){return null===n},Wt.isNumber=He,Wt.isObject=Je,Wt.isPlainObject=Wo,Wt.isRegExp=Qe,Wt.isString=nu,Wt.isTypedArray=tu,Wt.isUndefined=function(n){return typeof n=="undefined"},Wt.kebabCase=$o,Wt.last=function(n){var t=n?n.length:0;return t?n[t-1]:w},Wt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?eo(e+r,0):uo(r||0,e-1))+1;else if(r)return u=Tr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1; -if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=Ro,Wt.min=Io,Wt.noConflict=function(){return _._=Lu,this},Wt.noop=du,Wt.now=Co,Wt.pad=function(n,t,r){n=e(n),t=+t;var u=n.length;return ur?0:+r||0,n.length),n.lastIndexOf(t,r)==r -},Wt.template=function(n,t,r){var u=Wt.templateSettings;r&&ee(n,t,r)&&(t=r=null),n=e(n),t=Ht(Ht({},r||t),u,Xt),r=Ht(Ht({},t.imports),u.imports,Xt);var o,i,f=Uo(r),a=Or(r,f),c=0;r=t.interpolate||xt;var l="__p+='";r=Eu((t.escape||xt).source+"|"+r.source+"|"+(r===gt?vt:xt).source+"|"+(t.evaluate||xt).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Et,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t -}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(it,""):l).replace(ft,"$1").replace(at,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=pu(function(){return xu(f,p+"return "+l).apply(w,a)}),t.source=l,Ze(t))throw t;return t},Wt.trim=lu,Wt.trimLeft=function(n,t,r){var u=n;return(n=e(n))?n.slice((r?ee(u,t,r):null==t)?v(n):o(n,t+"")):n -},Wt.trimRight=function(n,t,r){var u=n;return(n=e(n))?(r?ee(u,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n},Wt.trunc=function(n,t,r){r&&ee(n,t,r)&&(t=null);var u=T;if(r=S,null!=t)if(Je(t)){var o="separator"in t?t.separator:o,u="length"in t?+t.length||0:u;r="omission"in t?e(t.omission):r}else u=+t||0;if(n=e(n),u>=n.length)return n;if(u-=r.length,1>u)return r;if(t=n.slice(0,u),null==o)return t+r;if(Qe(o)){if(n.slice(u).search(o)){var i,f=n.slice(0,u);for(o.global||(o=Eu(o.source,(yt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index; -t=t.slice(0,null==i?u:i)}}else n.indexOf(o,u)!=u&&(o=t.lastIndexOf(o),-1o.__dir__,f.push({iteratee:Xr(n,u,3),type:t}),o}}),Mt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Ut.prototype[n]=function(e){e=null==e?1:eo(+e||0,0); -var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?uo(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Ut.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Ut.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Mt(["first","last"],function(n,t){var r="take"+(t?"Right":"");Ut.prototype[n]=function(){return this[r](1).value()[0]}}),Mt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); -Ut.prototype[n]=function(){return this[r](1)}}),Mt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?br:Ar;Ut.prototype[n]=function(n){return this[r](e(t?n:n+""))}}),Ut.prototype.dropWhile=function(n,t){var r;return n=Xr(n,t,3),this.filter(function(t,e,u){return r||(r=!n(t,e,u))})},Ut.prototype.reject=function(n,t){return n=Xr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Ut.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r -},_r(Ut.prototype,function(n,t){var r=Wt[t],e=/^(?:first|last)$/.test(t);Wt.prototype[t]=function(){function t(n){return n=[n],Ku.apply(n,o),r.apply(Wt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Ut,c=a&&!f;return e&&!i?c?n.call(u):r.call(Wt,this.value()):a||To(u)?(u=n.apply(c?u:new Ut(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:Ae,args:[t],thisArg:Wt}),new Nt(u,i)):this.thru(t)}}),Mt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Ou[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n); -Wt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Ut.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Ut(this.__wrapped__);return e.__actions__=n?zt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?zt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?zt(r):null,e},Ut.prototype.reverse=function(){if(this.__filtered__){var n=new Ut(this); -n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Ut.prototype.value=function(){var n=this.__wrapped__.value();if(!To(n))return Cr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i"'`]/g,st=RegExp(ct.source),pt=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,gt=/<%=([\s\S]+?)%>/g,vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,dt=/^\s*function[ \n\r\t]+\w/,mt=/^0[xX]/,wt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,xt=/($^)/,At=/[.*+?^${}()|[\]\/\\]/g,jt=RegExp(At.source),kt=/\bthis\b/,Et=/['\n\r\u2028\u2029\\]/g,Rt=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),It=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ot="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Ct={}; +}function g(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++ui(r,a)&&u.push(a);return u}function or(n,t){var r=n?n.length:0;if(!oe(r))return _r(n,t);for(var e=-1,u=pe(n);++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=wu(u);++eu(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Cr(n,t){for(var r=-1,e=t.length,u=wu(e);++r>>1,i=n[o];(r?i<=t:it||null==r)return r;if(3=o&&f<=i&&(e=O&&t>u||e>u&&t>=O)||o)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Fr(u,e,p[4]):zt(e),r[4]=u?g(r[3],B):zt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Lr(u,e,p[6]):zt(e),r[6]=u?g(r[5],B):zt(p[6])),(e=p[7])&&(r[7]=zt(e)),t&C&&(r[8]=null==r[8]?p[8]:oo(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9] +}return r[9]=null==f?a?0:n.length:uo(f-c,0)||0,(p?bo:jo)(t==x?zr(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?Pr.apply(w,r):Vr.apply(w,r),r)}function Zr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++fu)||i===e&&i===o)&&(u=i,o=n)}),o}function Hr(n,t,r){var e=Wt.callback||_u,e=e===_u?tr:e;return r?e(n,t,r):e}function Qr(n,r,e){var u=Wt.indexOf||de,u=u===de?t:u;return n?u(n,r,e):u}function ne(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Uu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function te(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Eu),new n +}function re(n,t,r){var e=n.constructor;switch(t){case J:return Ur(n);case M:case q:return new e(+n);case X:case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:return t=n.buffer,new e(r?Ur(t):t,n.byteOffset,n.length);case V:case G:return new e(n);case Z:var u=new e(n.source,yt.exec(n));u.lastIndex=n.lastIndex}return u}function ee(n,t){return n=+n,t=null==t?vo:t,-1t?0:t)):[]}function ge(n,t,r){var e=n?n.length:0; +return e?((r?ue(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0,0>t?0:t)):[]}function ve(n,t,r){var e=-1,u=n?n.length:0;for(t=Hr(t,r,3);++ee?uo(u+e,0):e||0;else if(e)return e=Sr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function me(n){return _e(n,1)}function we(n,r,e,u){if(!n||!n.length)return[];typeof r!="boolean"&&null!=r&&(u=e,e=ue(n,r,u)?null:r,r=false); +var o=Hr();if((o!==tr||null!=e)&&(e=o(e,u,3)),r&&Qr()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=wu(r);++tr?uo(e+r,0):r||0:0,typeof n=="string"||!So(n)&&tu(n)?rarguments.length,or)}function We(n,t,r,e){return(So(n)?Zt:Er)(n,Hr(t,e,4),r,3>arguments.length,ir)}function Ne(n,t,r){return(r?ue(n,t,r):null==t)?(n=se(n),t=n.length,0t?0:+t||0,n.length),n)}function Ue(n){n=se(n); +for(var t=-1,r=n.length,e=wu(r);++t=r||r>t?(f&&qu(f),r=p,f=s=p=w,r&&(h=To(),a=n.apply(l,i),s||f||(i=l=null))):s=Gu(e,r)}function u(){s&&qu(s),f=s=p=w,(g||_!==t)&&(h=To(),a=n.apply(l,i),s||f||(i=l=null)) +}function o(){if(i=arguments,c=To(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=qu(f)),h=c,a=n.apply(l,i)):f||(f=Gu(u,o))}return y&&s?s=qu(s):s||t===_||(s=Gu(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Ou($);if(t=0>t?0:t,true===r)var v=true,g=false;else Xe(r)&&(v=r.leading,_="maxWait"in r&&uo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&qu(s),f&&qu(f),f=s=p=w +},o}function qe(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!qt(n,Je))throw new Ou($);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Pe(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Ou($);return r.cache=new Pe.Cache,r}function Ke(n){var t=Rr(arguments,1),r=g(t,Ke.placeholder); +return Yr(n,R,null,t,r)}function Ve(n){var t=Rr(arguments,1),r=g(t,Ve.placeholder);return Yr(n,I,null,t,r)}function Ye(n){return oe(h(n)?n.length:w)&&Lu.call(n)==z||false}function Ze(n){return n&&1===n.nodeType&&h(n)&&-1t||!n||!ro(t))return r;do t%2&&(r+=n),t=Pu(t/2),n+=n;while(t);return r}function su(n,t,r){var u=n;return(n=e(n))?(r?ue(u,t,r):null==t)?n.slice(v(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n +}function pu(n,t,r){return r&&ue(n,t,r)&&(t=null),n=e(n),n.match(t||Rt)||[]}function hu(n){try{return n.apply(w,Rr(arguments,1))}catch(t){return Ge(t)?t:new xu(t)}}function _u(n,t,r){return r&&ue(n,t,r)&&(t=null),h(n)?yu(n):tr(n,t)}function gu(n){return function(){return n}}function vu(n){return n}function yu(n){return br(rr(n,true))}function du(n,t,r){if(null==r){var e=Xe(t),u=e&&Fo(t);((u=u&&u.length&&vr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=vr(t,Fo(t)));var o=true,e=-1,i=Je(n),f=u.length; +!1===r?o=false:Xe(r)&&"chain"in r&&(o=r.chain);for(;++e>>1,go=Qu?Qu.BYTES_PER_ELEMENT:0,vo=ju.pow(2,53)-1,yo=Hu&&new Hu,mo=Wt.support={};!function(n){mo.funcDecomp=!He(_.WinRTError)&&kt.test(m),mo.funcNames=typeof Au.name=="string";try{mo.dom=11===Su.createDocumentFragment().nodeType +}catch(t){mo.dom=false}try{mo.nonEnumArgs=!Yu.call(arguments,1)}catch(r){mo.nonEnumArgs=true}}(0,0),Wt.templateSettings={escape:ht,evaluate:_t,interpolate:gt,variable:"",imports:{_:Wt}};var wo=function(){function n(){}return function(t){if(Xe(t)){n.prototype=t;var r=new n;n.prototype=null}return r||_.Object()}}(),bo=yo?function(n,t){return yo.set(n,t),n}:vu;Du||(Ur=zu&&Xu?function(n){var t=n.byteLength,r=Qu?Pu(t/go):0,e=r*go,u=new zu(t);if(r){var o=new Qu(u,0,r);o.set(new Qu(n,0,r))}return t!=e&&(o=new Xu(u,e),o.set(new Xu(n,e))),u +}:gu(null));var xo=to&&Zu?function(n){return new Lt(n)}:gu(null),Ao=yo?function(n){return yo.get(n)}:mu,jo=function(){var n=0,t=0;return function(r,e){var u=To(),o=N-(u-t);if(t=u,0=W)return r}else n=0;return bo(r,e)}}(),ko=$r(function(n,t,r){Uu.call(n,r)?++n[r]:n[r]=1}),Eo=$r(function(n,t,r){Uu.call(n,r)?n[r].push(t):n[r]=[t]}),Ro=$r(function(n,t,r){n[r]=t}),Io=qr(Vt),Oo=qr(function(n){for(var t=-1,r=n.length,e=so;++t--n?t.apply(this,arguments):void 0}},Wt.ary=function(n,t,r){return r&&ue(n,t,r)&&(t=null),t=n&&null==t?n.length:uo(+t||0,0),Yr(n,C,null,null,null,null,t)},Wt.assign=Uo,Wt.at=function(n){return oe(n?n.length:0)&&(n=se(n)),Qt(n,lr(arguments,false,false,1))},Wt.before=Le,Wt.bind=$e,Wt.bindAll=function(n){for(var t=n,r=1r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(s?Bt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Bt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Wt.invert=function(n,t,r){r&&ue(n,t,r)&&(t=null),r=-1; +for(var e=Fo(n),u=e.length,o={};++rt?0:t)):[]},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ue(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0>t?0:t)):[]},Wt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=Hr(t,r,3);e--&&t(n[e],e,n););return Rr(n,e+1)},Wt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=Hr(t,r,3);++un||!ro(n))return[];var e=-1,u=wu(oo(n,po));for(t=Nr(t,r,1);++er?0:+r||0,u))-t.length,0<=r&&n.indexOf(t,r)==r},Wt.escape=function(n){return(n=e(n))&&pt.test(n)?n.replace(lt,l):n},Wt.escapeRegExp=au,Wt.every=Ee,Wt.find=Ie,Wt.findIndex=ve,Wt.findKey=function(n,t,r){return t=Hr(t,r,3),cr(n,t,_r,true)},Wt.findLast=function(n,t,r){return t=Hr(t,r,3),cr(n,t,ir)},Wt.findLastIndex=function(n,t,r){var e=n?n.length:0; +for(t=Hr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Wt.findLastKey=function(n,t,r){return t=Hr(t,r,3),cr(n,t,gr,true)},Wt.findWhere=function(n,t){return Ie(n,br(t))},Wt.first=ye,Wt.has=function(n,t){return n?Uu.call(n,t):false},Wt.identity=vu,Wt.includes=ke,Wt.indexOf=de,Wt.isArguments=Ye,Wt.isArray=So,Wt.isBoolean=function(n){return true===n||false===n||h(n)&&Lu.call(n)==M||false},Wt.isDate=function(n){return h(n)&&Lu.call(n)==q||false},Wt.isElement=Ze,Wt.isEmpty=function(n){if(null==n)return true;var t=n.length; +return oe(t)&&(So(n)||tu(n)||Ye(n)||h(n)&&Je(n.splice))?!t:!Fo(n).length},Wt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Nr(r,e,3),!r&&ie(n)&&ie(t)?n===t:(e=r?r(n,t):w,typeof e=="undefined"?dr(n,t,r):!!e)},Wt.isError=Ge,Wt.isFinite=Wo,Wt.isFunction=Je,Wt.isMatch=function(n,t,r,e){var u=Fo(t),o=u.length;if(r=typeof r=="function"&&Nr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],ie(e))return null!=n&&e===n[i]&&Uu.call(n,i)}for(var i=wu(o),f=wu(o);o--;)e=i[o]=t[u[o]],f[o]=ie(e);return mr(n,u,i,f,r) +},Wt.isNaN=function(n){return Qe(n)&&n!=+n},Wt.isNative=He,Wt.isNull=function(n){return null===n},Wt.isNumber=Qe,Wt.isObject=Xe,Wt.isPlainObject=No,Wt.isRegExp=nu,Wt.isString=tu,Wt.isTypedArray=ru,Wt.isUndefined=function(n){return typeof n=="undefined"},Wt.kebabCase=Bo,Wt.last=function(n){var t=n?n.length:0;return t?n[t-1]:w},Wt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?uo(e+r,0):oo(r||0,e-1))+1;else if(r)return u=Sr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1; +if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=Io,Wt.min=Oo,Wt.noConflict=function(){return _._=$u,this},Wt.noop=mu,Wt.now=To,Wt.pad=function(n,t,r){n=e(n),t=+t;var u=n.length;return ur?0:+r||0,n.length),n.lastIndexOf(t,r)==r +},Wt.template=function(n,t,r){var u=Wt.templateSettings;r&&ue(n,t,r)&&(t=r=null),n=e(n),t=Ht(Ht({},r||t),u,Xt),r=Ht(Ht({},t.imports),u.imports,Xt);var o,i,f=Fo(r),a=Cr(r,f),c=0;r=t.interpolate||xt;var l="__p+='";r=Ru((t.escape||xt).source+"|"+r.source+"|"+(r===gt?vt:xt).source+"|"+(t.evaluate||xt).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Et,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t +}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(it,""):l).replace(ft,"$1").replace(at,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=hu(function(){return Au(f,p+"return "+l).apply(w,a)}),t.source=l,Ge(t))throw t;return t},Wt.trim=su,Wt.trimLeft=function(n,t,r){var u=n;return(n=e(n))?n.slice((r?ue(u,t,r):null==t)?v(n):o(n,t+"")):n +},Wt.trimRight=function(n,t,r){var u=n;return(n=e(n))?(r?ue(u,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n},Wt.trunc=function(n,t,r){r&&ue(n,t,r)&&(t=null);var u=T;if(r=S,null!=t)if(Xe(t)){var o="separator"in t?t.separator:o,u="length"in t?+t.length||0:u;r="omission"in t?e(t.omission):r}else u=+t||0;if(n=e(n),u>=n.length)return n;if(u-=r.length,1>u)return r;if(t=n.slice(0,u),null==o)return t+r;if(nu(o)){if(n.slice(u).search(o)){var i,f=n.slice(0,u);for(o.global||(o=Ru(o.source,(yt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index; +t=t.slice(0,null==i?u:i)}}else n.indexOf(o,u)!=u&&(o=t.lastIndexOf(o),-1o.__dir__,f.push({iteratee:Hr(n,u,3),type:t}),o}}),Mt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Ut.prototype[n]=function(e){e=null==e?1:uo(Pu(e)||0,0); +var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?oo(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Ut.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Ut.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Mt(["first","last"],function(n,t){var r="take"+(t?"Right":"");Ut.prototype[n]=function(){return this[r](1).value()[0]}}),Mt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); +Ut.prototype[n]=function(){return this[r](1)}}),Mt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?br:jr;Ut.prototype[n]=function(n){return this[r](e(n))}}),Ut.prototype.compact=function(){return this.filter(vu)},Ut.prototype.dropWhile=function(n,t){var r;return n=Hr(n,t,3),this.filter(function(t,e,u){return r||(r=!n(t,e,u))})},Ut.prototype.reject=function(n,t){return n=Hr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Ut.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n); +return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Ut.prototype.toArray=function(){return this.drop(0)},_r(Ut.prototype,function(n,t){var r=Wt[t],e=/^(?:first|last)$/.test(t);Wt.prototype[t]=function(){function t(n){return n=[n],Vu.apply(n,o),r.apply(Wt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Ut,c=a&&!f;return e&&!i?c?n.call(u):r.call(Wt,this.value()):a||So(u)?(u=n.apply(c?u:new Ut(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:je,args:[t],thisArg:Wt}),new Nt(u,i)):this.thru(t) +}}),Mt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Cu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Wt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Ut.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Ut(this.__wrapped__);return e.__actions__=n?zt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?zt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?zt(r):null,e +},Ut.prototype.reverse=function(){if(this.__filtered__){var n=new Ut(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Ut.prototype.value=function(){var n=this.__wrapped__.value();if(!So(n))return Tr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i"'`]/g,st=RegExp(ct.source),pt=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,gt=/<%=([\s\S]+?)%>/g,vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,dt=/^\s*function[ \n\r\t]+\w/,mt=/^0[xX]/,wt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,xt=/($^)/,At=/[.*+?^${}()|[\]\/\\]/g,jt=RegExp(At.source),kt=/\bthis\b/,Et=/['\n\r\u2028\u2029\\]/g,Rt=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),It=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ot="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Ct={}; Ct[X]=Ct[H]=Ct[Q]=Ct[nt]=Ct[tt]=Ct[rt]=Ct[et]=Ct[ut]=Ct[ot]=true,Ct[z]=Ct[D]=Ct[J]=Ct[M]=Ct[q]=Ct[P]=Ct[K]=Ct["[object Map]"]=Ct[V]=Ct[Y]=Ct[Z]=Ct["[object Set]"]=Ct[G]=Ct["[object WeakMap]"]=false;var Tt={};Tt[z]=Tt[D]=Tt[J]=Tt[M]=Tt[q]=Tt[X]=Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[V]=Tt[Y]=Tt[Z]=Tt[G]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=true,Tt[P]=Tt[K]=Tt["[object Map]"]=Tt["[object Set]"]=Tt["[object WeakMap]"]=false;var St={leading:false,maxWait:0,trailing:false},Wt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Nt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ut={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ft={"function":true,object:true},Lt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Ft[typeof window]&&window!==(this&&this.window)?window:this,Bt=Ft[typeof exports]&&exports&&!exports.nodeType&&exports,Ft=Ft[typeof module]&&module&&!module.nodeType&&module,zt=Bt&&Ft&&typeof global=="object"&&global; !zt||zt.global!==zt&&zt.window!==zt&&zt.self!==zt||($t=zt);var zt=Ft&&Ft.exports===Bt&&Bt,Dt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?($t._=Dt, define(function(){return Dt})):Bt&&Ft?zt?(Ft.exports=Dt)._=Dt:Bt._=Dt:$t._=Dt}).call(this); \ No newline at end of file diff --git a/lodash.src.js b/lodash.src.js index 2b6c2af26..be65b2cd9 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.1.0 + * lodash 3.2.0 * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.7.0 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -12,7 +12,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.1.0'; + var VERSION = '3.2.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1,