8000 Bump to v3.6.0. · lodash/lodash@9724afd · GitHub
[go: up one dir, main page]

Skip to content

Commit 9724afd

Browse files
committed
Bump to v3.6.0.
1 parent 707fe17 commit 9724afd

File tree

193 files changed

+2187
-1760
lines changed

Some content is hidden

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

193 files changed

+2187
-1760
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.5.0
1+
# lodash v3.6.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/difference.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseFlatten, isArguments, isArray) {
1+
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) {
22

33
/**
44
* Creates an array excluding all values of the provided arrays using
55
* `SameValueZero` for equality comparisons.
66
*
7-
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
8-
* e.g. `===`, except that `NaN` matches `NaN`. See the
9-
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
10-
* for more details.
7+
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
8+
* comparisons are like strict equality comparisons, e.g. `===`, except that
9+
* `NaN` matches `NaN`.
1110
*
1211
* @static
1312
* @memberOf _
@@ -20,19 +19,11 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
2019
* _.difference([1, 2, 3], [4, 2]);
2120
* // => [1, 3]
2221
*/
23-
function difference() {
24-
var args = arguments,
25-
index = -1,
26-
length = args.length;
27-
28-
while (++index < length) {
29-
var value = args[index];
30-
if (isArray(value) || isArguments(value)) {
31-
break;
32-
}
33-
}
34-
return baseDifference(value, baseFlatten(args, false, true, ++index));
35-
}
22+
var difference = restParam(function(array, values) {
23+
return (isArray(array) || isArguments(array))
24+
? baseDifference(array, baseFlatten(values, false, true))
25+
: [];
26+
});
3627

3728
return difference;
3829
});

array/dropRightWhile.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
1+
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
22

33
/**
44
* Creates a slice of `array` excluding elements dropped from the end.
55
* Elements are dropped until `predicate` returns falsey. The predicate is
6-
* bound to `thisArg` and invoked with three arguments; (value, index, array).
6+
* bound to `thisArg` and invoked with three arguments: (value, index, array).
77
*
88
* If a property name is provided for `predicate` the created `_.property`
99
* style callback returns the property value of the given element.
@@ -50,13 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
5050
* // => ['barney', 'fred', 'pebbles']
5151
*/
5252
function dropRightWhile(array, predicate, thisArg) {
53-
var length = array ? array.length : 0;
54-
if (!length) {
55-
return [];
56-
}
57-
predicate = baseCallback(predicate, thisArg, 3);
58-
while (length-- && predicate(array[length], length, array)) {}
59-
return baseSlice(array, 0, length + 1);
53+
return (array && array.length)
54+
? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true)
55+
: [];
6056
}
6157

6258
return dropRightWhile;

array/dropWhile.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
1+
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
22

33
/**
44
* Creates a slice of `array` excluding elements dropped from the beginning.
55
* Elements are dropped until `predicate` returns falsey. The predicate is
6-
* bound to `thisArg` and invoked with three arguments; (value, index, array).
6+
* bound to `thisArg` and invoked with three arguments: (value, index, array).
77
*
88
* If a property name is provided for `predicate` the created `_.property`
99
* style callback returns the property value of the given element.
@@ -50,14 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
5050
* // => ['barney', 'fred', 'pebbles']
5151
*/
5252
function dropWhile(array, predicate, thisArg) {
53-
var length = array ? array.length : 0;
54-
if (!length) {
55-
return [];
56-
}
57-
var index = -1;
58-
predicate = baseCallback(predicate, thisArg, 3);
59-
while (++index < length && predicate(array[index], index, array)) {}
60-
return baseSlice(array, index);
53+
return (array && array.length)
54+
? baseWhile(array, baseCallback(predicate, thisArg, 3), true)
55+
: [];
6156
}
6257

6358
return dropWhile;

array/fill.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ define(['../internal/baseFill', '../internal/isIterateeCall'], function(baseFill
1414
* @param {number} [start=0] The start position.
1515
* @param {number} [end=array.length] The end position.
1616
* @returns {Array} Returns `array`.
17+
* @example
18+
*
19+
* var array = [1, 2, 3];
20+
*
21+
* _.fill(array, 'a D7AE ');
22+
* console.log(array);
23+
* // => ['a', 'a', 'a']
24+
*
25+
* _.fill(Array(3), 2);
26+
* // => [2, 2, 2]
27+
*
28+
* _.fill([4, 6, 8], '*', 1, 2);
29+
* // => [4, '*', 8]
1730
*/
1831
function fill(array, value, start, end) {
1932
var length = array ? array.length : 0;

array/findIndex.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
define(['../internal/baseCallback'], function(baseCallback) {
1+
define(['../internal/createFindIndex'], function(createFindIndex) {
22

33
/**
44
* This method is like `_.find` except that it returns the index of the first
5-
* element `predicate` returns truthy for, instead of the element itself.
5+
* element `predicate` returns truthy for instead of the element itself.
66
*
77
* If a property name is provided for `predicate` the created `_.property`
88
* style callback returns the property value of the given element.
@@ -48,18 +48,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
4848
* _.findIndex(users, 'active');
4949
* // => 2
5050
*/
51-
function findIndex(array, predicate, thisArg) {
52-
var index = -1,
53-
length = array ? array.length : 0;
54-
55-
predicate = baseCallback(predicate, thisArg, 3);
56-
while (++index < length) {
57-
if (predicate(array[index], index, array)) {
58-
return index;
59-
}
60-
}
61-
return -1;
62-
}
51+
var findIndex = createFindIndex();
6352

6453
return findIndex;
6554
});

array/findLastIndex.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['../internal/baseCallback'], function(baseCallback) {
1+
define(['../internal/createFindIndex'], function(createFindIndex) {
22

33
/**
44
* This method is like `_.findIndex` except that it iterates over elements
@@ -48,16 +48,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
4848
* _.findLastIndex(users, 'active');
4949
* // => 0
5050
*/
51-
function findLastIndex(array, predicate, thisArg) {
52-
var length = array ? array.length : 0;
53-
predicate = baseCallback(predicate, thisArg, 3);
54-
while (length--) {
55-
if (predicate(array[length], length, array)) {
56-
return length;
57-
}
58-
}
59-
return -1;
60-
}
51+
var findLastIndex = createFindIndex(true);
6152

6253
return findLastIndex;
6354
});

array/flatten.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ define(['../internal/baseFlatten', '../internal/isIterateeCall'], function(baseF
1414
* @example
1515
*
1616
* _.flatten([1, [2, 3, [4]]]);
17-
* // => [1, 2, 3, [4]];
17+
* // => [1, 2, 3, [4]]
1818
*
1919
* // using `isDeep`
2020
* _.flatten([1, [2, 3, [4]]], true);
21-
* // => [1, 2, 3, 4];
21+
* // => [1, 2, 3, 4]
2222
*/
2323
function flatten(array, isDeep, guard) {
2424
var length = array ? array.length : 0;
2525
if (guard && isIterateeCall(array, isDeep, guard)) {
2626
isDeep = false;
2727
}
28-
return length ? baseFlatten(array, isDeep, false, 0) : [];
28+
return length ? baseFlatten(array, isDeep) : [];
2929
}
3030

3131
return flatten;

array/flattenDeep.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ define(['../internal/baseFlatten'], function(baseFlatten) {
1111
* @example
1212
*
1313
* _.flattenDeep([1, [2, 3, [4]]]);
14-
* // => [1, 2, 3, 4];
14+
* // => [1, 2, 3, 4]
1515
*/
1616
function flattenDeep(array) {
1717
var length = array ? array.length : 0;
18-
return length ? baseFlatten(array, true, false, 0) : [];
18+
return length ? baseFlatten(array, true) : [];
1919
}
2020

2121
return flattenDeep;

array/indexOf.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
99
* it is used as the offset from the end of `array`. If `array` is sorted
1010
* providing `true` for `fromIndex` performs a faster binary search.
1111
*
12-
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
13-
* e.g. `===`, except that `NaN` matches `NaN`. See the
14-
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
15-
* for more details.
12+
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
13+
* comparisons are like strict equality comparisons, e.g. `===`, except that
14+
* `NaN` matches `NaN`.
1615
*
1716
* @static
1817
* @memberOf _

0 commit comments

Comments
 (0)
0