8000 Bump to v3.2.0. · lodash/lodash@3ccb5e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ccb5e7

Browse files
committed
Bump to v3.2.0.
1 parent 1608d89 commit 3ccb5e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1541
-712
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash v3.1.0
1+
# lodash v3.2.0
22

33
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
44

array.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/without', './array/xor', './array/zip', './array/zipObject'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, without, xor, zip, zipObject) {
1+
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/fill', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/without', './array/xor', './array/zip', './array/zipObject'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, without, xor, zip, zipObject) {
22
return {
33
'chunk': chunk,
44
'compact': compact,
@@ -7,6 +7,7 @@ define(['./array/chunk', './array/compact', './array/difference', './array/drop'
77
'dropRight': dropRight,
88
'dropRightWhile': dropRightWhile,
99
'dropWhile': dropWhile,
10+
'fill': fill,
1011
'findIndex': findIndex,
1112
'findLastIndex': findLastIndex,
1213
'first': first,

array/chunk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
1515
* @memberOf _
1616
* @category Array
1717
* @param {Array} array The array to process.
18-
* @param {numer} [size=1] The length of each chunk.
18+
* @param {number} [size=1] The length of each chunk.
1919
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
2020
* @returns {Array} Returns the new array containing chunks.
2121
* @example

array/drop.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
55
*
66
* @static
77
* @memberOf _
8-
* @type Function
98
* @category Array
109
* @param {Array} array The array to query.
1110
* @param {number} [n=1] The number of elements to drop.

array/dropRight.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
55
*
66
* @static
77
* @memberOf _
8-
* @type Function
98
* @category Array
109
* @param {Array} array The array to query.
1110
* @param {number} [n=1] The number of elements to drop.

array/dropRightWhile.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
55
* Elements are dropped until `predicate` returns falsey. The predicate is
66
* bound to `thisArg` and invoked with three arguments; (value, index, array).
77
*
8-
* If a property name is provided for `predicate` the created "_.property"
8+
* If a property name is provided for `predicate` the created `_.property`
99
* style callback returns the property value of the given element.
1010
*
11-
* If an object is provided for `predicate` the created "_.matches" style
12-
* callback returns `true` for elements that have the properties of the given
11+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
12+
* style callback returns `true` for elements that have a matching property
13+
* value, else `false`.
14+
*
15+
* If an object is provided for `predicate` the created `_.matches` style
16+
* callback returns `true` for elements that match the properties of the given
1317
* object, else `false`.
1418
*
1519
* @static
1620
* @memberOf _
17-
* @type Function
1821
* @category Array
1922
* @param {Array} array The array to query.
2023
* @param {Function|Object|string} [predicate=_.identity] The function invoked
21-
* per element.
24+
* per iteration.
2225
* @param {*} [thisArg] The `this` binding of `predicate`.
2326
* @returns {Array} Returns the slice of `array`.
2427
* @example
@@ -27,18 +30,22 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
2730
* // => [1]
2831
*
2932
* var users = [
30-
* { 'user': 'barney', 'status': 'busy', 'active': false },
31-
* { 'user': 'fred', 'status': 'busy', 'active': true },
32-
* { 'user': 'pebbles', 'status': 'away', 'active': true }
33+
* { 'user': 'barney', 'active': true },
34+
* { 'user': 'fred', 'active': false },
35+
* { 'user': 'pebbles', 'active': false }
3336
* ];
3437
*
35-
* // using the "_.property" callback shorthand
36-
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
38+
* // using the `_.matches` callback shorthand
39+
* _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user');
40+
* // => ['barney', 'fred']
41+
*
42+
* // using the `_.matchesProperty` callback shorthand
43+
* _.pluck(_.dropRightWhile(users, 'active', false), 'user');
3744
* // => ['barney']
3845
*
39-
* // using the "_.matches" callback shorthand
40-
* _.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user');
41-
* // => ['barney', 'fred']
46+
* // using the `_.property` callback shorthand
47+
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
48+
* // => ['barney', 'fred', 'pebbles']
4249
*/
4350
function dropRightWhile(array, predicate, thisArg) {
4451
var length = array ? array.length : 0;

array/dropWhile.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
55
* Elements are dropped until `predicate` returns falsey. The predicate is
66
* bound to `thisArg` and invoked with three arguments; (value, index, array).
77
*
8-
* If a property name is provided for `predicate` the created "_.property"
8+
* If a property name is provided for `predicate` the created `_.property`
99
* style callback returns the property value of the given element.
1010
*
11-
* If an object is provided for `predicate` the created "_.matches" style
11+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
12+
* style callback returns `true` for elements that have a matching property
13+
* value, else `false`.
14+
*
15+
* If an object is provided for `predicate` the created `_.matches` style
1216
* callback returns `true` for elements that have the properties of the given
1317
* object, else `false`.
1418
*
1519
* @static
1620
* @memberOf _
17-
* @type Function
1821
* @category Array
1922
* @param {Array} array The array to query.
2023
* @param {Function|Object|string} [predicate=_.identity] The function invoked
21-
* per element.
24+
* per iteration.
2225
* @param {*} [thisArg] The `this` binding of `predicate`.
2326
* @returns {Array} Returns the slice of `array`.
2427
* @example
@@ -27,18 +30,22 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
2730
* // => [3]
2831
*
2932
* var users = [
30-
* { 'user': 'barney', 'status': 'busy', 'active': true },
31-
* { 'user': 'fred', 'status': 'busy', 'active': false },
32-
* { 'user': 'pebbles', 'status': 'away', 'active': true }
33+
* { 'user': 'barney', 'active': false },
34+
* { 'user': 'fred', 'active': false },
35+
* { 'user': 'pebbles', 'active': true }
3336
* ];
3437
*
35-
* // using the "_.property" callback shorthand
36-
* _.pluck(_.dropWhile(users, 'active'), 'user');
38+
* // using the `_.matches` callback shorthand
39+
* _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
3740
* // => ['fred', 'pebbles']
3841
*
39-
* // using the "_.matches" callback shorthand
40-
* _.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user');
42+
* // using the `_.matchesProperty` callback shorthand
43+
* _.pluck(_.dropWhile(users, 'active', false), 'user');
4144
* // => ['pebbles']
45+
*
46+
* // using the `_.property` callback shorthand
47+
* _.pluck(_.dropWhile(users, 'active'), 'user');
48+
* // => ['barney', 'fred', 'pebbles']
4249
*/
4350
function dropWhile(array, predicate, thisArg) {
4451
var length = array ? array.length : 0;

array/fill.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
define(['../internal/baseFill', '../internal/isIterateeCall'], function(baseFill, isIterateeCall) {
2+
3+
/**
4+
* Fills elements of `array` with `value` from `start` up to, but not
5+
* including, `end`.
6+
*
7+
* **Note:** This method mutates `array`.
8+
*
9+
* @static
10+
* @memberOf _
11+
* @category Array
12+
* @param {Array} array The array to fill.
13+
* @param {*} value The value to fill `array` with.
14+
* @param {number} [start=0] The start position.
15+
* @param {number} [end=array.length] The end position.
16+
* @returns {Array} Returns `array`.
17+
*/
18+
function fill(array, value, start, end) {
19+
var length = array ? array.length : 0;
20+
if (!length) {
21+
return [];
22+
}
23+
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
24+
start = 0;
25+
end = length;
26+
}
27+
return baseFill(array, value, start, end);
28+
}
29+
30+
return fill;
31+
});

array/findIndex.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ define(['../internal/baseCallback'], function(baseCallback) {
44
* This method is like `_.find` except that it returns the index of the first
55
* element `predicate` returns truthy for, instead of the element itself.
66
*
7-
* If a property name is provided for `predicate` the created "_.property"
7+
* If a property name is provided for `predicate` the created `_.property`
88
* style callback returns the property value of the given element.
99
*
10-
* If an object is provided for `predicate` the created "_.matches" style
10+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
11+
* style callback returns `true` for elements that have a matching property
12+
* value, else `false`.
13+
*
14+
* If an object is provided for `predicate` the created `_.matches` style
1115
* callback returns `true` for elements that have the properties of the given
1216
* object, else `false`.
1317
*
@@ -16,28 +20,31 @@ define(['../internal/baseCallback'], function(baseCallback) {
1620
* @category Array
1721
* @param {Array} array The array to search.
1822
* @param {Function|Object|string} [predicate=_.identity] The function invoked
19-
* per iteration. If a property name or object is provided it is used to
20-
* create a "_.property" or "_.matches" style callback respectively.
23+
* per iteration.
2124
* @param {*} [thisArg] The `this` binding of `predicate`.
2225
* @returns {number} Returns the index of the found element, else `-1`.
2326
* @example
2427
*
2528
* var users = [
26-
* { 'user': 'barney', 'age': 36, 'active': false },
27-
* { 'user': 'fred', 'age': 40, 'active': true },
28-
* { 'user': 'pebbles', 'age': 1, 'active': false }
29+
* { 'user': 'barney', 'active': false },
30+
* { 'user': 'fred', 'active': false },
31+< 3D24 /span>
* { 'user': 'pebbles', 'active': true }
2932
* ];
3033
*
31-
* _.findIndex(users, function(chr) { return chr.age < 40; });
34+
* _.findIndex(users, function(chr) { return chr.user == 'barney'; });
3235
* // => 0
3336
*
34-
* // using the "_.matches" callback shorthand
35-
* _.findIndex(users, { 'age': 1 });
36-
* // => 2
37+
* // using the `_.matches` callback shorthand
38+ * _.findIndex(users, { 'user': 'fred', 'active': false });
39+
* // => 1
3740
*
38-
* // using the "_.property" callback shorthand
41+
* // using the `_.matchesProperty` callback shorthand
42+
* _.findIndex(users, 'active', false);
43+
* // => 0
44+
*
45+
* // using the `_.property` callback shorthand
3946
* _.findIndex(users, 'active');
40-
* // => 1
47+
* // => 2
4148
*/
4249
function findIndex(array, predicate, thisArg) {
4350
var index = -1,

array/findLastIndex.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ define(['../internal/baseCallback'], function(baseCallback) {
44
* This method is like `_.findIndex` except that it iterates over elements
55
* of `collection` from right to left.
66
*
7-
* If a property name is provided for `predicate` the created "_.property"
7+
* If a property name is provided for `predicate` the created `_.property`
88
* style callback returns the property value of the given element.
99
*
10-
* If an object is provided for `predicate` the created "_.matches" style
10+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
11+
* style callback returns `true` for elements that have a matching property
12+
* value, else `false`.
13+
*
14+
* If an object is provided for `predicate` the created `_.matches` style
1115
* callback returns `true` for elements that have the properties of the given
1216
* object, else `false`.
1317
*
@@ -16,26 +20,29 @@ define(['../internal/baseCallback'], function(baseCallback) {
1620
* @category Array
1721
* @param {Array} array The array to search.
1822
* @param {Function|Object|string} [predicate=_.identity] The function invoked
19-
* per iteration. If a property name or object is provided it is used to
20-
* create a "_.property" or "_.matches" style callback respectively.
23+
* per iteration.
2124
* @param {*} [thisArg] The `this` binding of `predicate`.
2225
* @returns {number} Returns the index of the found element, else `-1`.
2326
* @example
2427
*
2528
* var users = [
26-
* { 'user': 'barney', 'age': 36, 'active': true },
27-
* { 'user': 'fred', 'age': 40, 'active': false },
28-
* { 'user': 'pebbles', 'age': 1, 'active': false }
29+
* { 'user': 'barney', 'active': true },
30+
* { 'user': 'fred', 'active': false },
31+
* { 'user': 'pebbles', 'active': false }
2932
* ];
3033
*
31-
* _.findLastIndex(users, function(chr) { return chr.age < 40; });
34+
* _.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; });
3235
* // => 2
3336
*
34-
* // using the "_.matches" callback shorthand
35-
* _.findLastIndex(users, { 'age': 40 });
37+
* // using the `_.matches` callback shorthand
38+
* _.findLastIndex(users, { user': 'barney', 'active': true });
39+
* // => 0
40+
*
41+
* // using the `_.matchesProperty` callback shorthand
42+
* _.findLastIndex(users, 'active', false);
3643
* // => 1
3744
*
38-
* // using the "_.property" callback shorthand
45+
* // using the `_.property` callback shorthand
3946
* _.findLastIndex(users, 'active');
4047
* // => 0
4148
*/

array/remove.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ define(['../internal/baseCallback'], function(baseCallback) {
1111
* and returns an array of the removed elements. The predicate is bound to
1212
* `thisArg` and invoked with three arguments; (value, index, array).
1313
*
14-
* If a property name is provided for `predicate` the created "_.property"
14+
* If a property name is provided for `predicate` the created `_.property`
1515
* style callback returns the property value of the given element.
1616
*
17-
* If an object is provided for `predicate` the created "_.matches" style
17+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
18+
* style callback returns `true` for elements that have a matching property
19+
* value, else `false`.
20+
*
21+
* If an object is provided for `predicate` the created `_.matches` style
1822
* callback returns `true` for elements that have the properties of the given
1923
* object, else `false`.
2024
*
@@ -25,8 +29,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
2529
* @category Array
2630
* @param {Array} array The array to modify.
2731
* @param {Function|Object|string} [predicate=_.identity] The function invoked
28-
* per iteration. If a property name or object is provided it is used to
29-
* create a "_.property" or "_.matches" style callback respectively.
32+
* per iteration.
3033
* @param {*} [thisArg] The `this` binding of `predicate`.
3134
* @returns {Array} Returns the new array of removed elements.
3235
* @example

array/sortedIndex.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
77
* to compute their sort ranking. The iteratee is bound to `thisArg` and
88
* invoked with one argument; (value).
99
*
10-
* If a property name is provided for `predicate` the created "_.property"
10+
* If a property name is provided for `predicate` the created `_.property`
1111
* style callback returns the property value of the given element.
1212
*
13-
* If an object is provided for `predicate` the created "_.matches" style
13+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
14+
* style callback returns `true` for elements that have a matching property
15+
* value, else `false`.
16+
*
17+
* If an object is provided for `predicate` the created `_.matches` style
1418
* callback returns `true` for elements that have the properties of the given
1519
* object, else `false`.
1620
*
@@ -20,8 +24,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
2024
* @param {Array} array The sorted array to inspect.
2125
* @param {*} value The value to evaluate.
2226
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
23-
* per iteration. If a property name or object is provided it is used to
24-
* create a "_.property" or "_.matches" style callback respectively.
27+
* per iteration.
2528
* @param {*} [thisArg] The `this` binding of `iteratee`.
2629
* @returns {number} Returns the index at which `value` should be inserted
2730
* into `array`.
@@ -41,7 +44,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
4144
* }, dict);
4245
* // => 1
4346
*
44-
* // using the "_.property" callback shorthand
47+
* // using the `_.property` callback shorthand
4548
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
4649
* // => 1
4750
*/

array/sortedLastIndex.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
1111
* @param {Array} array The sorted array to inspect.
1212
* @param {*} value The value to evaluate.
1313
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
14-
* per iteration. If a property name or object is provided it is used to
15-
* create a "_.property" or "_.matches" style callback respectively.
14+
* per iteration.
1615
* @param {*} [thisArg] The `this` binding of `iteratee`.
1716
* @returns {number} Returns the index at which `value` should be inserted
1817
* into `array`.

array/take.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
55
*
66
* @static
77
* @memberOf _
8-
* @type Function
98
* @category Array
109
* @param {Array} array The array to query.
1110
* @param {number} [n=1] The number of elements to take.

array/takeRight.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
55
*
66
* @static
77
* @memberOf _
8-
* @type Function
98
* @category Array
109
* @param {Array} array The array to query.
1110
* @param {number} [n=1] The number of elements to take.

0 commit comments

Comments
 (0)
0