mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26837e7fe2 |
@@ -1,4 +1,4 @@
|
||||
# lodash v3.7.0
|
||||
# lodash v3.8.0
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||
|
||||
@@ -13,8 +13,8 @@ $ lodash modern exports=amd -d -o ./main.js
|
||||
Using bower or volo:
|
||||
|
||||
```bash
|
||||
$ bower i lodash#3.7.0-amd
|
||||
$ volo add lodash/3.7.0-amd
|
||||
$ bower i lodash#3.8.0-amd
|
||||
$ volo add lodash/3.8.0-amd
|
||||
```
|
||||
|
||||
Defining a build as `'lodash'`.
|
||||
|
||||
6
array.js
6
array.js
@@ -1,4 +1,4 @@
|
||||
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/fill', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/without', './array/xor', './array/zip', './array/zipObject'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, without, xor, zip, zipObject) {
|
||||
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/fill', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/unzipWith', './array/without', './array/xor', './array/zip', './array/zipObject', './array/zipWith'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, unzipWith, without, xor, zip, zipObject, zipWith) {
|
||||
return {
|
||||
'chunk': chunk,
|
||||
'compact': compact,
|
||||
@@ -36,9 +36,11 @@ define(['./array/chunk', './array/compact', './array/difference', './array/drop'
|
||||
'uniq': uniq,
|
||||
'unique': unique,
|
||||
'unzip': unzip,
|
||||
'unzipWith': unzipWith,
|
||||
'without': without,
|
||||
'xor': xor,
|
||||
'zip': zip,
|
||||
'zipObject': zipObject
|
||||
'zipObject': zipObject,
|
||||
'zipWith': zipWith
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) {
|
||||
define(['../internal/baseDifference', '../internal/baseFlatten', '../internal/isArrayLike', '../function/restParam'], function(baseDifference, baseFlatten, isArrayLike, 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 _
|
||||
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
|
||||
* // => [1, 3]
|
||||
*/
|
||||
var difference = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
@@ -5,13 +5,10 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
|
||||
|
||||
/**
|
||||
* 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,13 +1,10 @@
|
||||
define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/createCache', '../lang/isArguments', '../lang/isArray'], function(baseIndexOf, cacheIndexOf, createCache, isArguments, isArray) {
|
||||
define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/createCache', '../internal/isArrayLike'], function(baseIndexOf, cacheIndexOf, createCache, 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
|
||||
@@ -28,7 +25,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
|
||||
|
||||
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 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
|
||||
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 _
|
||||
|
||||
@@ -26,7 +26,6 @@ define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/b
|
||||
* // => [10, 20]
|
||||
*/
|
||||
var pullAt = restParam(function(array, indexes) {
|
||||
array || (array = []);
|
||||
indexes = baseFlatten(indexes);
|
||||
|
||||
var result = baseAt(array, indexes);
|
||||
|
||||
@@ -2,11 +2,8 @@ define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restPara
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, 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
|
||||
@@ -20,10 +21,6 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
|
||||
* 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,8 +1,11 @@
|
||||
define(['../internal/arrayMap', '../internal/arrayMax', '../internal/baseProperty', '../internal/getLength'], function(arrayMap, arrayMax, baseProperty, getLength) {
|
||||
define(['../internal/arrayFilter', '../internal/arrayMap', '../internal/baseProperty', '../internal/isArrayLike'], function(arrayFilter, arrayMap, baseProperty, 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
|
||||
@@ -19,10 +22,19 @@ define(['../internal/arrayMap', '../internal/arrayMax', '../internal/basePropert
|
||||
* // => [['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));
|
||||
}
|
||||
|
||||
42
array/unzipWith.js
Normal file
42
array/unzipWith.js
Normal file
@@ -0,0 +1,42 @@
|
||||
define(['../internal/arrayMap', '../internal/arrayReduce', '../internal/bindCallback', './unzip'], function(arrayMap, arrayReduce, bindCallback, unzip) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
}
|
||||
|
||||
return unzipWith;
|
||||
});
|
||||
@@ -1,12 +1,9 @@
|
||||
define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, isArguments, isArray, restParam) {
|
||||
define(['../internal/baseDifference', '../internal/isArrayLike', '../function/restParam'], function(baseDifference, isArrayLike, 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 _
|
||||
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray',
|
||||
* // => [3]
|
||||
*/
|
||||
var without = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, values)
|
||||
: [];
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseUniq, isArguments, isArray) {
|
||||
define(['../internal/baseDifference', '../internal/baseUniq', '../internal/isArrayLike'], function(baseDifference, baseUniq, isArrayLike) {
|
||||
|
||||
/**
|
||||
* Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
|
||||
@@ -20,7 +20,7 @@ define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArgumen
|
||||
|
||||
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;
|
||||
|
||||
39
array/zipWith.js
Normal file
39
array/zipWith.js
Normal file
@@ -0,0 +1,39 @@
|
||||
define(['../function/restParam', './unzipWith'], function(restParam, unzipWith) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
|
||||
return zipWith;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/getLength', '../internal/isLength', '../function/restParam', '../internal/toIterable'], function(baseAt, baseFlatten, getLength, isLength, restParam, toIterable) {
|
||||
define(['../internal/baseAt', '../internal/baseFlatten', '../function/restParam'], function(baseAt, baseFlatten, restParam) {
|
||||
|
||||
/**
|
||||
* Creates an array of elements corresponding to the given keys, or indexes,
|
||||
@@ -21,10 +21,6 @@ define(['../internal/baseAt', '../internal/baseFlatten', '../internal/getLength'
|
||||
* // => ['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));
|
||||
});
|
||||
|
||||
|
||||
@@ -4,13 +4,10 @@ define(['../internal/baseIndexOf', '../internal/getLength', '../lang/isArray', '
|
||||
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,4 +1,4 @@
|
||||
define(['../internal/baseEach', '../internal/getLength', '../internal/invokePath', '../internal/isKey', '../internal/isLength', '../function/restParam'], function(baseEach, getLength, invokePath, isKey, isLength, restParam) {
|
||||
define(['../internal/baseEach', '../internal/invokePath', '../internal/isArrayLike', '../internal/isKey', '../function/restParam'], function(baseEach, invokePath, isArrayLike, isKey, restParam) {
|
||||
|
||||
/**
|
||||
* Invokes the method at `path` on each element in `collection`, returning
|
||||
@@ -26,8 +26,7 @@ define(['../internal/baseEach', '../internal/getLength', '../internal/invokePath
|
||||
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]);
|
||||
|
||||
@@ -20,10 +20,11 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
|
||||
* `_.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 _
|
||||
|
||||
@@ -22,7 +22,7 @@ define(['../internal/arrayReduceRight', '../internal/baseEachRight', '../interna
|
||||
* }, []);
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
|
||||
return reduceRight;
|
||||
});
|
||||
|
||||
@@ -4,17 +4,6 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
|
||||
* 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], function(baseCopy, getSymbols, isNative, 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() {
|
||||
@@ -11,12 +11,19 @@ define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], fun
|
||||
//
|
||||
// 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,4 +1,4 @@
|
||||
define(['./isIndex', './isLength'], function(isIndex, isLength) {
|
||||
define(['./isArrayLike', './isIndex'], function(isArrayLike, isIndex) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -14,8 +14,9 @@ define(['./isIndex', './isLength'], function(isIndex, 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);
|
||||
|
||||
@@ -24,7 +25,7 @@ define(['./isIndex', './isLength'], function(isIndex, isLength) {
|
||||
if (isArr) {
|
||||
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
||||
} else {
|
||||
result[index] = collection[key];
|
||||
result[index] = isNil ? undefined : collection[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'], function(isArguments, isArray, isLength, isObjectLike) {
|
||||
define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLike'], function(isArguments, isArray, isArrayLike, isObjectLike) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.flatten` with added support for restricting
|
||||
@@ -6,8 +6,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './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) {
|
||||
@@ -18,8 +18,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
||||
|
||||
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);
|
||||
@@ -27,7 +27,6 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
||||
var valIndex = -1,
|
||||
valLength = value.length;
|
||||
|
||||
result.length += valLength;
|
||||
while (++valIndex < valLength) {
|
||||
result[++resIndex] = value[valIndex];
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ define(['./toObject'], function(toObject) {
|
||||
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;
|
||||
}
|
||||
|
||||
return baseGet;
|
||||
|
||||
@@ -16,8 +16,7 @@ define(['./baseIsEqualDeep'], function(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,4 +1,4 @@
|
||||
define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength, isLength) {
|
||||
define(['./baseEach', './isArrayLike'], function(baseEach, isArrayLike) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.map` without support for callback shorthands
|
||||
@@ -11,8 +11,7 @@ define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './isLength', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, getSymbols, isArray, isLength, isObject, isObjectLike, isTypedArray, keys) {
|
||||
define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './isArrayLike', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, getSymbols, isArray, isArrayLike, isObject, isObjectLike, isTypedArray, keys) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -25,7 +25,7 @@ define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './
|
||||
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,4 +1,4 @@
|
||||
define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray', './isLength', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, getLength, isArguments, isArray, isLength, isPlainObject, isTypedArray, toPlainObject) {
|
||||
define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isArrayLike', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, isArguments, isArray, isArrayLike, isPlainObject, isTypedArray, toPlainObject) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -34,10 +34,10 @@ define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray',
|
||||
|
||||
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 @@ define(['./isIndex'], function(isIndex) {
|
||||
* @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)) {
|
||||
|
||||
@@ -11,7 +11,7 @@ define([], function() {
|
||||
|
||||
/** 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
|
||||
|
||||
@@ -25,12 +25,12 @@ define([], function() {
|
||||
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 @@ define(['./baseCallback', './baseFind', './baseFindIndex', '../lang/isArray'], f
|
||||
return index > -1 ? collection[index] : undefined;
|
||||
}
|
||||
return baseFind(collection, predicate, eachFunc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return createFind;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, 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';
|
||||
|
||||
@@ -35,7 +41,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
|
||||
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 @@
|
||||
define(['./baseCallback', './baseForOwn'], function(baseCallback, 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;
|
||||
};
|
||||
}
|
||||
|
||||
return createObjectMapper;
|
||||
});
|
||||
@@ -10,7 +10,7 @@ define(['./baseToString', './createPadding'], function(baseToString, createPaddi
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ define([], function() {
|
||||
// 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 @@ define(['./baseProperty'], function(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 @@
|
||||
define(['./getLength', './isLength'], function(getLength, 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));
|
||||
}
|
||||
|
||||
return isArrayLike;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(getLength, isIndex, isLength, isObject) {
|
||||
define(['./isArrayLike', './isIndex', '../lang/isObject'], function(isArrayLike, isIndex, isObject) {
|
||||
|
||||
/**
|
||||
* Checks if the provided arguments are from an iteratee call.
|
||||
@@ -14,13 +14,9 @@ define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['../lang/isArray', './toObject'], function(isArray, 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 @@ define(['../lang/isObject'], function(isObject) {
|
||||
* equality comparisons, else `false`.
|
||||
*/
|
||||
function isStrictComparable(value) {
|
||||
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
|
||||
return value === value && !isObject(value);
|
||||
}
|
||||
|
||||
return isStrictComparable;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./toObject'], function(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 @@
|
||||
define(['./baseForIn'], function(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,4 +1,4 @@
|
||||
define(['./getLength', './isLength', '../lang/isObject', '../object/values'], function(getLength, isLength, isObject, values) {
|
||||
define(['./isArrayLike', '../lang/isObject', '../object/values'], function(isArrayLike, isObject, values) {
|
||||
|
||||
/**
|
||||
* Converts `value` to an array-like object if it is not one.
|
||||
@@ -11,7 +11,7 @@ define(['./getLength', './isLength', '../lang/isObject', '../object/values'], fu
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
if (!isLength(getLength(value))) {
|
||||
if (!isArrayLike(value)) {
|
||||
return values(value);
|
||||
}
|
||||
return isObject(value) ? value : Object(value);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
define(['../internal/isLength', '../internal/isObjectLike'], function(isLength, isObjectLike) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
define(['../internal/isArrayLike', '../internal/isObjectLike'], function(isArrayLike, isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]';
|
||||
@@ -32,8 +29,7 @@ define(['../internal/isLength', '../internal/isObjectLike'], function(isLength,
|
||||
* // => 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;
|
||||
}
|
||||
|
||||
return isArguments;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/getLength', './isArguments', './isArray', './isFunction', '../internal/isLength', '../internal/isObjectLike', './isString', '../object/keys'], function(getLength, isArguments, isArray, isFunction, isLength, isObjectLike, isString, keys) {
|
||||
define(['./isArguments', './isArray', '../internal/isArrayLike', './isFunction', '../internal/isObjectLike', './isString', '../object/keys'], function(isArguments, isArray, isArrayLike, isFunction, isObjectLike, isString, keys) {
|
||||
|
||||
/**
|
||||
* Checks if `value` is empty. A value is considered empty unless it is an
|
||||
@@ -31,10 +31,9 @@ define(['../internal/getLength', './isArguments', './isArray', './isFunction', '
|
||||
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 @@ define(['../internal/isObjectLike'], function(isObjectLike) {
|
||||
* // => false
|
||||
*/
|
||||
function isRegExp(value) {
|
||||
return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
|
||||
return isObjectLike(value) && objToString.call(value) == regexpTag;
|
||||
}
|
||||
|
||||
return isRegExp;
|
||||
|
||||
440
main.js
440
main.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 modern exports="amd" -d -o ./main.js`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
@@ -13,7 +13,7 @@
|
||||
var undefined;
|
||||
|
||||
/** 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_FLAG = 1,
|
||||
@@ -88,7 +88,7 @@
|
||||
reInterpolate = /<%=([\s\S]+?)%>/g;
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
|
||||
reIsPlainProp = /^\w*$/,
|
||||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
|
||||
|
||||
@@ -277,8 +277,6 @@
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The base implementation of `compareAscending` which compares values and
|
||||
* sorts them in ascending order without guaranteeing a stable sort.
|
||||
@@ -649,8 +647,6 @@
|
||||
return htmlUnescapes[chr];
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Create a new pristine `lodash` function using the given `context` object.
|
||||
*
|
||||
@@ -746,7 +742,7 @@
|
||||
getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
|
||||
getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
||||
push = arrayProto.push,
|
||||
preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
|
||||
preventExtensions = isNative(preventExtensions = Object.preventExtensions) && preventExtensions,
|
||||
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||||
Set = isNative(Set = context.Set) && Set,
|
||||
setTimeout = context.setTimeout,
|
||||
@@ -774,12 +770,19 @@
|
||||
//
|
||||
// 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;
|
||||
}());
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
@@ -800,7 +803,7 @@
|
||||
|
||||
/** 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,
|
||||
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
||||
|
||||
/** Used as the size, in bytes, of each `Float64Array` element. */
|
||||
@@ -818,8 +821,6 @@
|
||||
/** Used to lookup unminified function names. */
|
||||
var realNames = {};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a `lodash` object which wraps `value` to enable implicit chaining.
|
||||
* Methods that operate on and return arrays, collections, and functions can
|
||||
@@ -959,6 +960,7 @@
|
||||
|
||||
(function(x) {
|
||||
var Ctor = function() { this.x = x; },
|
||||
args = arguments,
|
||||
object = { '0': x, 'length': x },
|
||||
props = [];
|
||||
|
||||
@@ -1008,7 +1010,7 @@
|
||||
* @type boolean
|
||||
*/
|
||||
try {
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(args, 1);
|
||||
} catch(e) {
|
||||
support.nonEnumArgs = true;
|
||||
}
|
||||
@@ -1075,8 +1077,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||
*
|
||||
@@ -1205,8 +1205,6 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a cache object to store key/value pairs.
|
||||
*
|
||||
@@ -1275,8 +1273,6 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a cache object to store unique values.
|
||||
@@ -1326,8 +1322,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Copies the values of `source` to `array`.
|
||||
*
|
||||
@@ -1671,8 +1665,9 @@
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -1681,7 +1676,7 @@
|
||||
if (isArr) {
|
||||
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
||||
} else {
|
||||
result[index] = collection[key];
|
||||
result[index] = isNil ? undefined : collection[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -2008,8 +2003,8 @@
|
||||
*
|
||||
* @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) {
|
||||
@@ -2020,8 +2015,8 @@
|
||||
|
||||
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);
|
||||
@@ -2029,7 +2024,6 @@
|
||||
var valIndex = -1,
|
||||
valLength = value.length;
|
||||
|
||||
result.length += valLength;
|
||||
while (++valIndex < valLength) {
|
||||
result[++resIndex] = value[valIndex];
|
||||
}
|
||||
@@ -2150,9 +2144,9 @@
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2171,8 +2165,7 @@
|
||||
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;
|
||||
@@ -2321,8 +2314,7 @@
|
||||
*/
|
||||
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);
|
||||
@@ -2421,7 +2413,7 @@
|
||||
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));
|
||||
@@ -2484,10 +2476,10 @@
|
||||
|
||||
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)
|
||||
@@ -2549,7 +2541,7 @@
|
||||
* @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)) {
|
||||
@@ -3035,12 +3027,12 @@
|
||||
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;
|
||||
}
|
||||
@@ -3308,7 +3300,7 @@
|
||||
return index > -1 ? collection[index] : undefined;
|
||||
}
|
||||
return baseFind(collection, predicate, eachFunc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3374,7 +3366,7 @@
|
||||
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);
|
||||
@@ -3444,6 +3436,28 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = getCallback(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;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function for `_.padLeft` or `_.padRight`.
|
||||
*
|
||||
@@ -3454,7 +3468,7 @@
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3800,8 +3814,7 @@
|
||||
// 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:
|
||||
@@ -3981,7 +3994,7 @@
|
||||
* 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.
|
||||
@@ -4120,6 +4133,17 @@
|
||||
return func == null ? undefined : func.apply(object, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a valid array-like index.
|
||||
*
|
||||
@@ -4148,13 +4172,9 @@
|
||||
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);
|
||||
}
|
||||
@@ -4215,7 +4235,7 @@
|
||||
* equality comparisons, else `false`.
|
||||
*/
|
||||
function isStrictComparable(value) {
|
||||
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
|
||||
return value === value && !isObject(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4289,7 +4309,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties specified
|
||||
* A specialized version of `_.pick` which picks `object` properties specified
|
||||
* by `props`.
|
||||
*
|
||||
* @private
|
||||
@@ -4314,7 +4334,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties `predicate`
|
||||
* A specialized version of `_.pick` which picks `object` properties `predicate`
|
||||
* returns truthy for.
|
||||
*
|
||||
* @private
|
||||
@@ -4459,7 +4479,7 @@
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
if (!isLength(getLength(value))) {
|
||||
if (!isArrayLike(value)) {
|
||||
return values(value);
|
||||
}
|
||||
return isObject(value) ? value : Object(value);
|
||||
@@ -4507,8 +4527,6 @@
|
||||
: new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates an array of elements split into groups the length of `size`.
|
||||
* If `collection` can't be split evenly, the final chunk will be the remaining
|
||||
@@ -4577,11 +4595,8 @@
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
@@ -4595,7 +4610,7 @@
|
||||
* // => [1, 3]
|
||||
*/
|
||||
var difference = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
: [];
|
||||
});
|
||||
@@ -4990,13 +5005,10 @@
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
@@ -5056,13 +5068,10 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -5083,7 +5092,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -5188,14 +5197,11 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
@@ -5259,7 +5265,6 @@
|
||||
* // => [10, 20]
|
||||
*/
|
||||
var pullAt = restParam(function(array, indexes) {
|
||||
array || (array = []);
|
||||
indexes = baseFlatten(indexes);
|
||||
|
||||
var result = baseAt(array, indexes);
|
||||
@@ -5626,11 +5631,8 @@
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
@@ -5647,8 +5649,9 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -5666,10 +5669,6 @@
|
||||
* 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
|
||||
@@ -5719,7 +5718,7 @@
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -5736,10 +5735,19 @@
|
||||
* // => [['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));
|
||||
}
|
||||
@@ -5747,12 +5755,44 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array excluding all provided values using `SameValueZero` for
|
||||
* equality comparisons.
|
||||
* 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).
|
||||
*
|
||||
* **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
|
||||
* @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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array excluding all provided values using
|
||||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -5766,7 +5806,7 @@
|
||||
* // => [3]
|
||||
*/
|
||||
var without = restParam(function(array, values) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
return isArrayLike(array)
|
||||
? baseDifference(array, values)
|
||||
: [];
|
||||
});
|
||||
@@ -5791,7 +5831,7 @@
|
||||
|
||||
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;
|
||||
@@ -5857,7 +5897,37 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a `lodash` object that wraps `value` with explicit method
|
||||
@@ -6109,8 +6179,6 @@
|
||||
return baseWrapperValue(this.__wrapped__, this.__actions__);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates an array of elements corresponding to the given keys, or indexes,
|
||||
* of `collection`. Keys may be specified as individual arguments or as arrays
|
||||
@@ -6132,10 +6200,6 @@
|
||||
* // => ['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));
|
||||
});
|
||||
|
||||
@@ -6508,13 +6572,10 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* 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 _
|
||||
@@ -6634,8 +6695,7 @@
|
||||
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]);
|
||||
@@ -6664,10 +6724,11 @@
|
||||
* `_.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 _
|
||||
@@ -6855,23 +6916,12 @@
|
||||
* }, []);
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -7250,8 +7300,6 @@
|
||||
return filter(collection, baseMatches(source));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
||||
* (1 January 1970 00:00:00 UTC).
|
||||
@@ -7270,8 +7318,6 @@
|
||||
return new Date().getTime();
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The opposite of `_.before`; this method creates a function that invokes
|
||||
* `func` once it is called `n` or more times.
|
||||
@@ -8251,8 +8297,6 @@
|
||||
return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
|
||||
* otherwise they are assigned by reference. If `customizer` is provided it is
|
||||
@@ -8384,8 +8428,7 @@
|
||||
* // => 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8506,10 +8549,9 @@
|
||||
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;
|
||||
}
|
||||
@@ -8899,7 +8941,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function isRegExp(value) {
|
||||
return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
|
||||
return isObjectLike(value) && objToString.call(value) == regexpTag;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9015,8 +9057,6 @@
|
||||
return baseCopy(value, keysIn(value));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source object(s) to the destination
|
||||
* object. Subsequent sources overwrite property assignments of previous sources.
|
||||
@@ -9027,7 +9067,6 @@
|
||||
* **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
|
||||
@@ -9499,12 +9538,9 @@
|
||||
* // => ['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) : [];
|
||||
@@ -9561,6 +9597,28 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated by
|
||||
* running each own enumerable property of `object` through `iteratee`. The
|
||||
@@ -9602,15 +9660,7 @@
|
||||
* _.mapValues(users, 'age');
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*/
|
||||
function mapValues(object, iteratee, thisArg) {
|
||||
var result = {};
|
||||
iteratee = getCallback(iteratee, thisArg, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[key] = iteratee(value, key, object);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
var mapValues = createObjectMapper();
|
||||
|
||||
/**
|
||||
* Recursively merges own enumerable properties of the source object(s), that
|
||||
@@ -9665,11 +9715,6 @@
|
||||
/**
|
||||
* 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 _
|
||||
@@ -9963,8 +10008,6 @@
|
||||
return baseValues(object, keysIn(object));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Checks if `n` is between `start` and up to but not including, `end`. If
|
||||
* `end` is not specified it is set to `start` with `start` then set to `0`.
|
||||
@@ -10069,8 +10112,6 @@
|
||||
return baseRandom(min, max);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
|
||||
*
|
||||
@@ -10936,8 +10977,6 @@
|
||||
return string.match(pattern || reWords) || [];
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Attempts to invoke `func`, returning either the result or the caught error
|
||||
* object. Any additional arguments are provided to `func` when it is invoked.
|
||||
@@ -11008,7 +11047,9 @@
|
||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||
thisArg = null;
|
||||
}
|
||||
return baseCallback(func, thisArg);
|
||||
return isObjectLike(func)
|
||||
? matches(func)
|
||||
: baseCallback(func, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -11133,7 +11174,7 @@
|
||||
var method = restParam(function(path, args) {
|
||||
return function(object) {
|
||||
return invokePath(object, path, args);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -11470,8 +11511,6 @@
|
||||
return baseToString(prefix) + id;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Adds two numbers.
|
||||
*
|
||||
@@ -11636,8 +11675,6 @@
|
||||
: baseSum(collection, iteratee);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// Ensure wrappers are instances of `baseLodash`.
|
||||
lodash.prototype = baseLodash.prototype;
|
||||
|
||||
@@ -11708,6 +11745,7 @@
|
||||
lodash.keys = keys;
|
||||
lodash.keysIn = keysIn;
|
||||
lodash.map = map;
|
||||
lodash.mapKeys = mapKeys;
|
||||
lodash.mapValues = mapValues;
|
||||
lodash.matches = matches;
|
||||
lodash.matchesProperty = matchesProperty;
|
||||
@@ -11756,6 +11794,7 @@
|
||||
lodash.union = union;
|
||||
lodash.uniq = uniq;
|
||||
lodash.unzip = unzip;
|
||||
lodash.unzipWith = unzipWith;
|
||||
lodash.values = values;
|
||||
lodash.valuesIn = valuesIn;
|
||||
lodash.where = where;
|
||||
@@ -11764,6 +11803,7 @@
|
||||
lodash.xor = xor;
|
||||
lodash.zip = zip;
|
||||
lodash.zipObject = zipObject;
|
||||
lodash.zipWith = zipWith;
|
||||
|
||||
// Add aliases.
|
||||
lodash.backflow = flowRight;
|
||||
@@ -11782,8 +11822,6 @@
|
||||
// Add functions to `lodash.prototype`.
|
||||
mixin(lodash, lodash);
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// Add functions that return unwrapped values when chaining.
|
||||
lodash.add = add;
|
||||
lodash.attempt = attempt;
|
||||
@@ -11887,8 +11925,6 @@
|
||||
return source;
|
||||
}()), false);
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// Add functions capable of returning wrapped and unwrapped values when chaining.
|
||||
lodash.sample = sample;
|
||||
|
||||
@@ -11901,8 +11937,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The semantic version number.
|
||||
*
|
||||
@@ -12013,8 +12047,13 @@
|
||||
|
||||
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);
|
||||
@@ -12037,7 +12076,6 @@
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var args = arguments,
|
||||
length = args.length,
|
||||
chainAll = this.__chain__,
|
||||
value = this.__wrapped__,
|
||||
isHybrid = !!this.__actions__.length,
|
||||
@@ -12126,8 +12164,6 @@
|
||||
return lodash;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// Export lodash.
|
||||
var _ = runInContext();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./object/assign', './object/create', './object/defaults', './object/extend', './object/findKey', './object/findLastKey', './object/forIn', './object/forInRight', './object/forOwn', './object/forOwnRight', './object/functions', './object/get', './object/has', './object/invert', './object/keys', './object/keysIn', './object/mapValues', './object/merge', './object/methods', './object/omit', './object/pairs', './object/pick', './object/result', './object/set', './object/transform', './object/values', './object/valuesIn'], function(assign, create, defaults, extend, findKey, findLastKey, forIn, forInRight, forOwn, forOwnRight, functions, get, has, invert, keys, keysIn, mapValues, merge, methods, omit, pairs, pick, result, set, transform, values, valuesIn) {
|
||||
define(['./object/assign', './object/create', './object/defaults', './object/extend', './object/findKey', './object/findLastKey', './object/forIn', './object/forInRight', './object/forOwn', './object/forOwnRight', './object/functions', './object/get', './object/has', './object/invert', './object/keys', './object/keysIn', './object/mapKeys', './object/mapValues', './object/merge', './object/methods', './object/omit', './object/pairs', './object/pick', './object/result', './object/set', './object/transform', './object/values', './object/valuesIn'], function(assign, create, defaults, extend, findKey, findLastKey, forIn, forInRight, forOwn, forOwnRight, functions, get, has, invert, keys, keysIn, mapKeys, mapValues, merge, methods, omit, pairs, pick, result, set, transform, values, valuesIn) {
|
||||
return {
|
||||
'assign': assign,
|
||||
'create': create,
|
||||
@@ -16,6 +16,7 @@ define(['./object/assign', './object/create', './object/defaults', './object/ext
|
||||
'invert': invert,
|
||||
'keys': keys,
|
||||
'keysIn': keysIn,
|
||||
'mapKeys': mapKeys,
|
||||
'mapValues': mapValues,
|
||||
'merge': merge,
|
||||
'methods': methods,
|
||||
|
||||
@@ -10,7 +10,6 @@ define(['../internal/assignWith', '../internal/baseAssign', '../internal/createA
|
||||
* **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 @@
|
||||
define(['../internal/isLength', '../lang/isNative', '../lang/isObject', '../internal/shimKeys'], function(isLength, isNative, isObject, shimKeys) {
|
||||
define(['../internal/isArrayLike', '../lang/isNative', '../lang/isObject', '../internal/shimKeys'], function(isArrayLike, isNative, isObject, shimKeys) {
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
|
||||
@@ -31,12 +31,9 @@ define(['../internal/isLength', '../lang/isNative', '../lang/isObject', '../inte
|
||||
* // => ['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) : [];
|
||||
|
||||
26
object/mapKeys.js
Normal file
26
object/mapKeys.js
Normal file
@@ -0,0 +1,26 @@
|
||||
define(['../internal/createObjectMapper'], function(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);
|
||||
|
||||
return mapKeys;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/baseCallback', '../internal/baseForOwn'], function(baseCallback, baseForOwn) {
|
||||
define(['../internal/createObjectMapper'], function(createObjectMapper) {
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated by
|
||||
@@ -41,15 +41,7 @@ define(['../internal/baseCallback', '../internal/baseForOwn'], function(baseCall
|
||||
* _.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();
|
||||
|
||||
return mapValues;
|
||||
});
|
||||
|
||||
@@ -3,11 +3,6 @@ define(['../internal/arrayMap', '../internal/baseDifference', '../internal/baseF
|
||||
/**
|
||||
* 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",
|
||||
"version": "3.7.0",
|
||||
"version": "3.8.0",
|
||||
"main": "main.js",
|
||||
"private": true,
|
||||
"volo": {
|
||||
|
||||
@@ -20,6 +20,7 @@ define(['./internal/root'], function(root) {
|
||||
|
||||
(function(x) {
|
||||
var Ctor = function() { this.x = x; },
|
||||
args = arguments,
|
||||
object = { '0': x, 'length': x },
|
||||
props = [];
|
||||
|
||||
@@ -69,7 +70,7 @@ define(['./internal/root'], function(root) {
|
||||
* @type boolean
|
||||
*/
|
||||
try {
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
|
||||
support.nonEnumArgs = !propertyIsEnumerable.call(args, 1);
|
||||
} catch(e) {
|
||||
support.nonEnumArgs = true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/baseCallback', '../internal/isIterateeCall'], function(baseCallback, isIterateeCall) {
|
||||
define(['../internal/baseCallback', '../internal/isIterateeCall', '../internal/isObjectLike', './matches'], function(baseCallback, isIterateeCall, isObjectLike, matches) {
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
||||
@@ -42,7 +42,9 @@ define(['../internal/baseCallback', '../internal/isIterateeCall'], function(base
|
||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||
thisArg = null;
|
||||
}
|
||||
return baseCallback(func, thisArg);
|
||||
return isObjectLike(func)
|
||||
? matches(func)
|
||||
: baseCallback(func, thisArg);
|
||||
}
|
||||
|
||||
return callback;
|
||||
|
||||
@@ -24,7 +24,7 @@ define(['../internal/invokePath', '../function/restParam'], function(invokePath,
|
||||
var method = restParam(function(path, args) {
|
||||
return function(object) {
|
||||
return invokePath(object, path, args);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return method;
|
||||
|
||||
Reference in New Issue
Block a user