mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
035ce4f44c | ||
|
|
95f47b6d19 |
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.17.0
|
# lodash-es v4.17.2
|
||||||
|
|
||||||
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
|||||||
$ lodash modularize exports=es -o ./
|
$ lodash modularize exports=es -o ./
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.17.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.17.2-es) for more details.
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import toKey from './_toKey.js';
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = castPath(path, object);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import apply from './_apply.js';
|
import apply from './_apply.js';
|
||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
import parent from './_parent.js';
|
import parent from './_parent.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
@@ -16,12 +15,9 @@ import toKey from './_toKey.js';
|
|||||||
* @returns {*} Returns the result of the invoked method.
|
* @returns {*} Returns the result of the invoked method.
|
||||||
*/
|
*/
|
||||||
function baseInvoke(object, path, args) {
|
function baseInvoke(object, path, args) {
|
||||||
if (!isKey(path, object)) {
|
path = castPath(path, object);
|
||||||
path = castPath(path);
|
object = parent(object, path);
|
||||||
object = parent(object, path);
|
var func = object == null ? object : object[toKey(last(path))];
|
||||||
path = last(path);
|
|
||||||
}
|
|
||||||
var func = object == null ? object : object[toKey(path)];
|
|
||||||
return func == null ? undefined : apply(func, object, args);
|
return func == null ? undefined : apply(func, object, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import baseGet from './_baseGet.js';
|
import baseGet from './_baseGet.js';
|
||||||
import baseSet from './_baseSet.js';
|
import baseSet from './_baseSet.js';
|
||||||
|
import castPath from './_castPath.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||||
@@ -20,7 +21,7 @@ function basePickBy(object, paths, predicate) {
|
|||||||
value = baseGet(object, path);
|
value = baseGet(object, path);
|
||||||
|
|
||||||
if (predicate(value, path)) {
|
if (predicate(value, path)) {
|
||||||
baseSet(result, path, value);
|
baseSet(result, castPath(path, object), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import castPath from './_castPath.js';
|
import baseUnset from './_baseUnset.js';
|
||||||
import isIndex from './_isIndex.js';
|
import isIndex from './_isIndex.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import last from './last.js';
|
|
||||||
import parent from './_parent.js';
|
|
||||||
import toKey from './_toKey.js';
|
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -30,17 +26,8 @@ function basePullAt(array, indexes) {
|
|||||||
var previous = index;
|
var previous = index;
|
||||||
if (isIndex(index)) {
|
if (isIndex(index)) {
|
||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
} else {
|
||||||
else if (!isKey(index, array)) {
|
baseUnset(array, index);
|
||||||
var path = castPath(index),
|
|
||||||
object = parent(array, path);
|
|
||||||
|
|
||||||
if (object != null) {
|
|
||||||
delete object[toKey(last(path))];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete array[toKey(index)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import assignValue from './_assignValue.js';
|
import assignValue from './_assignValue.js';
|
||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
import isIndex from './_isIndex.js';
|
import isIndex from './_isIndex.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ function baseSet(object, path, value, customizer) {
|
|||||||
if (!isObject(object)) {
|
if (!isObject(object)) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = castPath(path, object);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
import parent from './_parent.js';
|
import parent from './_parent.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
|
||||||
var objectProto = Object.prototype;
|
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.unset`.
|
* The base implementation of `_.unset`.
|
||||||
*
|
*
|
||||||
@@ -19,11 +12,9 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = castPath(path, object);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
|
return object == null || delete object[toKey(last(path))];
|
||||||
var key = toKey(last(path));
|
|
||||||
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseUnset;
|
export default baseUnset;
|
||||||
|
|||||||
10
_castPath.js
10
_castPath.js
@@ -1,15 +1,21 @@
|
|||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
import isKey from './_isKey.js';
|
||||||
import stringToPath from './_stringToPath.js';
|
import stringToPath from './_stringToPath.js';
|
||||||
|
import toString from './toString.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Casts `value` to a path array if it's not one.
|
* Casts `value` to a path array if it's not one.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to inspect.
|
* @param {*} value The value to inspect.
|
||||||
|
* @param {Object} [object] The object to query keys on.
|
||||||
* @returns {Array} Returns the cast property path array.
|
* @returns {Array} Returns the cast property path array.
|
||||||
*/
|
*/
|
||||||
function castPath(value) {
|
function castPath(value, object) {
|
||||||
return isArray(value) ? value : stringToPath(value);
|
if (isArray(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default castPath;
|
export default castPath;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import castPath from './_castPath.js';
|
|||||||
import isArguments from './isArguments.js';
|
import isArguments from './isArguments.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isIndex from './_isIndex.js';
|
import isIndex from './_isIndex.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import isLength from './isLength.js';
|
import isLength from './isLength.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ import toKey from './_toKey.js';
|
|||||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||||
*/
|
*/
|
||||||
function hasPath(object, path, hasFunc) {
|
function hasPath(object, path, hasFunc) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = castPath(path, object);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import baseSlice from './_baseSlice.js';
|
|||||||
* @returns {*} Returns the parent value.
|
* @returns {*} Returns the parent value.
|
||||||
*/
|
*/
|
||||||
function parent(object, path) {
|
function parent(object, path) {
|
||||||
return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default parent;
|
export default parent;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import memoizeCapped from './_memoizeCapped.js';
|
import memoizeCapped from './_memoizeCapped.js';
|
||||||
import toString from './toString.js';
|
|
||||||
|
|
||||||
/** Used to match property names within property paths. */
|
/** Used to match property names within property paths. */
|
||||||
var reLeadingDot = /^\./,
|
var reLeadingDot = /^\./,
|
||||||
@@ -16,8 +15,6 @@ var reEscapeChar = /\\(\\)?/g;
|
|||||||
* @returns {Array} Returns the property path array.
|
* @returns {Array} Returns the property path array.
|
||||||
*/
|
*/
|
||||||
var stringToPath = memoizeCapped(function(string) {
|
var stringToPath = memoizeCapped(function(string) {
|
||||||
string = toString(string);
|
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
if (reLeadingDot.test(string)) {
|
if (reLeadingDot.test(string)) {
|
||||||
result.push('');
|
result.push('');
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import baseEach from './_baseEach.js';
|
|||||||
import baseInvoke from './_baseInvoke.js';
|
import baseInvoke from './_baseInvoke.js';
|
||||||
import baseRest from './_baseRest.js';
|
import baseRest from './_baseRest.js';
|
||||||
import isArrayLike from './isArrayLike.js';
|
import isArrayLike from './isArrayLike.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes the method at `path` of each element in `collection`, returning
|
* Invokes the method at `path` of each element in `collection`, returning
|
||||||
@@ -31,12 +30,10 @@ import isKey from './_isKey.js';
|
|||||||
var invokeMap = baseRest(function(collection, path, args) {
|
var invokeMap = baseRest(function(collection, path, args) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
isFunc = typeof path == 'function',
|
isFunc = typeof path == 'function',
|
||||||
isProp = isKey(path),
|
|
||||||
result = isArrayLike(collection) ? Array(collection.length) : [];
|
result = isArrayLike(collection) ? Array(collection.length) : [];
|
||||||
|
|
||||||
baseEach(collection, function(value) {
|
baseEach(collection, function(value) {
|
||||||
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
|
result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
|
||||||
result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import toInteger from './toInteger.js';
|
|||||||
import lodash from './wrapperLodash.js';
|
import lodash from './wrapperLodash.js';
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '4.17.0';
|
var VERSION = '4.17.2';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
var WRAP_BIND_KEY_FLAG = 2;
|
var WRAP_BIND_KEY_FLAG = 2;
|
||||||
|
|||||||
13
omit.js
13
omit.js
@@ -1,5 +1,7 @@
|
|||||||
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseClone from './_baseClone.js';
|
import baseClone from './_baseClone.js';
|
||||||
import baseUnset from './_baseUnset.js';
|
import baseUnset from './_baseUnset.js';
|
||||||
|
import castPath from './_castPath.js';
|
||||||
import copyObject from './_copyObject.js';
|
import copyObject from './_copyObject.js';
|
||||||
import flatRest from './_flatRest.js';
|
import flatRest from './_flatRest.js';
|
||||||
import getAllKeysIn from './_getAllKeysIn.js';
|
import getAllKeysIn from './_getAllKeysIn.js';
|
||||||
@@ -34,9 +36,16 @@ var omit = flatRest(function(object, paths) {
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
var isDeep = false;
|
||||||
|
paths = arrayMap(paths, function(path) {
|
||||||
|
path = castPath(path, object);
|
||||||
|
isDeep || (isDeep = path.length > 1);
|
||||||
|
return path;
|
||||||
|
});
|
||||||
copyObject(object, getAllKeysIn(object), result);
|
copyObject(object, getAllKeysIn(object), result);
|
||||||
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
|
if (isDeep) {
|
||||||
|
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
|
||||||
|
}
|
||||||
var length = paths.length;
|
var length = paths.length;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
baseUnset(result, paths[length]);
|
baseUnset(result, paths[length]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.17.0",
|
"version": "4.17.2",
|
||||||
"description": "Lodash exported as ES modules.",
|
"description": "Lodash exported as ES modules.",
|
||||||
"keywords": "es6, modules, stdlib, util",
|
"keywords": "es6, modules, stdlib, util",
|
||||||
"homepage": "https://lodash.com/custom-builds",
|
"homepage": "https://lodash.com/custom-builds",
|
||||||
|
|||||||
4
pick.js
4
pick.js
@@ -1,7 +1,5 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
|
||||||
import basePick from './_basePick.js';
|
import basePick from './_basePick.js';
|
||||||
import flatRest from './_flatRest.js';
|
import flatRest from './_flatRest.js';
|
||||||
import toKey from './_toKey.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object composed of the picked `object` properties.
|
* Creates an object composed of the picked `object` properties.
|
||||||
@@ -21,7 +19,7 @@ import toKey from './_toKey.js';
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
var pick = flatRest(function(object, paths) {
|
var pick = flatRest(function(object, paths) {
|
||||||
return object == null ? {} : basePick(object, arrayMap(paths, toKey));
|
return object == null ? {} : basePick(object, paths);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default pick;
|
export default pick;
|
||||||
|
|||||||
12
pickBy.js
12
pickBy.js
@@ -1,3 +1,4 @@
|
|||||||
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
import basePickBy from './_basePickBy.js';
|
import basePickBy from './_basePickBy.js';
|
||||||
import getAllKeysIn from './_getAllKeysIn.js';
|
import getAllKeysIn from './_getAllKeysIn.js';
|
||||||
@@ -21,7 +22,16 @@ import getAllKeysIn from './_getAllKeysIn.js';
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
function pickBy(object, predicate) {
|
function pickBy(object, predicate) {
|
||||||
return object == null ? {} : basePickBy(object, getAllKeysIn(object), baseIteratee(predicate));
|
if (object == null) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
var props = arrayMap(getAllKeysIn(object), function(prop) {
|
||||||
|
return [prop];
|
||||||
|
});
|
||||||
|
predicate = baseIteratee(predicate);
|
||||||
|
return basePickBy(object, props, function(value, path) {
|
||||||
|
return predicate(value, path[0]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default pickBy;
|
export default pickBy;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
import isFunction from './isFunction.js';
|
import isFunction from './isFunction.js';
|
||||||
import isKey from './_isKey.js';
|
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,15 +32,15 @@ import toKey from './_toKey.js';
|
|||||||
* // => 'default'
|
* // => 'default'
|
||||||
*/
|
*/
|
||||||
function result(object, path, defaultValue) {
|
function result(object, path, defaultValue) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = castPath(path, object);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|
||||||
// Ensure the loop is entered when path is empty.
|
// Ensure the loop is entered when path is empty.
|
||||||
if (!length) {
|
if (!length) {
|
||||||
object = undefined;
|
|
||||||
length = 1;
|
length = 1;
|
||||||
|
object = undefined;
|
||||||
}
|
}
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = object == null ? undefined : object[toKey(path[index])];
|
var value = object == null ? undefined : object[toKey(path[index])];
|
||||||
|
|||||||
@@ -51,15 +51,11 @@ function spread(func, start) {
|
|||||||
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
||||||
return baseRest(function(args) {
|
return baseRest(function(args) {
|
||||||
var array = args[start],
|
var array = args[start],
|
||||||
lastIndex = args.length - 1,
|
|
||||||
otherArgs = castSlice(args, 0, start);
|
otherArgs = castSlice(args, 0, start);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
arrayPush(otherArgs, array);
|
arrayPush(otherArgs, array);
|
||||||
}
|
}
|
||||||
if (start != lastIndex) {
|
|
||||||
arrayPush(otherArgs, castSlice(args, start + 1));
|
|
||||||
}
|
|
||||||
return apply(func, this, otherArgs);
|
return apply(func, this, otherArgs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import isArray from './isArray.js';
|
|||||||
import isSymbol from './isSymbol.js';
|
import isSymbol from './isSymbol.js';
|
||||||
import stringToPath from './_stringToPath.js';
|
import stringToPath from './_stringToPath.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
import toString from './toString.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `value` to a property path array.
|
* Converts `value` to a property path array.
|
||||||
@@ -26,7 +27,7 @@ function toPath(value) {
|
|||||||
if (isArray(value)) {
|
if (isArray(value)) {
|
||||||
return arrayMap(value, toKey);
|
return arrayMap(value, toKey);
|
||||||
}
|
}
|
||||||
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
|
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default toPath;
|
export default toPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user