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

Skip to content

Commit 91d3468

Browse files
committed
Bump to v4.4.0.
1 parent e2aef0d commit 91d3468

File tree

115 files changed

+1019
-654
lines changed

Some content is hidden

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

115 files changed

+1019
-654
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash v4.3.0
1+
# lodash v4.4.0
22

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

@@ -12,23 +12,23 @@ $ npm i --save lodash
1212

1313
In Node.js:
1414
```js
15-
// load the full build
15+
// Load the full build.
1616
var _ = require('lodash');
17-
// load the core build
17+
// Load the core build.
1818
var _ = require('lodash/core');
19-
// load the fp build for immutable auto-curried iteratee-first data-last methods
19+
// Load the fp build for immutable auto-curried iteratee-first data-last methods.
2020
var _ = require('lodash/fp');
2121

22-
// or a method category
22+
// Load a method category.
2323
var array = require('lodash/array');
2424
var object = require('lodash/fp/object');
2525

26-
// or method for smaller builds with browserify/rollup/webpack
26+
// Load a single method for smaller builds with browserify/rollup/webpack.
2727
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.3.0-npm) for more details.
31+
See the [package source](https://github.com/lodash/lodash/tree/4.4.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>

_Hash.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var objectProto = Object.prototype;
77
* Creates an hash object.
88
*
99
* @private
10+
* @constructor
1011
* @returns {Object} Returns the new hash object.
1112
*/
1213
function Hash() {}

_LazyWrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
88
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
99
*
1010
* @private
11+
* @constructor
1112
* @param {*} value The value to wrap.
1213
*/
1314
function LazyWrapper(value) {

_MapCache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var mapClear = require('./_mapClear'),
88
* Creates a map cache object to store key-value pairs.
99
*
1010
* @private
11+
* @constructor
1112
* @param {Array} [values] The values to cache.
1213
*/
1314
function MapCache(values) {

_SetCache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var MapCache = require('./_MapCache'),
66
* Creates a set cache object to store unique values.
77
*
88
* @private
9+
* @constructor
910
* @param {Array} [values] The values to cache.
1011
*/
1112
function SetCache(values) {

_Stack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var stackClear = require('./_stackClear'),
88
* Creates a stack cache object to store key-value pairs.
99
*
1010
* @private
11+
* @constructor
1112
* @param {Array} [values] The values to cache.
1213
*/
1314
function Stack(values) {

_baseCastArrayLikeObject.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var isArrayLikeObject = require('./isArrayLikeObject');
2+
3+
/**
4+
* Casts `value` to an empty array if it's not an array like object.
5+
*
6+
* @private
7+
* @param {*} value The value to inspect.
8+
* @returns {Array} Returns the array-like object.
9+
*/
10+
function baseCastArrayLikeObject(value) {
11+
return isArrayLikeObject(value) ? value : [];
12+
}
13+
14+
module.exports = baseCastArrayLikeObject;

_baseCastFunction.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var identity = require('./identity');
2+
3+
/**
4+
* Casts `value` to `identity` if it's not a function.
5+
*
6+
* @private
7+
* @param {*} value The value to inspect.
8+
* @returns {Array} Returns the array-like object.
9+
*/
10+
function baseCastFunction(value) {
11+
return typeof value == 'function' ? value : identity;
12+
}
13+
14+
module.exports = baseCastFunction;

_baseCastPath.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var isArray = require('./isArray'),
2+
stringToPath = require('./_stringToPath');
3+
4+
/**
5+
* Casts `value` to a path array if it's not one.
6+
*
7+
* @private
8+
* @param {*} value The value to inspect.
9+
* @returns {Array} Returns the cast property path array.
10+
*/
11+
function baseCastPath(value) {
12+
return isArray(value) ? value : stringToPath(value);
13+
}
14+
15+
module.exports = baseCastPath;

_baseCreate.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
var isObject = require('./isObject');
22

3+
/** Built-in value references. */
4+
var objectCreate = Object.create;
5+
36
/**
47
* The base implementation of `_.create` without support for assigning
58
* properties to the created object.
@@ -8,16 +11,8 @@ var isObject = require('./isObject');
811
* @param {Object} prototype The object to inherit from.
912
* @returns {Object} Returns the new object.
1013
*/
11-
var baseCreate = (function() {
12-
function object() {}
13-
return function(prototype) {
14-
if (isObject(prototype)) {
15-
object.prototype = prototype;
16-
var result = new object;
17-
object.prototype = undefined;
18-
}
19-
return result || {};
20-
};
21-
}());
14+
function baseCreate(proto) {
15+
return isObject(proto) ? objectCreate(proto) : {};
16+
}
2217

2318
module.exports = baseCreate;

_baseFlatten.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ var arrayPush = require('./_arrayPush'),
88
*
99
* @private
1010
* @param {Array} array The array to flatten.
11-
* @param {boolean} [isDeep] Specify a deep flatten.
11+
* @param {number} depth The maximum recursion depth.
1212
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
1313
* @param {Array} [result=[]] The initial result value.
1414
* @returns {Array} Returns the new flattened array.
1515
*/
16-
function baseFlatten(array, isDeep, isStrict, result) {
16+
function baseFlatten(array, depth, isStrict, result) {
1717
result || (result = []);
1818

1919
var index = -1,
2020
length = array.length;
2121

2222
while (++index < length) {
2323
var value = array[index];
24-
if (isArrayLikeObject(value) &&
24+
if (depth > 0 && isArrayLikeObject(value) &&
2525
(isStrict || isArray(value) || isArguments(value))) {
26-
if (isDeep) {
26+
if (depth > 1) {
2727< 10000 code class="diff-text syntax-highlighted-line">
// Recursively flatten arrays (susceptible to call stack limits).
28-
baseFlatten(value, isDeep, isStrict, result);
28+
baseFlatten(value, depth - 1, isStrict, result);
2929
} else {
3030
arrayPush(result, value);
3131
}

_baseGet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var baseToPath = require('./_baseToPath'),
1+
var baseCastPath = require('./_baseCastPath'),
22
isKey = require('./_isKey');
33

44
/**
@@ -10,7 +10,7 @@ var baseToPath = require('./_baseToPath'),
1010
* @returns {*} Returns the resolved value.
1111
*/
1212
function baseGet(object, path) {
13-
path = isKey(path, object) ? [path + ''] : baseToPath(path);
13+
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
1414

1515
var index = 0,
1616
length = path.length;

_baseIntersection.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@ function baseIntersection(arrays, iteratee, comparator) {
4242
var value = array[index],
4343
computed = iteratee ? iteratee(value) : value;
4444

45-
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
45+
if (!(seen
46+
? cacheHas(seen, computed)
47+
: includes(result, computed, comparator)
48+
)) {
4649
var othIndex = othLength;
4750
while (--othIndex) {
4851
var cache = caches[othIndex];
49-
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
52+
if (!(cache
53+
? cacheHas(cache, computed)
54+
: includes(arrays[othIndex], computed, comparator))
55+
) {
5056
continue outer;
5157
}
5258
}

_baseInvoke.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var apply = require('./_apply'),
2-
baseToPath = require('./_baseToPath'),
2+
baseCastPath = require('./_baseCastPath'),
33
isKey = require('./_isKey'),
44
last = require('./last'),
55
parent = require('./_parent');
@@ -16,7 +16,7 @@ var apply = require('./_apply'),
1616
*/
1717
function baseInvoke(object, path, args) {
1818
if (!isKey(path, object)) {
19-
path = baseToPath(path);
19+
path = baseCastPath(path);
2020
object = parent(object, path);
2121
path = last(path);
2222
}

_baseKeys.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
66
* property of prototypes or treat sparse arrays as dense.
77
*
88
* @private
9-
* @type Function
109
* @param {Object} object The object to query.
1110
* @returns {Array} Returns the array of property names.
1211
*/

_baseMerge.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
2121
if (< F438 /span>object === source) {
2222
return;
2323
}
24-
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
24+
var props = (isArray(source) || isTypedArray(source))
25+
? undefined
26+
: keysIn(source);
27+
2528
arrayEach(props || source, function(srcValue, key) {
2629
if (props) {
2730
key = srcValue;
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
3235
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3336
}
3437
else {
35-
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
38+
var newValue = customizer
39+
? customizer(object[key], srcValue, (key + ''), object, source, stack)
40+
: undefined;
41+
3642
if (newValue === undefined) {
3743
newValue = srcValue;
3844
}

_baseMergeDeep.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
3333
assignMergeValue(object, key, stacked);
3434
return;
3535
}
36-
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
37-
isCommon = newValue === undefined;
36+
var newValue = customizer
37+
? customizer(objValue, srcValue, (key + ''), object, source, stack)
38+
: undefined;
39+
40+
var isCommon = newValue === undefined;
3841

3942
if (isCommon) {
4043
newValue = srcValue;
4144
if (isArray(srcValue) || isTypedArray(srcValue)) {
4245
if (isArray(objValue)) {
43-
newValue = srcIndex ? copyArray(objValue) : objValue;
46+
newValue = objValue;
4447
}
4548
else if (isArrayLikeObject(objValue)) {
4649
newValue = copyArray(objValue);
4750
}
4851
else {
4952
isCommon = false;
50-
newValue = baseClone(srcValue);
53+
newValue = baseClone(srcValue, true);
5154
}
5255
}
5356
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
5659
}
5760
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
5861
isCommon = false;
59-
newValue = baseClone(srcValue);
62+
newValue = baseClone(srcValue, true);
6063
}
6164
else {
62-
newValue = srcIndex ? baseClone(objValue) : objValue;
65+
newValue = objValue;
6366
}
6467
}
6568
else {

_basePullAt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var baseToPath = require('./_baseToPath'),
1+
var baseCastPath = require('./_baseCastPath'),
22
isIndex = require('./_isIndex'),
33
isKey = require('./_isKey'),
44
last = require('./last'),
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
3131
splice.call(array, index, 1);
3232
}
3333
else if (!isKey(index, array)) {
34-
var path = baseToPath(index),
34+
var path = baseCastPath(index),
3535
object = parent(array, path);
3636

3737
if (object != null) {

_baseSet.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var assignValue = require('./_assignValue'),
2-
baseToPath = require('./_baseToPath'),
2+
baseCastPath = require('./_baseCastPath'),
33
isIndex = require('./_isIndex'),
44
isKey = require('./_isKey'),
55
isObject = require('./isObject');
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
1515
* @returns {Object} Returns `object`.
1616
*/
1717
function baseSet(object, path, value, customizer) {
18-
path = isKey(path, object) ? [path + ''] : baseToPath(path);
18+
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
1919

2020
var index = -1,
2121
length = path.length,
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
3030
var objValue = nested[key];
3131
newValue = customizer ? customizer(objValue, key, nested) : undefined;
3232
if (newValue === undefined) {
33-
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
33+
newValue = objValue == null
34+
? (isIndex(path[index + 1]) ? [] : {})
35+
: objValue;
3436
}
3537
}
3638
assignValue(nested, key, newValue);

_baseToPath.js

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

_baseUnset.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var baseToPath = require('./_baseToPath'),
1+
var baseCastPath = require('./_baseCastPath'),
22
has = require('./has'),
33
isKey = require('./_isKey'),
44
last = require('./last'),
@@ -13,7 +13,7 @@ var baseToPath = require('./_baseToPath'),
1313
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
1414
*/
1515
function baseUnset(object, path) {
16-
path = isKey(path, object) ? [path + ''] : baseToPath(path);
16+
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
1717
object = parent(object, path);
1818
var key = last(path);
1919
return (object != null && has(object, key)) ? delete object[key] : true;

_cloneTypedArray.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ var cloneArrayBuffer = require('./_cloneArrayBuffer');
99
* @returns {Object} Returns the cloned typed array.
1010
*/
1111
function cloneTypedArray(typedArray, isDeep) {
12-
var buffer = typedArray.buffer,
12+
var arrayBuffer = typedArray.buffer,
13+
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
1314
Ctor = typedArray.constructor;
1415

15-
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
16+
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
1617
}
1718

1819
module.exports = cloneTypedArray;

0 commit comments

Comments
 (0)
0