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

Skip to content

Commit ddf9328

Browse files
committed
Bump to v4.6.0.
1 parent 7eeb5eb commit ddf9328

Some content is hidden

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

70 files changed

+971
-648
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash v4.5.1
1+
# lodash v4.6.0
22

33
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
44

@@ -28,7 +28,7 @@ var chunk = require('lodash/chunk');
2828
var extend = require('lodash/fp/extend');
2929
```
3030

31-
See the [package source](https://github.com/lodash/lodash/tree/4.5.1-npm) for more details.
31+
See the [package source](https://github.com/lodash/lodash/tree/4.6.0-npm) for more details.
3232

3333
**Note:**<br>
3434
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>

_addMapEntry.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @returns {Object} Returns `map`.
88
*/
99
function addMapEntry(map, pair) {
10+
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
1011
map.set(pair[0], pair[1]);
1112
return map;
1213
}

_arrayFilter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
function arrayFilter(array, predicate) {
1111
var index = -1,
1212
length = array.length,
13-
resIndex = -1,
13+
resIndex = 0,
1414
result = [];
1515

1616
while (++index < length) {
1717
var value = array[index];
1818
if (predicate(value, index, array)) {
19-
result[++resIndex] = value;
19+
result[resIndex++] = value;
2020
}
2121
}
2222
return result;

_arrayIncludesWith.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* A specialized version of `_.includesWith` for arrays without support for
3-
* specifying an index to search from.
2+
* This function is like `arrayIncludes` except that it accepts a comparator.
43
*
54
* @private
65
* @param {Array} array The array to search.

_assignMergeValue.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var eq = require('./eq');
22

33
/**
4-
* This function is like `assignValue` except that it doesn't assign `undefined` values.
4+
* This function is like `assignValue` except that it doesn't assign
5+
* `undefined` values.
56
*
67
* @private
78
* @param {Object} object The object to modify.

_baseIndexOfWith.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* This function is like `baseIndexOf` except that it accepts a comparator.
3+
*
4+
* @private
5+
* @param {Array} array The array to search.
6+
* @param {*} value The value to search for.
7+
* @param {number} fromIndex The index to search from.
8+
* @param {Function} comparator The comparator invoked per element.
9+
* @returns {number} Returns the index of the matched value, else `-1`.
10+
*/
11+
function baseIndexOfWith(array, value, fromIndex, comparator) {
12+
var index = fromIndex - 1,
13+
length = array.length;
14+
15+
while (++index < length) {
16+
if (comparator(array[index], value)) {
17+
return index;
18+
}
19+
}
20+
return -1;
21+
}
22+
23+
module.exports = baseIndexOfWith;

_baseIntersection.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var SetCache = require('./_SetCache'),
55
baseUnary = require('./_baseUnary'),
66
cacheHas = require('./_cacheHas');
77

8+
/* Built-in method references for those with the same name as other `lodash` methods. */
9+
var nativeMin = Math.min;
10+
811
/**
912
* The base implementation of methods like `_.intersection`, without support
1013
* for iteratee shorthands, that accepts an array of arrays to inspect.
@@ -17,36 +20,38 @@ var SetCache = require('./_SetCache'),
1720
*/
1821
function baseIntersection(arrays, iteratee, comparator) {
1922
var includes = comparator ? arrayIncludesWith : arrayIncludes,
23+
length = arrays[0].length,
2024
othLength = arrays.length,
2125
othIndex = othLength,
2226
caches = Array(othLength),
27+
maxLength = Infinity,
2328
result = [];
2429

2530
while (othIndex--) {
2631
var array = arrays[othIndex];
2732
if (othIndex && iteratee) {
2833
array = arrayMap(array, baseUnary(iteratee));
2934
}
30-
caches[othIndex] = !comparator && (iteratee || array.length >= 120)
35+
maxLength = nativeMin(array.length, maxLength);
36+
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3137
? new SetCache(othIndex && array)
3238
: undefined;
3339
}
3440
array = arrays[0];
3541

3642
var index = -1,
37-
length = array.length,
3843
seen = caches[0];
3944

4045
outer:
41-
while (++index < length) {
46+
while (++index < length && result.length < maxLength) {
4247
var value = array[index],
4348
computed = iteratee ? iteratee(value) : value;
4449

4550
if (!(seen
4651
? cacheHas(seen, computed)
4752
: includes(result, computed, comparator)
4853
)) {
49-
var othIndex = othLength;
54+
othIndex = othLength;
5055
while (--othIndex) {
5156
var cache = caches[othIndex];
5257
if (!(cache

_baseIsEqualDeep.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,36 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
4343

4444
if (!objIsArr) {
4545
objTag = getTag(object);
46-
if (objTag == argsTag) {
47-
objTag = objectTag;
48-
} else if (objTag != objectTag) {
49-
objIsArr = isTypedArray(object);
50-
}
46+
objTag = objTag == argsTag ? objectTag : objTag;
5147
}
5248
if (!othIsArr) {
5349
othTag = getTag(other);
54-
if (othTag == argsTag) {
55-
othTag = objectTag;
56-
} else if (othTag != objectTag) {
57-
othIsArr = isTypedArray(other);
58-
}
50+
othTag = othTag == argsTag ? objectTag : othTag;
5951
}
6052
var objIsObj = objTag == objectTag && !isHostObject(object),
6153
othIsObj = othTag == objectTag && !isHostObject(other),
6254
isSameTag = objTag == othTag;
6355

64-
if (isSameTag && !(objIsArr || objIsObj)) {
65-
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
56+
if (isSameTag && !objIsObj) {
57+
stack || (stack = new Stack);
58+
return (objIsArr || isTypedArray(object))
59+
? equalArrays(object, other, equalFunc, customi 224F zer, bitmask, stack)
60+
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
6661
}
67-
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
68-
if (!isPartial) {
62+
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
6963
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
7064
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
7165

7266
if (objIsWrapped || othIsWrapped) {
67+
stack || (stack = new Stack);
7368
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
7469
}
7570
}
7671
if (!isSameTag) {
7772
return false;
7873
}
7974
stack || (stack = new Stack);
80-
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
75+
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
8176
}
8277

8378
module.exports = baseIsEqualDeep;

_baseMergeDeep.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
5050
}
5151
else {
5252
isCommon = false;
53-
newValue = baseClone(srcValue, true);
53+
newValue = baseClone(srcValue, !customizer);
5454
}
5555
}
5656
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -59,7 +59,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
5959
}
6060
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
6161
isCommon = false;
62-
newValue = baseClone(srcValue, true);
62+
newValue = baseClone(srcValue, !customizer);
6363
}
6464
else {
6565
newValue = objValue;
@@ -75,6 +75,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
7575
// Recursively merge objects and arrays (susceptible to call stack limits).
7676
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
7777
}
78+
stack['delete'](srcValue);
7879
assignMergeValue(object, key, newValue);
7980
}
8081

_baseOrderBy.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ var arrayMap = require('./_arrayMap'),
1414
* @returns {Array} Returns the new sorted array.
1515
*/
1616
function baseOrderBy(collection, iteratees, orders) {
17-
var index = -1,
18-
toIteratee = baseIteratee;
19-
20-
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
21-
return toIteratee(iteratee);
22-
});
17+
var index = -1;
18+
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), baseIteratee);
2319

2420
var result = baseMap(collection, function(value, key, collection) {
2521
var criteria = arrayMap(iteratees, function(iteratee) {

_basePullAll.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
1-
var basePullAllBy = require('./_basePullAllBy');
1+
var arrayMap = require('./_arrayMap'),
2+
baseIndexOf = require('./_baseIndexOf'),
3+
baseIndexOfWith = require('./_baseIndexOfWith'),
4+
baseUnary = require('./_baseUnary');
5+
6+
/** Used for built-in method references. */
7+
var arrayProto = Array.prototype;
8+
9+
/** Built-in value references. */
10+
var splice = arrayProto.splice;
211

312
/**
4-
* The base implementation of `_.pullAll`.
13+
* The base implementation of `_.pullAllBy` without support for iteratee
14+
* shorthands.
515
*
616
* @private
717
* @param {Array} array The array to modify.
818
* @param {Array} values The values to remove.
19+
* @param {Function} [iteratee] The iteratee invoked per element.
20+
* @param {Function} [comparator] The comparator invoked per element.
921
* @returns {Array} Returns `array`.
1022
*/
11-
function basePullAll(array, values) {
12-
return basePullAllBy(array, values);
23+
function basePullAll(array, values, iteratee, comparator) {
24+
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
25+
index = -1,
26+
length = values.length,
27+
seen = array;
28+
29+
if (iteratee) {
30+
seen = arrayMap(array, baseUnary(iteratee));
31+
}
32+
while (++index < length) {
33+
var fromIndex = 0,
34+
value = values[index],
35+
computed = iteratee ? iteratee(value) : value;
36+
37+
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
38+
if (seen !== array) {
39+
splice.call(seen, fromIndex, 1);
40+
}
41+
splice.call(array, fromIndex, 1);
42+
}
43+
}
44+
return array;
1345
}
1446

1547
module.exports = basePullAll;

_basePullAllBy.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

_baseSortBy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* The base implementation of `_.sortBy` which uses `comparer` to define
3-
* the sort order of `array` and replaces criteria objects with their
4-
* corresponding values.
2+
* The base implementation of `_.sortBy` which uses `comparer` to define the
3+
* sort order of `array` and replaces criteria objects with their corresponding
4+
* values.
55
*
66
* @private
77
* @param {Array} array The array to sort.

_baseSortedUniqBy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
1515
value = array[0],
1616
computed = iteratee ? iteratee(value) : value,
1717
seen = computed,
18-
resIndex = 0,
18+
resIndex = 1,
1919
result = [value];
2020

2121
while (++index < length) {
@@ -24,7 +24,7 @@ function baseSortedUniqBy(array, iteratee) {
2424

2525
if (!eq(computed, seen)) {
2626
seen = computed;
27-
result[++resIndex] = value;
27+
result[resIndex++] = value;
2828
}
2929
}
3030
return result;

_baseUpdate.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var baseGet = require('./_baseGet'),
2+
baseSet = require('./_baseSet');
3+
4+
/**
5+
* The base implementation of `_.update`.
6+
*
7+
* @private
8+
* @param {Object} object The object to query.
9+
* @param {Array|string} path The path of the property to update.
10+
* @param {Function} updater The function to produce the updated value.
11+
* @param {Function} [customizer] The function to customize path creation.
12+
* @returns {Object} Returns `object`.
13+
*/
14+
function baseUpdate(object, path, updater, customizer) {
15+
return baseSet(object, path, updater(baseGet(object, path)), customizer);
16+
}
17+
18+
module.exports = baseUpdate;

_cloneArrayBuffer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ var Uint8Array = require('./_Uint8Array');
88
* @returns {ArrayBuffer} Returns the cloned array buffer.
99
*/
1010
function cloneArrayBuffer(arrayBuffer) {
11-
var Ctor = arrayBuffer.constructor,
12-
result = new Ctor(arrayBuffer.byteLength),
13-
view = new Uint8Array(result);
14-
15-
view.set(new Uint8Array(arrayBuffer));
11+
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
12+
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1613
return result;
1714
}
1815

_cloneBuffer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ function cloneBuffer(buffer, isDeep) {
1010
if (isDeep) {
1111
return buffer.slice();
1212
}
13-
var Ctor = buffer.constructor,
14-
result = new Ctor(buffer.length);
15-
13+
var result = new buffer.constructor(buffer.length);
1614
buffer.copy(result);
1715
return result;
1816
}

0 commit comments

Comments
 (0)
0