mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Bump to v3.8.0.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# lodash-es v3.7.0
|
||||
# lodash-es v3.8.0
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [ES](https://people.mozilla.org/~jorendorff/es6-draft.html) modules.
|
||||
|
||||
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||
$ lodash modularize modern exports=es -o ./
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/3.7.0-es) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/3.8.0-es) for more details.
|
||||
|
||||
6
array.js
6
array.js
@@ -34,10 +34,12 @@ import union from './array/union';
|
||||
import uniq from './array/uniq';
|
||||
import unique from './array/unique';
|
||||
import unzip from './array/unzip';
|
||||
import unzipWith from './array/unzipWith';
|
||||
import without from './array/without';
|
||||
import xor from './array/xor';
|
||||
import zip from './array/zip';
|
||||
import zipObject from './array/zipObject';
|
||||
import zipWith from './array/zipWith';
|
||||
|
||||
export default {
|
||||
'chunk': chunk,
|
||||
@@ -76,8 +78,10 @@ export default {
|
||||
'uniq': uniq,
|
||||
'unique': unique,
|
||||
'unzip': unzip,
|
||||
'unzipWith': unzipWith,
|
||||
'without': without,
|
||||
'xor': xor,
|
||||
'zip': zip,
|
||||
'zipObject': zipObject
|
||||
'zipObject': zipObject,
|
||||
'zipWith': zipWith
|
||||
};
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import baseDifference from '../internal/baseDifference';
|
||||
import baseFlatten from '../internal/baseFlatten';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import restParam from '../function/restParam';
|
||||
|
||||
/**
|
||||
* Creates an array excluding all values of the provided arrays using
|
||||
* `SameValueZero` for equality comparisons.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -24,7 +20,7 @@ import restParam from '../function/restParam';
|
||||
* // => [1, 3]
|
||||
*/
|
||||
var difference = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
@@ -6,13 +6,10 @@ var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `value` is found in `array`
|
||||
* using `SameValueZero` for equality comparisons. If `fromIndex` is negative,
|
||||
* it is used as the offset from the end of `array`. If `array` is sorted
|
||||
* providing `true` for `fromIndex` performs a faster binary search.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
|
||||
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
|
||||
* performs a faster binary search.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import baseIndexOf from '../internal/baseIndexOf';
|
||||
import cacheIndexOf from '../internal/cacheIndexOf';
|
||||
import createCache from '../internal/createCache';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
|
||||
/**
|
||||
* Creates an array of unique values in all provided arrays using `SameValueZero`
|
||||
* Creates an array of unique values in all provided arrays using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
@@ -32,7 +28,7 @@ function intersection() {
|
||||
|
||||
while (++argsIndex < argsLength) {
|
||||
var value = arguments[argsIndex];
|
||||
if (isArray(value) || isArguments(value)) {
|
||||
if (isArrayLike(value)) {
|
||||
args.push(value);
|
||||
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,11 @@ var arrayProto = Array.prototype;
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
/**
|
||||
* Removes all provided values from `array` using `SameValueZero` for equality
|
||||
* comparisons.
|
||||
* Removes all provided values from `array` using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* **Notes:**
|
||||
* - Unlike `_.without`, this method mutates `array`
|
||||
* - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except
|
||||
* that `NaN` matches `NaN`
|
||||
* **Note:** Unlike `_.without`, this method mutates `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -30,7 +30,6 @@ import restParam from '../function/restParam';
|
||||
* // => [10, 20]
|
||||
*/
|
||||
var pullAt = restParam(function(array, indexes) {
|
||||
array || (array = []);
|
||||
indexes = baseFlatten(indexes);
|
||||
|
||||
var result = baseAt(array, indexes);
|
||||
|
||||
@@ -4,11 +4,8 @@ import restParam from '../function/restParam';
|
||||
|
||||
/**
|
||||
* Creates an array of unique values, in order, of the provided arrays using
|
||||
* `SameValueZero` for equality comparisons.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -4,8 +4,9 @@ import isIterateeCall from '../internal/isIterateeCall';
|
||||
import sortedUniq from '../internal/sortedUniq';
|
||||
|
||||
/**
|
||||
* Creates a duplicate-free version of an array, using `SameValueZero` for
|
||||
* equality comparisons, in which only the first occurence of each element
|
||||
* Creates a duplicate-free version of an array, using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons, in which only the first occurence of each element
|
||||
* is kept. Providing `true` for `isSorted` performs a faster search algorithm
|
||||
* for sorted arrays. If an iteratee function is provided it is invoked for
|
||||
* each element in the array to generate the criterion by which uniqueness
|
||||
@@ -23,10 +24,6 @@ import sortedUniq from '../internal/sortedUniq';
|
||||
* callback returns `true` for elements that have the properties of the given
|
||||
* object, else `false`.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias unique
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import arrayFilter from '../internal/arrayFilter';
|
||||
import arrayMap from '../internal/arrayMap';
|
||||
import arrayMax from '../internal/arrayMax';
|
||||
import baseProperty from '../internal/baseProperty';
|
||||
import getLength from '../internal/getLength';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* This method is like `_.zip` except that it accepts an array of grouped
|
||||
* elements and creates an array regrouping the elements to their pre-`_.zip`
|
||||
* elements and creates an array regrouping the elements to their pre-zip
|
||||
* configuration.
|
||||
*
|
||||
* @static
|
||||
@@ -22,10 +25,19 @@ import getLength from '../internal/getLength';
|
||||
* // => [['fred', 'barney'], [30, 40], [true, false]]
|
||||
*/
|
||||
function unzip(array) {
|
||||
if (!(array && array.length)) {
|
||||
return [];
|
||||
}
|
||||
var index = -1,
|
||||
length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
|
||||
result = Array(length);
|
||||
length = 0;
|
||||
|
||||
array = arrayFilter(array, function(group) {
|
||||
if (isArrayLike(group)) {
|
||||
length = nativeMax(group.length, length);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
var result = Array(length);
|
||||
while (++index < length) {
|
||||
result[index] = arrayMap(array, baseProperty(index));
|
||||
}
|
||||
|
||||
41
array/unzipWith.js
Normal file
41
array/unzipWith.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import arrayMap from '../internal/arrayMap';
|
||||
import arrayReduce from '../internal/arrayReduce';
|
||||
import bindCallback from '../internal/bindCallback';
|
||||
import unzip from './unzip';
|
||||
|
||||
/**
|
||||
* This method is like `_.unzip` except that it accepts an iteratee to specify
|
||||
* how regrouped values should be combined. The `iteratee` is bound to `thisArg`
|
||||
* and invoked with four arguments: (accumulator, value, index, group).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array of grouped elements to process.
|
||||
* @param {Function} [iteratee] The function to combine regrouped values.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Array} Returns the new array of regrouped elements.
|
||||
* @example
|
||||
*
|
||||
* var zipped = _.zip([1, 2], [10, 20], [100, 200]);
|
||||
* // => [[1, 10, 100], [2, 20, 200]]
|
||||
*
|
||||
* _.unzipWith(zipped, _.add);
|
||||
* // => [3, 30, 300]
|
||||
*/
|
||||
function unzipWith(array, iteratee, thisArg) {
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
var result = unzip(array);
|
||||
if (iteratee == null) {
|
||||
return result;
|
||||
}
|
||||
iteratee = bindCallback(iteratee, thisArg, 4);
|
||||
return arrayMap(result, function(group) {
|
||||
return arrayReduce(group, iteratee, undefined, true);
|
||||
});
|
||||
}
|
||||
|
||||
export default unzipWith;
|
||||
@@ -1,15 +1,11 @@
|
||||
import baseDifference from '../internal/baseDifference';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import restParam from '../function/restParam';
|
||||
|
||||
/**
|
||||
* Creates an array excluding all provided values using `SameValueZero` for
|
||||
* equality comparisons.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
* Creates an array excluding all provided values using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -23,7 +19,7 @@ import restParam from '../function/restParam';
|
||||
* // => [3]
|
||||
*/
|
||||
var without = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, values)
|
||||
: [];
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import baseDifference from '../internal/baseDifference';
|
||||
import baseUniq from '../internal/baseUniq';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
|
||||
/**
|
||||
* Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
|
||||
@@ -23,7 +22,7 @@ function xor() {
|
||||
|
||||
while (++index < length) {
|
||||
var array = arguments[index];
|
||||
if (isArray(array) || isArguments(array)) {
|
||||
if (isArrayLike(array)) {
|
||||
var result = result
|
||||
? baseDifference(result, array).concat(baseDifference(array, result))
|
||||
: array;
|
||||
|
||||
36
array/zipWith.js
Normal file
36
array/zipWith.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import restParam from '../function/restParam';
|
||||
import unzipWith from './unzipWith';
|
||||
|
||||
/**
|
||||
* This method is like `_.zip` except that it accepts an iteratee to specify
|
||||
* how grouped values should be combined. The `iteratee` is bound to `thisArg`
|
||||
* and invoked with four arguments: (accumulator, value, index, group).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to process.
|
||||
* @param {Function} [iteratee] The function to combine grouped values.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Array} Returns the new array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
* _.zipWith([1, 2], [10, 20], [100, 200], _.add);
|
||||
* // => [111, 222]
|
||||
*/
|
||||
var zipWith = restParam(function(arrays) {
|
||||
var length = arrays.length,
|
||||
iteratee = arrays[length - 2],
|
||||
thisArg = arrays[length - 1];
|
||||
|
||||
if (length > 2 && typeof iteratee == 'function') {
|
||||
length -= 2;
|
||||
} else {
|
||||
iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;
|
||||
thisArg = undefined;
|
||||
}
|
||||
arrays.length = length;
|
||||
return unzipWith(arrays, iteratee, thisArg);
|
||||
});
|
||||
|
||||
export default zipWith;
|
||||
@@ -1,9 +1,6 @@
|
||||
import baseAt from '../internal/baseAt';
|
||||
import baseFlatten from '../internal/baseFlatten';
|
||||
import getLength from '../internal/getLength';
|
||||
import isLength from '../internal/isLength';
|
||||
import restParam from '../function/restParam';
|
||||
import toIterable from '../internal/toIterable';
|
||||
|
||||
/**
|
||||
* Creates an array of elements corresponding to the given keys, or indexes,
|
||||
@@ -26,10 +23,6 @@ import toIterable from '../internal/toIterable';
|
||||
* // => ['barney', 'pebbles']
|
||||
*/
|
||||
var at = restParam(function(collection, props) {
|
||||
var length = collection ? getLength(collection) : 0;
|
||||
if (isLength(length)) {
|
||||
collection = toIterable(collection);
|
||||
}
|
||||
return baseAt(collection, baseFlatten(props));
|
||||
});
|
||||
|
||||
|
||||
@@ -10,13 +10,10 @@ import values from '../object/values';
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* Checks if `value` is in `collection` using `SameValueZero` for equality
|
||||
* comparisons. If `fromIndex` is negative, it is used as the offset from
|
||||
* the end of `collection`.
|
||||
*
|
||||
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||
* `NaN` matches `NaN`.
|
||||
* Checks if `value` is in `collection` using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
|
||||
* from the end of `collection`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import baseEach from '../internal/baseEach';
|
||||
import getLength from '../internal/getLength';
|
||||
import invokePath from '../internal/invokePath';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import isKey from '../internal/isKey';
|
||||
import isLength from '../internal/isLength';
|
||||
import restParam from '../function/restParam';
|
||||
|
||||
/**
|
||||
@@ -31,8 +30,7 @@ var invoke = restParam(function(collection, path, args) {
|
||||
var index = -1,
|
||||
isFunc = typeof path == 'function',
|
||||
isProp = isKey(path),
|
||||
length = getLength(collection),
|
||||
result = isLength(length) ? Array(length) : [];
|
||||
result = isArrayLike(collection) ? Array(collection.length) : [];
|
||||
|
||||
baseEach(collection, function(value) {
|
||||
var func = isFunc ? path : (isProp && value != null && value[path]);
|
||||
|
||||
@@ -23,10 +23,11 @@ import isArray from '../lang/isArray';
|
||||
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
||||
*
|
||||
* The guarded methods are:
|
||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
||||
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
|
||||
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
|
||||
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
|
||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
|
||||
* `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
|
||||
* `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
|
||||
* `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
|
||||
* `sum`, `uniq`, and `words`
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -24,6 +24,6 @@ import createReduce from '../internal/createReduce';
|
||||
* }, []);
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
|
||||
export default reduceRight;
|
||||
|
||||
@@ -7,17 +7,6 @@ import isArray from '../lang/isArray';
|
||||
* The opposite of `_.filter`; this method returns the elements of `collection`
|
||||
* that `predicate` does **not** return truthy for.
|
||||
*
|
||||
* If a property name is provided for `predicate` the created `_.property`
|
||||
* style callback returns the property value of the given element.
|
||||
*
|
||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||
* style callback returns `true` for elements that have a matching property
|
||||
* value, else `false`.
|
||||
*
|
||||
* If an object is provided for `predicate` the created `_.matches` style
|
||||
* callback returns `true` for elements that have the properties of the given
|
||||
* object, else `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Collection
|
||||
|
||||
@@ -4,7 +4,7 @@ import isNative from '../lang/isNative';
|
||||
import keys from '../object/keys';
|
||||
|
||||
/** Native method references. */
|
||||
var preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions;
|
||||
var preventExtensions = isNative(preventExtensions = Object.preventExtensions) && preventExtensions;
|
||||
|
||||
/** Used as `baseAssign`. */
|
||||
var nativeAssign = (function() {
|
||||
@@ -14,12 +14,19 @@ var nativeAssign = (function() {
|
||||
//
|
||||
// Use `Object.preventExtensions` on a plain object instead of simply using
|
||||
// `Object('x')` because Chrome and IE fail to throw an error when attempting
|
||||
// to assign values to readonly indexes of strings in strict mode.
|
||||
var object = { '1': 0 },
|
||||
func = preventExtensions && isNative(func = Object.assign) && func;
|
||||
|
||||
try { func(preventExtensions(object), 'xo'); } catch(e) {}
|
||||
return !object[1] && func;
|
||||
// to assign values to readonly indexes of strings.
|
||||
var func = preventExtensions && isNative(func = Object.assign) && func;
|
||||
try {
|
||||
if (func) {
|
||||
var object = preventExtensions({ '1': 0 });
|
||||
object[0] = 1;
|
||||
}
|
||||
} catch(e) {
|
||||
// Only attempt in strict mode.
|
||||
try { func(object, 'xo'); } catch(e) {}
|
||||
return !object[1] && func;
|
||||
}
|
||||
return false;
|
||||
}());
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isIndex from './isIndex';
|
||||
import isLength from './isLength';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.at` without support for string collections
|
||||
@@ -12,8 +12,9 @@ import isLength from './isLength';
|
||||
*/
|
||||
function baseAt(collection, props) {
|
||||
var index = -1,
|
||||
length = collection.length,
|
||||
isArr = isLength(length),
|
||||
isNil = collection == null,
|
||||
isArr = !isNil && isArrayLike(collection),
|
||||
length = isArr && collection.length,
|
||||
propsLength = props.length,
|
||||
result = Array(propsLength);
|
||||
|
||||
@@ -22,7 +23,7 @@ function baseAt(collection, props) {
|
||||
if (isArr) {
|
||||
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
||||
} else {
|
||||
result[index] = collection[key];
|
||||
result[index] = isNil ? undefined : collection[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isLength from './isLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isObjectLike from './isObjectLike';
|
||||
|
||||
/**
|
||||
@@ -9,8 +9,8 @@ import isObjectLike from './isObjectLike';
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} isDeep Specify a deep flatten.
|
||||
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict) {
|
||||
@@ -21,8 +21,8 @@ function baseFlatten(array, isDeep, isStrict) {
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
||||
if (isObjectLike(value) && isArrayLike(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
value = baseFlatten(value, isDeep, isStrict);
|
||||
@@ -30,7 +30,6 @@ function baseFlatten(array, isDeep, isStrict) {
|
||||
var valIndex = -1,
|
||||
valLength = value.length;
|
||||
|
||||
result.length += valLength;
|
||||
while (++valIndex < valLength) {
|
||||
result[++resIndex] = value[valIndex];
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ function baseGet(object, path, pathKey) {
|
||||
length = path.length;
|
||||
|
||||
while (object != null && ++index < length) {
|
||||
var result = object = object[path[index]];
|
||||
object = object[path[index]];
|
||||
}
|
||||
return result;
|
||||
return (index && index == length) ? object : undefined;
|
||||
}
|
||||
|
||||
export default baseGet;
|
||||
|
||||
@@ -16,8 +16,7 @@ import baseIsEqualDeep from './baseIsEqualDeep';
|
||||
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
|
||||
// Exit early for identical values.
|
||||
if (value === other) {
|
||||
// Treat `+0` vs. `-0` as not equal.
|
||||
return value !== 0 || (1 / value == 1 / other);
|
||||
return true;
|
||||
}
|
||||
var valType = typeof value,
|
||||
othType = typeof other;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import baseEach from './baseEach';
|
||||
import getLength from './getLength';
|
||||
import isLength from './isLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.map` without support for callback shorthands
|
||||
@@ -13,8 +12,7 @@ import isLength from './isLength';
|
||||
*/
|
||||
function baseMap(collection, iteratee) {
|
||||
var index = -1,
|
||||
length = getLength(collection),
|
||||
result = isLength(length) ? Array(length) : [];
|
||||
result = isArrayLike(collection) ? Array(collection.length) : [];
|
||||
|
||||
baseEach(collection, function(value, key, collection) {
|
||||
result[++index] = iteratee(value, key, collection);
|
||||
|
||||
@@ -2,7 +2,7 @@ import arrayEach from './arrayEach';
|
||||
import baseMergeDeep from './baseMergeDeep';
|
||||
import getSymbols from './getSymbols';
|
||||
import isArray from '../lang/isArray';
|
||||
import isLength from './isLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isObject from '../lang/isObject';
|
||||
import isObjectLike from './isObjectLike';
|
||||
import isTypedArray from '../lang/isTypedArray';
|
||||
@@ -30,7 +30,7 @@ function baseMerge(object, source, customizer, stackA, stackB) {
|
||||
if (!isObject(object)) {
|
||||
return object;
|
||||
}
|
||||
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
|
||||
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source));
|
||||
if (!isSrcArr) {
|
||||
var props = keys(source);
|
||||
push.apply(props, getSymbols(source));
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import arrayCopy from './arrayCopy';
|
||||
import getLength from './getLength';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/isArray';
|
||||
import isLength from './isLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isPlainObject from '../lang/isPlainObject';
|
||||
import isTypedArray from '../lang/isTypedArray';
|
||||
import toPlainObject from '../lang/toPlainObject';
|
||||
@@ -38,10 +37,10 @@ function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stack
|
||||
|
||||
if (isCommon) {
|
||||
result = srcValue;
|
||||
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
||||
if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
||||
result = isArray(value)
|
||||
? value
|
||||
: (getLength(value) ? arrayCopy(value) : []);
|
||||
: (isArrayLike(value) ? arrayCopy(value) : []);
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
result = isArguments(value)
|
||||
|
||||
@@ -16,7 +16,7 @@ var splice = arrayProto.splice;
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function basePullAt(array, indexes) {
|
||||
var length = indexes.length;
|
||||
var length = array ? indexes.length : 0;
|
||||
while (length--) {
|
||||
var index = parseFloat(indexes[length]);
|
||||
if (index != previous && isIndex(index)) {
|
||||
|
||||
@@ -6,7 +6,7 @@ var nativeMin = Math.min;
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
|
||||
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
|
||||
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
|
||||
|
||||
/**
|
||||
* This function is like `binaryIndex` except that it invokes `iteratee` for
|
||||
|
||||
@@ -23,12 +23,12 @@ function composeArgsRight(args, partials, holders) {
|
||||
while (++argsIndex < argsLength) {
|
||||
result[argsIndex] = args[argsIndex];
|
||||
}
|
||||
var pad = argsIndex;
|
||||
var offset = argsIndex;
|
||||
while (++rightIndex < rightLength) {
|
||||
result[pad + rightIndex] = partials[rightIndex];
|
||||
result[offset + rightIndex] = partials[rightIndex];
|
||||
}
|
||||
while (++holdersIndex < holdersLength) {
|
||||
result[pad + holders[holdersIndex]] = args[argsIndex++];
|
||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function createFind(eachFunc, fromRight) {
|
||||
return index > -1 ? collection[index] : undefined;
|
||||
}
|
||||
return baseFind(collection, predicate, eachFunc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default createFind;
|
||||
|
||||
@@ -4,6 +4,12 @@ import getFuncName from './getFuncName';
|
||||
import isArray from '../lang/isArray';
|
||||
import isLaziable from './isLaziable';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var CURRY_FLAG = 8,
|
||||
PARTIAL_FLAG = 32,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
@@ -39,7 +45,7 @@ function createFlow(fromRight) {
|
||||
funcName = getFuncName(func);
|
||||
|
||||
var data = funcName == 'wrapper' ? getData(func) : null;
|
||||
if (data && isLaziable(data[0])) {
|
||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||
} else {
|
||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||
|
||||
26
internal/createObjectMapper.js
Normal file
26
internal/createObjectMapper.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import baseCallback from './baseCallback';
|
||||
import baseForOwn from './baseForOwn';
|
||||
|
||||
/**
|
||||
* Creates a function for `_.mapKeys` or `_.mapValues`.
|
||||
*
|
||||
* @private
|
||||
* @param {boolean} [isMapKeys] Specify mapping keys instead of values.
|
||||
* @returns {Function} Returns the new map function.
|
||||
*/
|
||||
function createObjectMapper(isMapKeys) {
|
||||
return function(object, iteratee, thisArg) {
|
||||
var result = {};
|
||||
iteratee = baseCallback(iteratee, thisArg, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
var mapped = iteratee(value, key, object);
|
||||
key = isMapKeys ? mapped : key;
|
||||
value = isMapKeys ? value : mapped;
|
||||
result[key] = value;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
export default createObjectMapper;
|
||||
@@ -11,7 +11,7 @@ import createPadding from './createPadding';
|
||||
function createPadDir(fromRight) {
|
||||
return function(string, length, chars) {
|
||||
string = baseToString(string);
|
||||
return string && ((fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string));
|
||||
return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ function equalByTag(object, other, tag) {
|
||||
// Treat `NaN` vs. `NaN` as equal.
|
||||
return (object != +object)
|
||||
? other != +other
|
||||
// But, treat `-0` vs. `+0` as not equal.
|
||||
: (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
|
||||
: object == +other;
|
||||
|
||||
case regexpTag:
|
||||
case stringTag:
|
||||
|
||||
@@ -4,7 +4,7 @@ import baseProperty from './baseProperty';
|
||||
* Gets the "length" property value of `object`.
|
||||
*
|
||||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
|
||||
* in Safari on iOS 8.1 ARM64.
|
||||
* that affects Safari on at least iOS 8.1-8.3 ARM64.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
|
||||
15
internal/isArrayLike.js
Normal file
15
internal/isArrayLike.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import getLength from './getLength';
|
||||
import isLength from './isLength';
|
||||
|
||||
/**
|
||||
* Checks if `value` is array-like.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||
*/
|
||||
function isArrayLike(value) {
|
||||
return value != null && isLength(getLength(value));
|
||||
}
|
||||
|
||||
export default isArrayLike;
|
||||
@@ -1,6 +1,5 @@
|
||||
import getLength from './getLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isIndex from './isIndex';
|
||||
import isLength from './isLength';
|
||||
import isObject from '../lang/isObject';
|
||||
|
||||
/**
|
||||
@@ -17,13 +16,9 @@ function isIterateeCall(value, index, object) {
|
||||
return false;
|
||||
}
|
||||
var type = typeof index;
|
||||
if (type == 'number') {
|
||||
var length = getLength(object),
|
||||
prereq = isLength(length) && isIndex(index, length);
|
||||
} else {
|
||||
prereq = type == 'string' && index in object;
|
||||
}
|
||||
if (prereq) {
|
||||
if (type == 'number'
|
||||
? (isArrayLike(object) && isIndex(index, object.length))
|
||||
: (type == 'string' && index in object)) {
|
||||
var other = object[index];
|
||||
return value === value ? (value === other) : (other !== other);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import isArray from '../lang/isArray';
|
||||
import toObject from './toObject';
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
|
||||
reIsPlainProp = /^\w*$/;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ import isObject from '../lang/isObject';
|
||||
* equality comparisons, else `false`.
|
||||
*/
|
||||
function isStrictComparable(value) {
|
||||
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
|
||||
return value === value && !isObject(value);
|
||||
}
|
||||
|
||||
export default isStrictComparable;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import toObject from './toObject';
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties specified
|
||||
* A specialized version of `_.pick` which picks `object` properties specified
|
||||
* by `props`.
|
||||
*
|
||||
* @private
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import baseForIn from './baseForIn';
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties `predicate`
|
||||
* A specialized version of `_.pick` which picks `object` properties `predicate`
|
||||
* returns truthy for.
|
||||
*
|
||||
* @private
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import getLength from './getLength';
|
||||
import isLength from './isLength';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isObject from '../lang/isObject';
|
||||
import values from '../object/values';
|
||||
|
||||
@@ -14,7 +13,7 @@ function toIterable(value) {
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
if (!isLength(getLength(value))) {
|
||||
if (!isArrayLike(value)) {
|
||||
return values(value);
|
||||
}
|
||||
return isObject(value) ? value : Object(value);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import isLength from '../internal/isLength';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import isObjectLike from '../internal/isObjectLike';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
@@ -30,8 +30,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
var length = isObjectLike(value) ? value.length : undefined;
|
||||
return isLength(length) && objToString.call(value) == argsTag;
|
||||
return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag;
|
||||
}
|
||||
|
||||
export default isArguments;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import getLength from '../internal/getLength';
|
||||
import isArguments from './isArguments';
|
||||
import isArray from './isArray';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import isFunction from './isFunction';
|
||||
import isLength from '../internal/isLength';
|
||||
import isObjectLike from '../internal/isObjectLike';
|
||||
import isString from './isString';
|
||||
import keys from '../object/keys';
|
||||
@@ -38,10 +37,9 @@ function isEmpty(value) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
var length = getLength(value);
|
||||
if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
|
||||
if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
|
||||
(isObjectLike(value) && isFunction(value.splice)))) {
|
||||
return !length;
|
||||
return !value.length;
|
||||
}
|
||||
return !keys(value).length;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isRegExp(value) {
|
||||
return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
|
||||
return isObjectLike(value) && objToString.call(value) == regexpTag;
|
||||
}
|
||||
|
||||
export default isRegExp;
|
||||
|
||||
15
lodash.js
15
lodash.js
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 3.7.0 (Custom Build) <https://lodash.com/>
|
||||
* lodash 3.8.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize modern exports="es" -o ./`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
@@ -42,7 +42,7 @@ import support from './support';
|
||||
import thru from './chain/thru';
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '3.7.0';
|
||||
var VERSION = '3.8.0';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_KEY_FLAG = 2;
|
||||
@@ -130,6 +130,7 @@ lodash.invoke = collection.invoke;
|
||||
lodash.keys = keys;
|
||||
lodash.keysIn = object.keysIn;
|
||||
lodash.map = collection.map;
|
||||
lodash.mapKeys = object.mapKeys;
|
||||
lodash.mapValues = object.mapValues;
|
||||
lodash.matches = utility.matches;
|
||||
lodash.matchesProperty = utility.matchesProperty;
|
||||
@@ -178,6 +179,7 @@ lodash.transform = object.transform;
|
||||
lodash.union = array.union;
|
||||
lodash.uniq = array.uniq;
|
||||
lodash.unzip = array.unzip;
|
||||
lodash.unzipWith = array.unzipWith;
|
||||
lodash.values = object.values;
|
||||
lodash.valuesIn = object.valuesIn;
|
||||
lodash.where = collection.where;
|
||||
@@ -186,6 +188,7 @@ lodash.wrap = func.wrap;
|
||||
lodash.xor = array.xor;
|
||||
lodash.zip = array.zip;
|
||||
lodash.zipObject = array.zipObject;
|
||||
lodash.zipWith = array.zipWith;
|
||||
|
||||
// Add aliases.
|
||||
lodash.backflow = func.flowRight;
|
||||
@@ -430,8 +433,13 @@ LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
||||
|
||||
LazyWrapper.prototype.slice = function(start, end) {
|
||||
start = start == null ? 0 : (+start || 0);
|
||||
var result = start < 0 ? this.takeRight(-start) : this.drop(start);
|
||||
|
||||
var result = this;
|
||||
if (start < 0) {
|
||||
result = this.takeRight(-start);
|
||||
} else if (start) {
|
||||
result = this.drop(start);
|
||||
}
|
||||
if (end !== undefined) {
|
||||
end = (+end || 0);
|
||||
result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
||||
@@ -454,7 +462,6 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var args = arguments,
|
||||
length = args.length,
|
||||
chainAll = this.__chain__,
|
||||
value = this.__wrapped__,
|
||||
isHybrid = !!this.__actions__.length,
|
||||
|
||||
@@ -14,6 +14,7 @@ import has from './object/has';
|
||||
import invert from './object/invert';
|
||||
import keys from './object/keys';
|
||||
import keysIn from './object/keysIn';
|
||||
import mapKeys from './object/mapKeys';
|
||||
import mapValues from './object/mapValues';
|
||||
import merge from './object/merge';
|
||||
import methods from './object/methods';
|
||||
@@ -43,6 +44,7 @@ export default {
|
||||
'invert': invert,
|
||||
'keys': keys,
|
||||
'keysIn': keysIn,
|
||||
'mapKeys': mapKeys,
|
||||
'mapValues': mapValues,
|
||||
'merge': merge,
|
||||
'methods': methods,
|
||||
|
||||
@@ -12,7 +12,6 @@ import createAssigner from '../internal/createAssigner';
|
||||
* **Note:** This method mutates `object` and is based on
|
||||
* [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extend
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import isLength from '../internal/isLength';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import isNative from '../lang/isNative';
|
||||
import isObject from '../lang/isObject';
|
||||
import shimKeys from '../internal/shimKeys';
|
||||
@@ -34,12 +34,9 @@ var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
|
||||
* // => ['0', '1']
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
if (object) {
|
||||
var Ctor = object.constructor,
|
||||
length = object.length;
|
||||
}
|
||||
var Ctor = object != null && object.constructor;
|
||||
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
|
||||
(typeof object != 'function' && isLength(length))) {
|
||||
(typeof object != 'function' && isArrayLike(object))) {
|
||||
return shimKeys(object);
|
||||
}
|
||||
return isObject(object) ? nativeKeys(object) : [];
|
||||
|
||||
25
object/mapKeys.js
Normal file
25
object/mapKeys.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import createObjectMapper from '../internal/createObjectMapper';
|
||||
|
||||
/**
|
||||
* The opposite of `_.mapValues`; this method creates an object with the
|
||||
* same values as `object` and keys generated by running each own enumerable
|
||||
* property of `object` through `iteratee`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
||||
* per iteration.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Object} Returns the new mapped object.
|
||||
* @example
|
||||
*
|
||||
* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
|
||||
* return key + value;
|
||||
* });
|
||||
* // => { 'a1': 1, 'b2': 2 }
|
||||
*/
|
||||
var mapKeys = createObjectMapper(true);
|
||||
|
||||
export default mapKeys;
|
||||
@@ -1,5 +1,4 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import baseForOwn from '../internal/baseForOwn';
|
||||
import createObjectMapper from '../internal/createObjectMapper';
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated by
|
||||
@@ -42,14 +41,6 @@ import baseForOwn from '../internal/baseForOwn';
|
||||
* _.mapValues(users, 'age');
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*/
|
||||
function mapValues(object, iteratee, thisArg) {
|
||||
var result = {};
|
||||
iteratee = baseCallback(iteratee, thisArg, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[key] = iteratee(value, key, object);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
var mapValues = createObjectMapper();
|
||||
|
||||
export default mapValues;
|
||||
|
||||
@@ -10,11 +10,6 @@ import restParam from '../function/restParam';
|
||||
/**
|
||||
* The opposite of `_.pick`; this method creates an object composed of the
|
||||
* own and inherited enumerable properties of `object` that are not omitted.
|
||||
* Property names may be specified as individual arguments or as arrays of
|
||||
* property names. If `predicate` is provided it is invoked for each property
|
||||
* of `object` omitting the properties `predicate` returns truthy for. The
|
||||
* predicate is bound to `thisArg` and invoked with three arguments:
|
||||
* (value, key, object).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lodash-es",
|
||||
"version": "3.7.0",
|
||||
"version": "3.8.0",
|
||||
"description": "The modern build of lodash exported as ES modules.",
|
||||
"homepage": "https://lodash.com/custom-builds",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -20,6 +20,7 @@ var support = {};
|
||||
|
||||
(function(x) {
|
||||
var Ctor = function() { this.x = x; },
|
||||
args = arguments,
|
||||
object = { '0': x, 'length': x },
|
||||
props = [];
|
||||
|
||||
@@ -69,7 +70,7 @@ var support = {};
|
||||
* @type boolean
|
||||
*/
|
||||
try {
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(args, 1);
|
||||
} catch(e) {
|
||||
support.nonEnumArgs = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import isIterateeCall from '../internal/isIterateeCall';
|
||||
import isObjectLike from '../internal/isObjectLike';
|
||||
import matches from './matches';
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
||||
@@ -43,7 +45,9 @@ function callback(func, thisArg, guard) {
|
||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||
thisArg = null;
|
||||
}
|
||||
return baseCallback(func, thisArg);
|
||||
return isObjectLike(func)
|
||||
? matches(func)
|
||||
: baseCallback(func, thisArg);
|
||||
}
|
||||
|
||||
export default callback;
|
||||
|
||||
@@ -25,7 +25,7 @@ import restParam from '../function/restParam';
|
||||
var method = restParam(function(path, args) {
|
||||
return function(object) {
|
||||
return invokePath(object, path, args);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export default method;
|
||||
|
||||
Reference in New Issue
Block a user