mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Remove baseIteratee and castFunction.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.forEach` for arrays without support for
|
* A specialized version of `_.forEach` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.forEachRight` for arrays without support for
|
* A specialized version of `_.forEachRight` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.every` for arrays without support for
|
* A specialized version of `_.every` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.filter` for arrays without support for
|
* A specialized version of `_.filter` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.map` for arrays without support for iteratee
|
* A specialized version of `_.map` for arrays.
|
||||||
* shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.reduce` for arrays without support for
|
* A specialized version of `_.reduce` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.reduceRight` for arrays without support for
|
* A specialized version of `_.reduceRight` for arrays.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* A specialized version of `_.some` for arrays without support for iteratee
|
* A specialized version of `_.some` for arrays.
|
||||||
* shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} [array] The array to iterate over.
|
* @param {Array} [array] The array to iterate over.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const LARGE_ARRAY_SIZE = 200;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.difference` without support
|
* The base implementation of methods like `_.difference` without support
|
||||||
* for excluding multiple arrays or iteratee shorthands.
|
* for excluding multiple arrays.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import baseForOwn from './_baseForOwn.js';
|
|||||||
import createBaseEach from './_createBaseEach.js';
|
import createBaseEach from './_createBaseEach.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
* The base implementation of `_.forEach`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import baseForOwnRight from './_baseForOwnRight.js';
|
|||||||
import createBaseEach from './_createBaseEach.js';
|
import createBaseEach from './_createBaseEach.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEachRight` without support for iteratee shorthands.
|
* The base implementation of `_.forEachRight`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import baseEach from './_baseEach.js';
|
import baseEach from './_baseEach.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.every` without support for iteratee shorthands.
|
* The base implementation of `_.every`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import baseEach from './_baseEach.js';
|
import baseEach from './_baseEach.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.filter` without support for iteratee shorthands.
|
* The base implementation of `_.filter`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
* The base implementation of `_.findIndex` and `_.findLastIndex`.
|
||||||
* support for iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.findKey` and `_.findLastKey`,
|
* The base implementation of methods like `_.findKey` and `_.findLastKey`
|
||||||
* without support for iteratee shorthands, which iterates over `collection`
|
* which iterates over `collection` using `eachFunc`.
|
||||||
* using `eachFunc`.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to inspect.
|
* @param {Array|Object} collection The collection to inspect.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import baseFor from './_baseFor.js';
|
|||||||
import keys from './keys.js';
|
import keys from './keys.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
* The base implementation of `_.forOwn`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import baseForRight from './_baseForRight.js';
|
|||||||
import keys from './keys.js';
|
import keys from './keys.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forOwnRight` without support for iteratee shorthands.
|
* The base implementation of `_.forOwnRight`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import cacheHas from './_cacheHas.js';
|
|||||||
const nativeMin = Math.min;
|
const nativeMin = Math.min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.intersection`, without support
|
* The base implementation of methods like `_.intersection` that accepts an
|
||||||
* for iteratee shorthands, that accepts an array of arrays to inspect.
|
* array of arrays to inspect.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} arrays The arrays to inspect.
|
* @param {Array} arrays The arrays to inspect.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const COMPARE_PARTIAL_FLAG = 1;
|
|||||||
const COMPARE_UNORDERED_FLAG = 2;
|
const COMPARE_UNORDERED_FLAG = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
* The base implementation of `_.isMatch`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import baseMatches from './_baseMatches.js';
|
|
||||||
import baseMatchesProperty from './_baseMatchesProperty.js';
|
|
||||||
import identity from './identity.js';
|
|
||||||
import isArray from './isArray.js';
|
|
||||||
import property from './property.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.iteratee`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|
||||||
* @returns {Function} Returns the iteratee.
|
|
||||||
*/
|
|
||||||
function baseIteratee(value) {
|
|
||||||
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
|
||||||
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
|
||||||
if (typeof value == 'function') {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (value == null) {
|
|
||||||
return identity;
|
|
||||||
}
|
|
||||||
if (typeof value == 'object') {
|
|
||||||
return isArray(value)
|
|
||||||
? baseMatchesProperty(value[0], value[1])
|
|
||||||
: baseMatches(value);
|
|
||||||
}
|
|
||||||
return property(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default baseIteratee;
|
|
||||||
@@ -2,7 +2,7 @@ import baseEach from './_baseEach.js';
|
|||||||
import isArrayLike from './isArrayLike.js';
|
import isArrayLike from './isArrayLike.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.map` without support for iteratee shorthands.
|
* The base implementation of `_.map`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
20
_baseMean.js
20
_baseMean.js
@@ -1,20 +0,0 @@
|
|||||||
import baseSum from './_baseSum.js';
|
|
||||||
|
|
||||||
/** Used as references for various `Number` constants. */
|
|
||||||
const NAN = 0 / 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.mean` and `_.meanBy` without support for
|
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to iterate over.
|
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
|
||||||
* @returns {number} Returns the mean.
|
|
||||||
*/
|
|
||||||
function baseMean(array, iteratee) {
|
|
||||||
const length = array == null ? 0 : array.length;
|
|
||||||
return length ? (baseSum(array, iteratee) / length) : NAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default baseMean;
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseMap from './_baseMap.js';
|
import baseMap from './_baseMap.js';
|
||||||
import baseSortBy from './_baseSortBy.js';
|
import baseSortBy from './_baseSortBy.js';
|
||||||
import compareMultiple from './_compareMultiple.js';
|
import compareMultiple from './_compareMultiple.js';
|
||||||
@@ -16,7 +15,7 @@ import identity from './identity.js';
|
|||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
iteratees = arrayMap(iteratees.length ? iteratees : [identity], value => baseIteratee(value));
|
iteratees = iteratees.length ? iteratees : [identity];
|
||||||
|
|
||||||
const result = baseMap(collection, (value, key, collection) => {
|
const result = baseMap(collection, (value, key, collection) => {
|
||||||
const criteria = arrayMap(iteratees, iteratee => iteratee(value));
|
const criteria = arrayMap(iteratees, iteratee => iteratee(value));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import baseSet from './_baseSet.js';
|
|||||||
import castPath from './_castPath.js';
|
import castPath from './_castPath.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
* The base implementation of `_.pickBy`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ const arrayProto = Array.prototype;
|
|||||||
const splice = arrayProto.splice;
|
const splice = arrayProto.splice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
* The base implementation of `_.pullAllBy`.
|
||||||
* shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to modify.
|
* @param {Array} array The array to modify.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
* The base implementation of `_.reduce` and `_.reduceRight` which iterates
|
||||||
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
* over `collection` using `eachFunc`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import baseEach from './_baseEach.js';
|
import baseEach from './_baseEach.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.some` without support for iteratee shorthands.
|
* The base implementation of `_.some`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import eq from './eq.js';
|
import eq from './eq.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
|
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy`.
|
||||||
* support for iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.sum` and `_.sumBy` without support for
|
* The base implementation of `_.sum` and `_.sumBy`.
|
||||||
* iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.times` without support for iteratee shorthands
|
* The base implementation of `_.times` without support for max array length checks.
|
||||||
* or max array length checks.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {number} n The number of times to invoke `iteratee`.
|
* @param {number} n The number of times to invoke `iteratee`.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import setToArray from './_setToArray.js';
|
|||||||
const LARGE_ARRAY_SIZE = 200;
|
const LARGE_ARRAY_SIZE = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
* The base implementation of `_.uniqBy`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import baseSlice from './_baseSlice.js';
|
import baseSlice from './_baseSlice.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.dropWhile` and `_.takeWhile`
|
* The base implementation of methods like `_.dropWhile` and `_.takeWhile`.
|
||||||
* without support for iteratee shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import baseFlatten from './_baseFlatten.js';
|
|||||||
import baseUniq from './_baseUniq.js';
|
import baseUniq from './_baseUniq.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.xor`, without support for
|
* The base implementation of methods like `_.xor` which accepts an array of
|
||||||
* iteratee shorthands, that accepts an array of arrays to inspect.
|
* arrays to inspect.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} arrays The arrays to inspect.
|
* @param {Array} arrays The arrays to inspect.
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import identity from './identity.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Casts `value` to `identity` if it's not a function.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to inspect.
|
|
||||||
* @returns {Function} Returns cast function.
|
|
||||||
*/
|
|
||||||
function castFunction(value) {
|
|
||||||
return typeof value == 'function' ? value : identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default castFunction;
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayAggregator from './_arrayAggregator.js';
|
import arrayAggregator from './_arrayAggregator.js';
|
||||||
import baseAggregator from './_baseAggregator.js';
|
import baseAggregator from './_baseAggregator.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +14,7 @@ function createAggregator(setter, initializer) {
|
|||||||
return (collection, iteratee) => {
|
return (collection, iteratee) => {
|
||||||
const func = isArray(collection) ? arrayAggregator : baseAggregator;
|
const func = isArray(collection) ? arrayAggregator : baseAggregator;
|
||||||
const accumulator = initializer ? initializer() : {};
|
const accumulator = initializer ? initializer() : {};
|
||||||
return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
|
return func(collection, setter, iteratee, accumulator);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArrayLike from './isArrayLike.js';
|
import isArrayLike from './isArrayLike.js';
|
||||||
import keys from './keys.js';
|
import keys from './keys.js';
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ function createFind(findIndexFunc) {
|
|||||||
let iteratee;
|
let iteratee;
|
||||||
const iterable = Object(collection);
|
const iterable = Object(collection);
|
||||||
if (!isArrayLike(collection)) {
|
if (!isArrayLike(collection)) {
|
||||||
iteratee = baseIteratee(predicate, 3);
|
|
||||||
collection = keys(collection);
|
collection = keys(collection);
|
||||||
predicate = key => iteratee(iterable[key], key, iterable);
|
predicate = key => iteratee(iterable[key], key, iterable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import baseInverter from './_baseInverter.js';
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} setter The function to set accumulator values.
|
* @param {Function} setter The function to set accumulator values.
|
||||||
* @param {Function} toIteratee The function to resolve iteratees.
|
|
||||||
* @returns {Function} Returns the new inverter function.
|
* @returns {Function} Returns the new inverter function.
|
||||||
*/
|
*/
|
||||||
function createInverter(setter, toIteratee) {
|
function createInverter(setter) {
|
||||||
return (object, iteratee) => baseInverter(object, setter, toIteratee(iteratee), {});
|
return (object, iteratee) => baseInverter(object, setter, iteratee, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createInverter;
|
export default createInverter;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import apply from './_apply.js';
|
import apply from './_apply.js';
|
||||||
import arrayMap from './_arrayMap.js';
|
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function like `_.over`.
|
* Creates a function like `_.over`.
|
||||||
@@ -11,8 +9,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return (...iteratees) => {
|
return (...iteratees) => {
|
||||||
iteratees = arrayMap(iteratees, iteratee => baseIteratee(iteratee));
|
return function(...args) {
|
||||||
return (...args) => {
|
|
||||||
const thisArg = this;
|
const thisArg = this;
|
||||||
return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args));
|
return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args));
|
||||||
};
|
};
|
||||||
|
|||||||
4
cond.js
4
cond.js
@@ -1,6 +1,5 @@
|
|||||||
import apply from './_apply.js';
|
import apply from './_apply.js';
|
||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/** Error message constants. */
|
/** Error message constants. */
|
||||||
const FUNC_ERROR_TEXT = 'Expected a function';
|
const FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
@@ -36,13 +35,12 @@ const FUNC_ERROR_TEXT = 'Expected a function';
|
|||||||
*/
|
*/
|
||||||
function cond(pairs) {
|
function cond(pairs) {
|
||||||
const length = pairs == null ? 0 : pairs.length;
|
const length = pairs == null ? 0 : pairs.length;
|
||||||
const toIteratee = baseIteratee;
|
|
||||||
|
|
||||||
pairs = !length ? [] : arrayMap(pairs, pair => {
|
pairs = !length ? [] : arrayMap(pairs, pair => {
|
||||||
if (typeof pair[1] != 'function') {
|
if (typeof pair[1] != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return [toIteratee(pair[0]), pair[1]];
|
return [pair[0], pair[1]];
|
||||||
});
|
});
|
||||||
|
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
|
|||||||
@@ -18,16 +18,12 @@ const hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* @since 0.5.0
|
* @since 0.5.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
|
* @param {Function} iteratee The iteratee to transform keys.
|
||||||
* @returns {Object} Returns the composed aggregate object.
|
* @returns {Object} Returns the composed aggregate object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.countBy([6.1, 4.2, 6.3], Math.floor);
|
* _.countBy([6.1, 4.2, 6.3], Math.floor);
|
||||||
* // => { '4': 1, '6': 2 }
|
* // => { '4': 1, '6': 2 }
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.countBy(['one', 'two', 'three'], 'length');
|
|
||||||
* // => { '3': 2, '5': 1 }
|
|
||||||
*/
|
*/
|
||||||
const countBy = createAggregator((result, value, key) => {
|
const countBy = createAggregator((result, value, key) => {
|
||||||
if (hasOwnProperty.call(result, key)) {
|
if (hasOwnProperty.call(result, key)) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import baseDifference from './_baseDifference.js';
|
import baseDifference from './_baseDifference.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
import baseFlatten from './_baseFlatten.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js';
|
import isArrayLikeObject from './isArrayLikeObject.js';
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
|
|
||||||
@@ -19,16 +18,12 @@ import last from './last.js';
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {...Array} [values] The values to exclude.
|
* @param {...Array} [values] The values to exclude.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new array of filtered values.
|
* @returns {Array} Returns the new array of filtered values.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
* _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
||||||
* // => [1.2]
|
* // => [1.2]
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
|
|
||||||
* // => [{ 'x': 2 }]
|
|
||||||
*/
|
*/
|
||||||
function differenceBy(array, ...values) {
|
function differenceBy(array, ...values) {
|
||||||
let iteratee = last(values);
|
let iteratee = last(values);
|
||||||
@@ -36,7 +31,7 @@ function differenceBy(array, ...values) {
|
|||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2))
|
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), iteratee)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseWhile from './_baseWhile.js';
|
import baseWhile from './_baseWhile.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js';
|
|||||||
*
|
*
|
||||||
* _.dropRightWhile(users, function(o) { return !o.active; });
|
* _.dropRightWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['barney']
|
* // => objects for ['barney']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
|
|
||||||
* // => objects for ['barney', 'fred']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.dropRightWhile(users, ['active', false]);
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.dropRightWhile(users, 'active');
|
|
||||||
* // => objects for ['barney', 'fred', 'pebbles']
|
|
||||||
*/
|
*/
|
||||||
function dropRightWhile(array, predicate) {
|
function dropRightWhile(array, predicate) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, baseIteratee(predicate, 3), true, true)
|
? baseWhile(array, predicate, true, true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
dropWhile.js
17
dropWhile.js
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseWhile from './_baseWhile.js';
|
import baseWhile from './_baseWhile.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js';
|
|||||||
*
|
*
|
||||||
* _.dropWhile(users, function(o) { return !o.active; });
|
* _.dropWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['pebbles']
|
* // => objects for ['pebbles']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.dropWhile(users, { 'user': 'barney', 'active': false });
|
|
||||||
* // => objects for ['fred', 'pebbles']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.dropWhile(users, ['active', false]);
|
|
||||||
* // => objects for ['pebbles']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.dropWhile(users, 'active');
|
|
||||||
* // => objects for ['barney', 'fred', 'pebbles']
|
|
||||||
*/
|
*/
|
||||||
function dropWhile(array, predicate) {
|
function dropWhile(array, predicate) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, baseIteratee(predicate, 3), true)
|
? baseWhile(array, predicate, true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
every.js
22
every.js
@@ -1,6 +1,5 @@
|
|||||||
import arrayEvery from './_arrayEvery.js';
|
import arrayEvery from './_arrayEvery.js';
|
||||||
import baseEvery from './_baseEvery.js';
|
import baseEvery from './_baseEvery.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isIterateeCall from './_isIterateeCall.js';
|
import isIterateeCall from './_isIterateeCall.js';
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ import isIterateeCall from './_isIterateeCall.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||||
* else `false`.
|
* else `false`.
|
||||||
@@ -27,30 +26,13 @@ import isIterateeCall from './_isIterateeCall.js';
|
|||||||
*
|
*
|
||||||
* _.every([true, 1, null, 'yes'], Boolean);
|
* _.every([true, 1, null, 'yes'], Boolean);
|
||||||
* // => false
|
* // => false
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'age': 36, 'active': false },
|
|
||||||
* { 'user': 'fred', 'age': 40, 'active': false }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.every(users, { 'user': 'barney', 'active': false });
|
|
||||||
* // => false
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.every(users, ['active', false]);
|
|
||||||
* // => true
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.every(users, 'active');
|
|
||||||
* // => false
|
|
||||||
*/
|
*/
|
||||||
function every(collection, predicate, guard) {
|
function every(collection, predicate, guard) {
|
||||||
const func = isArray(collection) ? arrayEvery : baseEvery;
|
const func = isArray(collection) ? arrayEvery : baseEvery;
|
||||||
if (guard && isIterateeCall(collection, predicate, guard)) {
|
if (guard && isIterateeCall(collection, predicate, guard)) {
|
||||||
predicate = undefined;
|
predicate = undefined;
|
||||||
}
|
}
|
||||||
return func(collection, baseIteratee(predicate, 3));
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default every;
|
export default every;
|
||||||
|
|||||||
17
filter.js
17
filter.js
@@ -1,6 +1,5 @@
|
|||||||
import arrayFilter from './_arrayFilter.js';
|
import arrayFilter from './_arrayFilter.js';
|
||||||
import baseFilter from './_baseFilter.js';
|
import baseFilter from './_baseFilter.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +14,7 @@ import isArray from './isArray.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new filtered array.
|
* @returns {Array} Returns the new filtered array.
|
||||||
* @see _.reject
|
* @see _.reject
|
||||||
* @example
|
* @example
|
||||||
@@ -27,22 +26,10 @@ import isArray from './isArray.js';
|
|||||||
*
|
*
|
||||||
* _.filter(users, function(o) { return !o.active; });
|
* _.filter(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['fred']
|
* // => objects for ['fred']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.filter(users, { 'age': 36, 'active': true });
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.filter(users, ['active', false]);
|
|
||||||
* // => objects for ['fred']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.filter(users, 'active');
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*/
|
*/
|
||||||
function filter(collection, predicate) {
|
function filter(collection, predicate) {
|
||||||
const func = isArray(collection) ? arrayFilter : baseFilter;
|
const func = isArray(collection) ? arrayFilter : baseFilter;
|
||||||
return func(collection, baseIteratee(predicate, 3));
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default filter;
|
export default filter;
|
||||||
|
|||||||
14
find.js
14
find.js
@@ -11,7 +11,7 @@ import findIndex from './findIndex.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to inspect.
|
* @param {Array|Object} collection The collection to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param {number} [fromIndex=0] The index to search from.
|
* @param {number} [fromIndex=0] The index to search from.
|
||||||
* @returns {*} Returns the matched element, else `undefined`.
|
* @returns {*} Returns the matched element, else `undefined`.
|
||||||
* @example
|
* @example
|
||||||
@@ -24,18 +24,6 @@ import findIndex from './findIndex.js';
|
|||||||
*
|
*
|
||||||
* _.find(users, function(o) { return o.age < 40; });
|
* _.find(users, function(o) { return o.age < 40; });
|
||||||
* // => object for 'barney'
|
* // => object for 'barney'
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.find(users, { 'age': 1, 'active': true });
|
|
||||||
* // => object for 'pebbles'
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.find(users, ['active', false]);
|
|
||||||
* // => object for 'fred'
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.find(users, 'active');
|
|
||||||
* // => object for 'barney'
|
|
||||||
*/
|
*/
|
||||||
const find = createFind(findIndex);
|
const find = createFind(findIndex);
|
||||||
|
|
||||||
|
|||||||
17
findIndex.js
17
findIndex.js
@@ -1,5 +1,4 @@
|
|||||||
import baseFindIndex from './_baseFindIndex.js';
|
import baseFindIndex from './_baseFindIndex.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
@@ -14,7 +13,7 @@ const nativeMax = Math.max;
|
|||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param {number} [fromIndex=0] The index to search from.
|
* @param {number} [fromIndex=0] The index to search from.
|
||||||
* @returns {number} Returns the index of the found element, else `-1`.
|
* @returns {number} Returns the index of the found element, else `-1`.
|
||||||
* @example
|
* @example
|
||||||
@@ -27,18 +26,6 @@ const nativeMax = Math.max;
|
|||||||
*
|
*
|
||||||
* _.findIndex(users, function(o) { return o.user == 'barney'; });
|
* _.findIndex(users, function(o) { return o.user == 'barney'; });
|
||||||
* // => 0
|
* // => 0
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.findIndex(users, ['active', false]);
|
|
||||||
* // => 0
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.findIndex(users, 'active');
|
|
||||||
* // => 2
|
|
||||||
*/
|
*/
|
||||||
function findIndex(array, predicate, fromIndex) {
|
function findIndex(array, predicate, fromIndex) {
|
||||||
const length = array == null ? 0 : array.length;
|
const length = array == null ? 0 : array.length;
|
||||||
@@ -49,7 +36,7 @@ function findIndex(array, predicate, fromIndex) {
|
|||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index = nativeMax(length + index, 0);
|
index = nativeMax(length + index, 0);
|
||||||
}
|
}
|
||||||
return baseFindIndex(array, baseIteratee(predicate, 3), index);
|
return baseFindIndex(array, predicate, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default findIndex;
|
export default findIndex;
|
||||||
|
|||||||
17
findKey.js
17
findKey.js
@@ -1,6 +1,5 @@
|
|||||||
import baseFindKey from './_baseFindKey.js';
|
import baseFindKey from './_baseFindKey.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.find` except that it returns the key of the first
|
* This method is like `_.find` except that it returns the key of the first
|
||||||
@@ -11,7 +10,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {string|undefined} Returns the key of the matched element,
|
* @returns {string|undefined} Returns the key of the matched element,
|
||||||
* else `undefined`.
|
* else `undefined`.
|
||||||
* @example
|
* @example
|
||||||
@@ -24,21 +23,9 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*
|
*
|
||||||
* _.findKey(users, function(o) { return o.age < 40; });
|
* _.findKey(users, function(o) { return o.age < 40; });
|
||||||
* // => 'barney' (iteration order is not guaranteed)
|
* // => 'barney' (iteration order is not guaranteed)
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.findKey(users, { 'age': 1, 'active': true });
|
|
||||||
* // => 'pebbles'
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.findKey(users, ['active', false]);
|
|
||||||
* // => 'fred'
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.findKey(users, 'active');
|
|
||||||
* // => 'barney'
|
|
||||||
*/
|
*/
|
||||||
function findKey(object, predicate) {
|
function findKey(object, predicate) {
|
||||||
return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn);
|
return baseFindKey(object, predicate, baseForOwn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default findKey;
|
export default findKey;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import findLastIndex from './findLastIndex.js';
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to inspect.
|
* @param {Array|Object} collection The collection to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param {number} [fromIndex=collection.length-1] The index to search from.
|
* @param {number} [fromIndex=collection.length-1] The index to search from.
|
||||||
* @returns {*} Returns the matched element, else `undefined`.
|
* @returns {*} Returns the matched element, else `undefined`.
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseFindIndex from './_baseFindIndex.js';
|
import baseFindIndex from './_baseFindIndex.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
@@ -15,7 +14,7 @@ const nativeMin = Math.min;
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param {number} [fromIndex=array.length-1] The index to search from.
|
* @param {number} [fromIndex=array.length-1] The index to search from.
|
||||||
* @returns {number} Returns the index of the found element, else `-1`.
|
* @returns {number} Returns the index of the found element, else `-1`.
|
||||||
* @example
|
* @example
|
||||||
@@ -28,18 +27,6 @@ const nativeMin = Math.min;
|
|||||||
*
|
*
|
||||||
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
||||||
* // => 2
|
* // => 2
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
|
||||||
* // => 0
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.findLastIndex(users, ['active', false]);
|
|
||||||
* // => 2
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.findLastIndex(users, 'active');
|
|
||||||
* // => 0
|
|
||||||
*/
|
*/
|
||||||
function findLastIndex(array, predicate, fromIndex) {
|
function findLastIndex(array, predicate, fromIndex) {
|
||||||
const length = array == null ? 0 : array.length;
|
const length = array == null ? 0 : array.length;
|
||||||
@@ -53,7 +40,7 @@ function findLastIndex(array, predicate, fromIndex) {
|
|||||||
? nativeMax(length + index, 0)
|
? nativeMax(length + index, 0)
|
||||||
: nativeMin(index, length - 1);
|
: nativeMin(index, length - 1);
|
||||||
}
|
}
|
||||||
return baseFindIndex(array, baseIteratee(predicate, 3), index, true);
|
return baseFindIndex(array, predicate, index, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default findLastIndex;
|
export default findLastIndex;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import baseFindKey from './_baseFindKey.js';
|
import baseFindKey from './_baseFindKey.js';
|
||||||
import baseForOwnRight from './_baseForOwnRight.js';
|
import baseForOwnRight from './_baseForOwnRight.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.findKey` except that it iterates over elements of
|
* This method is like `_.findKey` except that it iterates over elements of
|
||||||
@@ -11,7 +10,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {string|undefined} Returns the key of the matched element,
|
* @returns {string|undefined} Returns the key of the matched element,
|
||||||
* else `undefined`.
|
* else `undefined`.
|
||||||
* @example
|
* @example
|
||||||
@@ -24,21 +23,9 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*
|
*
|
||||||
* _.findLastKey(users, function(o) { return o.age < 40; });
|
* _.findLastKey(users, function(o) { return o.age < 40; });
|
||||||
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
|
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.findLastKey(users, { 'age': 36, 'active': true });
|
|
||||||
* // => 'barney'
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.findLastKey(users, ['active', false]);
|
|
||||||
* // => 'fred'
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.findLastKey(users, 'active');
|
|
||||||
* // => 'pebbles'
|
|
||||||
*/
|
*/
|
||||||
function findLastKey(object, predicate) {
|
function findLastKey(object, predicate) {
|
||||||
return baseFindKey(object, baseIteratee(predicate, 3), baseForOwnRight);
|
return baseFindKey(object, predicate, baseForOwnRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default findLastKey;
|
export default findLastKey;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import map from './map.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const INFINITY = 1 / 0;
|
|||||||
* @since 4.7.0
|
* @since 4.7.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import toInteger from './toInteger.js';
|
|||||||
* @since 4.7.0
|
* @since 4.7.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {number} [depth=1] The maximum recursion depth.
|
* @param {number} [depth=1] The maximum recursion depth.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayEach from './_arrayEach.js';
|
import arrayEach from './_arrayEach.js';
|
||||||
import baseEach from './_baseEach.js';
|
import baseEach from './_baseEach.js';;
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +17,7 @@ import isArray from './isArray.js';
|
|||||||
* @alias each
|
* @alias each
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array|Object} Returns `collection`.
|
* @returns {Array|Object} Returns `collection`.
|
||||||
* @see _.forEachRight
|
* @see _.forEachRight
|
||||||
* @example
|
* @example
|
||||||
@@ -35,7 +34,7 @@ import isArray from './isArray.js';
|
|||||||
*/
|
*/
|
||||||
function forEach(collection, iteratee) {
|
function forEach(collection, iteratee) {
|
||||||
const func = isArray(collection) ? arrayEach : baseEach;
|
const func = isArray(collection) ? arrayEach : baseEach;
|
||||||
return func(collection, castFunction(iteratee));
|
return func(collection, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forEach;
|
export default forEach;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayEachRight from './_arrayEachRight.js';
|
import arrayEachRight from './_arrayEachRight.js';
|
||||||
import baseEachRight from './_baseEachRight.js';
|
import baseEachRight from './_baseEachRight.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +12,7 @@ import isArray from './isArray.js';
|
|||||||
* @alias eachRight
|
* @alias eachRight
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array|Object} Returns `collection`.
|
* @returns {Array|Object} Returns `collection`.
|
||||||
* @see _.forEach
|
* @see _.forEach
|
||||||
* @example
|
* @example
|
||||||
@@ -25,7 +24,7 @@ import isArray from './isArray.js';
|
|||||||
*/
|
*/
|
||||||
function forEachRight(collection, iteratee) {
|
function forEachRight(collection, iteratee) {
|
||||||
const func = isArray(collection) ? arrayEachRight : baseEachRight;
|
const func = isArray(collection) ? arrayEachRight : baseEachRight;
|
||||||
return func(collection, castFunction(iteratee));
|
return func(collection, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forEachRight;
|
export default forEachRight;
|
||||||
|
|||||||
7
forIn.js
7
forIn.js
@@ -1,5 +1,4 @@
|
|||||||
import baseFor from './_baseFor.js';
|
import baseFor from './_baseFor.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
import keysIn from './keysIn.js';
|
import keysIn from './keysIn.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +12,7 @@ import keysIn from './keysIn.js';
|
|||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @see _.forInRight
|
* @see _.forInRight
|
||||||
* @example
|
* @example
|
||||||
@@ -31,9 +30,7 @@ import keysIn from './keysIn.js';
|
|||||||
* // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
|
* // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
|
||||||
*/
|
*/
|
||||||
function forIn(object, iteratee) {
|
function forIn(object, iteratee) {
|
||||||
return object == null
|
return object == null ? object : baseFor(object, iteratee, keysIn);
|
||||||
? object
|
|
||||||
: baseFor(object, castFunction(iteratee), keysIn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forIn;
|
export default forIn;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseForRight from './_baseForRight.js';
|
import baseForRight from './_baseForRight.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
import keysIn from './keysIn.js';
|
import keysIn from './keysIn.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import keysIn from './keysIn.js';
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @see _.forIn
|
* @see _.forIn
|
||||||
* @example
|
* @example
|
||||||
@@ -29,9 +28,7 @@ import keysIn from './keysIn.js';
|
|||||||
* // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
|
* // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
|
||||||
*/
|
*/
|
||||||
function forInRight(object, iteratee) {
|
function forInRight(object, iteratee) {
|
||||||
return object == null
|
return object == null ? object : baseForRight(object, iteratee, keysIn);
|
||||||
? object
|
|
||||||
: baseForRight(object, castFunction(iteratee), keysIn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forInRight;
|
export default forInRight;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own enumerable string keyed properties of an object and
|
* Iterates over own enumerable string keyed properties of an object and
|
||||||
@@ -12,7 +11,7 @@ import castFunction from './_castFunction.js';
|
|||||||
* @since 0.3.0
|
* @since 0.3.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @see _.forOwnRight
|
* @see _.forOwnRight
|
||||||
* @example
|
* @example
|
||||||
@@ -30,7 +29,7 @@ import castFunction from './_castFunction.js';
|
|||||||
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
||||||
*/
|
*/
|
||||||
function forOwn(object, iteratee) {
|
function forOwn(object, iteratee) {
|
||||||
return object && baseForOwn(object, castFunction(iteratee));
|
return object && baseForOwn(object, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forOwn;
|
export default forOwn;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseForOwnRight from './_baseForOwnRight.js';
|
import baseForOwnRight from './_baseForOwnRight.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forOwn` except that it iterates over properties of
|
* This method is like `_.forOwn` except that it iterates over properties of
|
||||||
@@ -10,7 +9,7 @@ import castFunction from './_castFunction.js';
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @see _.forOwn
|
* @see _.forOwn
|
||||||
* @example
|
* @example
|
||||||
@@ -28,7 +27,7 @@ import castFunction from './_castFunction.js';
|
|||||||
* // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
|
* // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
|
||||||
*/
|
*/
|
||||||
function forOwnRight(object, iteratee) {
|
function forOwnRight(object, iteratee) {
|
||||||
return object && baseForOwnRight(object, castFunction(iteratee));
|
return object && baseForOwnRight(object, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forOwnRight;
|
export default forOwnRight;
|
||||||
|
|||||||
@@ -19,16 +19,12 @@ const hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
|
* @param {Function} iteratee The iteratee to transform keys.
|
||||||
* @returns {Object} Returns the composed aggregate object.
|
* @returns {Object} Returns the composed aggregate object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
|
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
|
||||||
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.groupBy(['one', 'two', 'three'], 'length');
|
|
||||||
* // => { '3': ['one', 'two'], '5': ['three'] }
|
|
||||||
*/
|
*/
|
||||||
const groupBy = createAggregator((result, value, key) => {
|
const groupBy = createAggregator((result, value, key) => {
|
||||||
if (hasOwnProperty.call(result, key)) {
|
if (hasOwnProperty.call(result, key)) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIntersection from './_baseIntersection.js';
|
import baseIntersection from './_baseIntersection.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import castArrayLikeObject from './_castArrayLikeObject.js';
|
import castArrayLikeObject from './_castArrayLikeObject.js';
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
|
|
||||||
@@ -16,16 +15,12 @@ import last from './last.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {...Array} [arrays] The arrays to inspect.
|
* @param {...Array} [arrays] The arrays to inspect.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new array of intersecting values.
|
* @returns {Array} Returns the new array of intersecting values.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
* _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
||||||
* // => [2.1]
|
* // => [2.1]
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
|
||||||
* // => [{ 'x': 1 }]
|
|
||||||
*/
|
*/
|
||||||
function intersectionBy(...arrays) {
|
function intersectionBy(...arrays) {
|
||||||
let iteratee = last(arrays);
|
let iteratee = last(arrays);
|
||||||
@@ -37,7 +32,7 @@ function intersectionBy(...arrays) {
|
|||||||
mapped.pop();
|
mapped.pop();
|
||||||
}
|
}
|
||||||
return (mapped.length && mapped[0] === arrays[0])
|
return (mapped.length && mapped[0] === arrays[0])
|
||||||
? baseIntersection(mapped, baseIteratee(iteratee, 2))
|
? baseIntersection(mapped, iteratee)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ import identity from './identity.js';
|
|||||||
*/
|
*/
|
||||||
const invert = createInverter((result, value, key) => {
|
const invert = createInverter((result, value, key) => {
|
||||||
result[value] = key;
|
result[value] = key;
|
||||||
}, constant(identity));
|
});
|
||||||
|
|
||||||
export default invert;
|
export default invert;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import createInverter from './_createInverter.js';
|
import createInverter from './_createInverter.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
@@ -19,15 +18,12 @@ const hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* @since 4.1.0
|
* @since 4.1.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to invert.
|
* @param {Object} object The object to invert.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Object} Returns the new inverted object.
|
* @returns {Object} Returns the new inverted object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||||
*
|
*
|
||||||
* _.invertBy(object);
|
|
||||||
* // => { '1': ['a', 'c'], '2': ['b'] }
|
|
||||||
*
|
|
||||||
* _.invertBy(object, function(value) {
|
* _.invertBy(object, function(value) {
|
||||||
* return 'group' + value;
|
* return 'group' + value;
|
||||||
* });
|
* });
|
||||||
@@ -39,6 +35,6 @@ const invertBy = createInverter((result, value, key) => {
|
|||||||
} else {
|
} else {
|
||||||
result[value] = [key];
|
result[value] = [key];
|
||||||
}
|
}
|
||||||
}, baseIteratee);
|
});
|
||||||
|
|
||||||
export default invertBy;
|
export default invertBy;
|
||||||
|
|||||||
2
keyBy.js
2
keyBy.js
@@ -12,7 +12,7 @@ import createAggregator from './_createAggregator.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
|
* @param {Function} iteratee The iteratee to transform keys.
|
||||||
* @returns {Object} Returns the composed aggregate object.
|
* @returns {Object} Returns the composed aggregate object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
14
map.js
14
map.js
@@ -1,5 +1,4 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseMap from './_baseMap.js';
|
import baseMap from './_baseMap.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ import isArray from './isArray.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new mapped array.
|
* @returns {Array} Returns the new mapped array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -35,19 +34,10 @@ import isArray from './isArray.js';
|
|||||||
*
|
*
|
||||||
* _.map({ 'a': 4, 'b': 8 }, square);
|
* _.map({ 'a': 4, 'b': 8 }, square);
|
||||||
* // => [16, 64] (iteration order is not guaranteed)
|
* // => [16, 64] (iteration order is not guaranteed)
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney' },
|
|
||||||
* { 'user': 'fred' }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.map(users, 'user');
|
|
||||||
* // => ['barney', 'fred']
|
|
||||||
*/
|
*/
|
||||||
function map(collection, iteratee) {
|
function map(collection, iteratee) {
|
||||||
const func = isArray(collection) ? arrayMap : baseMap;
|
const func = isArray(collection) ? arrayMap : baseMap;
|
||||||
return func(collection, baseIteratee(iteratee, 3));
|
return func(collection, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default map;
|
export default map;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import baseAssignValue from './_baseAssignValue.js';
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The opposite of `_.mapValues`; this method creates an object with the
|
* The opposite of `_.mapValues`; this method creates an object with the
|
||||||
@@ -13,7 +12,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
* @since 3.8.0
|
* @since 3.8.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns the new mapped object.
|
* @returns {Object} Returns the new mapped object.
|
||||||
* @see _.mapValues
|
* @see _.mapValues
|
||||||
* @example
|
* @example
|
||||||
@@ -25,8 +24,6 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*/
|
*/
|
||||||
function mapKeys(object, iteratee) {
|
function mapKeys(object, iteratee) {
|
||||||
const result = {};
|
const result = {};
|
||||||
iteratee = baseIteratee(iteratee, 3);
|
|
||||||
|
|
||||||
baseForOwn(object, (value, key, object) => {
|
baseForOwn(object, (value, key, object) => {
|
||||||
baseAssignValue(result, iteratee(value, key, object), value);
|
baseAssignValue(result, iteratee(value, key, object), value);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import baseAssignValue from './_baseAssignValue.js';
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object with the same keys as `object` and values generated
|
* Creates an object with the same keys as `object` and values generated
|
||||||
@@ -13,7 +12,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
* @since 2.4.0
|
* @since 2.4.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Object} Returns the new mapped object.
|
* @returns {Object} Returns the new mapped object.
|
||||||
* @see _.mapKeys
|
* @see _.mapKeys
|
||||||
* @example
|
* @example
|
||||||
@@ -25,15 +24,9 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*
|
*
|
||||||
* _.mapValues(users, function(o) { return o.age; });
|
* _.mapValues(users, function(o) { return o.age; });
|
||||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.mapValues(users, 'age');
|
|
||||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
|
||||||
*/
|
*/
|
||||||
function mapValues(object, iteratee) {
|
function mapValues(object, iteratee) {
|
||||||
const result = {};
|
const result = {};
|
||||||
iteratee = baseIteratee(iteratee, 3);
|
|
||||||
|
|
||||||
baseForOwn(object, (value, key, object) => {
|
baseForOwn(object, (value, key, object) => {
|
||||||
baseAssignValue(result, key, iteratee(value, key, object));
|
baseAssignValue(result, key, iteratee(value, key, object));
|
||||||
});
|
});
|
||||||
|
|||||||
9
maxBy.js
9
maxBy.js
@@ -1,6 +1,5 @@
|
|||||||
import baseExtremum from './_baseExtremum.js';
|
import baseExtremum from './_baseExtremum.js';
|
||||||
import baseGt from './_baseGt.js';
|
import baseGt from './_baseGt.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.max` except that it accepts `iteratee` which is
|
* This method is like `_.max` except that it accepts `iteratee` which is
|
||||||
@@ -12,7 +11,7 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Math
|
* @category Math
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {*} Returns the maximum value.
|
* @returns {*} Returns the maximum value.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -20,14 +19,10 @@ import baseIteratee from './_baseIteratee.js';
|
|||||||
*
|
*
|
||||||
* _.maxBy(objects, function(o) { return o.n; });
|
* _.maxBy(objects, function(o) { return o.n; });
|
||||||
* // => { 'n': 2 }
|
* // => { 'n': 2 }
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.maxBy(objects, 'n');
|
|
||||||
* // => { 'n': 2 }
|
|
||||||
*/
|
*/
|
||||||
function maxBy(array, iteratee) {
|
function maxBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, baseIteratee(iteratee, 2), baseGt)
|
? baseExtremum(array, iteratee, baseGt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
mean.js
4
mean.js
@@ -1,4 +1,4 @@
|
|||||||
import baseMean from './_baseMean.js';
|
import baseMean from './meanBy.js';
|
||||||
import identity from './identity.js';
|
import identity from './identity.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +16,7 @@ import identity from './identity.js';
|
|||||||
* // => 5
|
* // => 5
|
||||||
*/
|
*/
|
||||||
function mean(array) {
|
function mean(array) {
|
||||||
return baseMean(array, identity);
|
return mean(array, identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default mean;
|
export default mean;
|
||||||
|
|||||||
15
meanBy.js
15
meanBy.js
@@ -1,5 +1,7 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
import baseSum from './_baseSum.js';
|
||||||
import baseMean from './_baseMean.js';
|
|
||||||
|
/** Used as references for various `Number` constants. */
|
||||||
|
const NAN = 0 / 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.mean` except that it accepts `iteratee` which is
|
* This method is like `_.mean` except that it accepts `iteratee` which is
|
||||||
@@ -11,7 +13,7 @@ import baseMean from './_baseMean.js';
|
|||||||
* @since 4.7.0
|
* @since 4.7.0
|
||||||
* @category Math
|
* @category Math
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {number} Returns the mean.
|
* @returns {number} Returns the mean.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -19,13 +21,10 @@ import baseMean from './_baseMean.js';
|
|||||||
*
|
*
|
||||||
* _.meanBy(objects, function(o) { return o.n; });
|
* _.meanBy(objects, function(o) { return o.n; });
|
||||||
* // => 5
|
* // => 5
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.meanBy(objects, 'n');
|
|
||||||
* // => 5
|
|
||||||
*/
|
*/
|
||||||
function meanBy(array, iteratee) {
|
function meanBy(array, iteratee) {
|
||||||
return baseMean(array, baseIteratee(iteratee, 2));
|
const length = array == null ? 0 : array.length;
|
||||||
|
return length ? (baseSum(array, iteratee) / length) : NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default meanBy;
|
export default meanBy;
|
||||||
|
|||||||
9
minBy.js
9
minBy.js
@@ -1,5 +1,4 @@
|
|||||||
import baseExtremum from './_baseExtremum.js';
|
import baseExtremum from './_baseExtremum.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseLt from './_baseLt.js';
|
import baseLt from './_baseLt.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ import baseLt from './_baseLt.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Math
|
* @category Math
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {*} Returns the minimum value.
|
* @returns {*} Returns the minimum value.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -20,14 +19,10 @@ import baseLt from './_baseLt.js';
|
|||||||
*
|
*
|
||||||
* _.minBy(objects, function(o) { return o.n; });
|
* _.minBy(objects, function(o) { return o.n; });
|
||||||
* // => { 'n': 1 }
|
* // => { 'n': 1 }
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.minBy(objects, 'n');
|
|
||||||
* // => { 'n': 1 }
|
|
||||||
*/
|
*/
|
||||||
function minBy(array, iteratee) {
|
function minBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, baseIteratee(iteratee, 2), baseLt)
|
? baseExtremum(array, iteratee, baseLt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import apply from './_apply.js';
|
import apply from './_apply.js';
|
||||||
import arrayMap from './_arrayMap.js';
|
|
||||||
import baseFlatten from './_baseFlatten.js';
|
import baseFlatten from './_baseFlatten.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
const nativeMin = Math.min;
|
const nativeMin = Math.min;
|
||||||
@@ -38,7 +36,6 @@ const nativeMin = Math.min;
|
|||||||
* // => [100, 10]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
function overArgs(func, ...transforms) {
|
function overArgs(func, ...transforms) {
|
||||||
transforms = arrayMap(transforms, transform => baseIteratee(transform));
|
|
||||||
const funcsLength = transforms.length;
|
const funcsLength = transforms.length;
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
|
|||||||
14
partition.js
14
partition.js
@@ -11,7 +11,7 @@ import createAggregator from './_createAggregator.js';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the array of grouped elements.
|
* @returns {Array} Returns the array of grouped elements.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,18 +23,6 @@ import createAggregator from './_createAggregator.js';
|
|||||||
*
|
*
|
||||||
* _.partition(users, function(o) { return o.active; });
|
* _.partition(users, function(o) { return o.active; });
|
||||||
* // => objects for [['fred'], ['barney', 'pebbles']]
|
* // => objects for [['fred'], ['barney', 'pebbles']]
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.partition(users, { 'age': 1, 'active': false });
|
|
||||||
* // => objects for [['pebbles'], ['barney', 'fred']]
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.partition(users, ['active', false]);
|
|
||||||
* // => objects for [['barney', 'pebbles'], ['fred']]
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.partition(users, 'active');
|
|
||||||
* // => objects for [['fred'], ['barney', 'pebbles']]
|
|
||||||
*/
|
*/
|
||||||
const partition = createAggregator((result, value, key) =>
|
const partition = createAggregator((result, value, key) =>
|
||||||
result[key ? 0 : 1].push(value), () => [[], []]);
|
result[key ? 0 : 1].push(value), () => [[], []]);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import basePickBy from './_basePickBy.js';
|
import basePickBy from './_basePickBy.js';
|
||||||
import getAllKeysIn from './_getAllKeysIn.js';
|
import getAllKeysIn from './_getAllKeysIn.js';
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ import getAllKeysIn from './_getAllKeysIn.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per property.
|
* @param {Function} predicate The function invoked per property.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -26,7 +25,6 @@ function pickBy(object, predicate) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const props = arrayMap(getAllKeysIn(object), prop => [prop]);
|
const props = arrayMap(getAllKeysIn(object), prop => [prop]);
|
||||||
predicate = baseIteratee(predicate);
|
|
||||||
return basePickBy(object, props, (value, path) => predicate(value, path[0]));
|
return basePickBy(object, props, (value, path) => predicate(value, path[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import basePullAll from './_basePullAll.js';
|
import basePullAll from './_basePullAll.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +13,7 @@ import basePullAll from './_basePullAll.js';
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to modify.
|
* @param {Array} array The array to modify.
|
||||||
* @param {Array} values The values to remove.
|
* @param {Array} values The values to remove.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns `array`.
|
* @returns {Array} Returns `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -26,7 +25,7 @@ import basePullAll from './_basePullAll.js';
|
|||||||
*/
|
*/
|
||||||
function pullAllBy(array, values, iteratee) {
|
function pullAllBy(array, values, iteratee) {
|
||||||
return (array && array.length && values && values.length)
|
return (array && array.length && values && values.length)
|
||||||
? basePullAll(array, values, baseIteratee(iteratee, 2))
|
? basePullAll(array, values, iteratee)
|
||||||
: array;
|
: array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayReduce from './_arrayReduce.js';
|
import arrayReduce from './_arrayReduce.js';
|
||||||
import baseEach from './_baseEach.js';
|
import baseEach from './_baseEach.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseReduce from './_baseReduce.js';
|
import baseReduce from './_baseReduce.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ import isArray from './isArray.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
* @see _.reduceRight
|
* @see _.reduceRight
|
||||||
@@ -44,8 +43,7 @@ import isArray from './isArray.js';
|
|||||||
function reduce(collection, iteratee, accumulator) {
|
function reduce(collection, iteratee, accumulator) {
|
||||||
const func = isArray(collection) ? arrayReduce : baseReduce;
|
const func = isArray(collection) ? arrayReduce : baseReduce;
|
||||||
const initAccum = arguments.length < 3;
|
const initAccum = arguments.length < 3;
|
||||||
|
return func(collection, iteratee, accumulator, initAccum, baseEach);
|
||||||
return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default reduce;
|
export default reduce;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import arrayReduceRight from './_arrayReduceRight.js';
|
import arrayReduceRight from './_arrayReduceRight.js';
|
||||||
import baseEachRight from './_baseEachRight.js';
|
import baseEachRight from './_baseEachRight.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseReduce from './_baseReduce.js';
|
import baseReduce from './_baseReduce.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ import isArray from './isArray.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
* @see _.reduce
|
* @see _.reduce
|
||||||
@@ -29,8 +28,7 @@ import isArray from './isArray.js';
|
|||||||
function reduceRight(collection, iteratee, accumulator) {
|
function reduceRight(collection, iteratee, accumulator) {
|
||||||
const func = isArray(collection) ? arrayReduceRight : baseReduce;
|
const func = isArray(collection) ? arrayReduceRight : baseReduce;
|
||||||
const initAccum = arguments.length < 3;
|
const initAccum = arguments.length < 3;
|
||||||
|
return func(collection, iteratee, accumulator, initAccum, baseEachRight);
|
||||||
return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default reduceRight;
|
export default reduceRight;
|
||||||
|
|||||||
17
reject.js
17
reject.js
@@ -1,6 +1,5 @@
|
|||||||
import arrayFilter from './_arrayFilter.js';
|
import arrayFilter from './_arrayFilter.js';
|
||||||
import baseFilter from './_baseFilter.js';
|
import baseFilter from './_baseFilter.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import negate from './negate.js';
|
import negate from './negate.js';
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ import negate from './negate.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new filtered array.
|
* @returns {Array} Returns the new filtered array.
|
||||||
* @see _.filter
|
* @see _.filter
|
||||||
* @example
|
* @example
|
||||||
@@ -25,22 +24,10 @@ import negate from './negate.js';
|
|||||||
*
|
*
|
||||||
* _.reject(users, function(o) { return !o.active; });
|
* _.reject(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['fred']
|
* // => objects for ['fred']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.reject(users, { 'age': 40, 'active': true });
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.reject(users, ['active', false]);
|
|
||||||
* // => objects for ['fred']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.reject(users, 'active');
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*/
|
*/
|
||||||
function reject(collection, predicate) {
|
function reject(collection, predicate) {
|
||||||
const func = isArray(collection) ? arrayFilter : baseFilter;
|
const func = isArray(collection) ? arrayFilter : baseFilter;
|
||||||
return func(collection, negate(baseIteratee(predicate, 3)));
|
return func(collection, negate(predicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default reject;
|
export default reject;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import basePullAt from './_basePullAt.js';
|
import basePullAt from './_basePullAt.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +13,7 @@ import basePullAt from './_basePullAt.js';
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to modify.
|
* @param {Array} array The array to modify.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new array of removed elements.
|
* @returns {Array} Returns the new array of removed elements.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -38,7 +37,6 @@ function remove(array, predicate) {
|
|||||||
const indexes = [];
|
const indexes = [];
|
||||||
const length = array.length;
|
const length = array.length;
|
||||||
|
|
||||||
predicate = baseIteratee(predicate, 3);
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
const value = array[index];
|
const value = array[index];
|
||||||
if (predicate(value, index, array)) {
|
if (predicate(value, index, array)) {
|
||||||
|
|||||||
22
some.js
22
some.js
@@ -1,5 +1,4 @@
|
|||||||
import arraySome from './_arraySome.js';
|
import arraySome from './_arraySome.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseSome from './_baseSome.js';
|
import baseSome from './_baseSome.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isIterateeCall from './_isIterateeCall.js';
|
import isIterateeCall from './_isIterateeCall.js';
|
||||||
@@ -14,7 +13,7 @@ import isIterateeCall from './_isIterateeCall.js';
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||||
* else `false`.
|
* else `false`.
|
||||||
@@ -22,30 +21,13 @@ import isIterateeCall from './_isIterateeCall.js';
|
|||||||
*
|
*
|
||||||
* _.some([null, 0, 'yes', false], Boolean);
|
* _.some([null, 0, 'yes', false], Boolean);
|
||||||
* // => true
|
* // => true
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': true },
|
|
||||||
* { 'user': 'fred', 'active': false }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.some(users, { 'user': 'barney', 'active': false });
|
|
||||||
* // => false
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.some(users, ['active', false]);
|
|
||||||
* // => true
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.some(users, 'active');
|
|
||||||
* // => true
|
|
||||||
*/
|
*/
|
||||||
function some(collection, predicate, guard) {
|
function some(collection, predicate, guard) {
|
||||||
const func = isArray(collection) ? arraySome : baseSome;
|
const func = isArray(collection) ? arraySome : baseSome;
|
||||||
if (guard && isIterateeCall(collection, predicate, guard)) {
|
if (guard && isIterateeCall(collection, predicate, guard)) {
|
||||||
predicate = undefined;
|
predicate = undefined;
|
||||||
}
|
}
|
||||||
return func(collection, baseIteratee(predicate, 3));
|
return func(collection, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default some;
|
export default some;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The sorted array to inspect.
|
* @param {Array} array The sorted array to inspect.
|
||||||
* @param {*} value The value to evaluate.
|
* @param {*} value The value to evaluate.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {number} Returns the index at which `value` should be inserted
|
* @returns {number} Returns the index at which `value` should be inserted
|
||||||
* into `array`.
|
* into `array`.
|
||||||
* @example
|
* @example
|
||||||
@@ -21,13 +20,9 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
|||||||
*
|
*
|
||||||
* _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
* _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
||||||
* // => 0
|
* // => 0
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.sortedIndexBy(objects, { 'x': 4 }, 'x');
|
|
||||||
* // => 0
|
|
||||||
*/
|
*/
|
||||||
function sortedIndexBy(array, value, iteratee) {
|
function sortedIndexBy(array, value, iteratee) {
|
||||||
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
|
return baseSortedIndexBy(array, value, iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default sortedIndexBy;
|
export default sortedIndexBy;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The sorted array to inspect.
|
* @param {Array} array The sorted array to inspect.
|
||||||
* @param {*} value The value to evaluate.
|
* @param {*} value The value to evaluate.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {number} Returns the index at which `value` should be inserted
|
* @returns {number} Returns the index at which `value` should be inserted
|
||||||
* into `array`.
|
* into `array`.
|
||||||
* @example
|
* @example
|
||||||
@@ -21,13 +20,9 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js';
|
|||||||
*
|
*
|
||||||
* _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
* _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
||||||
* // => 1
|
* // => 1
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
|
|
||||||
* // => 1
|
|
||||||
*/
|
*/
|
||||||
function sortedLastIndexBy(array, value, iteratee) {
|
function sortedLastIndexBy(array, value, iteratee) {
|
||||||
return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true);
|
return baseSortedIndexBy(array, value, iteratee, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default sortedLastIndexBy;
|
export default sortedLastIndexBy;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseSortedUniq from './_baseSortedUniq.js';
|
import baseSortedUniq from './_baseSortedUniq.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +9,7 @@ import baseSortedUniq from './_baseSortedUniq.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new duplicate free array.
|
* @returns {Array} Returns the new duplicate free array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -19,7 +18,7 @@ import baseSortedUniq from './_baseSortedUniq.js';
|
|||||||
*/
|
*/
|
||||||
function sortedUniqBy(array, iteratee) {
|
function sortedUniqBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseSortedUniq(array, baseIteratee(iteratee, 2))
|
? baseSortedUniq(array, iteratee)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
sumBy.js
9
sumBy.js
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseSum from './_baseSum.js';
|
import baseSum from './_baseSum.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import baseSum from './_baseSum.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Math
|
* @category Math
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {number} Returns the sum.
|
* @returns {number} Returns the sum.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -19,14 +18,10 @@ import baseSum from './_baseSum.js';
|
|||||||
*
|
*
|
||||||
* _.sumBy(objects, function(o) { return o.n; });
|
* _.sumBy(objects, function(o) { return o.n; });
|
||||||
* // => 20
|
* // => 20
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.sumBy(objects, 'n');
|
|
||||||
* // => 20
|
|
||||||
*/
|
*/
|
||||||
function sumBy(array, iteratee) {
|
function sumBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseSum(array, baseIteratee(iteratee, 2))
|
? baseSum(array, iteratee)
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseWhile from './_baseWhile.js';
|
import baseWhile from './_baseWhile.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js';
|
|||||||
*
|
*
|
||||||
* _.takeRightWhile(users, function(o) { return !o.active; });
|
* _.takeRightWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['fred', 'pebbles']
|
* // => objects for ['fred', 'pebbles']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
|
|
||||||
* // => objects for ['pebbles']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.takeRightWhile(users, ['active', false]);
|
|
||||||
* // => objects for ['fred', 'pebbles']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.takeRightWhile(users, 'active');
|
|
||||||
* // => []
|
|
||||||
*/
|
*/
|
||||||
function takeRightWhile(array, predicate) {
|
function takeRightWhile(array, predicate) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, baseIteratee(predicate, 3), false, true)
|
? baseWhile(array, predicate, false, true)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
takeWhile.js
17
takeWhile.js
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseWhile from './_baseWhile.js';
|
import baseWhile from './_baseWhile.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js';
|
|||||||
*
|
*
|
||||||
* _.takeWhile(users, function(o) { return !o.active; });
|
* _.takeWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['barney', 'fred']
|
* // => objects for ['barney', 'fred']
|
||||||
*
|
|
||||||
* // The `_.matches` iteratee shorthand.
|
|
||||||
* _.takeWhile(users, { 'user': 'barney', 'active': false });
|
|
||||||
* // => objects for ['barney']
|
|
||||||
*
|
|
||||||
* // The `_.matchesProperty` iteratee shorthand.
|
|
||||||
* _.takeWhile(users, ['active', false]);
|
|
||||||
* // => objects for ['barney', 'fred']
|
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.takeWhile(users, 'active');
|
|
||||||
* // => []
|
|
||||||
*/
|
*/
|
||||||
function takeWhile(array, predicate) {
|
function takeWhile(array, predicate) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseWhile(array, baseIteratee(predicate, 3))
|
? baseWhile(array, predicate)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
times.js
9
times.js
@@ -1,5 +1,4 @@
|
|||||||
import baseTimes from './_baseTimes.js';
|
import baseTimes from './_baseTimes.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/** Used as references for various `Number` constants. */
|
/** Used as references for various `Number` constants. */
|
||||||
@@ -20,7 +19,7 @@ const nativeMin = Math.min;
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {number} n The number of times to invoke `iteratee`.
|
* @param {number} n The number of times to invoke `iteratee`.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @returns {Array} Returns the array of results.
|
* @returns {Array} Returns the array of results.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -37,11 +36,9 @@ function times(n, iteratee) {
|
|||||||
}
|
}
|
||||||
let index = MAX_ARRAY_LENGTH;
|
let index = MAX_ARRAY_LENGTH;
|
||||||
const length = nativeMin(n, MAX_ARRAY_LENGTH);
|
const length = nativeMin(n, MAX_ARRAY_LENGTH);
|
||||||
|
|
||||||
iteratee = castFunction(iteratee);
|
|
||||||
n -= MAX_ARRAY_LENGTH;
|
|
||||||
|
|
||||||
const result = baseTimes(length, iteratee);
|
const result = baseTimes(length, iteratee);
|
||||||
|
|
||||||
|
n -= MAX_ARRAY_LENGTH;
|
||||||
while (++index < n) {
|
while (++index < n) {
|
||||||
iteratee(index);
|
iteratee(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import arrayEach from './_arrayEach.js';
|
import arrayEach from './_arrayEach.js';
|
||||||
import baseCreate from './_baseCreate.js';
|
import baseCreate from './_baseCreate.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import getPrototype from './_getPrototype.js';
|
import getPrototype from './_getPrototype.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isBuffer from './isBuffer.js';
|
import isBuffer from './isBuffer.js';
|
||||||
@@ -23,7 +22,7 @@ import isTypedArray from './isTypedArray.js';
|
|||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The custom accumulator value.
|
* @param {*} [accumulator] The custom accumulator value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
* @example
|
* @example
|
||||||
@@ -43,7 +42,6 @@ function transform(object, iteratee, accumulator) {
|
|||||||
const isArr = isArray(object);
|
const isArr = isArray(object);
|
||||||
const isArrLike = isArr || isBuffer(object) || isTypedArray(object);
|
const isArrLike = isArr || isBuffer(object) || isTypedArray(object);
|
||||||
|
|
||||||
iteratee = baseIteratee(iteratee, 4);
|
|
||||||
if (accumulator == null) {
|
if (accumulator == null) {
|
||||||
const Ctor = object && object.constructor;
|
const Ctor = object && object.constructor;
|
||||||
if (isArrLike) {
|
if (isArrLike) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseFlatten from './_baseFlatten.js';
|
import baseFlatten from './_baseFlatten.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseUniq from './_baseUniq.js';
|
import baseUniq from './_baseUniq.js';
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js';
|
import isArrayLikeObject from './isArrayLikeObject.js';
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
@@ -16,23 +15,19 @@ import last from './last.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {...Array} [arrays] The arrays to inspect.
|
* @param {...Array} [arrays] The arrays to inspect.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new array of combined values.
|
* @returns {Array} Returns the new array of combined values.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.unionBy([2.1], [1.2, 2.3], Math.floor);
|
* _.unionBy([2.1], [1.2, 2.3], Math.floor);
|
||||||
* // => [2.1, 1.2]
|
* // => [2.1, 1.2]
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
|
||||||
* // => [{ 'x': 1 }, { 'x': 2 }]
|
|
||||||
*/
|
*/
|
||||||
function unionBy(...arrays) {
|
function unionBy(...arrays) {
|
||||||
let iteratee = last(arrays);
|
let iteratee = last(arrays);
|
||||||
if (isArrayLikeObject(iteratee)) {
|
if (isArrayLikeObject(iteratee)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2));
|
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default unionBy;
|
export default unionBy;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseUniq from './_baseUniq.js';
|
import baseUniq from './_baseUniq.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,19 +12,15 @@ import baseUniq from './_baseUniq.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new duplicate free array.
|
* @returns {Array} Returns the new duplicate free array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
|
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
|
||||||
* // => [2.1, 1.2]
|
* // => [2.1, 1.2]
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
|
||||||
* // => [{ 'x': 1 }, { 'x': 2 }]
|
|
||||||
*/
|
*/
|
||||||
function uniqBy(array, iteratee) {
|
function uniqBy(array, iteratee) {
|
||||||
return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
|
return (array && array.length) ? baseUniq(array, iteratee) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default uniqBy;
|
export default uniqBy;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import unzip from './unzip.js';
|
|||||||
* @since 3.8.0
|
* @since 3.8.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array of grouped elements to process.
|
* @param {Array} array The array of grouped elements to process.
|
||||||
* @param {Function} [iteratee=_.identity] The function to combine
|
* @param {Function} iteratee The function to combine
|
||||||
* regrouped values.
|
* regrouped values.
|
||||||
* @returns {Array} Returns the new array of regrouped elements.
|
* @returns {Array} Returns the new array of regrouped elements.
|
||||||
* @example
|
* @example
|
||||||
@@ -28,9 +28,6 @@ function unzipWith(array, iteratee) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const result = unzip(array);
|
const result = unzip(array);
|
||||||
if (iteratee == null) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return arrayMap(result, group => apply(iteratee, undefined, group));
|
return arrayMap(result, group => apply(iteratee, undefined, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseUpdate from './_baseUpdate.js';
|
import baseUpdate from './_baseUpdate.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.set` except that accepts `updater` to produce the
|
* This method is like `_.set` except that accepts `updater` to produce the
|
||||||
@@ -29,7 +28,7 @@ import castFunction from './_castFunction.js';
|
|||||||
* // => 0
|
* // => 0
|
||||||
*/
|
*/
|
||||||
function update(object, path, updater) {
|
function update(object, path, updater) {
|
||||||
return object == null ? object : baseUpdate(object, path, castFunction(updater));
|
return object == null ? object : baseUpdate(object, path, updater);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default update;
|
export default update;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseUpdate from './_baseUpdate.js';
|
import baseUpdate from './_baseUpdate.js';
|
||||||
import castFunction from './_castFunction.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.update` except that it accepts `customizer` which is
|
* This method is like `_.update` except that it accepts `customizer` which is
|
||||||
@@ -27,7 +26,7 @@ import castFunction from './_castFunction.js';
|
|||||||
*/
|
*/
|
||||||
function updateWith(object, path, updater, customizer) {
|
function updateWith(object, path, updater, customizer) {
|
||||||
customizer = typeof customizer == 'function' ? customizer : undefined;
|
customizer = typeof customizer == 'function' ? customizer : undefined;
|
||||||
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
|
return object == null ? object : baseUpdate(object, path, updater, customizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default updateWith;
|
export default updateWith;
|
||||||
|
|||||||
9
xorBy.js
9
xorBy.js
@@ -1,5 +1,4 @@
|
|||||||
import arrayFilter from './_arrayFilter.js';
|
import arrayFilter from './_arrayFilter.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
|
||||||
import baseXor from './_baseXor.js';
|
import baseXor from './_baseXor.js';
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js';
|
import isArrayLikeObject from './isArrayLikeObject.js';
|
||||||
import last from './last.js';
|
import last from './last.js';
|
||||||
@@ -16,23 +15,19 @@ import last from './last.js';
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {...Array} [arrays] The arrays to inspect.
|
* @param {...Array} [arrays] The arrays to inspect.
|
||||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new array of filtered values.
|
* @returns {Array} Returns the new array of filtered values.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
* _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
||||||
* // => [1.2, 3.4]
|
* // => [1.2, 3.4]
|
||||||
*
|
|
||||||
* // The `_.property` iteratee shorthand.
|
|
||||||
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
|
||||||
* // => [{ 'x': 2 }]
|
|
||||||
*/
|
*/
|
||||||
function xorBy(...arrays) {
|
function xorBy(...arrays) {
|
||||||
let iteratee = last(arrays);
|
let iteratee = last(arrays);
|
||||||
if (isArrayLikeObject(iteratee)) {
|
if (isArrayLikeObject(iteratee)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2));
|
return baseXor(arrayFilter(arrays, isArrayLikeObject), iteratee);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default xorBy;
|
export default xorBy;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import unzipWith from './unzipWith.js';
|
|||||||
* @since 3.8.0
|
* @since 3.8.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {...Array} [arrays] The arrays to process.
|
* @param {...Array} [arrays] The arrays to process.
|
||||||
* @param {Function} [iteratee=_.identity] The function to combine
|
* @param {Function} iteratee The function to combine
|
||||||
* grouped values.
|
* grouped values.
|
||||||
* @returns {Array} Returns the new array of grouped elements.
|
* @returns {Array} Returns the new array of grouped elements.
|
||||||
* @example
|
* @example
|
||||||
@@ -23,7 +23,6 @@ import unzipWith from './unzipWith.js';
|
|||||||
function zipWith(...arrays) {
|
function zipWith(...arrays) {
|
||||||
const length = arrays.length;
|
const length = arrays.length;
|
||||||
let iteratee = length > 1 ? arrays[length - 1] : undefined;
|
let iteratee = length > 1 ? arrays[length - 1] : undefined;
|
||||||
|
|
||||||
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
|
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
|
||||||
return unzipWith(arrays, iteratee);
|
return unzipWith(arrays, iteratee);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user