mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32393ae520 | ||
|
|
d2754e0b9b | ||
|
|
81e41ca0c8 | ||
|
|
26837e7fe2 | ||
|
|
fec213a98c |
@@ -1,4 +1,4 @@
|
|||||||
# lodash v3.6.0
|
# lodash v3.9.3
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -10,6 +10,13 @@ $ lodash modern exports=amd -d -o ./main.js
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Using bower or volo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ bower i lodash#3.9.3-amd
|
||||||
|
$ volo add lodash/3.9.3-amd
|
||||||
|
```
|
||||||
|
|
||||||
Defining a build as `'lodash'`.
|
Defining a build as `'lodash'`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
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 {
|
return {
|
||||||
'chunk': chunk,
|
'chunk': chunk,
|
||||||
'compact': compact,
|
'compact': compact,
|
||||||
@@ -36,9 +36,11 @@ define(['./array/chunk', './array/compact', './array/difference', './array/drop'
|
|||||||
'uniq': uniq,
|
'uniq': uniq,
|
||||||
'unique': unique,
|
'unique': unique,
|
||||||
'unzip': unzip,
|
'unzip': unzip,
|
||||||
|
'unzipWith': unzipWith,
|
||||||
'without': without,
|
'without': without,
|
||||||
'xor': xor,
|
'xor': xor,
|
||||||
'zip': zip,
|
'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
|
* Creates an array of unique `array` values not included in the other
|
||||||
* `SameValueZero` for equality comparisons.
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
|
|||||||
* // => [1, 3]
|
* // => [1, 3]
|
||||||
*/
|
*/
|
||||||
var difference = restParam(function(array, values) {
|
var difference = restParam(function(array, values) {
|
||||||
return (isArray(array) || isArguments(array))
|
return isArrayLike(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true))
|
? 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`
|
* Gets the index at which the first occurrence of `value` is found in `array`
|
||||||
* using `SameValueZero` for equality comparisons. If `fromIndex` is negative,
|
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* it is used as the offset from the end of `array`. If `array` is sorted
|
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
|
||||||
* providing `true` for `fromIndex` performs a faster binary search.
|
* 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`.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @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/restParam'], function(baseIndexOf, cacheIndexOf, createCache, isArrayLike, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of unique values in all provided arrays using `SameValueZero`
|
* Creates an array of unique values that are included in all of the provided
|
||||||
|
* arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* for equality comparisons.
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Array
|
* @category Array
|
||||||
@@ -17,36 +14,31 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
|
|||||||
* _.intersection([1, 2], [4, 2], [2, 1]);
|
* _.intersection([1, 2], [4, 2], [2, 1]);
|
||||||
* // => [2]
|
* // => [2]
|
||||||
*/
|
*/
|
||||||
function intersection() {
|
var intersection = restParam(function(arrays) {
|
||||||
var args = [],
|
var othLength = arrays.length,
|
||||||
argsIndex = -1,
|
othIndex = othLength,
|
||||||
argsLength = arguments.length,
|
caches = Array(length),
|
||||||
caches = [],
|
|
||||||
indexOf = baseIndexOf,
|
indexOf = baseIndexOf,
|
||||||
isCommon = true;
|
isCommon = true,
|
||||||
|
result = [];
|
||||||
|
|
||||||
while (++argsIndex < argsLength) {
|
while (othIndex--) {
|
||||||
var value = arguments[argsIndex];
|
var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
|
||||||
if (isArray(value) || isArguments(value)) {
|
caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
|
||||||
args.push(value);
|
|
||||||
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
argsLength = args.length;
|
var array = arrays[0],
|
||||||
var array = args[0],
|
|
||||||
index = -1,
|
index = -1,
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
result = [],
|
|
||||||
seen = caches[0];
|
seen = caches[0];
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
value = array[index];
|
value = array[index];
|
||||||
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
|
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
|
||||||
argsIndex = argsLength;
|
var othIndex = othLength;
|
||||||
while (--argsIndex) {
|
while (--othIndex) {
|
||||||
var cache = caches[argsIndex];
|
var cache = caches[othIndex];
|
||||||
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) {
|
if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +49,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
});
|
||||||
|
|
||||||
return intersection;
|
return intersection;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,14 +7,11 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
|
|||||||
var splice = arrayProto.splice;
|
var splice = arrayProto.splice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all provided values from `array` using `SameValueZero` for equality
|
* Removes all provided values from `array` using
|
||||||
* comparisons.
|
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
|
* for equality comparisons.
|
||||||
*
|
*
|
||||||
* **Notes:**
|
* **Note:** Unlike `_.without`, this method mutates `array`.
|
||||||
* - 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`
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/baseFlatten', '../internal/isIndex', '../function/restParam'], function(baseAt, baseCompareAscending, baseFlatten, isIndex, restParam) {
|
define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/baseFlatten', '../internal/basePullAt', '../function/restParam'], function(baseAt, baseCompareAscending, baseFlatten, basePullAt, restParam) {
|
||||||
|
|
||||||
/** Used for native method references. */
|
|
||||||
var arrayProto = Array.prototype;
|
|
||||||
|
|
||||||
/** Native method references. */
|
|
||||||
var splice = arrayProto.splice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes elements from `array` corresponding to the given indexes and returns
|
* Removes elements from `array` corresponding to the given indexes and returns
|
||||||
@@ -32,20 +26,10 @@ define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/b
|
|||||||
* // => [10, 20]
|
* // => [10, 20]
|
||||||
*/
|
*/
|
||||||
var pullAt = restParam(function(array, indexes) {
|
var pullAt = restParam(function(array, indexes) {
|
||||||
array || (array = []);
|
|
||||||
indexes = baseFlatten(indexes);
|
indexes = baseFlatten(indexes);
|
||||||
|
|
||||||
var length = indexes.length,
|
var result = baseAt(array, indexes);
|
||||||
result = baseAt(array, indexes);
|
basePullAt(array, indexes.sort(baseCompareAscending));
|
||||||
|
|
||||||
indexes.sort(baseCompareAscending);
|
|
||||||
while (length--) {
|
|
||||||
var index = parseFloat(indexes[length]);
|
|
||||||
if (index != previous && isIndex(index)) {
|
|
||||||
var previous = index;
|
|
||||||
splice.call(array, index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
define(['../internal/baseCallback'], function(baseCallback) {
|
define(['../internal/baseCallback', '../internal/basePullAt'], function(baseCallback, basePullAt) {
|
||||||
|
|
||||||
/** Used for native method references. */
|
|
||||||
var arrayProto = Array.prototype;
|
|
||||||
|
|
||||||
/** Native method references. */
|
|
||||||
var splice = arrayProto.splice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all elements from `array` that `predicate` returns truthy for
|
* Removes all elements from `array` that `predicate` returns truthy for
|
||||||
@@ -46,19 +40,23 @@ define(['../internal/baseCallback'], function(baseCallback) {
|
|||||||
* // => [2, 4]
|
* // => [2, 4]
|
||||||
*/
|
*/
|
||||||
function remove(array, predicate, thisArg) {
|
function remove(array, predicate, thisArg) {
|
||||||
|
var result = [];
|
||||||
|
if (!(array && array.length)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array ? array.length : 0,
|
indexes = [],
|
||||||
result = [];
|
length = array.length;
|
||||||
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
predicate = baseCallback(predicate, thisArg, 3);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (predicate(value, index, array)) {
|
if (predicate(value, index, array)) {
|
||||||
result.push(value);
|
result.push(value);
|
||||||
splice.call(array, index--, 1);
|
indexes.push(index);
|
||||||
length--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
basePullAt(array, indexes);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
|
|||||||
/**
|
/**
|
||||||
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
||||||
*
|
*
|
||||||
* **Note:** This function is used instead of `Array#slice` to support node
|
* **Note:** This method is used instead of `Array#slice` to support node
|
||||||
* lists in IE < 9 and to ensure dense arrays are returned.
|
* lists in IE < 9 and to ensure dense arrays are returned.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restParam'], function(baseFlatten, baseUniq, restParam) {
|
define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restParam'], function(baseFlatten, baseUniq, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of unique values, in order, of the provided arrays using
|
* Creates an array of unique values, in order, from all of the provided arrays
|
||||||
* `SameValueZero` for equality comparisons.
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, sortedUniq) {
|
define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, sortedUniq) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a duplicate-value-free version of an array using `SameValueZero`
|
* Creates a duplicate-free version of an array, using
|
||||||
* for equality comparisons. Providing `true` for `isSorted` performs a faster
|
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* search algorithm for sorted arrays. If an iteratee function is provided it
|
* for equality comparisons, in which only the first occurence of each element
|
||||||
* is invoked for each value in the array to generate the criterion by which
|
* is kept. Providing `true` for `isSorted` performs a faster search algorithm
|
||||||
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
|
* for sorted arrays. If an iteratee function is provided it is invoked for
|
||||||
* with three arguments: (value, index, array).
|
* each element in the array to generate the criterion by which uniqueness
|
||||||
|
* is computed. The `iteratee` is bound to `thisArg` and invoked with three
|
||||||
|
* arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `iteratee` the created `_.property`
|
* If a property name is provided for `iteratee` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -19,10 +21,6 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
|
|||||||
* callback returns `true` for elements that have the properties of the given
|
* callback returns `true` for elements that have the properties of the given
|
||||||
* object, else `false`.
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @alias unique
|
* @alias unique
|
||||||
@@ -34,8 +32,8 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
|
|||||||
* @returns {Array} Returns the new duplicate-value-free array.
|
* @returns {Array} Returns the new duplicate-value-free array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.uniq([1, 2, 1]);
|
* _.uniq([2, 1, 2]);
|
||||||
* // => [1, 2]
|
* // => [2, 1]
|
||||||
*
|
*
|
||||||
* // using `isSorted`
|
* // using `isSorted`
|
||||||
* _.uniq([1, 1, 2], true);
|
* _.uniq([1, 1, 2], true);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
define(['../internal/arrayMap', '../internal/arrayMax', '../internal/baseProperty'], function(arrayMap, arrayMax, baseProperty) {
|
define(['../internal/arrayFilter', '../internal/arrayMap', '../internal/baseProperty', '../internal/isArrayLike'], function(arrayFilter, arrayMap, baseProperty, isArrayLike) {
|
||||||
|
|
||||||
/** Used to the length of n-tuples for `_.unzip`. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
var getLength = baseProperty('length');
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.zip` except that it accepts an array of grouped
|
* 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.
|
* configuration.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -22,10 +22,19 @@ define(['../internal/arrayMap', '../internal/arrayMax', '../internal/basePropert
|
|||||||
* // => [['fred', 'barney'], [30, 40], [true, false]]
|
* // => [['fred', 'barney'], [30, 40], [true, false]]
|
||||||
*/
|
*/
|
||||||
function unzip(array) {
|
function unzip(array) {
|
||||||
|
if (!(array && array.length)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
|
length = 0;
|
||||||
result = Array(length);
|
|
||||||
|
|
||||||
|
array = arrayFilter(array, function(group) {
|
||||||
|
if (isArrayLike(group)) {
|
||||||
|
length = nativeMax(group.length, length);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var result = Array(length);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
result[index] = arrayMap(array, baseProperty(index));
|
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
|
* Creates an array excluding all provided values using
|
||||||
* equality comparisons.
|
* [`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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray',
|
|||||||
* // => [3]
|
* // => [3]
|
||||||
*/
|
*/
|
||||||
var without = restParam(function(array, values) {
|
var without = restParam(function(array, values) {
|
||||||
return (isArray(array) || isArguments(array))
|
return isArrayLike(array)
|
||||||
? baseDifference(array, values)
|
? baseDifference(array, values)
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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)
|
* Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
|
||||||
* of the provided arrays.
|
* of the provided arrays.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -20,7 +20,7 @@ define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArgumen
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var array = arguments[index];
|
var array = arguments[index];
|
||||||
if (isArray(array) || isArguments(array)) {
|
if (isArrayLike(array)) {
|
||||||
var result = result
|
var result = result
|
||||||
? baseDifference(result, array).concat(baseDifference(array, result))
|
? baseDifference(result, array).concat(baseDifference(array, result))
|
||||||
: array;
|
: 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 = length > 2 ? arrays[length - 2] : undefined,
|
||||||
|
thisArg = length > 1 ? arrays[length - 1] : undefined;
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
@@ -45,30 +45,31 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
|
|||||||
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
|
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
|
||||||
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
|
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
|
||||||
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
|
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
|
||||||
* `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`,
|
* `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
|
||||||
* `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
|
* `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`,
|
||||||
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
|
* `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`,
|
||||||
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
* `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`,
|
||||||
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`,
|
* `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`,
|
||||||
* `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`,
|
* `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`,
|
||||||
* `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`,
|
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
||||||
* `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`,
|
* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,
|
||||||
* `without`, `wrap`, `xor`, `zip`, and `zipObject`
|
* `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`,
|
||||||
|
* `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
|
||||||
*
|
*
|
||||||
* The wrapper methods that are **not** chainable by default are:
|
* The wrapper methods that are **not** chainable by default are:
|
||||||
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
|
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
|
||||||
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
|
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
|
||||||
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`,
|
||||||
* `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`,
|
* `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,
|
||||||
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
|
* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
|
||||||
* `isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
* `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
||||||
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
||||||
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`,
|
||||||
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
* `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`,
|
||||||
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
* `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`,
|
||||||
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
* `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
||||||
* `startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`,
|
* `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`,
|
||||||
* `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
* `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
||||||
*
|
*
|
||||||
* The wrapper method `sample` will return a wrapped value when `n` is provided,
|
* The wrapper method `sample` will return a wrapped value when `n` is provided,
|
||||||
* otherwise an unwrapped value is returned.
|
* otherwise an unwrapped value is returned.
|
||||||
@@ -83,8 +84,8 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
|
|||||||
* var wrapped = _([1, 2, 3]);
|
* var wrapped = _([1, 2, 3]);
|
||||||
*
|
*
|
||||||
* // returns an unwrapped value
|
* // returns an unwrapped value
|
||||||
* wrapped.reduce(function(sum, n) {
|
* wrapped.reduce(function(total, n) {
|
||||||
* return sum + n;
|
* return total + n;
|
||||||
* });
|
* });
|
||||||
* // => 6
|
* // => 6
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength', '../function/restParam', '../internal/toIterable'], function(baseAt, baseFlatten, 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,
|
* Creates an array of elements corresponding to the given keys, or indexes,
|
||||||
@@ -21,10 +21,6 @@ define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength',
|
|||||||
* // => ['barney', 'pebbles']
|
* // => ['barney', 'pebbles']
|
||||||
*/
|
*/
|
||||||
var at = restParam(function(collection, props) {
|
var at = restParam(function(collection, props) {
|
||||||
var length = collection ? collection.length : 0;
|
|
||||||
if (isLength(length)) {
|
|
||||||
collection = toIterable(collection);
|
|
||||||
}
|
|
||||||
return baseAt(collection, baseFlatten(props));
|
return baseAt(collection, baseFlatten(props));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray', '../internal/isIterateeCall'], function(arrayEvery, baseCallback, baseEvery, isArray, isIterateeCall) {
|
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray', '../internal/isIterateeCall'], function(arrayEvery, baseCallback, baseEvery, isArray, isIterateeCall) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `predicate` returns truthy for **all** elements of `collection`.
|
* Checks if `predicate` returns truthy for **all** elements of `collection`.
|
||||||
* The predicate is bound to `thisArg` and invoked with three arguments:
|
* The predicate is bound to `thisArg` and invoked with three arguments:
|
||||||
@@ -53,7 +56,7 @@ define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseE
|
|||||||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
predicate = null;
|
predicate = null;
|
||||||
}
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || thisArg !== undefined) {
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
predicate = baseCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
return func(collection, predicate);
|
return func(collection, predicate);
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ define(['../internal/arrayEach', '../internal/baseEach', '../internal/createForE
|
|||||||
/**
|
/**
|
||||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||||
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
|
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
|
||||||
* (value, index|key, collection). Iterator functions may exit iteration early
|
* (value, index|key, collection). Iteratee functions may exit iteration early
|
||||||
* by explicitly returning `false`.
|
* by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
* **Note:** As with other "Collections" methods, objects with a `length` property
|
* **Note:** As with other "Collections" methods, objects with a "length" property
|
||||||
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
|
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
|
||||||
* may be used for object iteration.
|
* may be used for object iteration.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isIterateeCall', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, isArray, isIterateeCall, isLength, isString, values) {
|
define(['../internal/baseIndexOf', '../internal/getLength', '../lang/isArray', '../internal/isIterateeCall', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, getLength, isArray, isIterateeCall, isLength, isString, values) {
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeMax = Math.max;
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is in `collection` using `SameValueZero` for equality
|
* Checks if `value` is in `collection` using
|
||||||
* comparisons. If `fromIndex` is negative, it is used as the offset from
|
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* the end of `collection`.
|
* 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`.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -36,7 +33,7 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isIterateeCal
|
|||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
function includes(collection, target, fromIndex, guard) {
|
function includes(collection, target, fromIndex, guard) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? getLength(collection) : 0;
|
||||||
if (!isLength(length)) {
|
if (!isLength(length)) {
|
||||||
collection = values(collection);
|
collection = values(collection);
|
||||||
length = collection.length;
|
length = collection.length;
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
define(['../internal/baseEach', '../internal/isLength', '../function/restParam'], function(baseEach, isLength, restParam) {
|
define(['../internal/baseEach', '../internal/invokePath', '../internal/isArrayLike', '../internal/isKey', '../function/restParam'], function(baseEach, invokePath, isArrayLike, isKey, restParam) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
||||||
var undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes the method named by `methodName` on each element in `collection`,
|
* Invokes the method at `path` of each element in `collection`, returning
|
||||||
* returning an array of the results of each invoked method. Any additional
|
* an array of the results of each invoked method. Any additional arguments
|
||||||
* arguments are provided to each invoked method. If `methodName` is a function
|
* are provided to each invoked method. If `methodName` is a function it is
|
||||||
* it is invoked for, and `this` bound to, each element in `collection`.
|
* invoked for, and `this` bound to, each element in `collection`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {Function|string} methodName The name of the method to invoke or
|
* @param {Array|Function|string} path The path of the method to invoke or
|
||||||
* the function invoked per iteration.
|
* the function invoked per iteration.
|
||||||
* @param {...*} [args] The arguments to invoke the method with.
|
* @param {...*} [args] The arguments to invoke the method with.
|
||||||
* @returns {Array} Returns the array of results.
|
* @returns {Array} Returns the array of results.
|
||||||
@@ -25,15 +22,15 @@ define(['../internal/baseEach', '../internal/isLength', '../function/restParam']
|
|||||||
* _.invoke([123, 456], String.prototype.split, '');
|
* _.invoke([123, 456], String.prototype.split, '');
|
||||||
* // => [['1', '2', '3'], ['4', '5', '6']]
|
* // => [['1', '2', '3'], ['4', '5', '6']]
|
||||||
*/
|
*/
|
||||||
var invoke = restParam(function(collection, methodName, args) {
|
var invoke = restParam(function(collection, path, args) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
isFunc = typeof methodName == 'function',
|
isFunc = typeof path == 'function',
|
||||||
length = collection ? collection.length : 0,
|
isProp = isKey(path),
|
||||||
result = isLength(length) ? Array(length) : [];
|
result = isArrayLike(collection) ? Array(collection.length) : [];
|
||||||
|
|
||||||
baseEach(collection, function(value) {
|
baseEach(collection, function(value) {
|
||||||
var func = isFunc ? methodName : (value != null && value[methodName]);
|
var func = isFunc ? path : ((isProp && value != null) ? value[path] : null);
|
||||||
result[++index] = func ? func.apply(value, args) : undefined;
|
result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
|
|||||||
* callback returns `true` for elements that have the properties of the given
|
* callback returns `true` for elements that have the properties of the given
|
||||||
* object, else `false`.
|
* object, else `false`.
|
||||||
*
|
*
|
||||||
* Many lodash methods are guarded to work as interatees for methods like
|
* Many lodash methods are guarded to work as iteratees for methods like
|
||||||
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
|
||||||
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
|
* `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
|
||||||
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
|
* `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
|
||||||
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
|
* `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
|
||||||
|
* `sum`, `uniq`, and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -32,7 +33,6 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
|
|||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
||||||
* per iteration.
|
* per iteration.
|
||||||
* create a `_.property` or `_.matches` style callback respectively.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||||
* @returns {Array} Returns the new mapped array.
|
* @returns {Array} Returns the new mapped array.
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
define(['../internal/baseProperty', './map'], function(baseProperty, map) {
|
define(['./map', '../utility/property'], function(map, property) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of `key` from all elements in `collection`.
|
* Gets the property value of `path` from all elements in `collection`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {string} key The key of the property to pluck.
|
* @param {Array|string} path The path of the property to pluck.
|
||||||
* @returns {Array} Returns the property values.
|
* @returns {Array} Returns the property values.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,8 +23,8 @@ define(['../internal/baseProperty', './map'], function(baseProperty, map) {
|
|||||||
* _.pluck(userIndex, 'age');
|
* _.pluck(userIndex, 'age');
|
||||||
* // => [36, 40] (iteration order is not guaranteed)
|
* // => [36, 40] (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function pluck(collection, key) {
|
function pluck(collection, path) {
|
||||||
return map(collection, baseProperty(key));
|
return map(collection, property(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluck;
|
return pluck;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createRe
|
|||||||
* value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
|
* value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
|
||||||
* (accumulator, value, index|key, collection).
|
* (accumulator, value, index|key, collection).
|
||||||
*
|
*
|
||||||
* Many lodash methods are guarded to work as interatees for methods like
|
* Many lodash methods are guarded to work as iteratees for methods like
|
||||||
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
@@ -25,8 +25,8 @@ define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createRe
|
|||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.reduce([1, 2], function(sum, n) {
|
* _.reduce([1, 2], function(total, n) {
|
||||||
* return sum + n;
|
* return total + n;
|
||||||
* });
|
* });
|
||||||
* // => 3
|
* // => 3
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ define(['../internal/arrayReduceRight', '../internal/baseEachRight', '../interna
|
|||||||
* }, []);
|
* }, []);
|
||||||
* // => [4, 5, 2, 3, 0, 1]
|
* // => [4, 5, 2, 3, 0, 1]
|
||||||
*/
|
*/
|
||||||
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||||
|
|
||||||
return reduceRight;
|
return reduceRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,17 +4,6 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
|
|||||||
* The opposite of `_.filter`; this method returns the elements of `collection`
|
* The opposite of `_.filter`; this method returns the elements of `collection`
|
||||||
* that `predicate` does **not** return truthy for.
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseRandom', '../internal/isIterateeCall', './shuffle', '../internal/toIterable'], function(baseRandom, isIterateeCall, shuffle, toIterable) {
|
define(['../internal/baseRandom', '../internal/isIterateeCall', '../lang/toArray', '../internal/toIterable'], function(baseRandom, isIterateeCall, toArray, toIterable) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -30,8 +30,20 @@ define(['../internal/baseRandom', '../internal/isIterateeCall', './shuffle', '..
|
|||||||
var length = collection.length;
|
var length = collection.length;
|
||||||
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
||||||
}
|
}
|
||||||
var result = shuffle(collection);
|
var index = -1,
|
||||||
result.length = nativeMin(n < 0 ? 0 : (+n || 0), result.length);
|
result = toArray(collection),
|
||||||
|
length = result.length,
|
||||||
|
lastIndex = length - 1;
|
||||||
|
|
||||||
|
n = nativeMin(n < 0 ? 0 : (+n || 0), length);
|
||||||
|
while (++index < n) {
|
||||||
|
var rand = baseRandom(index, lastIndex),
|
||||||
|
value = result[rand];
|
||||||
|
|
||||||
|
result[rand] = result[index];
|
||||||
|
result[index] = value;
|
||||||
|
}
|
||||||
|
result.length = n;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom, toIterable) {
|
define(['./sample'], function(sample) {
|
||||||
|
|
||||||
|
/** Used as references for `-Infinity` and `Infinity`. */
|
||||||
|
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of shuffled values, using a version of the
|
* Creates an array of shuffled values, using a version of the
|
||||||
@@ -15,20 +18,7 @@ define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom
|
|||||||
* // => [4, 1, 3, 2]
|
* // => [4, 1, 3, 2]
|
||||||
*/
|
*/
|
||||||
function shuffle(collection) {
|
function shuffle(collection) {
|
||||||
collection = toIterable(collection);
|
return sample(collection, POSITIVE_INFINITY);
|
||||||
|
|
||||||
var index = -1,
|
|
||||||
length = collection.length,
|
|
||||||
result = Array(length);
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var rand = baseRandom(0, index);
|
|
||||||
if (index != rand) {
|
|
||||||
result[index] = result[rand];
|
|
||||||
}
|
|
||||||
result[rand] = collection[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return shuffle;
|
return shuffle;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/isLength', '../object/keys'], function(isLength, keys) {
|
define(['../internal/getLength', '../internal/isLength', '../object/keys'], function(getLength, isLength, keys) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the size of `collection` by returning its length for array-like
|
* Gets the size of `collection` by returning its length for array-like
|
||||||
@@ -21,7 +21,7 @@ define(['../internal/isLength', '../object/keys'], function(isLength, keys) {
|
|||||||
* // => 7
|
* // => 7
|
||||||
*/
|
*/
|
||||||
function size(collection) {
|
function size(collection) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? getLength(collection) : 0;
|
||||||
return isLength(length) ? length : keys(collection).length;
|
return isLength(length) ? length : keys(collection).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray', '../internal/isIterateeCall'], function(arraySome, baseCallback, baseSome, isArray, isIterateeCall) {
|
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray', '../internal/isIterateeCall'], function(arraySome, baseCallback, baseSome, isArray, isIterateeCall) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `predicate` returns truthy for **any** element of `collection`.
|
* Checks if `predicate` returns truthy for **any** element of `collection`.
|
||||||
* The function returns as soon as it finds a passing value and does not iterate
|
* The function returns as soon as it finds a passing value and does not iterate
|
||||||
@@ -54,7 +57,7 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo
|
|||||||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
predicate = null;
|
predicate = null;
|
||||||
}
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || thisArg !== undefined) {
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
predicate = baseCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
return func(collection, predicate);
|
return func(collection, predicate);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSortBy', '../internal/compareAscending', '../internal/isIterateeCall', '../internal/isLength'], function(baseCallback, baseEach, baseSortBy, compareAscending, isIterateeCall, isLength) {
|
define(['../internal/baseCallback', '../internal/baseMap', '../internal/baseSortBy', '../internal/compareAscending', '../internal/isIterateeCall'], function(baseCallback, baseMap, baseSortBy, compareAscending, isIterateeCall) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of elements, sorted in ascending order by the results of
|
* Creates an array of elements, sorted in ascending order by the results of
|
||||||
@@ -22,9 +22,8 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {Array|Function|Object|string} [iteratee=_.identity] The function
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
||||||
* invoked per iteration. If a property name or an object is provided it is
|
* per iteration.
|
||||||
* used to create a `_.property` or `_.matches` style callback respectively.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
* @example
|
* @example
|
||||||
@@ -53,16 +52,14 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
|
|||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var index = -1,
|
|
||||||
length = collection.length,
|
|
||||||
result = isLength(length) ? Array(length) : [];
|
|
||||||
|
|
||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
}
|
}
|
||||||
|
var index = -1;
|
||||||
iteratee = baseCallback(iteratee, thisArg, 3);
|
iteratee = baseCallback(iteratee, thisArg, 3);
|
||||||
baseEach(collection, function(value, key, collection) {
|
|
||||||
result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value };
|
var result = baseMap(collection, function(value, key, collection) {
|
||||||
|
return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };
|
||||||
});
|
});
|
||||||
return baseSortBy(result, compareAscending);
|
return baseSortBy(result, compareAscending);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,50 @@
|
|||||||
define(['../internal/baseFlatten', '../internal/baseSortByOrder', '../internal/isIterateeCall'], function(baseFlatten, baseSortByOrder, isIterateeCall) {
|
define(['../internal/baseFlatten', '../internal/baseSortByOrder', '../internal/isIterateeCall', '../function/restParam'], function(baseFlatten, baseSortByOrder, isIterateeCall, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.sortBy` except that it sorts by property names
|
* This method is like `_.sortBy` except that it can sort by multiple iteratees
|
||||||
* instead of an iteratee function.
|
* or property names.
|
||||||
|
*
|
||||||
|
* If a property name is provided for an iteratee the created `_.property`
|
||||||
|
* style callback returns the property value of the given element.
|
||||||
|
*
|
||||||
|
* If an object is provided for an iteratee the created `_.matches` style
|
||||||
|
* callback returns `true` for elements that have the properties of the given
|
||||||
|
* object, else `false`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {...(string|string[])} props The property names to sort by,
|
* @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees
|
||||||
* specified as individual property names or arrays of property names.
|
* The iteratees to sort by, specified as individual values or arrays of values.
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var users = [
|
* var users = [
|
||||||
|
* { 'user': 'fred', 'age': 48 },
|
||||||
* { 'user': 'barney', 'age': 36 },
|
* { 'user': 'barney', 'age': 36 },
|
||||||
* { 'user': 'fred', 'age': 40 },
|
* { 'user': 'fred', 'age': 42 },
|
||||||
* { 'user': 'barney', 'age': 26 },
|
* { 'user': 'barney', 'age': 34 }
|
||||||
* { 'user': 'fred', 'age': 30 }
|
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
||||||
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
* // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]
|
||||||
|
*
|
||||||
|
* _.map(_.sortByAll(users, 'user', function(chr) {
|
||||||
|
* return Math.floor(chr.age / 10);
|
||||||
|
* }), _.values);
|
||||||
|
* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
|
||||||
*/
|
*/
|
||||||
function sortByAll() {
|
var sortByAll = restParam(function(collection, iteratees) {
|
||||||
var args = arguments,
|
|
||||||
collection = args[0],
|
|
||||||
guard = args[3],
|
|
||||||
index = 0,
|
|
||||||
length = args.length - 1;
|
|
||||||
|
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var props = Array(length);
|
var guard = iteratees[2];
|
||||||
while (index < length) {
|
if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) {
|
||||||
props[index] = args[++index];
|
iteratees.length = 1;
|
||||||
}
|
}
|
||||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
return baseSortByOrder(collection, baseFlatten(iteratees), []);
|
||||||
props = args[1];
|
});
|
||||||
}
|
|
||||||
return baseSortByOrder(collection, baseFlatten(props), []);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sortByAll;
|
return sortByAll;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,45 +2,52 @@ define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterate
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.sortByAll` except that it allows specifying the
|
* This method is like `_.sortByAll` except that it allows specifying the
|
||||||
* sort orders of the property names to sort by. A truthy value in `orders`
|
* sort orders of the iteratees to sort by. A truthy value in `orders` will
|
||||||
* will sort the corresponding property name in ascending order while a
|
* sort the corresponding property name in ascending order while a falsey
|
||||||
* falsey value will sort it in descending order.
|
* value will sort it in descending order.
|
||||||
|
*
|
||||||
|
* If a property name is provided for an iteratee the created `_.property`
|
||||||
|
* style callback returns the property value of the given element.
|
||||||
|
*
|
||||||
|
* If an object is provided for an iteratee the created `_.matches` style
|
||||||
|
* callback returns `true` for elements that have the properties of the given
|
||||||
|
* object, else `false`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {string[]} props The property names to sort by.
|
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
|
||||||
* @param {boolean[]} orders The sort orders of `props`.
|
* @param {boolean[]} orders The sort orders of `iteratees`.
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var users = [
|
* var users = [
|
||||||
* { 'user': 'barney', 'age': 26 },
|
* { 'user': 'fred', 'age': 48 },
|
||||||
* { 'user': 'fred', 'age': 40 },
|
* { 'user': 'barney', 'age': 34 },
|
||||||
* { 'user': 'barney', 'age': 36 },
|
* { 'user': 'fred', 'age': 42 },
|
||||||
* { 'user': 'fred', 'age': 30 }
|
* { 'user': 'barney', 'age': 36 }
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* // sort by `user` in ascending order and by `age` in descending order
|
* // sort by `user` in ascending order and by `age` in descending order
|
||||||
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);
|
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);
|
||||||
* // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]]
|
* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
|
||||||
*/
|
*/
|
||||||
function sortByOrder(collection, props, orders, guard) {
|
function sortByOrder(collection, iteratees, orders, guard) {
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (guard && isIterateeCall(props, orders, guard)) {
|
if (guard && isIterateeCall(iteratees, orders, guard)) {
|
||||||
orders = null;
|
orders = null;
|
||||||
}
|
}
|
||||||
if (!isArray(props)) {
|
if (!isArray(iteratees)) {
|
||||||
props = props == null ? [] : [props];
|
iteratees = iteratees == null ? [] : [iteratees];
|
||||||
}
|
}
|
||||||
if (!isArray(orders)) {
|
if (!isArray(orders)) {
|
||||||
orders = orders == null ? [] : [orders];
|
orders = orders == null ? [] : [orders];
|
||||||
}
|
}
|
||||||
return baseSortByOrder(collection, props, orders);
|
return baseSortByOrder(collection, iteratees, orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sortByOrder;
|
return sortByOrder;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define(['../lang/isNative'], function(isNative) {
|
define(['../internal/getNative'], function(getNative) {
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeNow = isNative(nativeNow = Date.now) && nativeNow;
|
var nativeNow = getNative(Date, 'now');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ define([], function() {
|
|||||||
return function() {
|
return function() {
|
||||||
if (--n > 0) {
|
if (--n > 0) {
|
||||||
result = func.apply(this, arguments);
|
result = func.apply(this, arguments);
|
||||||
} else {
|
}
|
||||||
|
if (n <= 1) {
|
||||||
func = null;
|
func = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'
|
|||||||
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
|
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
|
||||||
* may be used as a placeholder for partially applied arguments.
|
* may be used as a placeholder for partially applied arguments.
|
||||||
*
|
*
|
||||||
* **Note:** Unlike native `Function#bind` this method does not set the `length`
|
* **Note:** Unlike native `Function#bind` this method does not set the "length"
|
||||||
* property of bound functions.
|
* property of bound functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ define(['../internal/baseFlatten', '../internal/createWrapper', '../object/funct
|
|||||||
* of method names. If no method names are provided all enumerable function
|
* of method names. If no method names are provided all enumerable function
|
||||||
* properties, own and inherited, of `object` are bound.
|
* properties, own and inherited, of `object` are bound.
|
||||||
*
|
*
|
||||||
* **Note:** This method does not set the `length` property of bound functions.
|
* **Note:** This method does not set the "length" property of bound functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'
|
|||||||
*
|
*
|
||||||
* This method differs from `_.bind` by allowing bound functions to reference
|
* This method differs from `_.bind` by allowing bound functions to reference
|
||||||
* methods that may be redefined or don't yet exist.
|
* methods that may be redefined or don't yet exist.
|
||||||
* See [Peter Michaux's article](http://michaux.ca/articles/lazy-function-definition-pattern)
|
* See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
|
* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ define(['../internal/createCurry'], function(createCurry) {
|
|||||||
* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
|
* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
|
||||||
* may be used as a placeholder for provided arguments.
|
* may be used as a placeholder for provided arguments.
|
||||||
*
|
*
|
||||||
* **Note:** This method does not set the `length` property of curried functions.
|
* **Note:** This method does not set the "length" property of curried functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ define(['../internal/createCurry'], function(createCurry) {
|
|||||||
* The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
|
* The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
|
||||||
* builds, may be used as a placeholder for provided arguments.
|
* builds, may be used as a placeholder for provided arguments.
|
||||||
*
|
*
|
||||||
* **Note:** This method does not set the `length` property of curried functions.
|
* **Note:** This method does not set the "length" property of curried functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
|
|||||||
var nativeMax = Math.max;
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that delays invoking `func` until after `wait` milliseconds
|
* Creates a debounced function that delays invoking `func` until after `wait`
|
||||||
* have elapsed since the last time it was invoked. The created function comes
|
* milliseconds have elapsed since the last time the debounced function was
|
||||||
* with a `cancel` method to cancel delayed invocations. Provide an options
|
* invoked. The debounced function comes with a `cancel` method to cancel
|
||||||
* object to indicate that `func` should be invoked on the leading and/or
|
* delayed invocations. Provide an options object to indicate that `func`
|
||||||
* trailing edge of the `wait` timeout. Subsequent calls to the debounced
|
* should be invoked on the leading and/or trailing edge of the `wait` timeout.
|
||||||
* function return the result of the last `func` invocation.
|
* Subsequent calls to the debounced function return the result of the last
|
||||||
|
* `func` invocation.
|
||||||
*
|
*
|
||||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
||||||
* on the trailing edge of the timeout only if the the debounced function is
|
* on the trailing edge of the timeout only if the the debounced function is
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ define(['../internal/MapCache'], function(MapCache) {
|
|||||||
}
|
}
|
||||||
var memoized = function() {
|
var memoized = function() {
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
cache = memoized.cache,
|
key = resolver ? resolver.apply(this, args) : args[0],
|
||||||
key = resolver ? resolver.apply(this, args) : args[0];
|
cache = memoized.cache;
|
||||||
|
|
||||||
if (cache.has(key)) {
|
if (cache.has(key)) {
|
||||||
return cache.get(key);
|
return cache.get(key);
|
||||||
}
|
}
|
||||||
var result = func.apply(this, args);
|
var result = func.apply(this, args);
|
||||||
cache.set(key, result);
|
memoized.cache = cache.set(key, result);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
memoized.cache = new memoize.Cache;
|
memoized.cache = new memoize.Cache;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ define(['./before'], function(before) {
|
|||||||
* // `initialize` invokes `createApplication` once
|
* // `initialize` invokes `createApplication` once
|
||||||
*/
|
*/
|
||||||
function once(func) {
|
function once(func) {
|
||||||
return before(func, 2);
|
return before(2, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
return once;
|
return once;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ define(['../internal/createPartial'], function(createPartial) {
|
|||||||
* The `_.partial.placeholder` value, which defaults to `_` in monolithic
|
* The `_.partial.placeholder` value, which defaults to `_` in monolithic
|
||||||
* builds, may be used as a placeholder for partially applied arguments.
|
* builds, may be used as a placeholder for partially applied arguments.
|
||||||
*
|
*
|
||||||
* **Note:** This method does not set the `length` property of partially
|
* **Note:** This method does not set the "length" property of partially
|
||||||
* applied functions.
|
* applied functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ define(['../internal/createPartial'], function(createPartial) {
|
|||||||
* The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
|
* The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
|
||||||
* builds, may be used as a placeholder for partially applied arguments.
|
* builds, may be used as a placeholder for partially applied arguments.
|
||||||
*
|
*
|
||||||
* **Note:** This method does not set the `length` property of partially
|
* **Note:** This method does not set the "length" property of partially
|
||||||
* applied functions.
|
* applied functions.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
@@ -32,7 +35,7 @@ define([], function() {
|
|||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
|
start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
|
||||||
return function() {
|
return function() {
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
index = -1,
|
index = -1,
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that only invokes `func` at most once per every `wait`
|
* Creates a throttled function that only invokes `func` at most once per
|
||||||
* milliseconds. The created function comes with a `cancel` method to cancel
|
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
||||||
* delayed invocations. Provide an options object to indicate that `func`
|
* method to cancel delayed invocations. Provide an options object to indicate
|
||||||
* should be invoked on the leading and/or trailing edge of the `wait` timeout.
|
* that `func` should be invoked on the leading and/or trailing edge of the
|
||||||
* Subsequent calls to the throttled function return the result of the last
|
* `wait` timeout. Subsequent calls to the throttled function return the
|
||||||
* `func` call.
|
* result of the last `func` call.
|
||||||
*
|
*
|
||||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
||||||
* on the trailing edge of the timeout only if the the throttled function is
|
* on the trailing edge of the timeout only if the the throttled function is
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
define(['./cachePush', '../lang/isNative', './root'], function(cachePush, isNative, root) {
|
define(['./cachePush', './getNative', './root'], function(cachePush, getNative, root) {
|
||||||
|
|
||||||
/** Native method references. */
|
/** Native method references. */
|
||||||
var Set = isNative(Set = root.Set) && Set;
|
var Set = getNative(root, 'Set');
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
|
var nativeCreate = getNative(Object, 'create');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
33
internal/arrayExtremum.js
Normal file
33
internal/arrayExtremum.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `baseExtremum` for arrays which invokes `iteratee`
|
||||||
|
* with one argument: (value).
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to iterate over.
|
||||||
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
|
* @param {Function} comparator The function used to compare values.
|
||||||
|
* @param {*} exValue The initial extremum value.
|
||||||
|
* @returns {*} Returns the extremum value.
|
||||||
|
*/
|
||||||
|
function arrayExtremum(array, iteratee, comparator, exValue) {
|
||||||
|
var index = -1,
|
||||||
|
length = array.length,
|
||||||
|
computed = exValue,
|
||||||
|
result = computed;
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
var value = array[index],
|
||||||
|
current = +iteratee(value);
|
||||||
|
|
||||||
|
if (comparator(current, computed)) {
|
||||||
|
computed = current;
|
||||||
|
result = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arrayExtremum;
|
||||||
|
});
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
define([], function() {
|
|
||||||
|
|
||||||
/** Used as references for `-Infinity` and `Infinity`. */
|
|
||||||
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A specialized version of `_.max` for arrays without support for iteratees.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to iterate over.
|
|
||||||
* @returns {*} Returns the maximum value.
|
|
||||||
*/
|
|
||||||
function arrayMax(array) {
|
|
||||||
var index = -1,
|
|
||||||
length = array.length,
|
|
||||||
result = NEGATIVE_INFINITY;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var value = array[index];
|
|
||||||
if (value > result) {
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return arrayMax;
|
|
||||||
});
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
define([], function() {
|
|
||||||
|
|
||||||
/** Used as references for `-Infinity` and `Infinity`. */
|
|
||||||
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A specialized version of `_.min` for arrays without support for iteratees.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to iterate over.
|
|
||||||
* @returns {*} Returns the minimum value.
|
|
||||||
*/
|
|
||||||
function arrayMin(array) {
|
|
||||||
var index = -1,
|
|
||||||
length = array.length,
|
|
||||||
result = POSITIVE_INFINITY;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var value = array[index];
|
|
||||||
if (value < result) {
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return arrayMin;
|
|
||||||
});
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by `_.defaults` to customize its `_.assign` use.
|
* Used by `_.defaults` to customize its `_.assign` use.
|
||||||
*
|
*
|
||||||
@@ -9,7 +12,7 @@ define([], function() {
|
|||||||
* @returns {*} Returns the value to assign to the destination object.
|
* @returns {*} Returns the value to assign to the destination object.
|
||||||
*/
|
*/
|
||||||
function assignDefaults(objectValue, sourceValue) {
|
function assignDefaults(objectValue, sourceValue) {
|
||||||
return typeof objectValue == 'undefined' ? sourceValue : objectValue;
|
return objectValue === undefined ? sourceValue : objectValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return assignDefaults;
|
return assignDefaults;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/** Used for native method references. */
|
/** Used for native method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
@@ -9,7 +12,7 @@ define([], function() {
|
|||||||
/**
|
/**
|
||||||
* Used by `_.template` to customize its `_.assign` use.
|
* Used by `_.template` to customize its `_.assign` use.
|
||||||
*
|
*
|
||||||
* **Note:** This method is like `assignDefaults` except that it ignores
|
* **Note:** This function is like `assignDefaults` except that it ignores
|
||||||
* inherited property values when checking if a property is `undefined`.
|
* inherited property values when checking if a property is `undefined`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
@@ -20,7 +23,7 @@ define([], function() {
|
|||||||
* @returns {*} Returns the value to assign to the destination object.
|
* @returns {*} Returns the value to assign to the destination object.
|
||||||
*/
|
*/
|
||||||
function assignOwnDefaults(objectValue, sourceValue, key, object) {
|
function assignOwnDefaults(objectValue, sourceValue, key, object) {
|
||||||
return (typeof objectValue == 'undefined' || !hasOwnProperty.call(object, key))
|
return (objectValue === undefined || !hasOwnProperty.call(object, key))
|
||||||
? sourceValue
|
? sourceValue
|
||||||
: objectValue;
|
: objectValue;
|
||||||
}
|
}
|
||||||
|
|||||||
36
internal/assignWith.js
Normal file
36
internal/assignWith.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
define(['../object/keys'], function(keys) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.assign` for customizing assigned values without
|
||||||
|
* support for argument juggling, multiple sources, and `this` binding `customizer`
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The destination object.
|
||||||
|
* @param {Object} source The source object.
|
||||||
|
* @param {Function} customizer The function to customize assigned values.
|
||||||
|
* @returns {Object} Returns `object`.
|
||||||
|
*/
|
||||||
|
function assignWith(object, source, customizer) {
|
||||||
|
var index = -1,
|
||||||
|
props = keys(source),
|
||||||
|
length = props.length;
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
var key = props[index],
|
||||||
|
value = object[key],
|
||||||
|
result = customizer(value, source[key], key, object, source);
|
||||||
|
|
||||||
|
if ((result === result ? (result !== value) : (value === value)) ||
|
||||||
|
(value === undefined && !(key in object))) {
|
||||||
|
object[key] = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
return assignWith;
|
||||||
|
});
|
||||||
@@ -2,33 +2,17 @@ define(['./baseCopy', '../object/keys'], function(baseCopy, keys) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.assign` without support for argument juggling,
|
* The base implementation of `_.assign` without support for argument juggling,
|
||||||
* multiple sources, and `this` binding `customizer` functions.
|
* multiple sources, and `customizer` functions.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {Object} source The source object.
|
* @param {Object} source The source object.
|
||||||
* @param {Function} [customizer] The function to customize assigning values.
|
* @returns {Object} Returns `object`.
|
||||||
* @returns {Object} Returns the destination object.
|
|
||||||
*/
|
*/
|
||||||
function baseAssign(object, source, customizer) {
|
function baseAssign(object, source) {
|
||||||
var props = keys(source);
|
return source == null
|
||||||
if (!customizer) {
|
? object
|
||||||
return baseCopy(source, object, props);
|
: baseCopy(source, keys(source), object);
|
||||||
}
|
|
||||||
var index = -1,
|
|
||||||
length = props.length;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var key = props[index],
|
|
||||||
value = object[key],
|
|
||||||
result = customizer(value, source[key], key, object, source);
|
|
||||||
|
|
||||||
if ((result === result ? (result !== value) : (value === value)) ||
|
|
||||||
(typeof value == 'undefined' && !(key in object))) {
|
|
||||||
object[key] = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseAssign;
|
return baseAssign;
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
define(['./isIndex', './isLength'], function(isIndex, isLength) {
|
define(['./isArrayLike', './isIndex'], function(isArrayLike, isIndex) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.at` without support for strings and individual
|
* The base implementation of `_.at` without support for string collections
|
||||||
* key arguments.
|
* and individual key arguments.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {number[]|string[]} [props] The property names or indexes of elements to pick.
|
* @param {number[]|string[]} props The property names or indexes of elements to pick.
|
||||||
* @returns {Array} Returns the new array of picked elements.
|
* @returns {Array} Returns the new array of picked elements.
|
||||||
*/
|
*/
|
||||||
function baseAt(collection, props) {
|
function baseAt(collection, props) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = collection.length,
|
isNil = collection == null,
|
||||||
isArr = isLength(length),
|
isArr = !isNil && isArrayLike(collection),
|
||||||
|
length = isArr ? collection.length : 0,
|
||||||
propsLength = props.length,
|
propsLength = props.length,
|
||||||
result = Array(propsLength);
|
result = Array(propsLength);
|
||||||
|
|
||||||
while(++index < propsLength) {
|
while(++index < propsLength) {
|
||||||
var key = props[index];
|
var key = props[index];
|
||||||
if (isArr) {
|
if (isArr) {
|
||||||
key = parseFloat(key);
|
|
||||||
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
||||||
} else {
|
} else {
|
||||||
result[index] = collection[key];
|
result[index] = isNil ? undefined : collection[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallback', '../utility/identity'], function(baseMatches, baseMatchesProperty, baseProperty, bindCallback, identity) {
|
define(['./baseMatches', './baseMatchesProperty', './bindCallback', '../utility/identity', '../utility/property'], function(baseMatches, baseMatchesProperty, bindCallback, identity, property) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.callback` which supports specifying the
|
* The base implementation of `_.callback` which supports specifying the
|
||||||
@@ -13,7 +16,7 @@ define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallb
|
|||||||
function baseCallback(func, thisArg, argCount) {
|
function baseCallback(func, thisArg, argCount) {
|
||||||
var type = typeof func;
|
var type = typeof func;
|
||||||
if (type == 'function') {
|
if (type == 'function') {
|
||||||
return typeof thisArg == 'undefined'
|
return thisArg === undefined
|
||||||
? func
|
? func
|
||||||
: bindCallback(func, thisArg, argCount);
|
: bindCallback(func, thisArg, argCount);
|
||||||
}
|
}
|
||||||
@@ -23,9 +26,9 @@ define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallb
|
|||||||
if (type == 'object') {
|
if (type == 'object') {
|
||||||
return baseMatches(func);
|
return baseMatches(func);
|
||||||
}
|
}
|
||||||
return typeof thisArg == 'undefined'
|
return thisArg === undefined
|
||||||
? baseProperty(func + '')
|
? property(func)
|
||||||
: baseMatchesProperty(func + '', thisArg);
|
: baseMatchesProperty(func, thisArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseCallback;
|
return baseCallback;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['./arrayCopy', './arrayEach', './baseCopy', './baseForOwn', './initCloneArray', './initCloneByTag', './initCloneObject', '../lang/isArray', '../lang/isObject', '../object/keys'], function(arrayCopy, arrayEach, baseCopy, baseForOwn, initCloneArray, initCloneByTag, initCloneObject, isArray, isObject, keys) {
|
define(['./arrayCopy', './arrayEach', './baseAssign', './baseForOwn', './initCloneArray', './initCloneByTag', './initCloneObject', '../lang/isArray', '../lang/isObject'], function(arrayCopy, arrayEach, baseAssign, baseForOwn, initCloneArray, initCloneByTag, initCloneObject, isArray, isObject) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var argsTag = '[object Arguments]',
|
var argsTag = '[object Arguments]',
|
||||||
@@ -69,7 +72,7 @@ define(['./arrayCopy', './arrayEach', './baseCopy', './baseForOwn', './initClone
|
|||||||
if (customizer) {
|
if (customizer) {
|
||||||
result = object ? customizer(value, key, object) : customizer(value);
|
result = object ? customizer(value, key, object) : customizer(value);
|
||||||
}
|
}
|
||||||
if (typeof result != 'undefined') {
|
if (result !== undefined) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (!isObject(value)) {
|
if (!isObject(value)) {
|
||||||
@@ -88,7 +91,7 @@ define(['./arrayCopy', './arrayEach', './baseCopy', './baseForOwn', './initClone
|
|||||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||||
result = initCloneObject(isFunc ? {} : value);
|
result = initCloneObject(isFunc ? {} : value);
|
||||||
if (!isDeep) {
|
if (!isDeep) {
|
||||||
return baseCopy(value, result, keys(value));
|
return baseAssign(result, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return cloneableTags[tag]
|
return cloneableTags[tag]
|
||||||
|
|||||||
@@ -1,23 +1,35 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `compareAscending` which compares values and
|
* The base implementation of `compareAscending` which compares values and
|
||||||
* sorts them in ascending order without guaranteeing a stable sort.
|
* sorts them in ascending order without guaranteeing a stable sort.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to compare to `other`.
|
* @param {*} value The value to compare.
|
||||||
* @param {*} other The value to compare to `value`.
|
* @param {*} other The other value to compare.
|
||||||
* @returns {number} Returns the sort order indicator for `value`.
|
* @returns {number} Returns the sort order indicator for `value`.
|
||||||
*/
|
*/
|
||||||
function baseCompareAscending(value, other) {
|
function baseCompareAscending(value, other) {
|
||||||
if (value !== other) {
|
if (value !== other) {
|
||||||
var valIsReflexive = value === value,
|
var valIsNull = value === null,
|
||||||
|
valIsUndef = value === undefined,
|
||||||
|
valIsReflexive = value === value;
|
||||||
|
|
||||||
|
var othIsNull = other === null,
|
||||||
|
othIsUndef = other === undefined,
|
||||||
othIsReflexive = other === other;
|
othIsReflexive = other === other;
|
||||||
|
|
||||||
if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) {
|
if ((value > other && !othIsNull) || !valIsReflexive ||
|
||||||
|
(valIsNull && !othIsUndef && othIsReflexive) ||
|
||||||
|
(valIsUndef && othIsReflexive)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) {
|
if ((value < other && !valIsNull) || !othIsReflexive ||
|
||||||
|
(othIsNull && !valIsUndef && valIsReflexive) ||
|
||||||
|
(othIsUndef && valIsReflexive)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the properties of `source` to `object`.
|
* Copies properties of `source` to `object`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} source The object to copy properties from.
|
* @param {Object} source The object to copy properties from.
|
||||||
* @param {Object} [object={}] The object to copy properties to.
|
|
||||||
* @param {Array} props The property names to copy.
|
* @param {Array} props The property names to copy.
|
||||||
|
* @param {Object} [object={}] The object to copy properties to.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseCopy(source, object, props) {
|
function baseCopy(source, props, object) {
|
||||||
if (!props) {
|
object || (object = {});
|
||||||
props = object;
|
|
||||||
object = {};
|
|
||||||
}
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../lang/isObject', './root'], function(isObject, root) {
|
define(['../lang/isObject'], function(isObject) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
@@ -9,14 +9,14 @@ define(['../lang/isObject', './root'], function(isObject, root) {
|
|||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
var baseCreate = (function() {
|
var baseCreate = (function() {
|
||||||
function Object() {}
|
function object() {}
|
||||||
return function(prototype) {
|
return function(prototype) {
|
||||||
if (isObject(prototype)) {
|
if (isObject(prototype)) {
|
||||||
Object.prototype = prototype;
|
object.prototype = prototype;
|
||||||
var result = new Object;
|
var result = new object;
|
||||||
Object.prototype = null;
|
object.prototype = null;
|
||||||
}
|
}
|
||||||
return result || root.Object();
|
return result || {};
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,24 @@
|
|||||||
define(['./baseEach'], function(baseEach) {
|
define(['./baseEach'], function(baseEach) {
|
||||||
|
|
||||||
/** Used as references for `-Infinity` and `Infinity`. */
|
|
||||||
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
|
|
||||||
POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the extremum value of `collection` invoking `iteratee` for each value
|
* Gets the extremum value of `collection` invoking `iteratee` for each value
|
||||||
* in `collection` to generate the criterion by which the value is ranked.
|
* in `collection` to generate the criterion by which the value is ranked.
|
||||||
* The `iteratee` is invoked with three arguments: (value, index, collection).
|
* The `iteratee` is invoked with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {boolean} [isMin] Specify returning the minimum, instead of the
|
* @param {Function} comparator The function used to compare values.
|
||||||
* maximum, extremum value.
|
* @param {*} exValue The initial extremum value.
|
||||||
* @returns {*} Returns the extremum value.
|
* @returns {*} Returns the extremum value.
|
||||||
*/
|
*/
|
||||||
function extremumBy(collection, iteratee, isMin) {
|
function baseExtremum(collection, iteratee, comparator, exValue) {
|
||||||
var exValue = isMin ? POSITIVE_INFINITY : NEGATIVE_INFINITY,
|
var computed = exValue,
|
||||||
computed = exValue,
|
|
||||||
result = computed;
|
result = computed;
|
||||||
|
|
||||||
baseEach(collection, function(value, index, collection) {
|
baseEach(collection, function(value, index, collection) {
|
||||||
var current = iteratee(value, index, collection);
|
var current = +iteratee(value, index, collection);
|
||||||
if ((isMin ? (current < computed) : (current > computed)) ||
|
if (comparator(current, computed) || (current === exValue && current === result)) {
|
||||||
(current === exValue && current === result)) {
|
|
||||||
computed = current;
|
computed = current;
|
||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
@@ -32,5 +26,5 @@ define(['./baseEach'], function(baseEach) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return extremumBy;
|
return baseExtremum;
|
||||||
});
|
});
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.fill` without an iteratee call guard.
|
* The base implementation of `_.fill` without an iteratee call guard.
|
||||||
*
|
*
|
||||||
@@ -17,7 +20,7 @@ define([], function() {
|
|||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = -start > length ? 0 : (length + start);
|
start = -start > length ? 0 : (length + start);
|
||||||
}
|
}
|
||||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
end = (end === undefined || end > length) ? length : (+end || 0);
|
||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
* The base implementation of `_.flatten` with added support for restricting
|
||||||
@@ -6,8 +6,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @param {boolean} isDeep Specify a deep flatten.
|
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||||
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
|
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict) {
|
function baseFlatten(array, isDeep, isStrict) {
|
||||||
@@ -18,8 +18,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
|
if (isObjectLike(value) && isArrayLike(value) &&
|
||||||
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (isDeep) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
value = baseFlatten(value, isDeep, isStrict);
|
value = baseFlatten(value, isDeep, isStrict);
|
||||||
@@ -27,7 +27,6 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
|||||||
var valIndex = -1,
|
var valIndex = -1,
|
||||||
valLength = value.length;
|
valLength = value.length;
|
||||||
|
|
||||||
result.length += valLength;
|
|
||||||
while (++valIndex < valLength) {
|
while (++valIndex < valLength) {
|
||||||
result[++resIndex] = value[valIndex];
|
result[++resIndex] = value[valIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./createBaseFor'], function(createBaseFor) {
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
||||||
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
||||||
* each property. Iterator functions may exit iteration early by explicitly
|
* each property. Iteratee functions may exit iteration early by explicitly
|
||||||
* returning `false`.
|
* returning `false`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
33
internal/baseGet.js
Normal file
33
internal/baseGet.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
define(['./toObject'], function(toObject) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `get` without support for string paths
|
||||||
|
* and default values.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to query.
|
||||||
|
* @param {Array} path The path of the property to get.
|
||||||
|
* @param {string} [pathKey] The key representation of path.
|
||||||
|
* @returns {*} Returns the resolved value.
|
||||||
|
*/
|
||||||
|
function baseGet(object, path, pathKey) {
|
||||||
|
if (object == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pathKey !== undefined && pathKey in toObject(object)) {
|
||||||
|
path = [pathKey];
|
||||||
|
}
|
||||||
|
var index = 0,
|
||||||
|
length = path.length;
|
||||||
|
|
||||||
|
while (object != null && index < length) {
|
||||||
|
object = object[path[index++]];
|
||||||
|
}
|
||||||
|
return (index && index == length) ? object : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseGet;
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
|
define(['./baseIsEqualDeep', '../lang/isObject', './isObjectLike'], function(baseIsEqualDeep, isObject, isObjectLike) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.isEqual` without support for `this` binding
|
* The base implementation of `_.isEqual` without support for `this` binding
|
||||||
@@ -14,18 +14,10 @@ define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
|
|||||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
|
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
|
||||||
// Exit early for identical values.
|
|
||||||
if (value === other) {
|
if (value === other) {
|
||||||
// Treat `+0` vs. `-0` as not equal.
|
return true;
|
||||||
return value !== 0 || (1 / value == 1 / other);
|
|
||||||
}
|
}
|
||||||
var valType = typeof value,
|
if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
|
||||||
othType = typeof other;
|
|
||||||
|
|
||||||
// Exit early for unlike primitive values.
|
|
||||||
if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
|
|
||||||
value == null || other == null) {
|
|
||||||
// Return `false` unless both values are `NaN`.
|
|
||||||
return value !== value && other !== other;
|
return value !== value && other !== other;
|
||||||
}
|
}
|
||||||
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
|
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var argsTag = '[object Arguments]',
|
var argsTag = '[object Arguments]',
|
||||||
arrayTag = '[object Array]',
|
arrayTag = '[object Array]',
|
||||||
funcTag = '[object Function]',
|
|
||||||
objectTag = '[object Object]';
|
objectTag = '[object Object]';
|
||||||
|
|
||||||
/** Used for native method references. */
|
/** Used for native method references. */
|
||||||
@@ -55,28 +54,24 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
othIsArr = isTypedArray(other);
|
othIsArr = isTypedArray(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)),
|
var objIsObj = objTag == objectTag,
|
||||||
othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)),
|
othIsObj = othTag == objectTag,
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||||
return equalByTag(object, other, objTag);
|
return equalByTag(object, other, objTag);
|
||||||
}
|
}
|
||||||
if (isLoose) {
|
if (!isLoose) {
|
||||||
if (!isSameTag && !(objIsObj && othIsObj)) {
|
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||||
return false;
|
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
||||||
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
||||||
|
|
||||||
if (valWrapped || othWrapped) {
|
if (objIsWrapped || othIsWrapped) {
|
||||||
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
|
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
|
||||||
}
|
|
||||||
if (!isSameTag) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isSameTag) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Assume cyclic values are equal.
|
// Assume cyclic values are equal.
|
||||||
// For more information on detecting circular references see https://es5.github.io/#JO.
|
// For more information on detecting circular references see https://es5.github.io/#JO.
|
||||||
stackA || (stackA = []);
|
stackA || (stackA = []);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseIsEqual'], function(baseIsEqual) {
|
define(['./baseIsEqual', './toObject'], function(baseIsEqual, toObject) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -9,41 +9,43 @@ define(['./baseIsEqual'], function(baseIsEqual) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @param {Array} props The source property names to match.
|
* @param {Array} matchData The propery names, values, and compare flags to match.
|
||||||
* @param {Array} values The source values to match.
|
|
||||||
* @param {Array} strictCompareFlags Strict comparison flags for source values.
|
|
||||||
* @param {Function} [customizer] The function to customize comparing objects.
|
* @param {Function} [customizer] The function to customize comparing objects.
|
||||||
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
|
function baseIsMatch(object, matchData, customizer) {
|
||||||
var index = -1,
|
var index = matchData.length,
|
||||||
length = props.length,
|
length = index,
|
||||||
noCustomizer = !customizer;
|
noCustomizer = !customizer;
|
||||||
|
|
||||||
while (++index < length) {
|
if (object == null) {
|
||||||
if ((noCustomizer && strictCompareFlags[index])
|
return !length;
|
||||||
? values[index] !== object[props[index]]
|
}
|
||||||
: !(props[index] in object)
|
object = toObject(object);
|
||||||
|
while (index--) {
|
||||||
|
var data = matchData[index];
|
||||||
|
if ((noCustomizer && data[2])
|
||||||
|
? data[1] !== object[data[0]]
|
||||||
|
: !(data[0] in object)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = -1;
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
data = matchData[index];
|
||||||
|
var key = data[0],
|
||||||
objValue = object[key],
|
objValue = object[key],
|
||||||
srcValue = values[index];
|
srcValue = data[1];
|
||||||
|
|
||||||
if (noCustomizer && strictCompareFlags[index]) {
|
if (noCustomizer && data[2]) {
|
||||||
var result = typeof objValue != 'undefined' || (key in object);
|
if (objValue === undefined && !(key in object)) {
|
||||||
} else {
|
return false;
|
||||||
result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
}
|
||||||
if (typeof result == 'undefined') {
|
} else {
|
||||||
result = baseIsEqual(srcValue, objValue, customizer, true);
|
var result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
||||||
|
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseEach'], function(baseEach) {
|
define(['./baseEach', './isArrayLike'], function(baseEach, isArrayLike) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.map` without support for callback shorthands
|
* The base implementation of `_.map` without support for callback shorthands
|
||||||
@@ -10,9 +10,11 @@ define(['./baseEach'], function(baseEach) {
|
|||||||
* @returns {Array} Returns the new mapped array.
|
* @returns {Array} Returns the new mapped array.
|
||||||
*/
|
*/
|
||||||
function baseMap(collection, iteratee) {
|
function baseMap(collection, iteratee) {
|
||||||
var result = [];
|
var index = -1,
|
||||||
|
result = isArrayLike(collection) ? Array(collection.length) : [];
|
||||||
|
|
||||||
baseEach(collection, function(value, key, collection) {
|
baseEach(collection, function(value, key, collection) {
|
||||||
result.push(iteratee(value, key, collection));
|
result[++index] = iteratee(value, key, collection);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['./baseIsMatch', '../utility/constant', './isStrictComparable', '../object/keys', './toObject'], function(baseIsMatch, constant, isStrictComparable, keys, toObject) {
|
define(['./baseIsMatch', './getMatchData', './toObject'], function(baseIsMatch, getMatchData, toObject) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matches` which does not clone `source`.
|
* The base implementation of `_.matches` which does not clone `source`.
|
||||||
@@ -8,33 +11,20 @@ define(['./baseIsMatch', '../utility/constant', './isStrictComparable', '../obje
|
|||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseMatches(source) {
|
function baseMatches(source) {
|
||||||
var props = keys(source),
|
var matchData = getMatchData(source);
|
||||||
length = props.length;
|
if (matchData.length == 1 && matchData[0][2]) {
|
||||||
|
var key = matchData[0][0],
|
||||||
|
value = matchData[0][1];
|
||||||
|
|
||||||
if (!length) {
|
return function(object) {
|
||||||
return constant(true);
|
if (object == null) {
|
||||||
}
|
return false;
|
||||||
if (length == 1) {
|
}
|
||||||
var key = props[0],
|
return object[key] === value && (value !== undefined || (key in toObject(object)));
|
||||||
value = source[key];
|
};
|
||||||
|
|
||||||
if (isStrictComparable(value)) {
|
|
||||||
return function(object) {
|
|
||||||
return object != null && object[key] === value &&
|
|
||||||
(typeof value != 'undefined' || (key in toObject(object)));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var values = Array(length),
|
|
||||||
strictCompareFlags = Array(length);
|
|
||||||
|
|
||||||
while (length--) {
|
|
||||||
value = source[props[length]];
|
|
||||||
values[length] = value;
|
|
||||||
strictCompareFlags[length] = isStrictComparable(value);
|
|
||||||
}
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
|
return baseIsMatch(object, matchData);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,39 @@
|
|||||||
define(['./baseIsEqual', './isStrictComparable', './toObject'], function(baseIsEqual, isStrictComparable, toObject) {
|
define(['./baseGet', './baseIsEqual', './baseSlice', '../lang/isArray', './isKey', './isStrictComparable', '../array/last', './toObject', './toPath'], function(baseGet, baseIsEqual, baseSlice, isArray, isKey, isStrictComparable, last, toObject, toPath) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
* The base implementation of `_.matchesProperty` which does not clone `srcValue`.
|
||||||
* to a string.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {string} key The key of the property to get.
|
* @param {string} path The path of the property to get.
|
||||||
* @param {*} value The value to compare.
|
* @param {*} srcValue The value to compare.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseMatchesProperty(key, value) {
|
function baseMatchesProperty(path, srcValue) {
|
||||||
if (isStrictComparable(value)) {
|
var isArr = isArray(path),
|
||||||
return function(object) {
|
isCommon = isKey(path) && isStrictComparable(srcValue),
|
||||||
return object != null && object[key] === value &&
|
pathKey = (path + '');
|
||||||
(typeof value != 'undefined' || (key in toObject(object)));
|
|
||||||
};
|
path = toPath(path);
|
||||||
}
|
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return object != null && baseIsEqual(value, object[key], null, true);
|
if (object == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var key = pathKey;
|
||||||
|
object = toObject(object);
|
||||||
|
if ((isArr || !isCommon) && !(key in object)) {
|
||||||
|
object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
||||||
|
if (object == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
key = last(path);
|
||||||
|
object = toObject(object);
|
||||||
|
}
|
||||||
|
return object[key] === srcValue
|
||||||
|
? (srcValue !== undefined || (key in object))
|
||||||
|
: baseIsEqual(srcValue, object[key], undefined, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./arrayEach', './baseForOwn', './baseMergeDeep', '../lang/isArray', './isLength', '../lang/isObject', './isObjectLike', '../lang/isTypedArray'], function(arrayEach, baseForOwn, baseMergeDeep, isArray, isLength, isObject, isObjectLike, isTypedArray) {
|
define(['./arrayEach', './baseMergeDeep', '../lang/isArray', './isArrayLike', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, isArray, isArrayLike, isObject, isObjectLike, isTypedArray, keys) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -13,29 +13,37 @@ define(['./arrayEach', './baseForOwn', './baseMergeDeep', '../lang/isArray', './
|
|||||||
* @param {Function} [customizer] The function to customize merging properties.
|
* @param {Function} [customizer] The function to customize merging properties.
|
||||||
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
||||||
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
||||||
* @returns {Object} Returns the destination object.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseMerge(object, source, customizer, stackA, stackB) {
|
function baseMerge(object, source, customizer, stackA, stackB) {
|
||||||
if (!isObject(object)) {
|
if (!isObject(object)) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
|
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
|
||||||
(isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
|
props = isSrcArr ? null : keys(source);
|
||||||
|
|
||||||
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
|
if (props) {
|
||||||
|
key = srcValue;
|
||||||
|
srcValue = source[key];
|
||||||
|
}
|
||||||
if (isObjectLike(srcValue)) {
|
if (isObjectLike(srcValue)) {
|
||||||
stackA || (stackA = []);
|
stackA || (stackA = []);
|
||||||
stackB || (stackB = []);
|
stackB || (stackB = []);
|
||||||
return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
||||||
}
|
}
|
||||||
var value = object[key],
|
else {
|
||||||
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
var value = object[key],
|
||||||
isCommon = typeof result == 'undefined';
|
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
||||||
|
isCommon = result === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
result = srcValue;
|
result = srcValue;
|
||||||
}
|
}
|
||||||
if ((isSrcArr || typeof result != 'undefined') &&
|
if ((result !== undefined || (isSrcArr && !(key in object))) &&
|
||||||
(isCommon || (result === result ? (result !== value) : (value === value)))) {
|
(isCommon || (result === result ? (result !== value) : (value === value)))) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isLength', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, 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. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -30,14 +30,14 @@ define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isLength', '
|
|||||||
}
|
}
|
||||||
var value = object[key],
|
var value = object[key],
|
||||||
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
||||||
isCommon = typeof result == 'undefined';
|
isCommon = result === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
result = srcValue;
|
result = srcValue;
|
||||||
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
||||||
result = isArray(value)
|
result = isArray(value)
|
||||||
? value
|
? value
|
||||||
: ((value && value.length) ? arrayCopy(value) : []);
|
: (isArrayLike(value) ? arrayCopy(value) : []);
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
result = isArguments(value)
|
result = isArguments(value)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ define([], function() {
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.property` which does not coerce `key` to a string.
|
* The base implementation of `_.property` without support for deep paths.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {string} key The key of the property to get.
|
* @param {string} key The key of the property to get.
|
||||||
|
|||||||
19
internal/basePropertyDeep.js
Normal file
19
internal/basePropertyDeep.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
define(['./baseGet', './toPath'], function(baseGet, toPath) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `baseProperty` which supports deep paths.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array|string} path The path of the property to get.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
*/
|
||||||
|
function basePropertyDeep(path) {
|
||||||
|
var pathKey = (path + '');
|
||||||
|
path = toPath(path);
|
||||||
|
return function(object) {
|
||||||
|
return baseGet(object, path, pathKey);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePropertyDeep;
|
||||||
|
});
|
||||||
31
internal/basePullAt.js
Normal file
31
internal/basePullAt.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
define(['./isIndex'], function(isIndex) {
|
||||||
|
|
||||||
|
/** Used for native method references. */
|
||||||
|
var arrayProto = Array.prototype;
|
||||||
|
|
||||||
|
/** Native method references. */
|
||||||
|
var splice = arrayProto.splice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.pullAt` without support for individual
|
||||||
|
* index arguments and capturing the removed elements.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to modify.
|
||||||
|
* @param {number[]} indexes The indexes of elements to remove.
|
||||||
|
* @returns {Array} Returns `array`.
|
||||||
|
*/
|
||||||
|
function basePullAt(array, indexes) {
|
||||||
|
var length = array ? indexes.length : 0;
|
||||||
|
while (length--) {
|
||||||
|
var index = indexes[length];
|
||||||
|
if (index != previous && isIndex(index)) {
|
||||||
|
var previous = index;
|
||||||
|
splice.call(array, index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePullAt;
|
||||||
|
});
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.slice` without an iteratee call guard.
|
* The base implementation of `_.slice` without an iteratee call guard.
|
||||||
*
|
*
|
||||||
@@ -17,7 +20,7 @@ define([], function() {
|
|||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = -start > length ? 0 : (length + start);
|
start = -start > length ? 0 : (length + start);
|
||||||
}
|
}
|
||||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
end = (end === undefined || end > length) ? length : (+end || 0);
|
||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,22 @@
|
|||||||
define(['./baseEach', './baseSortBy', './compareMultiple', './isLength'], function(baseEach, baseSortBy, compareMultiple, isLength) {
|
define(['./arrayMap', './baseCallback', './baseMap', './baseSortBy', './compareMultiple'], function(arrayMap, baseCallback, baseMap, baseSortBy, compareMultiple) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
||||||
var undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.sortByOrder` without param guards.
|
* The base implementation of `_.sortByOrder` without param guards.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
* @param {string[]} props The property names to sort by.
|
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
|
||||||
* @param {boolean[]} orders The sort orders of `props`.
|
* @param {boolean[]} orders The sort orders of `iteratees`.
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
*/
|
*/
|
||||||
function baseSortByOrder(collection, props, orders) {
|
function baseSortByOrder(collection, iteratees, orders) {
|
||||||
var index = -1,
|
var index = -1;
|
||||||
length = collection.length,
|
|
||||||
result = isLength(length) ? Array(length) : [];
|
|
||||||
|
|
||||||
baseEach(collection, function(value) {
|
iteratees = arrayMap(iteratees, function(iteratee) { return baseCallback(iteratee); });
|
||||||
var length = props.length,
|
|
||||||
criteria = Array(length);
|
|
||||||
|
|
||||||
while (length--) {
|
var result = baseMap(collection, function(value) {
|
||||||
criteria[length] = value == null ? undefined : value[props[length]];
|
var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); });
|
||||||
}
|
return { 'criteria': criteria, 'index': ++index, 'value': value };
|
||||||
result[++index] = { 'criteria': criteria, 'index': index, 'value': value };
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return baseSortBy(result, function(object, other) {
|
return baseSortBy(result, function(object, other) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `value` to a string if it is not one. An empty string is returned
|
* Converts `value` to a string if it's not one. An empty string is returned
|
||||||
* for `null` or `undefined` values.
|
* for `null` or `undefined` values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define([], function() {
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.values` and `_.valuesIn` which creates an
|
* The base implementation of `_.values` and `_.valuesIn` which creates an
|
||||||
* array of `object` property values corresponding to the property names
|
* array of `object` property values corresponding to the property names
|
||||||
* returned by `keysFunc`.
|
* of `props`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, identity) {
|
define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, identity) {
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
|
var MAX_ARRAY_LENGTH = 4294967295,
|
||||||
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +24,7 @@ define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, ident
|
|||||||
var mid = (low + high) >>> 1,
|
var mid = (low + high) >>> 1,
|
||||||
computed = array[mid];
|
computed = array[mid];
|
||||||
|
|
||||||
if (retHighest ? (computed <= value) : (computed < value)) {
|
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
high = mid;
|
high = mid;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/** Native method references. */
|
/** Native method references. */
|
||||||
var floor = Math.floor;
|
var floor = Math.floor;
|
||||||
|
|
||||||
@@ -7,8 +10,8 @@ define([], function() {
|
|||||||
var nativeMin = Math.min;
|
var nativeMin = Math.min;
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
|
var MAX_ARRAY_LENGTH = 4294967295,
|
||||||
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
|
* This function is like `binaryIndex` except that it invokes `iteratee` for
|
||||||
@@ -29,17 +32,23 @@ define([], function() {
|
|||||||
var low = 0,
|
var low = 0,
|
||||||
high = array ? array.length : 0,
|
high = array ? array.length : 0,
|
||||||
valIsNaN = value !== value,
|
valIsNaN = value !== value,
|
||||||
valIsUndef = typeof value == 'undefined';
|
valIsNull = value === null,
|
||||||
|
valIsUndef = value === undefined;
|
||||||
|
|
||||||
while (low < high) {
|
while (low < high) {
|
||||||
var mid = floor((low + high) / 2),
|
var mid = floor((low + high) / 2),
|
||||||
computed = iteratee(array[mid]),
|
computed = iteratee(array[mid]),
|
||||||
|
isDef = computed !== undefined,
|
||||||
isReflexive = computed === computed;
|
isReflexive = computed === computed;
|
||||||
|
|
||||||
if (valIsNaN) {
|
if (valIsNaN) {
|
||||||
var setLow = isReflexive || retHighest;
|
var setLow = isReflexive || retHighest;
|
||||||
|
} else if (valIsNull) {
|
||||||
|
setLow = isReflexive && isDef && (retHighest || computed != null);
|
||||||
} else if (valIsUndef) {
|
} else if (valIsUndef) {
|
||||||
setLow = isReflexive && (retHighest || typeof computed != 'undefined');
|
setLow = isReflexive && (retHighest || isDef);
|
||||||
|
} else if (computed == null) {
|
||||||
|
setLow = false;
|
||||||
} else {
|
} else {
|
||||||
setLow = retHighest ? (computed <= value) : (computed < value);
|
setLow = retHighest ? (computed <= value) : (computed < value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['../utility/identity'], function(identity) {
|
define(['../utility/identity'], function(identity) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `baseCallback` which only supports `this` binding
|
* A specialized version of `baseCallback` which only supports `this` binding
|
||||||
* and specifying the number of arguments to provide to `func`.
|
* and specifying the number of arguments to provide to `func`.
|
||||||
@@ -14,7 +17,7 @@ define(['../utility/identity'], function(identity) {
|
|||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
if (typeof thisArg == 'undefined') {
|
if (thisArg === undefined) {
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
switch (argCount) {
|
switch (argCount) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
define(['../utility/constant', '../lang/isNative', './root'], function(constant, isNative, root) {
|
define(['../utility/constant', './getNative', './root'], function(constant, getNative, root) {
|
||||||
|
|
||||||
/** Native method references. */
|
/** Native method references. */
|
||||||
var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
|
var ArrayBuffer = getNative(root, 'ArrayBuffer'),
|
||||||
bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
|
bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'),
|
||||||
floor = Math.floor,
|
floor = Math.floor,
|
||||||
Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
|
Uint8Array = getNative(root, 'Uint8Array');
|
||||||
|
|
||||||
/** Used to clone array buffers. */
|
/** Used to clone array buffers. */
|
||||||
var Float64Array = (function() {
|
var Float64Array = (function() {
|
||||||
@@ -12,10 +12,10 @@ define(['../utility/constant', '../lang/isNative', './root'], function(constant,
|
|||||||
// where the array buffer's `byteLength` is not a multiple of the typed
|
// where the array buffer's `byteLength` is not a multiple of the typed
|
||||||
// array's `BYTES_PER_ELEMENT`.
|
// array's `BYTES_PER_ELEMENT`.
|
||||||
try {
|
try {
|
||||||
var func = isNative(func = root.Float64Array) && func,
|
var func = getNative(root, 'Float64Array'),
|
||||||
result = new func(new ArrayBuffer(10), 0, 1) && func;
|
result = new func(new ArrayBuffer(10), 0, 1) && func;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
return result;
|
return result || null;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/** Used as the size, in bytes, of each `Float64Array` element. */
|
/** Used as the size, in bytes, of each `Float64Array` element. */
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
define([], function() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by `_.max` and `_.min` as the default callback for string values.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {string} string The string to inspect.
|
|
||||||
* @returns {number} Returns the code unit of the first character of the string.
|
|
||||||
*/
|
|
||||||
function charAtCallback(string) {
|
|
||||||
return string.charCodeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return charAtCallback;
|
|
||||||
});
|
|
||||||
@@ -4,7 +4,7 @@ define(['./baseCompareAscending'], function(baseCompareAscending) {
|
|||||||
* Used by `_.sortByOrder` to compare multiple properties of each element
|
* Used by `_.sortByOrder` to compare multiple properties of each element
|
||||||
* in a collection and stable sort them in the following order:
|
* in a collection and stable sort them in the following order:
|
||||||
*
|
*
|
||||||
* If orders is unspecified, sort in ascending order for all properties.
|
* If `orders` is unspecified, sort in ascending order for all properties.
|
||||||
* Otherwise, for each property, sort in ascending order if its corresponding value in
|
* Otherwise, for each property, sort in ascending order if its corresponding value in
|
||||||
* orders is true, and descending order if false.
|
* orders is true, and descending order if false.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ define([], function() {
|
|||||||
while (++argsIndex < argsLength) {
|
while (++argsIndex < argsLength) {
|
||||||
result[argsIndex] = args[argsIndex];
|
result[argsIndex] = args[argsIndex];
|
||||||
}
|
}
|
||||||
var pad = argsIndex;
|
var offset = argsIndex;
|
||||||
while (++rightIndex < rightLength) {
|
while (++rightIndex < rightLength) {
|
||||||
result[pad + rightIndex] = partials[rightIndex];
|
result[offset + rightIndex] = partials[rightIndex];
|
||||||
}
|
}
|
||||||
while (++holdersIndex < holdersLength) {
|
while (++holdersIndex < holdersLength) {
|
||||||
result[pad + holders[holdersIndex]] = args[argsIndex++];
|
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['./bindCallback', './isIterateeCall'], function(bindCallback, isIterateeCall) {
|
define(['./bindCallback', './isIterateeCall', '../function/restParam'], function(bindCallback, isIterateeCall, restParam) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that assigns properties of source object(s) to a given
|
* Creates a function that assigns properties of source object(s) to a given
|
||||||
@@ -11,38 +14,32 @@ define(['./bindCallback', './isIterateeCall'], function(bindCallback, isIteratee
|
|||||||
* @returns {Function} Returns the new assigner function.
|
* @returns {Function} Returns the new assigner function.
|
||||||
*/
|
*/
|
||||||
function createAssigner(assigner) {
|
function createAssigner(assigner) {
|
||||||
return function() {
|
return restParam(function(object, sources) {
|
||||||
var args = arguments,
|
var index = -1,
|
||||||
length = args.length,
|
length = object == null ? 0 : sources.length,
|
||||||
object = args[0];
|
customizer = length > 2 ? sources[length - 2] : undefined,
|
||||||
|
guard = length > 2 ? sources[2] : undefined,
|
||||||
|
thisArg = length > 1 ? sources[length - 1] : undefined;
|
||||||
|
|
||||||
if (length < 2 || object == null) {
|
if (typeof customizer == 'function') {
|
||||||
return object;
|
|
||||||
}
|
|
||||||
var customizer = args[length - 2],
|
|
||||||
thisArg = args[length - 1],
|
|
||||||
guard = args[3];
|
|
||||||
|
|
||||||
if (length > 3 && typeof customizer == 'function') {
|
|
||||||
customizer = bindCallback(customizer, thisArg, 5);
|
customizer = bindCallback(customizer, thisArg, 5);
|
||||||
length -= 2;
|
length -= 2;
|
||||||
} else {
|
} else {
|
||||||
customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null;
|
customizer = typeof thisArg == 'function' ? thisArg : undefined;
|
||||||
length -= (customizer ? 1 : 0);
|
length -= (customizer ? 1 : 0);
|
||||||
}
|
}
|
||||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||||
customizer = length == 3 ? null : customizer;
|
customizer = length < 3 ? undefined : customizer;
|
||||||
length = 2;
|
length = 1;
|
||||||
}
|
}
|
||||||
var index = 0;
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var source = args[index];
|
var source = sources[index];
|
||||||
if (source) {
|
if (source) {
|
||||||
assigner(object, source, customizer);
|
assigner(object, source, customizer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return createAssigner;
|
return createAssigner;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./isLength', './toObject'], function(isLength, toObject) {
|
define(['./getLength', './isLength', './toObject'], function(getLength, isLength, toObject) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a `baseEach` or `baseEachRight` function.
|
* Creates a `baseEach` or `baseEachRight` function.
|
||||||
@@ -10,7 +10,7 @@ define(['./isLength', './toObject'], function(isLength, toObject) {
|
|||||||
*/
|
*/
|
||||||
function createBaseEach(eachFunc, fromRight) {
|
function createBaseEach(eachFunc, fromRight) {
|
||||||
return function(collection, iteratee) {
|
return function(collection, iteratee) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? getLength(collection) : 0;
|
||||||
if (!isLength(length)) {
|
if (!isLength(length)) {
|
||||||
return eachFunc(collection, iteratee);
|
return eachFunc(collection, iteratee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
define(['./SetCache', '../utility/constant', '../lang/isNative', './root'], function(SetCache, constant, isNative, root) {
|
define(['./SetCache', '../utility/constant', './getNative', './root'], function(SetCache, constant, getNative, root) {
|
||||||
|
|
||||||
/** Native method references. */
|
/** Native method references. */
|
||||||
var Set = isNative(Set = root.Set) && Set;
|
var Set = getNative(root, 'Set');
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
|
var nativeCreate = getNative(Object, 'create');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a `Set` cache object to optimize linear searches of large arrays.
|
* Creates a `Set` cache object to optimize linear searches of large arrays.
|
||||||
|
|||||||
@@ -10,8 +10,20 @@ define(['./baseCreate', '../lang/isObject'], function(baseCreate, isObject) {
|
|||||||
*/
|
*/
|
||||||
function createCtorWrapper(Ctor) {
|
function createCtorWrapper(Ctor) {
|
||||||
return function() {
|
return function() {
|
||||||
|
// Use a `switch` statement to work with class constructors.
|
||||||
|
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist
|
||||||
|
// for more details.
|
||||||
|
var args = arguments;
|
||||||
|
switch (args.length) {
|
||||||
|
case 0: return new Ctor;
|
||||||
|
case 1: return new Ctor(args[0]);
|
||||||
|
case 2: return new Ctor(args[0], args[1]);
|
||||||
|
case 3: return new Ctor(args[0], args[1], args[2]);
|
||||||
|
case 4: return new Ctor(args[0], args[1], args[2], args[3]);
|
||||||
|
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
|
||||||
|
}
|
||||||
var thisBinding = baseCreate(Ctor.prototype),
|
var thisBinding = baseCreate(Ctor.prototype),
|
||||||
result = Ctor.apply(thisBinding, arguments);
|
result = Ctor.apply(thisBinding, args);
|
||||||
|
|
||||||
// Mimic the constructor's `return` behavior.
|
// Mimic the constructor's `return` behavior.
|
||||||
// See https://es5.github.io/#x13.2.2 for more details.
|
// See https://es5.github.io/#x13.2.2 for more details.
|
||||||
|
|||||||
@@ -1,31 +1,27 @@
|
|||||||
define(['./baseCallback', './charAtCallback', './extremumBy', '../lang/isArray', './isIterateeCall', '../lang/isString', './toIterable'], function(baseCallback, charAtCallback, extremumBy, isArray, isIterateeCall, isString, toIterable) {
|
define(['./arrayExtremum', './baseCallback', './baseExtremum', './isIterateeCall', './toIterable'], function(arrayExtremum, baseCallback, baseExtremum, isIterateeCall, toIterable) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a `_.max` or `_.min` function.
|
* Creates a `_.max` or `_.min` function.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} arrayFunc The function to get the extremum value from an array.
|
* @param {Function} comparator The function used to compare values.
|
||||||
* @param {boolean} [isMin] Specify returning the minimum, instead of the maximum,
|
* @param {*} exValue The initial extremum value.
|
||||||
* extremum value.
|
|
||||||
* @returns {Function} Returns the new extremum function.
|
* @returns {Function} Returns the new extremum function.
|
||||||
*/
|
*/
|
||||||
function createExtremum(arrayFunc, isMin) {
|
function createExtremum(comparator, exValue) {
|
||||||
return function(collection, iteratee, thisArg) {
|
return function(collection, iteratee, thisArg) {
|
||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
}
|
}
|
||||||
var noIteratee = iteratee == null;
|
iteratee = baseCallback(iteratee, thisArg, 3);
|
||||||
|
if (iteratee.length == 1) {
|
||||||
iteratee = noIteratee ? iteratee : baseCallback(iteratee, thisArg, 3);
|
collection = toIterable(collection);
|
||||||
if (noIteratee) {
|
var result = arrayExtremum(collection, iteratee, comparator, exValue);
|
||||||
var isArr = isArray(collection);
|
if (!(collection.length && result === exValue)) {
|
||||||
if (!isArr && isString(collection)) {
|
return result;
|
||||||
iteratee = charAtCallback;
|
|
||||||
} else {
|
|
||||||
return arrayFunc(isArr ? collection : toIterable(collection));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return extremumBy(collection, iteratee, isMin);
|
return baseExtremum(collection, iteratee, comparator, exValue);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ define(['./baseCallback', './baseFind', './baseFindIndex', '../lang/isArray'], f
|
|||||||
return index > -1 ? collection[index] : undefined;
|
return index > -1 ? collection[index] : undefined;
|
||||||
}
|
}
|
||||||
return baseFind(collection, predicate, eachFunc);
|
return baseFind(collection, predicate, eachFunc);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return createFind;
|
return createFind;
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, isLaziable) {
|
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. */
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
@@ -12,11 +18,8 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
|
|||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return function() {
|
return function() {
|
||||||
var length = arguments.length;
|
|
||||||
if (!length) {
|
|
||||||
return function() { return arguments[0]; };
|
|
||||||
}
|
|
||||||
var wrapper,
|
var wrapper,
|
||||||
|
length = arguments.length,
|
||||||
index = fromRight ? length : -1,
|
index = fromRight ? length : -1,
|
||||||
leftIndex = 0,
|
leftIndex = 0,
|
||||||
funcs = Array(length);
|
funcs = Array(length);
|
||||||
@@ -26,16 +29,18 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
|
|||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
var funcName = wrapper ? '' : getFuncName(func);
|
if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
|
||||||
wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper;
|
wrapper = new LodashWrapper([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
index = wrapper ? -1 : length;
|
index = wrapper ? -1 : length;
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
func = funcs[index];
|
func = funcs[index];
|
||||||
funcName = getFuncName(func);
|
|
||||||
|
|
||||||
var data = funcName == 'wrapper' ? getData(func) : null;
|
var funcName = getFuncName(func),
|
||||||
if (data && isLaziable(data[0])) {
|
data = funcName == 'wrapper' ? getData(func) : null;
|
||||||
|
|
||||||
|
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]);
|
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||||
} else {
|
} else {
|
||||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||||
@@ -47,7 +52,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
|
|||||||
return wrapper.plant(args[0]).value();
|
return wrapper.plant(args[0]).value();
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
result = funcs[index].apply(this, args);
|
result = length ? funcs[index].apply(this, args) : args[0];
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
result = funcs[index].call(this, result);
|
result = funcs[index].call(this, result);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./bindCallback', '../lang/isArray'], function(bindCallback, isArray) {
|
define(['./bindCallback', '../lang/isArray'], function(bindCallback, isArray) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function for `_.forEach` or `_.forEachRight`.
|
* Creates a function for `_.forEach` or `_.forEachRight`.
|
||||||
*
|
*
|
||||||
@@ -10,7 +13,7 @@ define(['./bindCallback', '../lang/isArray'], function(bindCallback, isArray) {
|
|||||||
*/
|
*/
|
||||||
function createForEach(arrayFunc, eachFunc) {
|
function createForEach(arrayFunc, eachFunc) {
|
||||||
return function(collection, iteratee, thisArg) {
|
return function(collection, iteratee, thisArg) {
|
||||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
|
||||||
? arrayFunc(collection, iteratee)
|
? arrayFunc(collection, iteratee)
|
||||||
: eachFunc(collection, bindCallback(iteratee, thisArg, 3));
|
: eachFunc(collection, bindCallback(iteratee, thisArg, 3));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./bindCallback', '../object/keysIn'], function(bindCallback, keysIn) {
|
define(['./bindCallback', '../object/keysIn'], function(bindCallback, keysIn) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function for `_.forIn` or `_.forInRight`.
|
* Creates a function for `_.forIn` or `_.forInRight`.
|
||||||
*
|
*
|
||||||
@@ -9,7 +12,7 @@ define(['./bindCallback', '../object/keysIn'], function(bindCallback, keysIn) {
|
|||||||
*/
|
*/
|
||||||
function createForIn(objectFunc) {
|
function createForIn(objectFunc) {
|
||||||
return function(object, iteratee, thisArg) {
|
return function(object, iteratee, thisArg) {
|
||||||
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
|
if (typeof iteratee != 'function' || thisArg !== undefined) {
|
||||||
iteratee = bindCallback(iteratee, thisArg, 3);
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
||||||
}
|
}
|
||||||
return objectFunc(object, iteratee, keysIn);
|
return objectFunc(object, iteratee, keysIn);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./bindCallback'], function(bindCallback) {
|
define(['./bindCallback'], function(bindCallback) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function for `_.forOwn` or `_.forOwnRight`.
|
* Creates a function for `_.forOwn` or `_.forOwnRight`.
|
||||||
*
|
*
|
||||||
@@ -9,7 +12,7 @@ define(['./bindCallback'], function(bindCallback) {
|
|||||||
*/
|
*/
|
||||||
function createForOwn(objectFunc) {
|
function createForOwn(objectFunc) {
|
||||||
return function(object, iteratee, thisArg) {
|
return function(object, iteratee, thisArg) {
|
||||||
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
|
if (typeof iteratee != 'function' || thisArg !== undefined) {
|
||||||
iteratee = bindCallback(iteratee, thisArg, 3);
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
||||||
}
|
}
|
||||||
return objectFunc(object, iteratee);
|
return objectFunc(object, iteratee);
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
|
|||||||
isBindKey = bitmask & BIND_KEY_FLAG,
|
isBindKey = bitmask & BIND_KEY_FLAG,
|
||||||
isCurry = bitmask & CURRY_FLAG,
|
isCurry = bitmask & CURRY_FLAG,
|
||||||
isCurryBound = bitmask & CURRY_BOUND_FLAG,
|
isCurryBound = bitmask & CURRY_BOUND_FLAG,
|
||||||
isCurryRight = bitmask & CURRY_RIGHT_FLAG;
|
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
|
||||||
|
Ctor = isBindKey ? null : createCtorWrapper(func);
|
||||||
var Ctor = !isBindKey && createCtorWrapper(func),
|
|
||||||
key = func;
|
|
||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
// Avoid `arguments` object use disqualifying optimizations by
|
// Avoid `arguments` object use disqualifying optimizations by
|
||||||
@@ -89,17 +87,18 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var thisBinding = isBind ? thisArg : this;
|
var thisBinding = isBind ? thisArg : this,
|
||||||
if (isBindKey) {
|
fn = isBindKey ? thisBinding[func] : func;
|
||||||
func = thisBinding[key];
|
|
||||||
}
|
|
||||||
if (argPos) {
|
if (argPos) {
|
||||||
args = reorder(args, argPos);
|
args = reorder(args, argPos);
|
||||||
}
|
}
|
||||||
if (isAry && ary < args.length) {
|
if (isAry && ary < args.length) {
|
||||||
args.length = ary;
|
args.length = ary;
|
||||||
}
|
}
|
||||||
var fn = (this && this !== root && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func;
|
if (this && this !== root && this instanceof wrapper) {
|
||||||
|
fn = Ctor || createCtorWrapper(func);
|
||||||
|
}
|
||||||
return fn.apply(thisBinding, args);
|
return fn.apply(thisBinding, args);
|
||||||
}
|
}
|
||||||
return wrapper;
|
return wrapper;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user