mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9724afd7a6 | ||
|
|
707fe171fc |
@@ -1,4 +1,4 @@
|
|||||||
# lodash v3.4.0
|
# lodash v3.6.0
|
||||||
|
|
||||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseFlatten, isArguments, isArray) {
|
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array excluding all values of the provided arrays using
|
* Creates an array excluding all values of the provided arrays using
|
||||||
* `SameValueZero` for equality comparisons.
|
* `SameValueZero` for equality comparisons.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -20,19 +19,11 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
|
|||||||
* _.difference([1, 2, 3], [4, 2]);
|
* _.difference([1, 2, 3], [4, 2]);
|
||||||
* // => [1, 3]
|
* // => [1, 3]
|
||||||
*/
|
*/
|
||||||
function difference() {
|
var difference = restParam(function(array, values) {
|
||||||
var args = arguments,
|
return (isArray(array) || isArguments(array))
|
||||||
index = -1,
|
? baseDifference(array, baseFlatten(values, false, true))
|
||||||
length = args.length;
|
: [];
|
||||||
|
});
|
||||||
while (++index < length) {
|
|
||||||
var value = args[index];
|
|
||||||
if (isArray(value) || isArguments(value)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return baseDifference(value, baseFlatten(args, false, true, ++index));
|
|
||||||
}
|
|
||||||
|
|
||||||
return difference;
|
return difference;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
|
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a slice of `array` excluding elements dropped from the end.
|
* Creates a slice of `array` excluding elements dropped from the end.
|
||||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
* Elements are dropped until `predicate` returns falsey. The predicate is
|
||||||
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
* bound to `thisArg` and invoked with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -50,13 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
|
|||||||
* // => ['barney', 'fred', 'pebbles']
|
* // => ['barney', 'fred', 'pebbles']
|
||||||
*/
|
*/
|
||||||
function dropRightWhile(array, predicate, thisArg) {
|
function dropRightWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0;
|
return (array && array.length)
|
||||||
if (!length) {
|
? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true)
|
||||||
return [];
|
: [];
|
||||||
}
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (length-- && predicate(array[length], length, array)) {}
|
|
||||||
return baseSlice(array, 0, length + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dropRightWhile;
|
return dropRightWhile;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
|
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a slice of `array` excluding elements dropped from the beginning.
|
* Creates a slice of `array` excluding elements dropped from the beginning.
|
||||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
* Elements are dropped until `predicate` returns falsey. The predicate is
|
||||||
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
* bound to `thisArg` and invoked with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -50,14 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
|
|||||||
* // => ['barney', 'fred', 'pebbles']
|
* // => ['barney', 'fred', 'pebbles']
|
||||||
*/
|
*/
|
||||||
function dropWhile(array, predicate, thisArg) {
|
function dropWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0;
|
return (array && array.length)
|
||||||
if (!length) {
|
? baseWhile(array, baseCallback(predicate, thisArg, 3), true)
|
||||||
return [];
|
: [];
|
||||||
}
|
|
||||||
var index = -1;
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (++index < length && predicate(array[index], index, array)) {}
|
|
||||||
return baseSlice(array, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dropWhile;
|
return dropWhile;
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ define(['../internal/baseFill', '../internal/isIterateeCall'], function(baseFill
|
|||||||
* @param {number} [start=0] The start position.
|
* @param {number} [start=0] The start position.
|
||||||
* @param {number} [end=array.length] The end position.
|
* @param {number} [end=array.length] The end position.
|
||||||
* @returns {Array} Returns `array`.
|
* @returns {Array} Returns `array`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var array = [1, 2, 3];
|
||||||
|
*
|
||||||
|
* _.fill(array, 'a');
|
||||||
|
* console.log(array);
|
||||||
|
* // => ['a', 'a', 'a']
|
||||||
|
*
|
||||||
|
* _.fill(Array(3), 2);
|
||||||
|
* // => [2, 2, 2]
|
||||||
|
*
|
||||||
|
* _.fill([4, 6, 8], '*', 1, 2);
|
||||||
|
* // => [4, '*', 8]
|
||||||
*/
|
*/
|
||||||
function fill(array, value, start, end) {
|
function fill(array, value, start, end) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
define(['../internal/baseCallback'], function(baseCallback) {
|
define(['../internal/createFindIndex'], function(createFindIndex) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.find` except that it returns the index of the first
|
* This method is like `_.find` except that it returns the index of the first
|
||||||
* element `predicate` returns truthy for, instead of the element itself.
|
* element `predicate` returns truthy for instead of the element itself.
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -48,18 +48,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
|
|||||||
* _.findIndex(users, 'active');
|
* _.findIndex(users, 'active');
|
||||||
* // => 2
|
* // => 2
|
||||||
*/
|
*/
|
||||||
function findIndex(array, predicate, thisArg) {
|
var findIndex = createFindIndex();
|
||||||
var index = -1,
|
|
||||||
length = array ? array.length : 0;
|
|
||||||
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (++index < length) {
|
|
||||||
if (predicate(array[index], index, array)) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return findIndex;
|
return findIndex;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback'], function(baseCallback) {
|
define(['../internal/createFindIndex'], function(createFindIndex) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.findIndex` except that it iterates over elements
|
* This method is like `_.findIndex` except that it iterates over elements
|
||||||
@@ -48,16 +48,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
|
|||||||
* _.findLastIndex(users, 'active');
|
* _.findLastIndex(users, 'active');
|
||||||
* // => 0
|
* // => 0
|
||||||
*/
|
*/
|
||||||
function findLastIndex(array, predicate, thisArg) {
|
var findLastIndex = createFindIndex(true);
|
||||||
var length = array ? array.length : 0;
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (length--) {
|
|
||||||
if (predicate(array[length], length, array)) {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return findLastIndex;
|
return findLastIndex;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,18 +14,18 @@ define(['../internal/baseFlatten', '../internal/isIterateeCall'], function(baseF
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flatten([1, [2, 3, [4]]]);
|
* _.flatten([1, [2, 3, [4]]]);
|
||||||
* // => [1, 2, 3, [4]];
|
* // => [1, 2, 3, [4]]
|
||||||
*
|
*
|
||||||
* // using `isDeep`
|
* // using `isDeep`
|
||||||
* _.flatten([1, [2, 3, [4]]], true);
|
* _.flatten([1, [2, 3, [4]]], true);
|
||||||
* // => [1, 2, 3, 4];
|
* // => [1, 2, 3, 4]
|
||||||
*/
|
*/
|
||||||
function flatten(array, isDeep, guard) {
|
function flatten(array, isDeep, guard) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
if (guard && isIterateeCall(array, isDeep, guard)) {
|
if (guard && isIterateeCall(array, isDeep, guard)) {
|
||||||
isDeep = false;
|
isDeep = false;
|
||||||
}
|
}
|
||||||
return length ? baseFlatten(array, isDeep, false, 0) : [];
|
return length ? baseFlatten(array, isDeep) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return flatten;
|
return flatten;
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ define(['../internal/baseFlatten'], function(baseFlatten) {
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
* _.flattenDeep([1, [2, 3, [4]]]);
|
||||||
* // => [1, 2, 3, 4];
|
* // => [1, 2, 3, 4]
|
||||||
*/
|
*/
|
||||||
function flattenDeep(array) {
|
function flattenDeep(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array, true, false, 0) : [];
|
return length ? baseFlatten(array, true) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return flattenDeep;
|
return flattenDeep;
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
|
|||||||
* it is used as the offset from the end of `array`. If `array` is sorted
|
* it is used as the offset from the end of `array`. If `array` is sorted
|
||||||
* providing `true` for `fromIndex` performs a faster binary search.
|
* providing `true` for `fromIndex` performs a faster binary search.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -46,7 +45,10 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
|
|||||||
var index = binaryIndex(array, value),
|
var index = binaryIndex(array, value),
|
||||||
other = array[index];
|
other = array[index];
|
||||||
|
|
||||||
return (value === value ? value === other : other !== other) ? index : -1;
|
if (value === value ? (value === other) : (other !== other)) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return baseIndexOf(array, value, fromIndex || 0);
|
return baseIndexOf(array, value, fromIndex || 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
|
|||||||
* Creates an array of unique values in all provided arrays using `SameValueZero`
|
* Creates an array of unique values in all provided arrays using `SameValueZero`
|
||||||
* for equality comparisons.
|
* for equality comparisons.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ define(['../internal/binaryIndex', '../internal/indexOfNaN'], function(binaryInd
|
|||||||
} else if (fromIndex) {
|
} else if (fromIndex) {
|
||||||
index = binaryIndex(array, value, true) - 1;
|
index = binaryIndex(array, value, true) - 1;
|
||||||
var other = array[index];
|
var other = array[index];
|
||||||
return (value === value ? value === other : other !== other) ? index : -1;
|
if (value === value ? (value === other) : (other !== other)) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
if (value !== value) {
|
if (value !== value) {
|
||||||
return indexOfNaN(array, index, true);
|
return indexOfNaN(array, index, true);
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
|
|||||||
* comparisons.
|
* comparisons.
|
||||||
*
|
*
|
||||||
* **Notes:**
|
* **Notes:**
|
||||||
* - Unlike `_.without`, this method mutates `array`.
|
* - Unlike `_.without`, this method mutates `array`
|
||||||
* - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`,
|
* - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* comparisons are like strict equality comparisons, e.g. `===`, except
|
||||||
* for more details.
|
* that `NaN` matches `NaN`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
define(['../internal/baseFlatten', '../internal/basePullAt'], function(baseFlatten, basePullAt) {
|
define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/baseFlatten', '../internal/isIndex', '../function/restParam'], function(baseAt, baseCompareAscending, baseFlatten, isIndex, 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
|
||||||
@@ -25,9 +31,23 @@ define(['../internal/baseFlatten', '../internal/basePullAt'], function(baseFlatt
|
|||||||
* console.log(evens);
|
* console.log(evens);
|
||||||
* // => [10, 20]
|
* // => [10, 20]
|
||||||
*/
|
*/
|
||||||
function pullAt(array) {
|
var pullAt = restParam(function(array, indexes) {
|
||||||
return basePullAt(array || [], baseFlatten(arguments, false, false, 1));
|
array || (array = []);
|
||||||
}
|
indexes = baseFlatten(indexes);
|
||||||
|
|
||||||
|
var length = indexes.length,
|
||||||
|
result = baseAt(array, indexes);
|
||||||
|
|
||||||
|
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 pullAt;
|
return pullAt;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ define(['../internal/baseCallback'], function(baseCallback) {
|
|||||||
/**
|
/**
|
||||||
* Removes all elements from `array` that `predicate` returns truthy for
|
* Removes all elements from `array` that `predicate` returns truthy for
|
||||||
* and returns an array of the removed elements. The predicate is bound to
|
* and returns an array of the removed elements. The predicate is bound to
|
||||||
* `thisArg` and invoked with three arguments; (value, index, array).
|
* `thisArg` and invoked with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/binaryIndexBy'], function(baseCallback, binaryIndex, binaryIndexBy) {
|
define(['../internal/createSortedIndex'], function(createSortedIndex) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses a binary search to determine the lowest index at which `value` should
|
* Uses a binary search to determine the lowest index at which `value` should
|
||||||
@@ -7,14 +7,14 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
|
|||||||
* to compute their sort ranking. The iteratee is bound to `thisArg` and
|
* to compute their sort ranking. The iteratee is bound to `thisArg` and
|
||||||
* invoked with one argument; (value).
|
* invoked with one argument; (value).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
@@ -48,11 +48,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
|
|||||||
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
||||||
* // => 1
|
* // => 1
|
||||||
*/
|
*/
|
||||||
function sortedIndex(array, value, iteratee, thisArg) {
|
var sortedIndex = createSortedIndex();
|
||||||
return iteratee == null
|
|
||||||
? binaryIndex(array, value)
|
|
||||||
: binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sortedIndex;
|
return sortedIndex;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/binaryIndexBy'], function(baseCallback, binaryIndex, binaryIndexBy) {
|
define(['../internal/createSortedIndex'], function(createSortedIndex) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.sortedIndex` except that it returns the highest
|
* This method is like `_.sortedIndex` except that it returns the highest
|
||||||
@@ -20,11 +20,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
|
|||||||
* _.sortedLastIndex([4, 4, 5, 5], 5);
|
* _.sortedLastIndex([4, 4, 5, 5], 5);
|
||||||
* // => 4
|
* // => 4
|
||||||
*/
|
*/
|
||||||
function sortedLastIndex(array, value, iteratee, thisArg) {
|
var sortedLastIndex = createSortedIndex(true);
|
||||||
return iteratee == null
|
|
||||||
? binaryIndex(array, value, true)
|
|
||||||
: binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sortedLastIndex;
|
return sortedLastIndex;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
|
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a slice of `array` with elements taken from the end. Elements are
|
* Creates a slice of `array` with elements taken from the end. Elements are
|
||||||
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
|
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
|
||||||
* and invoked with three arguments; (value, index, array).
|
* and invoked with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -50,13 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
|
|||||||
* // => []
|
* // => []
|
||||||
*/
|
*/
|
||||||
function takeRightWhile(array, predicate, thisArg) {
|
function takeRightWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0;
|
return (array && array.length)
|
||||||
if (!length) {
|
? baseWhile(array, baseCallback(predicate, thisArg, 3), false, true)
|
||||||
return [];
|
: [];
|
||||||
}
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (length-- && predicate(array[length], length, array)) {}
|
|
||||||
return baseSlice(array, length + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return takeRightWhile;
|
return takeRightWhile;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
|
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a slice of `array` with elements taken from the beginning. Elements
|
* Creates a slice of `array` with elements taken from the beginning. Elements
|
||||||
* are taken until `predicate` returns falsey. The predicate is bound to
|
* are taken until `predicate` returns falsey. The predicate is bound to
|
||||||
* `thisArg` and invoked with three arguments; (value, index, array).
|
* `thisArg` and invoked with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -50,14 +50,9 @@ define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallb
|
|||||||
* // => []
|
* // => []
|
||||||
*/
|
*/
|
||||||
function takeWhile(array, predicate, thisArg) {
|
function takeWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0;
|
return (array && array.length)
|
||||||
if (!length) {
|
? baseWhile(array, baseCallback(predicate, thisArg, 3))
|
||||||
return [];
|
: [];
|
||||||
}
|
|
||||||
var index = -1;
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (++index < length && predicate(array[index], index, array)) {}
|
|
||||||
return baseSlice(array, 0, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return takeWhile;
|
return takeWhile;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
define(['../internal/baseFlatten', '../internal/baseUniq'], function(baseFlatten, baseUniq) {
|
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, of the provided arrays using
|
||||||
* `SameValueZero` for equality comparisons.
|
* `SameValueZero` for equality comparisons.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -19,9 +18,9 @@ define(['../internal/baseFlatten', '../internal/baseUniq'], function(baseFlatten
|
|||||||
* _.union([1, 2], [4, 2], [2, 1]);
|
* _.union([1, 2], [4, 2], [2, 1]);
|
||||||
* // => [1, 2, 4]
|
* // => [1, 2, 4]
|
||||||
*/
|
*/
|
||||||
function union() {
|
var union = restParam(function(arrays) {
|
||||||
return baseUniq(baseFlatten(arguments, false, true, 0));
|
return baseUniq(baseFlatten(arrays, false, true));
|
||||||
}
|
});
|
||||||
|
|
||||||
return union;
|
return union;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,23 +6,22 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
|
|||||||
* search algorithm for sorted arrays. If an iteratee function is provided it
|
* search algorithm for sorted arrays. If an iteratee function is provided it
|
||||||
* is invoked for each value in the array to generate the criterion by which
|
* is invoked for each value in the array to generate the criterion by which
|
||||||
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
|
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
|
||||||
* with three arguments; (value, index, array).
|
* with three arguments: (value, index, array).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
define(['../internal/baseDifference', '../internal/baseSlice'], function(baseDifference, baseSlice) {
|
define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, isArguments, isArray, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array excluding all provided values using `SameValueZero` for
|
* Creates an array excluding all provided values using `SameValueZero` for
|
||||||
* equality comparisons.
|
* equality comparisons.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -20,9 +19,11 @@ define(['../internal/baseDifference', '../internal/baseSlice'], function(baseDif
|
|||||||
* _.without([1, 2, 1, 3], 1, 2);
|
* _.without([1, 2, 1, 3], 1, 2);
|
||||||
* // => [3]
|
* // => [3]
|
||||||
*/
|
*/
|
||||||
function without(array) {
|
var without = restParam(function(array, values) {
|
||||||
return baseDifference(array, baseSlice(arguments, 1));
|
return (isArray(array) || isArguments(array))
|
||||||
}
|
? baseDifference(array, values)
|
||||||
|
: [];
|
||||||
|
});
|
||||||
|
|
||||||
return without;
|
return without;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseUniq, isArguments, isArray) {
|
define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseUniq, isArguments, isArray) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array that is the symmetric difference of the provided arrays.
|
* Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
|
||||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for
|
* of the provided arrays.
|
||||||
* more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
12
array/zip.js
12
array/zip.js
@@ -1,4 +1,4 @@
|
|||||||
define(['./unzip'], function(unzip) {
|
define(['../function/restParam', './unzip'], function(restParam, unzip) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of grouped elements, the first of which contains the first
|
* Creates an array of grouped elements, the first of which contains the first
|
||||||
@@ -15,15 +15,7 @@ define(['./unzip'], function(unzip) {
|
|||||||
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
||||||
* // => [['fred', 30, true], ['barney', 40, false]]
|
* // => [['fred', 30, true], ['barney', 40, false]]
|
||||||
*/
|
*/
|
||||||
function zip() {
|
var zip = restParam(unzip);
|
||||||
var length = arguments.length,
|
|
||||||
array = Array(length);
|
|
||||||
|
|
||||||
while (length--) {
|
|
||||||
array[length] = arguments[length];
|
|
||||||
}
|
|
||||||
return unzip(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
return zip;
|
return zip;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
define(['../lang/isArray'], function(isArray) {
|
define(['../lang/isArray'], function(isArray) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object composed from arrays of property names and values. Provide
|
* The inverse of `_.pairs`; this method returns an object composed from arrays
|
||||||
* either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]`
|
* of property names and values. Provide either a single two dimensional array,
|
||||||
* or two arrays, one of property names and one of corresponding values.
|
* e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names
|
||||||
|
* and one of corresponding values.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -14,6 +15,9 @@ define(['../lang/isArray'], function(isArray) {
|
|||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
* _.zipObject([['fred', 30], ['barney', 40]]);
|
||||||
|
* // => { 'fred': 30, 'barney': 40 }
|
||||||
|
*
|
||||||
* _.zipObject(['fred', 'barney'], [30, 40]);
|
* _.zipObject(['fred', 'barney'], [30, 40]);
|
||||||
* // => { 'fred': 30, 'barney': 40 }
|
* // => { 'fred': 30, 'barney': 40 }
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,9 +22,14 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
|
|||||||
* Chaining is supported in custom builds as long as the `_#value` method is
|
* Chaining is supported in custom builds as long as the `_#value` method is
|
||||||
* directly or indirectly included in the build.
|
* directly or indirectly included in the build.
|
||||||
*
|
*
|
||||||
* In addition to lodash methods, wrappers also have the following `Array` methods:
|
* In addition to lodash methods, wrappers have `Array` and `String` methods.
|
||||||
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
|
*
|
||||||
* and `unshift`
|
* The wrapper `Array` methods are:
|
||||||
|
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
|
||||||
|
* `splice`, and `unshift`
|
||||||
|
*
|
||||||
|
* The wrapper `String` methods are:
|
||||||
|
* `replace` and `split`
|
||||||
*
|
*
|
||||||
* The wrapper methods that support shortcut fusion are:
|
* The wrapper methods that support shortcut fusion are:
|
||||||
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
|
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ define([], function() {
|
|||||||
* @returns {*} Returns the result of `interceptor`.
|
* @returns {*} Returns the result of `interceptor`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2, 3])
|
* _(' abc ')
|
||||||
* .last()
|
* .chain()
|
||||||
|
* .trim()
|
||||||
* .thru(function(value) {
|
* .thru(function(value) {
|
||||||
* return [value];
|
* return [value];
|
||||||
* })
|
* })
|
||||||
* .value();
|
* .value();
|
||||||
* // => [3]
|
* // => ['abc']
|
||||||
*/
|
*/
|
||||||
function thru(value, interceptor, thisArg) {
|
function thru(value, interceptor, thisArg) {
|
||||||
return interceptor.call(thisArg, value);
|
return interceptor.call(thisArg, value);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength', '../internal/toIterable'], function(baseAt, baseFlatten, isLength, toIterable) {
|
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength', '../function/restParam', '../internal/toIterable'], function(baseAt, baseFlatten, isLength, restParam, toIterable) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of elements corresponding to the given keys, or indexes,
|
* Creates an array of elements corresponding to the given keys, or indexes,
|
||||||
@@ -17,16 +17,16 @@ define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength',
|
|||||||
* _.at(['a', 'b', 'c'], [0, 2]);
|
* _.at(['a', 'b', 'c'], [0, 2]);
|
||||||
* // => ['a', 'c']
|
* // => ['a', 'c']
|
||||||
*
|
*
|
||||||
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
|
* _.at(['barney', 'fred', 'pebbles'], 0, 2);
|
||||||
* // => ['fred', 'pebbles']
|
* // => ['barney', 'pebbles']
|
||||||
*/
|
*/
|
||||||
function at(collection) {
|
var at = restParam(function(collection, props) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? collection.length : 0;
|
||||||
if (isLength(length)) {
|
if (isLength(length)) {
|
||||||
collection = toIterable(collection);
|
collection = toIterable(collection);
|
||||||
}
|
}
|
||||||
return baseAt(collection, baseFlatten(arguments, false, false, 1));
|
return baseAt(collection, baseFlatten(props));
|
||||||
}
|
});
|
||||||
|
|
||||||
return at;
|
return at;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
|
|||||||
* Creates an object composed of keys generated from the results of running
|
* Creates an object composed of keys generated from the results of running
|
||||||
* each element of `collection` through `iteratee`. The corresponding value
|
* each element of `collection` through `iteratee`. The corresponding value
|
||||||
* of each key is the number of times the key was returned by `iteratee`.
|
* of each key is the number of times the key was returned by `iteratee`.
|
||||||
* 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).
|
* (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray'], function(arrayEvery, baseCallback, baseEvery, isArray) {
|
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray', '../internal/isIterateeCall'], function(arrayEvery, baseCallback, baseEvery, isArray, isIterateeCall) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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:
|
||||||
* (value, index|key, collection).
|
* (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
@@ -50,6 +50,9 @@ define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseE
|
|||||||
*/
|
*/
|
||||||
function every(collection, predicate, thisArg) {
|
function every(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arrayEvery : baseEvery;
|
var func = isArray(collection) ? arrayEvery : baseEvery;
|
||||||
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
|
predicate = null;
|
||||||
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
predicate = baseCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
|
|||||||
/**
|
/**
|
||||||
* Iterates over elements of `collection`, returning an array of all elements
|
* Iterates over elements of `collection`, returning an array of all elements
|
||||||
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
||||||
* invoked with three arguments; (value, index|key, collection).
|
* invoked with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseFind', '../array/findIndex', '../lang/isArray'], function(baseCallback, baseEach, baseFind, findIndex, isArray) {
|
define(['../internal/baseEach', '../internal/createFind'], function(baseEach, createFind) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
||||||
var undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over elements of `collection`, returning the first element
|
* Iterates over elements of `collection`, returning the first element
|
||||||
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
||||||
* invoked with three arguments; (value, index|key, collection).
|
* invoked with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -53,14 +50,7 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseFin
|
|||||||
* _.result(_.find(users, 'active'), 'user');
|
* _.result(_.find(users, 'active'), 'user');
|
||||||
* // => 'barney'
|
* // => 'barney'
|
||||||
*/
|
*/
|
||||||
function find(collection, predicate, thisArg) {
|
var find = createFind(baseEach);
|
||||||
if (isArray(collection)) {
|
|
||||||
var index = findIndex(collection, predicate, thisArg);
|
|
||||||
return index > -1 ? collection[index] : undefined;
|
|
||||||
}
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
return baseFind(collection, predicate, baseEach);
|
|
||||||
}
|
|
||||||
|
|
||||||
return find;
|
return find;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback', '../internal/baseEachRight', '../internal/baseFind'], function(baseCallback, baseEachRight, baseFind) {
|
define(['../internal/baseEachRight', '../internal/createFind'], function(baseEachRight, createFind) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.find` except that it iterates over elements of
|
* This method is like `_.find` except that it iterates over elements of
|
||||||
@@ -19,10 +19,7 @@ define(['../internal/baseCallback', '../internal/baseEachRight', '../internal/ba
|
|||||||
* });
|
* });
|
||||||
* // => 3
|
* // => 3
|
||||||
*/
|
*/
|
||||||
function findLast(collection, predicate, thisArg) {
|
var findLast = createFind(baseEachRight, true);
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
return baseFind(collection, predicate, baseEachRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
return findLast;
|
return findLast;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
define(['../internal/arrayEach', '../internal/baseEach', '../internal/bindCallback', '../lang/isArray'], function(arrayEach, baseEach, bindCallback, isArray) {
|
define(['../internal/arrayEach', '../internal/baseEach', '../internal/createForEach'], function(arrayEach, baseEach, createForEach) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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). Iterator functions may exit iteration early
|
||||||
* by explicitly returning `false`.
|
* by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
@@ -30,11 +30,7 @@ define(['../internal/arrayEach', '../internal/baseEach', '../internal/bindCallba
|
|||||||
* });
|
* });
|
||||||
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
|
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forEach(collection, iteratee, thisArg) {
|
var forEach = createForEach(arrayEach, baseEach);
|
||||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
|
||||||
? arrayEach(collection, iteratee)
|
|
||||||
: baseEach(collection, bindCallback(iteratee, thisArg, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
return forEach;
|
return forEach;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/bindCallback', '../lang/isArray'], function(arrayEachRight, baseEachRight, bindCallback, isArray) {
|
define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/createForEach'], function(arrayEachRight, baseEachRight, createForEach) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forEach` except that it iterates over elements of
|
* This method is like `_.forEach` except that it iterates over elements of
|
||||||
@@ -16,14 +16,10 @@ define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/
|
|||||||
*
|
*
|
||||||
* _([1, 2]).forEachRight(function(n) {
|
* _([1, 2]).forEachRight(function(n) {
|
||||||
* console.log(n);
|
* console.log(n);
|
||||||
* }).join(',');
|
* }).value();
|
||||||
* // => logs each value from right to left and returns the array
|
* // => logs each value from right to left and returns the array
|
||||||
*/
|
*/
|
||||||
function forEachRight(collection, iteratee, thisArg) {
|
var forEachRight = createForEach(arrayEachRight, baseEachRight);
|
||||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
|
||||||
? arrayEachRight(collection, iteratee)
|
|
||||||
: baseEachRight(collection, bindCallback(iteratee, thisArg, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
return forEachRight;
|
return forEachRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
|
|||||||
* Creates an object composed of keys generated from the results of running
|
* Creates an object composed of keys generated from the results of running
|
||||||
* each element of `collection` through `iteratee`. The corresponding value
|
* each element of `collection` through `iteratee`. The corresponding value
|
||||||
* of each key is an array of the elements responsible for generating the key.
|
* of each key is an array of the elements responsible for generating the key.
|
||||||
* 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).
|
* (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, isArray, isLength, isString, values) {
|
define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isIterateeCall', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, 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;
|
||||||
@@ -8,10 +8,9 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
|
|||||||
* comparisons. If `fromIndex` is negative, it is used as the offset from
|
* comparisons. If `fromIndex` is negative, it is used as the offset from
|
||||||
* the end of `collection`.
|
* the end of `collection`.
|
||||||
*
|
*
|
||||||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
||||||
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
* `NaN` matches `NaN`.
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -20,6 +19,7 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
|
|||||||
* @param {Array|Object|string} collection The collection to search.
|
* @param {Array|Object|string} collection The collection to search.
|
||||||
* @param {*} target The value to search for.
|
* @param {*} target The value to search for.
|
||||||
* @param {number} [fromIndex=0] The index to search from.
|
* @param {number} [fromIndex=0] The index to search from.
|
||||||
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
|
||||||
* @returns {boolean} Returns `true` if a matching element is found, else `false`.
|
* @returns {boolean} Returns `true` if a matching element is found, else `false`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -35,7 +35,7 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
|
|||||||
* _.includes('pebbles', 'eb');
|
* _.includes('pebbles', 'eb');
|
||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
function includes(collection, target, fromIndex) {
|
function includes(collection, target, fromIndex, guard) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? collection.length : 0;
|
||||||
if (!isLength(length)) {
|
if (!isLength(length)) {
|
||||||
collection = values(collection);
|
collection = values(collection);
|
||||||
@@ -44,10 +44,10 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
|
|||||||
if (!length) {
|
if (!length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (typeof fromIndex == 'number') {
|
if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
|
||||||
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
|
||||||
} else {
|
|
||||||
fromIndex = 0;
|
fromIndex = 0;
|
||||||
|
} else {
|
||||||
|
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
||||||
}
|
}
|
||||||
return (typeof collection == 'string' || !isArray(collection) && isString(collection))
|
return (typeof collection == 'string' || !isArray(collection) && isString(collection))
|
||||||
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
|
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
|
|||||||
* Creates an object composed of keys generated from the results of running
|
* Creates an object composed of keys generated from the results of running
|
||||||
* each element of `collection` through `iteratee`. The corresponding value
|
* each element of `collection` through `iteratee`. The corresponding value
|
||||||
* of each key is the last element responsible for generating the key. The
|
* of each key is the last element responsible for generating the key. The
|
||||||
* iteratee function is bound to `thisArg` and invoked with three arguments;
|
* iteratee function is bound to `thisArg` and invoked with three arguments:
|
||||||
* (value, index|key, collection).
|
* (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['../internal/baseInvoke', '../internal/baseSlice'], function(baseInvoke, baseSlice) {
|
define(['../internal/baseEach', '../internal/isLength', '../function/restParam'], function(baseEach, isLength, 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 named by `methodName` on each element in `collection`,
|
||||||
@@ -22,9 +25,18 @@ define(['../internal/baseInvoke', '../internal/baseSlice'], function(baseInvoke,
|
|||||||
* _.invoke([123, 456], String.prototype.split, '');
|
* _.invoke([123, 456], String.prototype.split, '');
|
||||||
* // => [['1', '2', '3'], ['4', '5', '6']]
|
* // => [['1', '2', '3'], ['4', '5', '6']]
|
||||||
*/
|
*/
|
||||||
function invoke(collection, methodName) {
|
var invoke = restParam(function(collection, methodName, args) {
|
||||||
return baseInvoke(collection, methodName, baseSlice(arguments, 2));
|
var index = -1,
|
||||||
}
|
isFunc = typeof methodName == 'function',
|
||||||
|
length = collection ? collection.length : 0,
|
||||||
|
result = isLength(length) ? Array(length) : [];
|
||||||
|
|
||||||
|
baseEach(collection, function(value) {
|
||||||
|
var func = isFunc ? methodName : (value != null && value[methodName]);
|
||||||
|
result[++index] = func ? func.apply(value, args) : undefined;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
return invoke;
|
return invoke;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
|
|||||||
/**
|
/**
|
||||||
* Creates an array of values by running each element in `collection` through
|
* Creates an array of values by running each element in `collection` through
|
||||||
* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
|
* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
|
||||||
* arguments; (value, index|key, collection).
|
* arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
@@ -21,9 +21,9 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
|
|||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
||||||
* `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
|
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
|
||||||
* `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
|
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
|
||||||
* `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
|
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ define(['../internal/createAggregator'], function(createAggregator) {
|
|||||||
* Creates an array of elements split into two groups, the first of which
|
* Creates an array of elements split into two groups, the first of which
|
||||||
* contains elements `predicate` returns truthy for, while the second of which
|
* contains elements `predicate` returns truthy for, while the second of which
|
||||||
* contains elements `predicate` returns falsey for. The predicate is bound
|
* contains elements `predicate` returns falsey for. The predicate is bound
|
||||||
* to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
* to `thisArg` and invoked with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
define(['../internal/arrayReduce', '../internal/baseCallback', '../internal/baseEach', '../internal/baseReduce', '../lang/isArray'], function(arrayReduce, baseCallback, baseEach, baseReduce, isArray) {
|
define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createReduce'], function(arrayReduce, baseEach, createReduce) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reduces `collection` to a value which is the accumulated result of running
|
* Reduces `collection` to a value which is the accumulated result of running
|
||||||
* each element in `collection` through `iteratee`, where each successive
|
* each element in `collection` through `iteratee`, where each successive
|
||||||
* invocation is supplied the return value of the previous. If `accumulator`
|
* invocation is supplied the return value of the previous. If `accumulator`
|
||||||
* is not provided the first element of `collection` is used as the initial
|
* is not provided the first element of `collection` is used as the initial
|
||||||
* 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 interatees for methods like
|
||||||
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `assign`, `defaults`, `merge`, and `sortAllBy`
|
* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -36,10 +36,7 @@ define(['../internal/arrayReduce', '../internal/baseCallback', '../internal/base
|
|||||||
* }, {});
|
* }, {});
|
||||||
* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
|
* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function reduce(collection, iteratee, accumulator, thisArg) {
|
var reduce = createReduce(arrayReduce, baseEach);
|
||||||
var func = isArray(collection) ? arrayReduce : baseReduce;
|
|
||||||
return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach);
|
|
||||||
}
|
|
||||||
|
|
||||||
return reduce;
|
return reduce;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/arrayReduceRight', '../internal/baseCallback', '../internal/baseEachRight', '../internal/baseReduce', '../lang/isArray'], function(arrayReduceRight, baseCallback, baseEachRight, baseReduce, isArray) {
|
define(['../internal/arrayReduceRight', '../internal/baseEachRight', '../internal/createReduce'], function(arrayReduceRight, baseEachRight, createReduce) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.reduce` except that it iterates over elements of
|
* This method is like `_.reduce` except that it iterates over elements of
|
||||||
@@ -22,10 +22,7 @@ define(['../internal/arrayReduceRight', '../internal/baseCallback', '../internal
|
|||||||
* }, []);
|
* }, []);
|
||||||
* // => [4, 5, 2, 3, 0, 1]
|
* // => [4, 5, 2, 3, 0, 1]
|
||||||
*/
|
*/
|
||||||
function reduceRight(collection, iteratee, accumulator, thisArg) {
|
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
||||||
var func = isArray(collection) ? arrayReduceRight : baseReduce;
|
|
||||||
return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
return reduceRight;
|
return reduceRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom, toIterable) {
|
define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom, toIterable) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of shuffled values, using a version of the Fisher-Yates
|
* Creates an array of shuffled values, using a version of the
|
||||||
* shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle)
|
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray'], function(arraySome, baseCallback, baseSome, isArray) {
|
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray', '../internal/isIterateeCall'], function(arraySome, baseCallback, baseSome, isArray, isIterateeCall) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
* over the entire collection. The predicate is bound to `thisArg` and invoked
|
* over the entire collection. The predicate is bound to `thisArg` and invoked
|
||||||
* with three arguments; (value, index|key, collection).
|
* with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
* If a property name is provided for `predicate` the created `_.property`
|
||||||
* style callback returns the property value of the given element.
|
* style callback returns the property value of the given element.
|
||||||
@@ -51,6 +51,9 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo
|
|||||||
*/
|
*/
|
||||||
function some(collection, predicate, thisArg) {
|
function some(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arraySome : baseSome;
|
var func = isArray(collection) ? arraySome : baseSome;
|
||||||
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
|
predicate = null;
|
||||||
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
predicate = baseCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
|
|||||||
* 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
|
||||||
* running each element in a collection through `iteratee`. This method performs
|
* running each element in a collection through `iteratee`. This method performs
|
||||||
* a stable sort, that is, it preserves the original sort order of equal elements.
|
* a stable sort, that is, it preserves the original sort order of equal elements.
|
||||||
* 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).
|
* (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* If a property name is provided for `predicate` 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.
|
||||||
*
|
*
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
||||||
* style callback returns `true` for elements that have a matching property
|
* style callback returns `true` for elements that have a matching property
|
||||||
* value, else `false`.
|
* value, else `false`.
|
||||||
*
|
*
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
* If an object is provided for `iteratee` the created `_.matches` style
|
||||||
* 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`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,17 +23,24 @@ define(['../internal/baseFlatten', '../internal/baseSortByOrder', '../internal/i
|
|||||||
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
||||||
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
||||||
*/
|
*/
|
||||||
function sortByAll(collection) {
|
function sortByAll() {
|
||||||
|
var args = arguments,
|
||||||
|
collection = args[0],
|
||||||
|
guard = args[3],
|
||||||
|
index = 0,
|
||||||
|
length = args.length - 1;
|
||||||
|
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var args = arguments,
|
var props = Array(length);
|
||||||
guard = args[3];
|
while (index < length) {
|
||||||
|
props[index] = args[++index];
|
||||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
|
||||||
args = [collection, args[1]];
|
|
||||||
}
|
}
|
||||||
return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []);
|
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
||||||
|
props = args[1];
|
||||||
|
}
|
||||||
|
return baseSortByOrder(collection, baseFlatten(props), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sortByAll;
|
return sortByAll;
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterate
|
|||||||
* @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 {string[]} props The property names to sort by.
|
||||||
* @param {boolean[]} orders The sort orders of `props`.
|
* @param {boolean[]} orders The sort orders of `props`.
|
||||||
|
* @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': 36 },
|
|
||||||
* { 'user': 'fred', 'age': 40 },
|
|
||||||
* { 'user': 'barney', 'age': 26 },
|
* { 'user': 'barney', 'age': 26 },
|
||||||
|
* { 'user': 'fred', 'age': 40 },
|
||||||
|
* { 'user': 'barney', 'age': 36 },
|
||||||
* { 'user': 'fred', 'age': 30 }
|
* { 'user': 'fred', 'age': 30 }
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/spread', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, negate, once, partial, partialRight, rearg, spread, throttle, wrap) {
|
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/restParam', './function/spread', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, negate, once, partial, partialRight, rearg, restParam, spread, throttle, wrap) {
|
||||||
return {
|
return {
|
||||||
'after': after,
|
'after': after,
|
||||||
'ary': ary,
|
'ary': ary,
|
||||||
@@ -21,6 +21,7 @@ define(['./function/after', './function/ary', './function/backflow', './function
|
|||||||
'partial': partial,
|
'partial': partial,
|
||||||
'partialRight': partialRight,
|
'partialRight': partialRight,
|
||||||
'rearg': rearg,
|
'rearg': rearg,
|
||||||
|
'restParam': restParam,
|
||||||
'spread': spread,
|
'spread': spread,
|
||||||
'throttle': throttle,
|
'throttle': throttle,
|
||||||
'wrap': wrap
|
'wrap': wrap
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
|
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var ARY_FLAG = 256;
|
var ARY_FLAG = 128;
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
|
define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'], function(createWrapper, replaceHolders, restParam) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -20,7 +20,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to bind.
|
* @param {Function} func The function to bind.
|
||||||
* @param {*} thisArg The `this` binding of `func`.
|
* @param {*} thisArg The `this` binding of `func`.
|
||||||
* @param {...*} [args] The arguments to be partially applied.
|
* @param {...*} [partials] The arguments to be partially applied.
|
||||||
* @returns {Function} Returns the new bound function.
|
* @returns {Function} Returns the new bound function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -39,16 +39,14 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* bound('hi');
|
* bound('hi');
|
||||||
* // => 'hi fred!'
|
* // => 'hi fred!'
|
||||||
*/
|
*/
|
||||||
function bind(func, thisArg) {
|
var bind = restParam(function(func, thisArg, partials) {
|
||||||
var bitmask = BIND_FLAG;
|
var bitmask = BIND_FLAG;
|
||||||
if (arguments.length > 2) {
|
if (partials.length) {
|
||||||
var partials = baseSlice(arguments, 2),
|
var holders = replaceHolders(partials, bind.placeholder);
|
||||||
holders = replaceHolders(partials, bind.placeholder);
|
|
||||||
|
|
||||||
bitmask |= PARTIAL_FLAG;
|
bitmask |= PARTIAL_FLAG;
|
||||||
}
|
}
|
||||||
return createWrapper(func, bitmask, thisArg, partials, holders);
|
return createWrapper(func, bitmask, thisArg, partials, holders);
|
||||||
}
|
});
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
bind.placeholder = {};
|
bind.placeholder = {};
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
define(['../internal/baseBindAll', '../internal/baseFlatten', '../object/functions'], function(baseBindAll, baseFlatten, functions) {
|
define(['../internal/baseFlatten', '../internal/createWrapper', '../object/functions', './restParam'], function(baseFlatten, createWrapper, functions, restParam) {
|
||||||
|
|
||||||
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
|
var BIND_FLAG = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds methods of an object to the object itself, overwriting the existing
|
* Binds methods of an object to the object itself, overwriting the existing
|
||||||
@@ -28,13 +31,18 @@ define(['../internal/baseBindAll', '../internal/baseFlatten', '../object/functio
|
|||||||
* jQuery('#docs').on('click', view.onClick);
|
* jQuery('#docs').on('click', view.onClick);
|
||||||
* // => logs 'clicked docs' when the element is clicked
|
* // => logs 'clicked docs' when the element is clicked
|
||||||
*/
|
*/
|
||||||
function bindAll(object) {
|
var bindAll = restParam(function(object, methodNames) {
|
||||||
return baseBindAll(object,
|
methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);
|
||||||
arguments.length > 1
|
|
||||||
? baseFlatten(arguments, false, false, 1)
|
var index = -1,
|
||||||
: functions(object)
|
length = methodNames.length;
|
||||||
);
|
|
||||||
}
|
while (++index < length) {
|
||||||
|
var key = methodNames[index];
|
||||||
|
object[key] = createWrapper(object[key], BIND_FLAG, object);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
});
|
||||||
|
|
||||||
return bindAll;
|
return bindAll;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
|
define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'], function(createWrapper, replaceHolders, restParam) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -22,7 +22,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* @category Function
|
* @category Function
|
||||||
* @param {Object} object The object the method belongs to.
|
* @param {Object} object The object the method belongs to.
|
||||||
* @param {string} key The key of the method.
|
* @param {string} key The key of the method.
|
||||||
* @param {...*} [args] The arguments to be partially applied.
|
* @param {...*} [partials] The arguments to be partially applied.
|
||||||
* @returns {Function} Returns the new bound function.
|
* @returns {Function} Returns the new bound function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -49,16 +49,14 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* bound('hi');
|
* bound('hi');
|
||||||
* // => 'hiya fred!'
|
* // => 'hiya fred!'
|
||||||
*/
|
*/
|
||||||
function bindKey(object, key) {
|
var bindKey = restParam(function(object, key, partials) {
|
||||||
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
||||||
if (arguments.length > 2) {
|
if (partials.length) {
|
||||||
var partials = baseSlice(arguments, 2),
|
var holders = replaceHolders(partials, bindKey.placeholder);
|
||||||
holders = replaceHolders(partials, bindKey.placeholder);
|
|
||||||
|
|
||||||
bitmask |= PARTIAL_FLAG;
|
bitmask |= PARTIAL_FLAG;
|
||||||
}
|
}
|
||||||
return createWrapper(key, bitmask, object, partials, holders);
|
return createWrapper(key, bitmask, object, partials, holders);
|
||||||
}
|
});
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
bindKey.placeholder = {};
|
bindKey.placeholder = {};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
|
define(['../internal/createCurry'], function(createCurry) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var CURRY_FLAG = 8;
|
var CURRY_FLAG = 8;
|
||||||
@@ -43,14 +43,7 @@ define(['../internal/createWrapper', '../internal/isIterateeCall'], function(cre
|
|||||||
* curried(1)(_, 3)(2);
|
* curried(1)(_, 3)(2);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function curry(func, arity, guard) {
|
var curry = createCurry(CURRY_FLAG);
|
||||||
if (guard && isIterateeCall(func, arity, guard)) {
|
|
||||||
arity = null;
|
|
||||||
}
|
|
||||||
var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity);
|
|
||||||
result.placeholder = curry.placeholder;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
curry.placeholder = {};
|
curry.placeholder = {};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
|
define(['../internal/createCurry'], function(createCurry) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var CURRY_RIGHT_FLAG = 16;
|
var CURRY_RIGHT_FLAG = 16;
|
||||||
@@ -40,14 +40,7 @@ define(['../internal/createWrapper', '../internal/isIterateeCall'], function(cre
|
|||||||
* curried(3)(1, _)(2);
|
* curried(3)(1, _)(2);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function curryRight(func, arity, guard) {
|
var curryRight = createCurry(CURRY_RIGHT_FLAG);
|
||||||
if (guard && isIterateeCall(func, arity, guard)) {
|
|
||||||
arity = null;
|
|
||||||
}
|
|
||||||
var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity);
|
|
||||||
result.placeholder = curryRight.placeholder;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
curryRight.placeholder = {};
|
curryRight.placeholder = {};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseDelay'], function(baseDelay) {
|
define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defers invoking the `func` until the current call stack has cleared. Any
|
* Defers invoking the `func` until the current call stack has cleared. Any
|
||||||
@@ -17,9 +17,9 @@ define(['../internal/baseDelay'], function(baseDelay) {
|
|||||||
* }, 'deferred');
|
* }, 'deferred');
|
||||||
* // logs 'deferred' after one or more milliseconds
|
* // logs 'deferred' after one or more milliseconds
|
||||||
*/
|
*/
|
||||||
function defer(func) {
|
var defer = restParam(function(func, args) {
|
||||||
return baseDelay(func, 1, arguments, 1);
|
return baseDelay(func, 1, args);
|
||||||
}
|
});
|
||||||
|
|
||||||
return defer;
|
return defer;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseDelay'], function(baseDelay) {
|
define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes `func` after `wait` milliseconds. Any additional arguments are
|
* Invokes `func` after `wait` milliseconds. Any additional arguments are
|
||||||
@@ -18,9 +18,9 @@ define(['../internal/baseDelay'], function(baseDelay) {
|
|||||||
* }, 1000, 'later');
|
* }, 1000, 'later');
|
||||||
* // => logs 'later' after one second
|
* // => logs 'later' after one second
|
||||||
*/
|
*/
|
||||||
function delay(func, wait) {
|
var delay = restParam(function(func, wait, args) {
|
||||||
return baseDelay(func, wait, arguments, 2);
|
return baseDelay(func, wait, args);
|
||||||
}
|
});
|
||||||
|
|
||||||
return delay;
|
return delay;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/createComposer'], function(createComposer) {
|
define(['../internal/createFlow'], function(createFlow) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that returns the result of invoking the provided
|
* Creates a function that returns the result of invoking the provided
|
||||||
@@ -20,7 +20,7 @@ define(['../internal/createComposer'], function(createComposer) {
|
|||||||
* addSquare(1, 2);
|
* addSquare(1, 2);
|
||||||
* // => 9
|
* // => 9
|
||||||
*/
|
*/
|
||||||
var flow = createComposer();
|
var flow = createFlow();
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/createComposer'], function(createComposer) {
|
define(['../internal/createFlow'], function(createFlow) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.flow` except that it creates a function that
|
* This method is like `_.flow` except that it creates a function that
|
||||||
@@ -20,7 +20,7 @@ define(['../internal/createComposer'], function(createComposer) {
|
|||||||
* addSquare(1, 2);
|
* addSquare(1, 2);
|
||||||
* // => 9
|
* // => 9
|
||||||
*/
|
*/
|
||||||
var flowRight = createComposer(true);
|
var flowRight = createFlow(true);
|
||||||
|
|
||||||
return flowRight;
|
return flowRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,10 +13,8 @@ define(['../internal/MapCache'], function(MapCache) {
|
|||||||
*
|
*
|
||||||
* **Note:** The cache is exposed as the `cache` property on the memoized
|
* **Note:** The cache is exposed as the `cache` property on the memoized
|
||||||
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
||||||
* constructor with one whose instances implement the ES `Map` method interface
|
* constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
|
||||||
* of `get`, `has`, and `set`. See the
|
* method interface of `get`, `has`, and `set`.
|
||||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
|
|
||||||
* for more details.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./before'], function(before) {
|
|||||||
/**
|
/**
|
||||||
* Creates a function that is restricted to invoking `func` once. Repeat calls
|
* Creates a function that is restricted to invoking `func` once. Repeat calls
|
||||||
* to the function return the value of the first call. The `func` is invoked
|
* to the function return the value of the first call. The `func` is invoked
|
||||||
* with the `this` binding of the created function.
|
* with the `this` binding and arguments of the created function.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
|
define(['../internal/createPartial'], function(createPartial) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var PARTIAL_FLAG = 32;
|
var PARTIAL_FLAG = 32;
|
||||||
@@ -18,7 +18,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to partially apply arguments to.
|
* @param {Function} func The function to partially apply arguments to.
|
||||||
* @param {...*} [args] The arguments to be partially applied.
|
* @param {...*} [partials] The arguments to be partially applied.
|
||||||
* @returns {Function} Returns the new partially applied function.
|
* @returns {Function} Returns the new partially applied function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -35,12 +35,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* greetFred('hi');
|
* greetFred('hi');
|
||||||
* // => 'hi fred'
|
* // => 'hi fred'
|
||||||
*/
|
*/
|
||||||
function partial(func) {
|
var partial = createPartial(PARTIAL_FLAG);
|
||||||
var partials = baseSlice(arguments, 1),
|
|
||||||
holders = replaceHolders(partials, partial.placeholder);
|
|
||||||
|
|
||||||
return createWrapper(func, PARTIAL_FLAG, null, partials, holders);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
partial.placeholder = {};
|
partial.placeholder = {};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
|
define(['../internal/createPartial'], function(createPartial) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var PARTIAL_RIGHT_FLAG = 64;
|
var PARTIAL_RIGHT_FLAG = 64;
|
||||||
@@ -17,7 +17,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to partially apply arguments to.
|
* @param {Function} func The function to partially apply arguments to.
|
||||||
* @param {...*} [args] The arguments to be partially applied.
|
* @param {...*} [partials] The arguments to be partially applied.
|
||||||
* @returns {Function} Returns the new partially applied function.
|
* @returns {Function} Returns the new partially applied function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -34,12 +34,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
|
|||||||
* sayHelloTo('fred');
|
* sayHelloTo('fred');
|
||||||
* // => 'hello fred'
|
* // => 'hello fred'
|
||||||
*/
|
*/
|
||||||
function partialRight(func) {
|
var partialRight = createPartial(PARTIAL_RIGHT_FLAG);
|
||||||
var partials = baseSlice(arguments, 1),
|
|
||||||
holders = replaceHolders(partials, partialRight.placeholder);
|
|
||||||
|
|
||||||
return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign default placeholders.
|
// Assign default placeholders.
|
||||||
partialRight.placeholder = {};
|
partialRight.placeholder = {};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define(['../internal/baseFlatten', '../internal/createWrapper'], function(baseFlatten, createWrapper) {
|
define(['../internal/baseFlatten', '../internal/createWrapper', './restParam'], function(baseFlatten, createWrapper, restParam) {
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var REARG_FLAG = 128;
|
var REARG_FLAG = 256;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that invokes `func` with arguments arranged according
|
* Creates a function that invokes `func` with arguments arranged according
|
||||||
@@ -31,10 +31,9 @@ define(['../internal/baseFlatten', '../internal/createWrapper'], function(baseFl
|
|||||||
* }, [1, 2, 3]);
|
* }, [1, 2, 3]);
|
||||||
* // => [3, 6, 9]
|
* // => [3, 6, 9]
|
||||||
*/
|
*/
|
||||||
function rearg(func) {
|
var rearg = restParam(function(func, indexes) {
|
||||||
var indexes = baseFlatten(arguments, false, false, 1);
|
return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes));
|
||||||
return createWrapper(func, REARG_FLAG, null, null, null, indexes);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return rearg;
|
return rearg;
|
||||||
});
|
});
|
||||||
|
|||||||
61
function/restParam.js
Normal file
61
function/restParam.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a function that invokes `func` with the `this` binding of the
|
||||||
|
* created function and arguments from `start` and beyond provided as an array.
|
||||||
|
*
|
||||||
|
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Function
|
||||||
|
* @param {Function} func The function to apply a rest parameter to.
|
||||||
|
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var say = _.restParam(function(what, names) {
|
||||||
|
* return what + ' ' + _.initial(names).join(', ') +
|
||||||
|
* (_.size(names) > 1 ? ', & ' : '') + _.last(names);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* say('hello', 'fred', 'barney', 'pebbles');
|
||||||
|
* // => 'hello fred, barney, & pebbles'
|
||||||
|
*/
|
||||||
|
function restParam(func, start) {
|
||||||
|
if (typeof func != 'function') {
|
||||||
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
|
}
|
||||||
|
start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
|
||||||
|
return function() {
|
||||||
|
var args = arguments,
|
||||||
|
index = -1,
|
||||||
|
length = nativeMax(args.length - start, 0),
|
||||||
|
rest = Array(length);
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
rest[index] = args[start + index];
|
||||||
|
}
|
||||||
|
switch (start) {
|
||||||
|
case 0: return func.call(this, rest);
|
||||||
|
case 1: return func.call(this, args[0], rest);
|
||||||
|
case 2: return func.call(this, args[0], args[1], rest);
|
||||||
|
}
|
||||||
|
var otherArgs = Array(start + 1);
|
||||||
|
index = -1;
|
||||||
|
while (++index < start) {
|
||||||
|
otherArgs[index] = args[index];
|
||||||
|
}
|
||||||
|
otherArgs[start] = rest;
|
||||||
|
return func.apply(this, otherArgs);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return restParam;
|
||||||
|
});
|
||||||
@@ -4,23 +4,24 @@ define([], function() {
|
|||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that invokes `func` with the `this` binding of the
|
* Creates a function that invokes `func` with the `this` binding of the created
|
||||||
* created function and the array of arguments provided to the created
|
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
|
||||||
* function much like [Function#apply](http://es5.github.io/#x15.3.4.3).
|
*
|
||||||
|
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to spread arguments over.
|
* @param {Function} func The function to spread arguments over.
|
||||||
* @returns {*} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var spread = _.spread(function(who, what) {
|
* var say = _.spread(function(who, what) {
|
||||||
* return who + ' says ' + what;
|
* return who + ' says ' + what;
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* spread(['Fred', 'hello']);
|
* say(['fred', 'hello']);
|
||||||
* // => 'Fred says hello'
|
* // => 'fred says hello'
|
||||||
*
|
*
|
||||||
* // with a Promise
|
* // with a Promise
|
||||||
* var numbers = Promise.all([
|
* var numbers = Promise.all([
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.forEach` for arrays without support for callback
|
* A specialized version of `_.forEach` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.forEachRight` for arrays without support for
|
* A specialized version of `_.forEachRight` for arrays without support for
|
||||||
* callback shorthands or `this` binding.
|
* callback shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.every` for arrays without support for callback
|
* A specialized version of `_.every` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.filter` for arrays without support for callback
|
* A specialized version of `_.filter` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.map` for arrays without support for callback
|
* A specialized version of `_.map` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.reduce` for arrays without support for callback
|
* A specialized version of `_.reduce` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.reduceRight` for arrays without support for
|
* A specialized version of `_.reduceRight` for arrays without support for
|
||||||
* callback shorthands or `this` binding.
|
* callback shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.some` for arrays without support for callback
|
* A specialized version of `_.some` for arrays without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
21
internal/arraySum.js
Normal file
21
internal/arraySum.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.sum` for arrays without support for iteratees.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to iterate over.
|
||||||
|
* @returns {number} Returns the sum.
|
||||||
|
*/
|
||||||
|
function arraySum(array) {
|
||||||
|
var length = array.length,
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
result += +array[length] || 0;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arraySum;
|
||||||
|
});
|
||||||
@@ -23,7 +23,7 @@ define(['./baseCopy', '../object/keys'], function(baseCopy, keys) {
|
|||||||
value = object[key],
|
value = object[key],
|
||||||
result = customizer(value, source[key], key, object, source);
|
result = customizer(value, source[key], key, object, source);
|
||||||
|
|
||||||
if ((result === result ? result !== value : value === value) ||
|
if ((result === result ? (result !== value) : (value === value)) ||
|
||||||
(typeof value == 'undefined' && !(key in object))) {
|
(typeof value == 'undefined' && !(key in object))) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
define(['./createWrapper'], function(createWrapper) {
|
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
|
||||||
var BIND_FLAG = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.bindAll` without support for individual
|
|
||||||
* method name arguments.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Object} object The object to bind and assign the bound methods to.
|
|
||||||
* @param {string[]} methodNames The object method names to bind.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
*/
|
|
||||||
function baseBindAll(object, methodNames) {
|
|
||||||
var index = -1,
|
|
||||||
length = methodNames.length;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var key = methodNames[index];
|
|
||||||
object[key] = createWrapper(object[key], BIND_FLAG, object);
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseBindAll;
|
|
||||||
});
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallback', '../utility/identity', './isBindable'], function(baseMatches, baseMatchesProperty, baseProperty, bindCallback, identity, isBindable) {
|
define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallback', '../utility/identity'], function(baseMatches, baseMatchesProperty, baseProperty, bindCallback, identity) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.callback` which supports specifying the
|
* The base implementation of `_.callback` which supports specifying the
|
||||||
@@ -13,9 +13,9 @@ 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' && isBindable(func))
|
return typeof thisArg == 'undefined'
|
||||||
? bindCallback(func, thisArg, argCount)
|
? func
|
||||||
: func;
|
: bindCallback(func, thisArg, argCount);
|
||||||
}
|
}
|
||||||
if (func == null) {
|
if (func == null) {
|
||||||
return identity;
|
return identity;
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ define(['./arrayCopy', './arrayEach', './baseCopy', './baseForOwn', './initClone
|
|||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to resolve the `toStringTag` of values.
|
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
* of values.
|
||||||
* for more details.
|
|
||||||
*/
|
*/
|
||||||
var objToString = objectProto.toString;
|
var objToString = objectProto.toString;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseSlice'], function(baseSlice) {
|
define([], function() {
|
||||||
|
|
||||||
/** 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,14 +13,14 @@ define(['./baseSlice'], function(baseSlice) {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to delay.
|
* @param {Function} func The function to delay.
|
||||||
* @param {number} wait The number of milliseconds to delay invocation.
|
* @param {number} wait The number of milliseconds to delay invocation.
|
||||||
* @param {Object} args The `arguments` object to slice and provide to `func`.
|
* @param {Object} args The arguments provide to `func`.
|
||||||
* @returns {number} Returns the timer id.
|
* @returns {number} Returns the timer id.
|
||||||
*/
|
*/
|
||||||
function baseDelay(func, wait, args, fromIndex) {
|
function baseDelay(func, wait, args) {
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait);
|
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseDelay;
|
return baseDelay;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseForOwn', './isLength', './toObject'], function(baseForOwn, isLength, toObject) {
|
define(['./baseForOwn', './createBaseEach'], function(baseForOwn, createBaseEach) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEach` without support for callback
|
* The base implementation of `_.forEach` without support for callback
|
||||||
@@ -9,21 +9,7 @@ define(['./baseForOwn', './isLength', './toObject'], function(baseForOwn, isLeng
|
|||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array|Object|string} Returns `collection`.
|
* @returns {Array|Object|string} Returns `collection`.
|
||||||
*/
|
*/
|
||||||
function baseEach(collection, iteratee) {
|
var baseEach = createBaseEach(baseForOwn);
|
||||||
var length = collection ? collection.length : 0;
|
|
||||||
if (!isLength(length)) {
|
|
||||||
return baseForOwn(collection, iteratee);
|
|
||||||
}
|
|
||||||
var index = -1,
|
|
||||||
iterable = toObject(collection);
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
if (iteratee(iterable[index], index, iterable) === false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseEach;
|
return baseEach;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseForOwnRight', './isLength', './toObject'], function(baseForOwnRight, isLength, toObject) {
|
define(['./baseForOwnRight', './createBaseEach'], function(baseForOwnRight, createBaseEach) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEachRight` without support for callback
|
* The base implementation of `_.forEachRight` without support for callback
|
||||||
@@ -9,19 +9,7 @@ define(['./baseForOwnRight', './isLength', './toObject'], function(baseForOwnRig
|
|||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array|Object|string} Returns `collection`.
|
* @returns {Array|Object|string} Returns `collection`.
|
||||||
*/
|
*/
|
||||||
function baseEachRight(collection, iteratee) {
|
var baseEachRight = createBaseEach(baseForOwnRight, true);
|
||||||
var length = collection ? collection.length : 0;
|
|
||||||
if (!isLength(length)) {
|
|
||||||
return baseForOwnRight(collection, iteratee);
|
|
||||||
}
|
|
||||||
var iterable = toObject(collection);
|
|
||||||
while (length--) {
|
|
||||||
if (iteratee(iterable[length], length, iterable) === false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseEachRight;
|
return baseEachRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define(['./baseEach'], function(baseEach) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.every` without support for callback
|
* The base implementation of `_.every` without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ define([], function() {
|
|||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
length = start > end ? 0 : end >>> 0;
|
length = start > end ? 0 : (end >>> 0);
|
||||||
start >>>= 0;
|
start >>>= 0;
|
||||||
|
|
||||||
while (start < length) {
|
while (start < length) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define(['./baseEach'], function(baseEach) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.filter` without support for callback
|
* The base implementation of `_.filter` without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
|
|||||||
26
internal/baseFindIndex.js
Normal file
26
internal/baseFindIndex.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
||||||
|
* support for callback shorthands and `this` binding.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to search.
|
||||||
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||||
|
*/
|
||||||
|
function baseFindIndex(array, predicate, fromRight) {
|
||||||
|
var length = array.length,
|
||||||
|
index = fromRight ? length : -1;
|
||||||
|
|
||||||
|
while ((fromRight ? index-- : ++index < length)) {
|
||||||
|
if (predicate(array[index], index, array)) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseFindIndex;
|
||||||
|
});
|
||||||
@@ -8,11 +8,10 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
|||||||
* @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 and `arguments` objects.
|
||||||
* @param {number} fromIndex The index to start from.
|
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
function baseFlatten(array, isDeep, isStrict) {
|
||||||
var index = fromIndex - 1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
resIndex = -1,
|
resIndex = -1,
|
||||||
result = [];
|
result = [];
|
||||||
@@ -23,7 +22,7 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
|
|||||||
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
if (isObjectLike(value) && isLength(value.length) && (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, 0);
|
value = baseFlatten(value, isDeep, isStrict);
|
||||||
}
|
}
|
||||||
var valIndex = -1,
|
var valIndex = -1,
|
||||||
valLength = value.length;
|
valLength = value.length;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./toObject'], function(toObject) {
|
define(['./createBaseFor'], function(createBaseFor) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
||||||
@@ -12,20 +12,7 @@ define(['./toObject'], function(toObject) {
|
|||||||
* @param {Function} keysFunc The function to get the keys of `object`.
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseFor(object, iteratee, keysFunc) {
|
var baseFor = createBaseFor();
|
||||||
var index = -1,
|
|
||||||
iterable = toObject(object),
|
|
||||||
props = keysFunc(object),
|
|
||||||
length = props.length;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var key = props[index];
|
|
||||||
if (iteratee(iterable[key], key, iterable) === false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseFor;
|
return baseFor;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./toObject'], function(toObject) {
|
define(['./createBaseFor'], function(createBaseFor) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is like `baseFor` except that it iterates over properties
|
* This function is like `baseFor` except that it iterates over properties
|
||||||
@@ -10,19 +10,7 @@ define(['./toObject'], function(toObject) {
|
|||||||
* @param {Function} keysFunc The function to get the keys of `object`.
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseForRight(object, iteratee, keysFunc) {
|
var baseForRight = createBaseFor(true);
|
||||||
var iterable = toObject(object),
|
|
||||||
props = keysFunc(object),
|
|
||||||
length = props.length;
|
|
||||||
|
|
||||||
while (length--) {
|
|
||||||
var key = props[length];
|
|
||||||
if (iteratee(iterable[key], key, iterable) === false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseForRight;
|
return baseForRight;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
define(['./baseEach', './isLength'], function(baseEach, isLength) {
|
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
||||||
var undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.invoke` which requires additional arguments
|
|
||||||
* to be provided as an array of arguments rather than individually.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
|
||||||
* @param {Function|string} methodName The name of the method to invoke or
|
|
||||||
* the function invoked per iteration.
|
|
||||||
* @param {Array} [args] The arguments to invoke the method with.
|
|
||||||
* @returns {Array} Returns the array of results.
|
|
||||||
*/
|
|
||||||
function baseInvoke(collection, methodName, args) {
|
|
||||||
var index = -1,
|
|
||||||
isFunc = typeof methodName == 'function',
|
|
||||||
length = collection ? collection.length : 0,
|
|
||||||
result = isLength(length) ? Array(length) : [];
|
|
||||||
|
|
||||||
baseEach(collection, function(value) {
|
|
||||||
var func = isFunc ? methodName : (value != null && value[methodName]);
|
|
||||||
result[++index] = func ? func.apply(value, args) : undefined;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseInvoke;
|
|
||||||
});
|
|
||||||
@@ -8,12 +8,12 @@ define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
|
|||||||
* @param {*} value The value to compare.
|
* @param {*} value The value to compare.
|
||||||
* @param {*} other The other value to compare.
|
* @param {*} other The other value to compare.
|
||||||
* @param {Function} [customizer] The function to customize comparing values.
|
* @param {Function} [customizer] The function to customize comparing values.
|
||||||
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
* @param {boolean} [isLoose] Specify performing partial comparisons.
|
||||||
* @param {Array} [stackA] Tracks traversed `value` objects.
|
* @param {Array} [stackA] Tracks traversed `value` objects.
|
||||||
* @param {Array} [stackB] Tracks traversed `other` objects.
|
* @param {Array} [stackB] Tracks traversed `other` objects.
|
||||||
* @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, isWhere, stackA, stackB) {
|
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
|
||||||
// Exit early for identical values.
|
// Exit early for identical values.
|
||||||
if (value === other) {
|
if (value === other) {
|
||||||
// Treat `+0` vs. `-0` as not equal.
|
// Treat `+0` vs. `-0` as not equal.
|
||||||
@@ -28,7 +28,7 @@ define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
|
|||||||
// Return `false` unless both values are `NaN`.
|
// Return `false` unless both values are `NaN`.
|
||||||
return value !== value && other !== other;
|
return value !== value && other !== other;
|
||||||
}
|
}
|
||||||
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB);
|
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseIsEqual;
|
return baseIsEqual;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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. */
|
||||||
@@ -12,9 +13,8 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to resolve the `toStringTag` of values.
|
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
* of values.
|
||||||
* for more details.
|
|
||||||
*/
|
*/
|
||||||
var objToString = objectProto.toString;
|
var objToString = objectProto.toString;
|
||||||
|
|
||||||
@@ -28,12 +28,12 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
* @param {Object} other The other object to compare.
|
* @param {Object} other The other object to compare.
|
||||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||||
* @param {Function} [customizer] The function to customize comparing objects.
|
* @param {Function} [customizer] The function to customize comparing objects.
|
||||||
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
* @param {boolean} [isLoose] Specify performing partial comparisons.
|
||||||
* @param {Array} [stackA=[]] Tracks traversed `value` objects.
|
* @param {Array} [stackA=[]] Tracks traversed `value` objects.
|
||||||
* @param {Array} [stackB=[]] Tracks traversed `other` objects.
|
* @param {Array} [stackB=[]] Tracks traversed `other` objects.
|
||||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseIsEqualDeep(object, other, equalFunc, customizer, isWhere, stackA, stackB) {
|
function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
|
||||||
var objIsArr = isArray(object),
|
var objIsArr = isArray(object),
|
||||||
othIsArr = isArray(other),
|
othIsArr = isArray(other),
|
||||||
objTag = arrayTag,
|
objTag = arrayTag,
|
||||||
@@ -55,21 +55,27 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
othIsArr = isTypedArray(other);
|
othIsArr = isTypedArray(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var objIsObj = objTag == objectTag,
|
var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)),
|
||||||
othIsObj = othTag == objectTag,
|
othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)),
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||||
return equalByTag(object, other, objTag);
|
return equalByTag(object, other, objTag);
|
||||||
}
|
}
|
||||||
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
if (isLoose) {
|
||||||
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
if (!isSameTag && !(objIsObj && othIsObj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||||
|
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||||
|
|
||||||
if (valWrapped || othWrapped) {
|
if (valWrapped || othWrapped) {
|
||||||
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB);
|
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
|
||||||
}
|
}
|
||||||
if (!isSameTag) {
|
if (!isSameTag) {
|
||||||
return false;
|
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.
|
||||||
@@ -86,7 +92,7 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
|
|||||||
stackA.push(object);
|
stackA.push(object);
|
||||||
stackB.push(other);
|
stackB.push(other);
|
||||||
|
|
||||||
var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB);
|
var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
|
||||||
|
|
||||||
stackA.pop();
|
stackA.pop();
|
||||||
stackB.pop();
|
stackB.pop();
|
||||||
|
|||||||
@@ -3,15 +3,9 @@ define(['./baseIsEqual'], function(baseIsEqual) {
|
|||||||
/** 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;
|
||||||
|
|
||||||
/** Used for native method references. */
|
|
||||||
var objectProto = Object.prototype;
|
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.isMatch` without support for callback
|
* The base implementation of `_.isMatch` without support for callback
|
||||||
* shorthands or `this` binding.
|
* shorthands and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
@@ -22,30 +16,27 @@ define(['./baseIsEqual'], function(baseIsEqual) {
|
|||||||
* @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, props, values, strictCompareFlags, customizer) {
|
||||||
var length = props.length;
|
|
||||||
if (object == null) {
|
|
||||||
return !length;
|
|
||||||
}
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
length = props.length,
|
||||||
noCustomizer = !customizer;
|
noCustomizer = !customizer;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if ((noCustomizer && strictCompareFlags[index])
|
if ((noCustomizer && strictCompareFlags[index])
|
||||||
? values[index] !== object[props[index]]
|
? values[index] !== object[props[index]]
|
||||||
: !hasOwnProperty.call(object, props[index])
|
: !(props[index] in object)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = -1;
|
index = -1;
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index];
|
var key = props[index],
|
||||||
if (noCustomizer && strictCompareFlags[index]) {
|
objValue = object[key],
|
||||||
var result = hasOwnProperty.call(object, key);
|
srcValue = values[index];
|
||||||
} else {
|
|
||||||
var objValue = object[key],
|
|
||||||
srcValue = values[index];
|
|
||||||
|
|
||||||
|
if (noCustomizer && strictCompareFlags[index]) {
|
||||||
|
var result = typeof objValue != 'undefined' || (key in object);
|
||||||
|
} else {
|
||||||
result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
||||||
if (typeof result == 'undefined') {
|
if (typeof result == 'undefined') {
|
||||||
result = baseIsEqual(srcValue, objValue, customizer, true);
|
result = baseIsEqual(srcValue, objValue, customizer, true);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define(['./baseEach'], function(baseEach) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.map` without support for callback shorthands
|
* The base implementation of `_.map` without support for callback shorthands
|
||||||
* or `this` binding.
|
* and `this` binding.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object|string} collection The collection to iterate over.
|
* @param {Array|Object|string} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(baseIsMatch, isStrictComparable, keys) {
|
define(['./baseIsMatch', '../utility/constant', './isStrictComparable', '../object/keys', './toObject'], function(baseIsMatch, constant, isStrictComparable, keys, toObject) {
|
||||||
|
|
||||||
/** Used for native method references. */
|
|
||||||
var objectProto = Object.prototype;
|
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matches` which does not clone `source`.
|
* The base implementation of `_.matches` which does not clone `source`.
|
||||||
@@ -17,13 +11,17 @@ define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(bas
|
|||||||
var props = keys(source),
|
var props = keys(source),
|
||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
|
if (!length) {
|
||||||
|
return constant(true);
|
||||||
|
}
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
var key = props[0],
|
var key = props[0],
|
||||||
value = source[key];
|
value = source[key];
|
||||||
|
|
||||||
if (isStrictComparable(value)) {
|
if (isStrictComparable(value)) {
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return object != null && object[key] === value && hasOwnProperty.call(object, key);
|
return object != null && object[key] === value &&
|
||||||
|
(typeof value != 'undefined' || (key in toObject(object)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +34,7 @@ define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(bas
|
|||||||
strictCompareFlags[length] = isStrictComparable(value);
|
strictCompareFlags[length] = isStrictComparable(value);
|
||||||
}
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return baseIsMatch(object, props, values, strictCompareFlags);
|
return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseIsEqual', './isStrictComparable'], function(baseIsEqual, isStrictComparable) {
|
define(['./baseIsEqual', './isStrictComparable', './toObject'], function(baseIsEqual, isStrictComparable, toObject) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
||||||
@@ -12,7 +12,8 @@ define(['./baseIsEqual', './isStrictComparable'], function(baseIsEqual, isStrict
|
|||||||
function baseMatchesProperty(key, value) {
|
function baseMatchesProperty(key, value) {
|
||||||
if (isStrictComparable(value)) {
|
if (isStrictComparable(value)) {
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return object != null && object[key] === value;
|
return object != null && object[key] === value &&
|
||||||
|
(typeof value != 'undefined' || (key in toObject(object)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ define(['./arrayEach', './baseForOwn', './baseMergeDeep', '../lang/isArray', './
|
|||||||
result = srcValue;
|
result = srcValue;
|
||||||
}
|
}
|
||||||
if ((isSrcArr || typeof result != 'undefined') &&
|
if ((isSrcArr || typeof result != 'undefined') &&
|
||||||
(isCommon || (result === result ? result !== value : value === value))) {
|
(isCommon || (result === result ? (result !== value) : (value === value)))) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isLength', '
|
|||||||
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
||||||
result = isArray(value)
|
result = isArray(value)
|
||||||
? value
|
? value
|
||||||
: (value ? arrayCopy(value) : []);
|
: ((value && value.length) ? arrayCopy(value) : []);
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
result = isArguments(value)
|
result = isArguments(value)
|
||||||
@@ -56,7 +56,7 @@ define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isLength', '
|
|||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||||
object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
|
object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
|
||||||
} else if (result === result ? result !== value : value === value) {
|
} else if (result === result ? (result !== value) : (value === value)) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
define(['./baseAt', './baseCompareAscending', './isIndex'], function(baseAt, baseCompareAscending, 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.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {number[]} indexes The indexes of elements to remove.
|
|
||||||
* @returns {Array} Returns the new array of removed elements.
|
|
||||||
*/
|
|
||||||
function basePullAt(array, indexes) {
|
|
||||||
var length = indexes.length,
|
|
||||||
result = baseAt(array, indexes);
|
|
||||||
|
|
||||||
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 basePullAt;
|
|
||||||
});
|
|
||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.reduce` and `_.reduceRight` without support
|
* The base implementation of `_.reduce` and `_.reduceRight` without support
|
||||||
* for callback shorthands or `this` binding, which iterates over `collection`
|
* for callback shorthands and `this` binding, which iterates over `collection`
|
||||||
* using the provided `eachFunc`.
|
* using the provided `eachFunc`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user