mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Remove aliases and rename _.callback to _.iteratee.
This commit is contained in:
committed by
John-David Dalton
parent
bd98779b3c
commit
1bfe25f1a5
265
lodash.src.js
265
lodash.src.js
@@ -1786,34 +1786,6 @@
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.callback` which supports specifying the
|
|
||||||
* number of arguments to provide to `func`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} [func=_.identity] The value to convert to a callback.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `func`.
|
|
||||||
* @param {number} [argCount] The number of arguments to provide to `func`.
|
|
||||||
* @returns {Function} Returns the callback.
|
|
||||||
*/
|
|
||||||
function baseCallback(func, thisArg, argCount) {
|
|
||||||
var type = typeof func;
|
|
||||||
if (type == 'function') {
|
|
||||||
return thisArg === undefined
|
|
||||||
? func
|
|
||||||
: bindCallback(func, thisArg, argCount);
|
|
||||||
}
|
|
||||||
if (func == null) {
|
|
||||||
return identity;
|
|
||||||
}
|
|
||||||
if (type == 'object') {
|
|
||||||
return baseMatches(func);
|
|
||||||
}
|
|
||||||
return thisArg === undefined
|
|
||||||
? property(func)
|
|
||||||
: baseMatchesProperty(func, thisArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.clone` without support for argument juggling
|
* The base implementation of `_.clone` without support for argument juggling
|
||||||
* and `this` binding `customizer` functions.
|
* and `this` binding `customizer` functions.
|
||||||
@@ -2142,6 +2114,34 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.iteratee` which supports specifying the
|
||||||
|
* number of arguments to provide to `func`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} [func=_.identity] The value to convert to an iteratee.
|
||||||
|
* @param {*} [thisArg] The `this` binding of `func`.
|
||||||
|
* @param {number} [argCount] The number of arguments to provide to `func`.
|
||||||
|
* @returns {Function} Returns the iteratee.
|
||||||
|
*/
|
||||||
|
function baseIteratee(func, thisArg, argCount) {
|
||||||
|
var type = typeof func;
|
||||||
|
if (type == 'function') {
|
||||||
|
return thisArg === undefined
|
||||||
|
? func
|
||||||
|
: bindCallback(func, thisArg, argCount);
|
||||||
|
}
|
||||||
|
if (func == null) {
|
||||||
|
return identity;
|
||||||
|
}
|
||||||
|
if (type == 'object') {
|
||||||
|
return baseMatches(func);
|
||||||
|
}
|
||||||
|
return thisArg === undefined
|
||||||
|
? property(func)
|
||||||
|
: baseMatchesProperty(func, thisArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
||||||
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
||||||
@@ -2769,7 +2769,7 @@
|
|||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
*/
|
*/
|
||||||
function baseSortByOrder(collection, iteratees, orders) {
|
function baseSortByOrder(collection, iteratees, orders) {
|
||||||
var callback = getCallback(),
|
var callback = getIteratee(),
|
||||||
index = -1;
|
index = -1;
|
||||||
|
|
||||||
iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); });
|
iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); });
|
||||||
@@ -3000,7 +3000,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `baseCallback` which only supports `this` binding
|
* A specialized version of `baseIteratee` which only supports `this` binding
|
||||||
* and specifying the number of arguments to provide to `func`.
|
* and specifying the number of arguments to provide to `func`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
@@ -3123,7 +3123,7 @@
|
|||||||
function createAggregator(setter, initializer) {
|
function createAggregator(setter, initializer) {
|
||||||
return function(collection, iteratee, thisArg) {
|
return function(collection, iteratee, thisArg) {
|
||||||
var result = initializer ? initializer() : {};
|
var result = initializer ? initializer() : {};
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
|
|
||||||
if (isArray(collection)) {
|
if (isArray(collection)) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -3364,7 +3364,7 @@
|
|||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
if (iteratee.length == 1) {
|
if (iteratee.length == 1) {
|
||||||
collection = isArray(collection) ? collection : toIterable(collection);
|
collection = isArray(collection) ? collection : toIterable(collection);
|
||||||
var result = arrayExtremum(collection, iteratee, comparator, exValue);
|
var result = arrayExtremum(collection, iteratee, comparator, exValue);
|
||||||
@@ -3386,7 +3386,7 @@
|
|||||||
*/
|
*/
|
||||||
function createFind(eachFunc, fromRight) {
|
function createFind(eachFunc, fromRight) {
|
||||||
return function(collection, predicate, thisArg) {
|
return function(collection, predicate, thisArg) {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
if (isArray(collection)) {
|
if (isArray(collection)) {
|
||||||
var index = baseFindIndex(collection, predicate, fromRight);
|
var index = baseFindIndex(collection, predicate, fromRight);
|
||||||
return index > -1 ? collection[index] : undefined;
|
return index > -1 ? collection[index] : undefined;
|
||||||
@@ -3407,7 +3407,7 @@
|
|||||||
if (!(array && array.length)) {
|
if (!(array && array.length)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
return baseFindIndex(array, predicate, fromRight);
|
return baseFindIndex(array, predicate, fromRight);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3421,7 +3421,7 @@
|
|||||||
*/
|
*/
|
||||||
function createFindKey(objectFunc) {
|
function createFindKey(objectFunc) {
|
||||||
return function(object, predicate, thisArg) {
|
return function(object, predicate, thisArg) {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
return baseFind(object, predicate, objectFunc, true);
|
return baseFind(object, predicate, objectFunc, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3539,7 +3539,7 @@
|
|||||||
function createObjectMapper(isMapKeys) {
|
function createObjectMapper(isMapKeys) {
|
||||||
return function(object, iteratee, thisArg) {
|
return function(object, iteratee, thisArg) {
|
||||||
var result = {};
|
var result = {};
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
|
|
||||||
baseForOwn(object, function(value, key, object) {
|
baseForOwn(object, function(value, key, object) {
|
||||||
var mapped = iteratee(value, key, object);
|
var mapped = iteratee(value, key, object);
|
||||||
@@ -3593,7 +3593,7 @@
|
|||||||
var initFromArray = arguments.length < 3;
|
var initFromArray = arguments.length < 3;
|
||||||
return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
|
return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
|
||||||
? arrayFunc(collection, iteratee, accumulator, initFromArray)
|
? arrayFunc(collection, iteratee, accumulator, initFromArray)
|
||||||
: baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
|
: baseReduce(collection, getIteratee(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3772,8 +3772,8 @@
|
|||||||
*/
|
*/
|
||||||
function createSortedIndex(retHighest) {
|
function createSortedIndex(retHighest) {
|
||||||
return function(array, value, iteratee, thisArg) {
|
return function(array, value, iteratee, thisArg) {
|
||||||
var callback = getCallback(iteratee);
|
var callback = getIteratee(iteratee);
|
||||||
return (iteratee == null && callback === baseCallback)
|
return (iteratee == null && callback === baseIteratee)
|
||||||
? binaryIndex(array, value, retHighest)
|
? binaryIndex(array, value, retHighest)
|
||||||
: binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest);
|
: binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest);
|
||||||
};
|
};
|
||||||
@@ -3989,21 +3989,6 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the appropriate "callback" function. If the `_.callback` method is
|
|
||||||
* customized this function returns the custom method, otherwise it returns
|
|
||||||
* the `baseCallback` function. If arguments are provided the chosen function
|
|
||||||
* is invoked with them and its result is returned.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @returns {Function} Returns the chosen function or its result.
|
|
||||||
*/
|
|
||||||
function getCallback(func, thisArg, argCount) {
|
|
||||||
var result = lodash.callback || callback;
|
|
||||||
result = result === callback ? baseCallback : result;
|
|
||||||
return argCount ? result(func, thisArg, argCount) : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets metadata for `func`.
|
* Gets metadata for `func`.
|
||||||
*
|
*
|
||||||
@@ -4052,6 +4037,21 @@
|
|||||||
return collection ? result(collection, target, fromIndex) : result;
|
return collection ? result(collection, target, fromIndex) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the appropriate "iteratee" function. If the `_.iteratee` method is
|
||||||
|
* customized this function returns the custom method, otherwise it returns
|
||||||
|
* the `baseIteratee` function. If arguments are provided the chosen function
|
||||||
|
* is invoked with them and its result is returned.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @returns {Function} Returns the chosen function or its result.
|
||||||
|
*/
|
||||||
|
function getIteratee(func, thisArg, argCount) {
|
||||||
|
var result = lodash.iteratee || iteratee;
|
||||||
|
result = result === iteratee ? baseIteratee : result;
|
||||||
|
return argCount ? result(func, thisArg, argCount) : result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the "length" property value of `object`.
|
* Gets the "length" property value of `object`.
|
||||||
*
|
*
|
||||||
@@ -4825,7 +4825,7 @@
|
|||||||
*/
|
*/
|
||||||
function dropRightWhile(array, predicate, thisArg) {
|
function dropRightWhile(array, predicate, thisArg) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, getCallback(predicate, thisArg, 3), true, true)
|
? baseWhile(array, getIteratee(predicate, thisArg, 3), true, true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4880,7 +4880,7 @@
|
|||||||
*/
|
*/
|
||||||
function dropWhile(array, predicate, thisArg) {
|
function dropWhile(array, predicate, thisArg) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, getCallback(predicate, thisArg, 3), true)
|
? baseWhile(array, getIteratee(predicate, thisArg, 3), true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5399,7 +5399,7 @@
|
|||||||
indexes = [],
|
indexes = [],
|
||||||
length = array.length;
|
length = array.length;
|
||||||
|
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (predicate(value, index, array)) {
|
if (predicate(value, index, array)) {
|
||||||
@@ -5649,7 +5649,7 @@
|
|||||||
*/
|
*/
|
||||||
function takeRightWhile(array, predicate, thisArg) {
|
function takeRightWhile(array, predicate, thisArg) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, getCallback(predicate, thisArg, 3), false, true)
|
? baseWhile(array, getIteratee(predicate, thisArg, 3), false, true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5704,7 +5704,7 @@
|
|||||||
*/
|
*/
|
||||||
function takeWhile(array, predicate, thisArg) {
|
function takeWhile(array, predicate, thisArg) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, getCallback(predicate, thisArg, 3))
|
? baseWhile(array, getIteratee(predicate, thisArg, 3))
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5786,8 +5786,8 @@
|
|||||||
iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
|
iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
|
||||||
isSorted = false;
|
isSorted = false;
|
||||||
}
|
}
|
||||||
var callback = getCallback();
|
var callback = getIteratee();
|
||||||
if (!(iteratee == null && callback === baseCallback)) {
|
if (!(iteratee == null && callback === baseIteratee)) {
|
||||||
iteratee = callback(iteratee, thisArg, 3);
|
iteratee = callback(iteratee, thisArg, 3);
|
||||||
}
|
}
|
||||||
return (isSorted && getIndexOf() === baseIndexOf)
|
return (isSorted && getIndexOf() === baseIndexOf)
|
||||||
@@ -6420,7 +6420,7 @@
|
|||||||
predicate = undefined;
|
predicate = undefined;
|
||||||
}
|
}
|
||||||
if (typeof predicate != 'function' || thisArg !== undefined) {
|
if (typeof predicate != 'function' || thisArg !== undefined) {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
return func(collection, predicate);
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
@@ -6476,7 +6476,7 @@
|
|||||||
*/
|
*/
|
||||||
function filter(collection, predicate, thisArg) {
|
function filter(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arrayFilter : baseFilter;
|
var func = isArray(collection) ? arrayFilter : baseFilter;
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
return func(collection, predicate);
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6877,7 +6877,7 @@
|
|||||||
*/
|
*/
|
||||||
function map(collection, iteratee, thisArg) {
|
function map(collection, iteratee, thisArg) {
|
||||||
var func = isArray(collection) ? arrayMap : baseMap;
|
var func = isArray(collection) ? arrayMap : baseMap;
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
return func(collection, iteratee);
|
return func(collection, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7072,7 +7072,7 @@
|
|||||||
*/
|
*/
|
||||||
function reject(collection, predicate, thisArg) {
|
function reject(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arrayFilter : baseFilter;
|
var func = isArray(collection) ? arrayFilter : baseFilter;
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
return func(collection, function(value, index, collection) {
|
return func(collection, function(value, index, collection) {
|
||||||
return !predicate(value, index, collection);
|
return !predicate(value, index, collection);
|
||||||
});
|
});
|
||||||
@@ -7217,7 +7217,7 @@
|
|||||||
predicate = undefined;
|
predicate = undefined;
|
||||||
}
|
}
|
||||||
if (typeof predicate != 'function' || thisArg !== undefined) {
|
if (typeof predicate != 'function' || thisArg !== undefined) {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getIteratee(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
return func(collection, predicate);
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
@@ -7278,7 +7278,7 @@
|
|||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
var index = -1;
|
var index = -1;
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
|
|
||||||
var result = baseMap(collection, function(value, key, collection) {
|
var result = baseMap(collection, function(value, key, collection) {
|
||||||
return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };
|
return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };
|
||||||
@@ -10223,7 +10223,7 @@
|
|||||||
*/
|
*/
|
||||||
function transform(object, iteratee, accumulator, thisArg) {
|
function transform(object, iteratee, accumulator, thisArg) {
|
||||||
var isArr = isArray(object) || isTypedArray(object);
|
var isArr = isArray(object) || isTypedArray(object);
|
||||||
iteratee = getCallback(iteratee, thisArg, 4);
|
iteratee = getIteratee(iteratee, thisArg, 4);
|
||||||
|
|
||||||
if (accumulator == null) {
|
if (accumulator == null) {
|
||||||
if (isArr || isObject(object)) {
|
if (isArr || isObject(object)) {
|
||||||
@@ -11293,53 +11293,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
|
||||||
* and arguments of the created function. If `func` is a property name the
|
|
||||||
* created callback returns the property value for a given element. If `func`
|
|
||||||
* is an object the created callback returns `true` for elements that contain
|
|
||||||
* the equivalent object properties, otherwise it returns `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @alias iteratee
|
|
||||||
* @category Utility
|
|
||||||
* @param {*} [func=_.identity] The value to convert to a callback.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `func`.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Function} Returns the callback.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'age': 36 },
|
|
||||||
* { 'user': 'fred', 'age': 40 }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // wrap to create custom callback shorthands
|
|
||||||
* _.callback = _.wrap(_.callback, function(callback, func, thisArg) {
|
|
||||||
* var match = /^(.+?)__([gl]t)(.+)$/.exec(func);
|
|
||||||
* if (!match) {
|
|
||||||
* return callback(func, thisArg);
|
|
||||||
* }
|
|
||||||
* return function(object) {
|
|
||||||
* return match[2] == 'gt'
|
|
||||||
* ? object[match[1]] > match[3]
|
|
||||||
* : object[match[1]] < match[3];
|
|
||||||
* };
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* _.filter(users, 'age__gt36');
|
|
||||||
* // => [{ 'user': 'fred', 'age': 40 }]
|
|
||||||
*/
|
|
||||||
function callback(func, thisArg, guard) {
|
|
||||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
|
||||||
thisArg = undefined;
|
|
||||||
}
|
|
||||||
return isObjectLike(func)
|
|
||||||
? matches(func)
|
|
||||||
: baseCallback(func, thisArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that returns `value`.
|
* Creates a function that returns `value`.
|
||||||
*
|
*
|
||||||
@@ -11381,6 +11334,53 @@
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
||||||
|
* and arguments of the created function. If `func` is a property name the
|
||||||
|
* created callback returns the property value for a given element. If `func`
|
||||||
|
* is an object the created callback returns `true` for elements that contain
|
||||||
|
* the equivalent object properties, otherwise it returns `false`.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @alias iteratee
|
||||||
|
* @category Utility
|
||||||
|
* @param {*} [func=_.identity] The value to convert to a callback.
|
||||||
|
* @param {*} [thisArg] The `this` binding of `func`.
|
||||||
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||||
|
* @returns {Function} Returns the callback.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var users = [
|
||||||
|
* { 'user': 'barney', 'age': 36 },
|
||||||
|
* { 'user': 'fred', 'age': 40 }
|
||||||
|
* ];
|
||||||
|
*
|
||||||
|
* // wrap to create custom callback shorthands
|
||||||
|
* _.iteratee = _.wrap(_.iteratee, function(callback, func, thisArg) {
|
||||||
|
* var match = /^(.+?)__([gl]t)(.+)$/.exec(func);
|
||||||
|
* if (!match) {
|
||||||
|
* return callback(func, thisArg);
|
||||||
|
* }
|
||||||
|
* return function(object) {
|
||||||
|
* return match[2] == 'gt'
|
||||||
|
* ? object[match[1]] > match[3]
|
||||||
|
* : object[match[1]] < match[3];
|
||||||
|
* };
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* _.filter(users, 'age__gt36');
|
||||||
|
* // => [{ 'user': 'fred', 'age': 40 }]
|
||||||
|
*/
|
||||||
|
function iteratee(func, thisArg, guard) {
|
||||||
|
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||||
|
thisArg = undefined;
|
||||||
|
}
|
||||||
|
return isObjectLike(func)
|
||||||
|
? matches(func)
|
||||||
|
: baseIteratee(func, thisArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that performs a deep comparison between a given object
|
* Creates a function that performs a deep comparison between a given object
|
||||||
* and `source`, returning `true` if the given object has equivalent property
|
* and `source`, returning `true` if the given object has equivalent property
|
||||||
@@ -12018,7 +12018,7 @@
|
|||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
iteratee = getCallback(iteratee, thisArg, 3);
|
iteratee = getIteratee(iteratee, thisArg, 3);
|
||||||
return iteratee.length == 1
|
return iteratee.length == 1
|
||||||
? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)
|
? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)
|
||||||
: baseSum(collection, iteratee);
|
: baseSum(collection, iteratee);
|
||||||
@@ -12056,7 +12056,6 @@
|
|||||||
lodash.bind = bind;
|
lodash.bind = bind;
|
||||||
lodash.bindAll = bindAll;
|
lodash.bindAll = bindAll;
|
||||||
lodash.bindKey = bindKey;
|
lodash.bindKey = bindKey;
|
||||||
lodash.callback = callback;
|
|
||||||
lodash.chain = chain;
|
lodash.chain = chain;
|
||||||
lodash.chunk = chunk;
|
lodash.chunk = chunk;
|
||||||
lodash.compact = compact;
|
lodash.compact = compact;
|
||||||
@@ -12094,6 +12093,7 @@
|
|||||||
lodash.intersection = intersection;
|
lodash.intersection = intersection;
|
||||||
lodash.invert = invert;
|
lodash.invert = invert;
|
||||||
lodash.invoke = invoke;
|
lodash.invoke = invoke;
|
||||||
|
lodash.iteratee = iteratee;
|
||||||
lodash.keys = keys;
|
lodash.keys = keys;
|
||||||
lodash.keysIn = keysIn;
|
lodash.keysIn = keysIn;
|
||||||
lodash.map = map;
|
lodash.map = map;
|
||||||
@@ -12159,18 +12159,8 @@
|
|||||||
lodash.zipWith = zipWith;
|
lodash.zipWith = zipWith;
|
||||||
|
|
||||||
// Add aliases.
|
// Add aliases.
|
||||||
lodash.backflow = flowRight;
|
|
||||||
lodash.collect = map;
|
|
||||||
lodash.compose = flowRight;
|
|
||||||
lodash.each = forEach;
|
lodash.each = forEach;
|
||||||
lodash.eachRight = forEachRight;
|
lodash.eachRight = forEachRight;
|
||||||
lodash.extend = assign;
|
|
||||||
lodash.iteratee = callback;
|
|
||||||
lodash.methods = functions;
|
|
||||||
lodash.object = zipObject;
|
|
||||||
lodash.select = filter;
|
|
||||||
lodash.tail = rest;
|
|
||||||
lodash.unique = uniq;
|
|
||||||
|
|
||||||
// Add functions to `lodash.prototype`.
|
// Add functions to `lodash.prototype`.
|
||||||
mixin(lodash, lodash);
|
mixin(lodash, lodash);
|
||||||
@@ -12266,17 +12256,8 @@
|
|||||||
lodash.uniqueId = uniqueId;
|
lodash.uniqueId = uniqueId;
|
||||||
lodash.words = words;
|
lodash.words = words;
|
||||||
|
|
||||||
// Add aliases.
|
// Add aliases
|
||||||
lodash.all = every;
|
|
||||||
lodash.any = some;
|
|
||||||
lodash.contains = includes;
|
|
||||||
lodash.eq = isEqual;
|
lodash.eq = isEqual;
|
||||||
lodash.detect = find;
|
|
||||||
lodash.foldl = reduce;
|
|
||||||
lodash.foldr = reduceRight;
|
|
||||||
lodash.head = first;
|
|
||||||
lodash.include = includes;
|
|
||||||
lodash.inject = reduce;
|
|
||||||
|
|
||||||
mixin(lodash, (function() {
|
mixin(lodash, (function() {
|
||||||
var source = {};
|
var source = {};
|
||||||
@@ -12348,7 +12329,7 @@
|
|||||||
|
|
||||||
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
||||||
var result = this.clone();
|
var result = this.clone();
|
||||||
result.__iteratees__.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type });
|
result.__iteratees__.push({ 'iteratee': getIteratee(iteratee, thisArg, 1), 'type': type });
|
||||||
result.__filtered__ = result.__filtered__ || isFilter;
|
result.__filtered__ = result.__filtered__ || isFilter;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -12387,7 +12368,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
||||||
predicate = getCallback(predicate, thisArg, 1);
|
predicate = getIteratee(predicate, thisArg, 1);
|
||||||
return this.filter(function(value) {
|
return this.filter(function(value) {
|
||||||
return !predicate(value);
|
return !predicate(value);
|
||||||
});
|
});
|
||||||
@@ -12524,12 +12505,6 @@
|
|||||||
lodash.prototype.toString = wrapperToString;
|
lodash.prototype.toString = wrapperToString;
|
||||||
lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
|
lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
|
||||||
|
|
||||||
// Add function aliases to the `lodash` wrapper.
|
|
||||||
lodash.prototype.collect = lodash.prototype.map;
|
|
||||||
lodash.prototype.head = lodash.prototype.first;
|
|
||||||
lodash.prototype.select = lodash.prototype.filter;
|
|
||||||
lodash.prototype.tail = lodash.prototype.rest;
|
|
||||||
|
|
||||||
return lodash;
|
return lodash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1258
test/test.js
1258
test/test.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user