diff --git a/_arrayEach.js b/_arrayEach.js index 0158205ee..5c7b057ec 100644 --- a/_arrayEach.js +++ b/_arrayEach.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.forEach` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayEachRight.js b/_arrayEachRight.js index 713406c15..fa885a744 100644 --- a/_arrayEachRight.js +++ b/_arrayEachRight.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.forEachRight` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.forEachRight` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayEvery.js b/_arrayEvery.js index a24e76600..aa2462269 100644 --- a/_arrayEvery.js +++ b/_arrayEvery.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.every` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.every` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayFilter.js b/_arrayFilter.js index 84b6e7e28..4a586f375 100644 --- a/_arrayFilter.js +++ b/_arrayFilter.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.filter` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.filter` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayMap.js b/_arrayMap.js index 811f9dbb3..9f29ecb79 100644 --- a/_arrayMap.js +++ b/_arrayMap.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. + * A specialized version of `_.map` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayReduce.js b/_arrayReduce.js index 15a961582..f14a02e90 100644 --- a/_arrayReduce.js +++ b/_arrayReduce.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.reduce` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arrayReduceRight.js b/_arrayReduceRight.js index 63d2ca542..bd49f47bc 100644 --- a/_arrayReduceRight.js +++ b/_arrayReduceRight.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.reduceRight` for arrays without support for - * iteratee shorthands. + * A specialized version of `_.reduceRight` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_arraySome.js b/_arraySome.js index afffba804..73be88a5e 100644 --- a/_arraySome.js +++ b/_arraySome.js @@ -1,6 +1,5 @@ /** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. + * A specialized version of `_.some` for arrays. * * @private * @param {Array} [array] The array to iterate over. diff --git a/_baseDifference.js b/_baseDifference.js index be119496a..f1bda043c 100644 --- a/_baseDifference.js +++ b/_baseDifference.js @@ -9,7 +9,7 @@ const LARGE_ARRAY_SIZE = 200; /** * The base implementation of methods like `_.difference` without support - * for excluding multiple arrays or iteratee shorthands. + * for excluding multiple arrays. * * @private * @param {Array} array The array to inspect. diff --git a/_baseEach.js b/_baseEach.js index 1495f8376..f7ab97790 100644 --- a/_baseEach.js +++ b/_baseEach.js @@ -2,7 +2,7 @@ import baseForOwn from './_baseForOwn.js'; import createBaseEach from './_createBaseEach.js'; /** - * The base implementation of `_.forEach` without support for iteratee shorthands. + * The base implementation of `_.forEach`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseEachRight.js b/_baseEachRight.js index c722b0557..a4112929d 100644 --- a/_baseEachRight.js +++ b/_baseEachRight.js @@ -2,7 +2,7 @@ import baseForOwnRight from './_baseForOwnRight.js'; import createBaseEach from './_createBaseEach.js'; /** - * The base implementation of `_.forEachRight` without support for iteratee shorthands. + * The base implementation of `_.forEachRight`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseEvery.js b/_baseEvery.js index 96964b9d5..f417be0c7 100644 --- a/_baseEvery.js +++ b/_baseEvery.js @@ -1,7 +1,7 @@ import baseEach from './_baseEach.js'; /** - * The base implementation of `_.every` without support for iteratee shorthands. + * The base implementation of `_.every`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseFilter.js b/_baseFilter.js index 4376c7908..7c282c082 100644 --- a/_baseFilter.js +++ b/_baseFilter.js @@ -1,7 +1,7 @@ import baseEach from './_baseEach.js'; /** - * The base implementation of `_.filter` without support for iteratee shorthands. + * The base implementation of `_.filter`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseFindIndex.js b/_baseFindIndex.js index 26042d78e..a5e810a22 100644 --- a/_baseFindIndex.js +++ b/_baseFindIndex.js @@ -1,6 +1,5 @@ /** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. + * The base implementation of `_.findIndex` and `_.findLastIndex`. * * @private * @param {Array} array The array to inspect. diff --git a/_baseFindKey.js b/_baseFindKey.js index d840ed875..c4ebfb084 100644 --- a/_baseFindKey.js +++ b/_baseFindKey.js @@ -1,7 +1,6 @@ /** - * The base implementation of methods like `_.findKey` and `_.findLastKey`, - * without support for iteratee shorthands, which iterates over `collection` - * using `eachFunc`. + * The base implementation of methods like `_.findKey` and `_.findLastKey` + * which iterates over `collection` using `eachFunc`. * * @private * @param {Array|Object} collection The collection to inspect. diff --git a/_baseForOwn.js b/_baseForOwn.js index 2293e9a6c..e560a9b76 100644 --- a/_baseForOwn.js +++ b/_baseForOwn.js @@ -2,7 +2,7 @@ import baseFor from './_baseFor.js'; import keys from './keys.js'; /** - * The base implementation of `_.forOwn` without support for iteratee shorthands. + * The base implementation of `_.forOwn`. * * @private * @param {Object} object The object to iterate over. diff --git a/_baseForOwnRight.js b/_baseForOwnRight.js index 06871b4bb..c44d69e56 100644 --- a/_baseForOwnRight.js +++ b/_baseForOwnRight.js @@ -2,7 +2,7 @@ import baseForRight from './_baseForRight.js'; import keys from './keys.js'; /** - * The base implementation of `_.forOwnRight` without support for iteratee shorthands. + * The base implementation of `_.forOwnRight`. * * @private * @param {Object} object The object to iterate over. diff --git a/_baseIntersection.js b/_baseIntersection.js index 7935b4d99..3fb8f0af3 100644 --- a/_baseIntersection.js +++ b/_baseIntersection.js @@ -8,8 +8,8 @@ import cacheHas from './_cacheHas.js'; const nativeMin = Math.min; /** - * The base implementation of methods like `_.intersection`, without support - * for iteratee shorthands, that accepts an array of arrays to inspect. + * The base implementation of methods like `_.intersection` that accepts an + * array of arrays to inspect. * * @private * @param {Array} arrays The arrays to inspect. diff --git a/_baseIsMatch.js b/_baseIsMatch.js index 5dc19d211..c70054185 100644 --- a/_baseIsMatch.js +++ b/_baseIsMatch.js @@ -6,7 +6,7 @@ const COMPARE_PARTIAL_FLAG = 1; const COMPARE_UNORDERED_FLAG = 2; /** - * The base implementation of `_.isMatch` without support for iteratee shorthands. + * The base implementation of `_.isMatch`. * * @private * @param {Object} object The object to inspect. diff --git a/_baseIteratee.js b/_baseIteratee.js deleted file mode 100644 index af052002e..000000000 --- a/_baseIteratee.js +++ /dev/null @@ -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; diff --git a/_baseMap.js b/_baseMap.js index 0cc1933b1..3e9b16d0e 100644 --- a/_baseMap.js +++ b/_baseMap.js @@ -2,7 +2,7 @@ import baseEach from './_baseEach.js'; import isArrayLike from './isArrayLike.js'; /** - * The base implementation of `_.map` without support for iteratee shorthands. + * The base implementation of `_.map`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseMean.js b/_baseMean.js deleted file mode 100644 index c87baec2c..000000000 --- a/_baseMean.js +++ /dev/null @@ -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; diff --git a/_baseOrderBy.js b/_baseOrderBy.js index 147612a82..a45eac894 100644 --- a/_baseOrderBy.js +++ b/_baseOrderBy.js @@ -1,5 +1,4 @@ import arrayMap from './_arrayMap.js'; -import baseIteratee from './_baseIteratee.js'; import baseMap from './_baseMap.js'; import baseSortBy from './_baseSortBy.js'; import compareMultiple from './_compareMultiple.js'; @@ -16,7 +15,7 @@ import identity from './identity.js'; */ function baseOrderBy(collection, iteratees, orders) { 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 criteria = arrayMap(iteratees, iteratee => iteratee(value)); diff --git a/_basePickBy.js b/_basePickBy.js index 67d04cb87..e2cafb0c8 100644 --- a/_basePickBy.js +++ b/_basePickBy.js @@ -3,7 +3,7 @@ import baseSet from './_baseSet.js'; import castPath from './_castPath.js'; /** - * The base implementation of `_.pickBy` without support for iteratee shorthands. + * The base implementation of `_.pickBy`. * * @private * @param {Object} object The source object. diff --git a/_basePullAll.js b/_basePullAll.js index 19784a9c1..57dd0c3a7 100644 --- a/_basePullAll.js +++ b/_basePullAll.js @@ -10,8 +10,7 @@ const arrayProto = Array.prototype; const splice = arrayProto.splice; /** - * The base implementation of `_.pullAllBy` without support for iteratee - * shorthands. + * The base implementation of `_.pullAllBy`. * * @private * @param {Array} array The array to modify. diff --git a/_baseReduce.js b/_baseReduce.js index e836d73a4..1d559b719 100644 --- a/_baseReduce.js +++ b/_baseReduce.js @@ -1,6 +1,6 @@ /** - * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * The base implementation of `_.reduce` and `_.reduceRight` which iterates + * over `collection` using `eachFunc`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseSome.js b/_baseSome.js index 7db1a7b6d..7b1b5246b 100644 --- a/_baseSome.js +++ b/_baseSome.js @@ -1,7 +1,7 @@ import baseEach from './_baseEach.js'; /** - * The base implementation of `_.some` without support for iteratee shorthands. + * The base implementation of `_.some`. * * @private * @param {Array|Object} collection The collection to iterate over. diff --git a/_baseSortedUniq.js b/_baseSortedUniq.js index d4bf82fad..fe00745bc 100644 --- a/_baseSortedUniq.js +++ b/_baseSortedUniq.js @@ -1,8 +1,7 @@ import eq from './eq.js'; /** - * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without - * support for iteratee shorthands. + * The base implementation of `_.sortedUniq` and `_.sortedUniqBy`. * * @private * @param {Array} array The array to inspect. diff --git a/_baseSum.js b/_baseSum.js index 9d79920f7..b82fc04be 100644 --- a/_baseSum.js +++ b/_baseSum.js @@ -1,6 +1,5 @@ /** - * The base implementation of `_.sum` and `_.sumBy` without support for - * iteratee shorthands. + * The base implementation of `_.sum` and `_.sumBy`. * * @private * @param {Array} array The array to iterate over. diff --git a/_baseTimes.js b/_baseTimes.js index e4954747e..09c1c447e 100644 --- a/_baseTimes.js +++ b/_baseTimes.js @@ -1,6 +1,5 @@ /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. + * The base implementation of `_.times` without support for max array length checks. * * @private * @param {number} n The number of times to invoke `iteratee`. diff --git a/_baseUniq.js b/_baseUniq.js index fde5ed1e1..acf3c6736 100644 --- a/_baseUniq.js +++ b/_baseUniq.js @@ -9,7 +9,7 @@ import setToArray from './_setToArray.js'; const LARGE_ARRAY_SIZE = 200; /** - * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * The base implementation of `_.uniqBy`. * * @private * @param {Array} array The array to inspect. diff --git a/_baseWhile.js b/_baseWhile.js index d9fbe0c4a..3adb8ace6 100644 --- a/_baseWhile.js +++ b/_baseWhile.js @@ -1,8 +1,7 @@ import baseSlice from './_baseSlice.js'; /** - * The base implementation of methods like `_.dropWhile` and `_.takeWhile` - * without support for iteratee shorthands. + * The base implementation of methods like `_.dropWhile` and `_.takeWhile`. * * @private * @param {Array} array The array to query. diff --git a/_baseXor.js b/_baseXor.js index 8509f3807..5fd3f68b1 100644 --- a/_baseXor.js +++ b/_baseXor.js @@ -3,8 +3,8 @@ import baseFlatten from './_baseFlatten.js'; import baseUniq from './_baseUniq.js'; /** - * The base implementation of methods like `_.xor`, without support for - * iteratee shorthands, that accepts an array of arrays to inspect. + * The base implementation of methods like `_.xor` which accepts an array of + * arrays to inspect. * * @private * @param {Array} arrays The arrays to inspect. diff --git a/_castFunction.js b/_castFunction.js deleted file mode 100644 index 03a2e9913..000000000 --- a/_castFunction.js +++ /dev/null @@ -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; diff --git a/_createAggregator.js b/_createAggregator.js index 37c5b1591..b35b374d8 100644 --- a/_createAggregator.js +++ b/_createAggregator.js @@ -1,6 +1,5 @@ import arrayAggregator from './_arrayAggregator.js'; import baseAggregator from './_baseAggregator.js'; -import baseIteratee from './_baseIteratee.js'; import isArray from './isArray.js'; /** @@ -15,7 +14,7 @@ function createAggregator(setter, initializer) { return (collection, iteratee) => { const func = isArray(collection) ? arrayAggregator : baseAggregator; const accumulator = initializer ? initializer() : {}; - return func(collection, setter, baseIteratee(iteratee, 2), accumulator); + return func(collection, setter, iteratee, accumulator); }; } diff --git a/_createFind.js b/_createFind.js index ef0182a67..eb31fed6a 100644 --- a/_createFind.js +++ b/_createFind.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import isArrayLike from './isArrayLike.js'; import keys from './keys.js'; @@ -14,7 +13,6 @@ function createFind(findIndexFunc) { let iteratee; const iterable = Object(collection); if (!isArrayLike(collection)) { - iteratee = baseIteratee(predicate, 3); collection = keys(collection); predicate = key => iteratee(iterable[key], key, iterable); } diff --git a/_createInverter.js b/_createInverter.js index 939c43a16..0f2d181d2 100644 --- a/_createInverter.js +++ b/_createInverter.js @@ -5,11 +5,10 @@ import baseInverter from './_baseInverter.js'; * * @private * @param {Function} setter The function to set accumulator values. - * @param {Function} toIteratee The function to resolve iteratees. * @returns {Function} Returns the new inverter function. */ -function createInverter(setter, toIteratee) { - return (object, iteratee) => baseInverter(object, setter, toIteratee(iteratee), {}); +function createInverter(setter) { + return (object, iteratee) => baseInverter(object, setter, iteratee, {}); } export default createInverter; diff --git a/_createOver.js b/_createOver.js index ae55b3a0b..35c32f061 100644 --- a/_createOver.js +++ b/_createOver.js @@ -1,6 +1,4 @@ import apply from './_apply.js'; -import arrayMap from './_arrayMap.js'; -import baseIteratee from './_baseIteratee.js'; /** * Creates a function like `_.over`. @@ -11,8 +9,7 @@ import baseIteratee from './_baseIteratee.js'; */ function createOver(arrayFunc) { return (...iteratees) => { - iteratees = arrayMap(iteratees, iteratee => baseIteratee(iteratee)); - return (...args) => { + return function(...args) { const thisArg = this; return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args)); }; diff --git a/cond.js b/cond.js index 15075e889..00f217d25 100644 --- a/cond.js +++ b/cond.js @@ -1,6 +1,5 @@ import apply from './_apply.js'; import arrayMap from './_arrayMap.js'; -import baseIteratee from './_baseIteratee.js'; /** Error message constants. */ const FUNC_ERROR_TEXT = 'Expected a function'; @@ -36,13 +35,12 @@ const FUNC_ERROR_TEXT = 'Expected a function'; */ function cond(pairs) { const length = pairs == null ? 0 : pairs.length; - const toIteratee = baseIteratee; pairs = !length ? [] : arrayMap(pairs, pair => { if (typeof pair[1] != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return [toIteratee(pair[0]), pair[1]]; + return [pair[0], pair[1]]; }); return (...args) => { diff --git a/countBy.js b/countBy.js index 98def343e..66f198e35 100644 --- a/countBy.js +++ b/countBy.js @@ -18,16 +18,12 @@ const hasOwnProperty = objectProto.hasOwnProperty; * @since 0.5.0 * @category Collection * @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. * @example * * _.countBy([6.1, 4.2, 6.3], Math.floor); * // => { '4': 1, '6': 2 } - * - * // The `_.property` iteratee shorthand. - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } */ const countBy = createAggregator((result, value, key) => { if (hasOwnProperty.call(result, key)) { diff --git a/differenceBy.js b/differenceBy.js index d0629aee4..28a9ae20f 100644 --- a/differenceBy.js +++ b/differenceBy.js @@ -1,6 +1,5 @@ import baseDifference from './_baseDifference.js'; import baseFlatten from './_baseFlatten.js'; -import baseIteratee from './_baseIteratee.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -19,16 +18,12 @@ import last from './last.js'; * @category Array * @param {Array} array The array to inspect. * @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. * @example * * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); * // => [1.2] - * - * // The `_.property` iteratee shorthand. - * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] */ function differenceBy(array, ...values) { let iteratee = last(values); @@ -36,7 +31,7 @@ function differenceBy(array, ...values) { iteratee = undefined; } return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), iteratee) : []; } diff --git a/dropRightWhile.js b/dropRightWhile.js index c5cdbc6c1..8d9814f59 100644 --- a/dropRightWhile.js +++ b/dropRightWhile.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseWhile from './_baseWhile.js'; /** @@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js'; * @since 3.0.0 * @category Array * @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`. * @example * @@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js'; * * _.dropRightWhile(users, function(o) { return !o.active; }); * // => 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) { return (array && array.length) - ? baseWhile(array, baseIteratee(predicate, 3), true, true) + ? baseWhile(array, predicate, true, true) : []; } diff --git a/dropWhile.js b/dropWhile.js index 688c4dccd..62d058f31 100644 --- a/dropWhile.js +++ b/dropWhile.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseWhile from './_baseWhile.js'; /** @@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js'; * @since 3.0.0 * @category Array * @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`. * @example * @@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js'; * * _.dropWhile(users, function(o) { return !o.active; }); * // => 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) { return (array && array.length) - ? baseWhile(array, baseIteratee(predicate, 3), true) + ? baseWhile(array, predicate, true) : []; } diff --git a/every.js b/every.js index 61bf5f349..1cc28cde7 100644 --- a/every.js +++ b/every.js @@ -1,6 +1,5 @@ import arrayEvery from './_arrayEvery.js'; import baseEvery from './_baseEvery.js'; -import baseIteratee from './_baseIteratee.js'; import isArray from './isArray.js'; import isIterateeCall from './_isIterateeCall.js'; @@ -19,7 +18,7 @@ import isIterateeCall from './_isIterateeCall.js'; * @since 0.1.0 * @category Collection * @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`. * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. @@ -27,30 +26,13 @@ import isIterateeCall from './_isIterateeCall.js'; * * _.every([true, 1, null, 'yes'], Boolean); * // => 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) { const func = isArray(collection) ? arrayEvery : baseEvery; if (guard && isIterateeCall(collection, predicate, guard)) { predicate = undefined; } - return func(collection, baseIteratee(predicate, 3)); + return func(collection, predicate); } export default every; diff --git a/filter.js b/filter.js index 8c4073682..fc5aa3d93 100644 --- a/filter.js +++ b/filter.js @@ -1,6 +1,5 @@ import arrayFilter from './_arrayFilter.js'; import baseFilter from './_baseFilter.js'; -import baseIteratee from './_baseIteratee.js'; import isArray from './isArray.js'; /** @@ -15,7 +14,7 @@ import isArray from './isArray.js'; * @since 0.1.0 * @category Collection * @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. * @see _.reject * @example @@ -27,22 +26,10 @@ import isArray from './isArray.js'; * * _.filter(users, function(o) { return !o.active; }); * // => 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) { const func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, baseIteratee(predicate, 3)); + return func(collection, predicate); } export default filter; diff --git a/find.js b/find.js index d7dab9c25..42767ba28 100644 --- a/find.js +++ b/find.js @@ -11,7 +11,7 @@ import findIndex from './findIndex.js'; * @since 0.1.0 * @category Collection * @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. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -24,18 +24,6 @@ import findIndex from './findIndex.js'; * * _.find(users, function(o) { return o.age < 40; }); * // => 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); diff --git a/findIndex.js b/findIndex.js index 15fa25620..2223959f9 100644 --- a/findIndex.js +++ b/findIndex.js @@ -1,5 +1,4 @@ import baseFindIndex from './_baseFindIndex.js'; -import baseIteratee from './_baseIteratee.js'; import toInteger from './toInteger.js'; /* 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 * @category Array * @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. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -27,18 +26,6 @@ const nativeMax = Math.max; * * _.findIndex(users, function(o) { return o.user == 'barney'; }); * // => 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) { const length = array == null ? 0 : array.length; @@ -49,7 +36,7 @@ function findIndex(array, predicate, fromIndex) { if (index < 0) { index = nativeMax(length + index, 0); } - return baseFindIndex(array, baseIteratee(predicate, 3), index); + return baseFindIndex(array, predicate, index); } export default findIndex; diff --git a/findKey.js b/findKey.js index a578ede4e..caf489712 100644 --- a/findKey.js +++ b/findKey.js @@ -1,6 +1,5 @@ import baseFindKey from './_baseFindKey.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 @@ -11,7 +10,7 @@ import baseIteratee from './_baseIteratee.js'; * @since 1.1.0 * @category Object * @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, * else `undefined`. * @example @@ -24,21 +23,9 @@ import baseIteratee from './_baseIteratee.js'; * * _.findKey(users, function(o) { return o.age < 40; }); * // => '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) { - return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn); + return baseFindKey(object, predicate, baseForOwn); } export default findKey; diff --git a/findLast.js b/findLast.js index 23d408efa..b80f36e1f 100644 --- a/findLast.js +++ b/findLast.js @@ -10,7 +10,7 @@ import findLastIndex from './findLastIndex.js'; * @since 2.0.0 * @category Collection * @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. * @returns {*} Returns the matched element, else `undefined`. * @example diff --git a/findLastIndex.js b/findLastIndex.js index a17dafd57..877dd3e29 100644 --- a/findLastIndex.js +++ b/findLastIndex.js @@ -1,5 +1,4 @@ import baseFindIndex from './_baseFindIndex.js'; -import baseIteratee from './_baseIteratee.js'; import toInteger from './toInteger.js'; /* 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 * @category Array * @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. * @returns {number} Returns the index of the found element, else `-1`. * @example @@ -28,18 +27,6 @@ const nativeMin = Math.min; * * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); * // => 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) { const length = array == null ? 0 : array.length; @@ -53,7 +40,7 @@ function findLastIndex(array, predicate, fromIndex) { ? nativeMax(length + index, 0) : nativeMin(index, length - 1); } - return baseFindIndex(array, baseIteratee(predicate, 3), index, true); + return baseFindIndex(array, predicate, index, true); } export default findLastIndex; diff --git a/findLastKey.js b/findLastKey.js index 6b391dc03..95022ffd6 100644 --- a/findLastKey.js +++ b/findLastKey.js @@ -1,6 +1,5 @@ import baseFindKey from './_baseFindKey.js'; import baseForOwnRight from './_baseForOwnRight.js'; -import baseIteratee from './_baseIteratee.js'; /** * 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 * @category Object * @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, * else `undefined`. * @example @@ -24,21 +23,9 @@ import baseIteratee from './_baseIteratee.js'; * * _.findLastKey(users, function(o) { return o.age < 40; }); * // => 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) { - return baseFindKey(object, baseIteratee(predicate, 3), baseForOwnRight); + return baseFindKey(object, predicate, baseForOwnRight); } export default findLastKey; diff --git a/flatMap.js b/flatMap.js index 52a6a7aeb..8e6b56643 100644 --- a/flatMap.js +++ b/flatMap.js @@ -11,7 +11,7 @@ import map from './map.js'; * @since 4.0.0 * @category Collection * @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. * @example * diff --git a/flatMapDeep.js b/flatMapDeep.js index 59f54621a..3e292a4b1 100644 --- a/flatMapDeep.js +++ b/flatMapDeep.js @@ -13,7 +13,7 @@ const INFINITY = 1 / 0; * @since 4.7.0 * @category Collection * @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. * @example * diff --git a/flatMapDepth.js b/flatMapDepth.js index 4be00964c..6200b6bd1 100644 --- a/flatMapDepth.js +++ b/flatMapDepth.js @@ -11,7 +11,7 @@ import toInteger from './toInteger.js'; * @since 4.7.0 * @category Collection * @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. * @returns {Array} Returns the new flattened array. * @example diff --git a/forEach.js b/forEach.js index 15f9780f3..19fe274f0 100644 --- a/forEach.js +++ b/forEach.js @@ -1,6 +1,5 @@ import arrayEach from './_arrayEach.js'; -import baseEach from './_baseEach.js'; -import castFunction from './_castFunction.js'; +import baseEach from './_baseEach.js';; import isArray from './isArray.js'; /** @@ -18,7 +17,7 @@ import isArray from './isArray.js'; * @alias each * @category Collection * @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`. * @see _.forEachRight * @example @@ -35,7 +34,7 @@ import isArray from './isArray.js'; */ function forEach(collection, iteratee) { const func = isArray(collection) ? arrayEach : baseEach; - return func(collection, castFunction(iteratee)); + return func(collection, iteratee); } export default forEach; diff --git a/forEachRight.js b/forEachRight.js index cb12c147a..7b1191376 100644 --- a/forEachRight.js +++ b/forEachRight.js @@ -1,6 +1,5 @@ import arrayEachRight from './_arrayEachRight.js'; import baseEachRight from './_baseEachRight.js'; -import castFunction from './_castFunction.js'; import isArray from './isArray.js'; /** @@ -13,7 +12,7 @@ import isArray from './isArray.js'; * @alias eachRight * @category Collection * @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`. * @see _.forEach * @example @@ -25,7 +24,7 @@ import isArray from './isArray.js'; */ function forEachRight(collection, iteratee) { const func = isArray(collection) ? arrayEachRight : baseEachRight; - return func(collection, castFunction(iteratee)); + return func(collection, iteratee); } export default forEachRight; diff --git a/forIn.js b/forIn.js index 436f319d2..0fac23bad 100644 --- a/forIn.js +++ b/forIn.js @@ -1,5 +1,4 @@ import baseFor from './_baseFor.js'; -import castFunction from './_castFunction.js'; import keysIn from './keysIn.js'; /** @@ -13,7 +12,7 @@ import keysIn from './keysIn.js'; * @since 0.3.0 * @category Object * @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`. * @see _.forInRight * @example @@ -31,9 +30,7 @@ import keysIn from './keysIn.js'; * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). */ function forIn(object, iteratee) { - return object == null - ? object - : baseFor(object, castFunction(iteratee), keysIn); + return object == null ? object : baseFor(object, iteratee, keysIn); } export default forIn; diff --git a/forInRight.js b/forInRight.js index cc92970fb..3b68d768a 100644 --- a/forInRight.js +++ b/forInRight.js @@ -1,5 +1,4 @@ import baseForRight from './_baseForRight.js'; -import castFunction from './_castFunction.js'; import keysIn from './keysIn.js'; /** @@ -11,7 +10,7 @@ import keysIn from './keysIn.js'; * @since 2.0.0 * @category Object * @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`. * @see _.forIn * @example @@ -29,9 +28,7 @@ import keysIn from './keysIn.js'; * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. */ function forInRight(object, iteratee) { - return object == null - ? object - : baseForRight(object, castFunction(iteratee), keysIn); + return object == null ? object : baseForRight(object, iteratee, keysIn); } export default forInRight; diff --git a/forOwn.js b/forOwn.js index fe661690c..71b98b340 100644 --- a/forOwn.js +++ b/forOwn.js @@ -1,5 +1,4 @@ import baseForOwn from './_baseForOwn.js'; -import castFunction from './_castFunction.js'; /** * Iterates over own enumerable string keyed properties of an object and @@ -12,7 +11,7 @@ import castFunction from './_castFunction.js'; * @since 0.3.0 * @category Object * @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`. * @see _.forOwnRight * @example @@ -30,7 +29,7 @@ import castFunction from './_castFunction.js'; * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forOwn(object, iteratee) { - return object && baseForOwn(object, castFunction(iteratee)); + return object && baseForOwn(object, iteratee); } export default forOwn; diff --git a/forOwnRight.js b/forOwnRight.js index fe2dd281a..f93234de4 100644 --- a/forOwnRight.js +++ b/forOwnRight.js @@ -1,5 +1,4 @@ import baseForOwnRight from './_baseForOwnRight.js'; -import castFunction from './_castFunction.js'; /** * 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 * @category Object * @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`. * @see _.forOwn * @example @@ -28,7 +27,7 @@ import castFunction from './_castFunction.js'; * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. */ function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, castFunction(iteratee)); + return object && baseForOwnRight(object, iteratee); } export default forOwnRight; diff --git a/groupBy.js b/groupBy.js index 4ab3cd924..5fa8bf87c 100644 --- a/groupBy.js +++ b/groupBy.js @@ -19,16 +19,12 @@ const hasOwnProperty = objectProto.hasOwnProperty; * @since 0.1.0 * @category Collection * @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. * @example * * _.groupBy([6.1, 4.2, 6.3], Math.floor); * // => { '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) => { if (hasOwnProperty.call(result, key)) { diff --git a/intersectionBy.js b/intersectionBy.js index 794a78f4f..f81d1382f 100644 --- a/intersectionBy.js +++ b/intersectionBy.js @@ -1,6 +1,5 @@ import arrayMap from './_arrayMap.js'; import baseIntersection from './_baseIntersection.js'; -import baseIteratee from './_baseIteratee.js'; import castArrayLikeObject from './_castArrayLikeObject.js'; import last from './last.js'; @@ -16,16 +15,12 @@ import last from './last.js'; * @since 4.0.0 * @category Array * @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. * @example * * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); * // => [2.1] - * - * // The `_.property` iteratee shorthand. - * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }] */ function intersectionBy(...arrays) { let iteratee = last(arrays); @@ -37,7 +32,7 @@ function intersectionBy(...arrays) { mapped.pop(); } return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped, baseIteratee(iteratee, 2)) + ? baseIntersection(mapped, iteratee) : []; } diff --git a/invert.js b/invert.js index 8ba4c3b24..ccc08fe34 100644 --- a/invert.js +++ b/invert.js @@ -22,6 +22,6 @@ import identity from './identity.js'; */ const invert = createInverter((result, value, key) => { result[value] = key; -}, constant(identity)); +}); export default invert; diff --git a/invertBy.js b/invertBy.js index c9b85259a..eabae038a 100644 --- a/invertBy.js +++ b/invertBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import createInverter from './_createInverter.js'; /** Used for built-in method references. */ @@ -19,15 +18,12 @@ const hasOwnProperty = objectProto.hasOwnProperty; * @since 4.1.0 * @category Object * @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. * @example * * var object = { 'a': 1, 'b': 2, 'c': 1 }; * - * _.invertBy(object); - * // => { '1': ['a', 'c'], '2': ['b'] } - * * _.invertBy(object, function(value) { * return 'group' + value; * }); @@ -39,6 +35,6 @@ const invertBy = createInverter((result, value, key) => { } else { result[value] = [key]; } -}, baseIteratee); +}); export default invertBy; diff --git a/keyBy.js b/keyBy.js index 13b34e79b..e64f7ec86 100644 --- a/keyBy.js +++ b/keyBy.js @@ -12,7 +12,7 @@ import createAggregator from './_createAggregator.js'; * @since 4.0.0 * @category Collection * @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. * @example * diff --git a/map.js b/map.js index 975fea381..9daf124b7 100644 --- a/map.js +++ b/map.js @@ -1,5 +1,4 @@ import arrayMap from './_arrayMap.js'; -import baseIteratee from './_baseIteratee.js'; import baseMap from './_baseMap.js'; import isArray from './isArray.js'; @@ -22,7 +21,7 @@ import isArray from './isArray.js'; * @since 0.1.0 * @category Collection * @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. * @example * @@ -35,19 +34,10 @@ import isArray from './isArray.js'; * * _.map({ 'a': 4, 'b': 8 }, square); * // => [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) { const func = isArray(collection) ? arrayMap : baseMap; - return func(collection, baseIteratee(iteratee, 3)); + return func(collection, iteratee); } export default map; diff --git a/mapKeys.js b/mapKeys.js index 0d8969a7a..f578519b9 100644 --- a/mapKeys.js +++ b/mapKeys.js @@ -1,6 +1,5 @@ import baseAssignValue from './_baseAssignValue.js'; import baseForOwn from './_baseForOwn.js'; -import baseIteratee from './_baseIteratee.js'; /** * The opposite of `_.mapValues`; this method creates an object with the @@ -13,7 +12,7 @@ import baseIteratee from './_baseIteratee.js'; * @since 3.8.0 * @category Object * @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. * @see _.mapValues * @example @@ -25,8 +24,6 @@ import baseIteratee from './_baseIteratee.js'; */ function mapKeys(object, iteratee) { const result = {}; - iteratee = baseIteratee(iteratee, 3); - baseForOwn(object, (value, key, object) => { baseAssignValue(result, iteratee(value, key, object), value); }); diff --git a/mapValues.js b/mapValues.js index 513db9de5..102ba4d6d 100644 --- a/mapValues.js +++ b/mapValues.js @@ -1,6 +1,5 @@ import baseAssignValue from './_baseAssignValue.js'; import baseForOwn from './_baseForOwn.js'; -import baseIteratee from './_baseIteratee.js'; /** * 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 * @category Object * @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. * @see _.mapKeys * @example @@ -25,15 +24,9 @@ import baseIteratee from './_baseIteratee.js'; * * _.mapValues(users, function(o) { return o.age; }); * // => { '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) { const result = {}; - iteratee = baseIteratee(iteratee, 3); - baseForOwn(object, (value, key, object) => { baseAssignValue(result, key, iteratee(value, key, object)); }); diff --git a/maxBy.js b/maxBy.js index 6cbd1ceea..e69ac9ac0 100644 --- a/maxBy.js +++ b/maxBy.js @@ -1,6 +1,5 @@ import baseExtremum from './_baseExtremum.js'; import baseGt from './_baseGt.js'; -import baseIteratee from './_baseIteratee.js'; /** * 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 * @category Math * @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. * @example * @@ -20,14 +19,10 @@ import baseIteratee from './_baseIteratee.js'; * * _.maxBy(objects, function(o) { return o.n; }); * // => { 'n': 2 } - * - * // The `_.property` iteratee shorthand. - * _.maxBy(objects, 'n'); - * // => { 'n': 2 } */ function maxBy(array, iteratee) { return (array && array.length) - ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt) + ? baseExtremum(array, iteratee, baseGt) : undefined; } diff --git a/mean.js b/mean.js index 2323aefc1..26ee2a958 100644 --- a/mean.js +++ b/mean.js @@ -1,4 +1,4 @@ -import baseMean from './_baseMean.js'; +import baseMean from './meanBy.js'; import identity from './identity.js'; /** @@ -16,7 +16,7 @@ import identity from './identity.js'; * // => 5 */ function mean(array) { - return baseMean(array, identity); + return mean(array, identity); } export default mean; diff --git a/meanBy.js b/meanBy.js index 4a29ebdc9..d2a4173a5 100644 --- a/meanBy.js +++ b/meanBy.js @@ -1,5 +1,7 @@ -import baseIteratee from './_baseIteratee.js'; -import baseMean from './_baseMean.js'; +import baseSum from './_baseSum.js'; + +/** Used as references for various `Number` constants. */ +const NAN = 0 / 0; /** * 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 * @category Math * @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. * @example * @@ -19,13 +21,10 @@ import baseMean from './_baseMean.js'; * * _.meanBy(objects, function(o) { return o.n; }); * // => 5 - * - * // The `_.property` iteratee shorthand. - * _.meanBy(objects, 'n'); - * // => 5 */ 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; diff --git a/minBy.js b/minBy.js index 2d810a840..0e0e5515e 100644 --- a/minBy.js +++ b/minBy.js @@ -1,5 +1,4 @@ import baseExtremum from './_baseExtremum.js'; -import baseIteratee from './_baseIteratee.js'; import baseLt from './_baseLt.js'; /** @@ -12,7 +11,7 @@ import baseLt from './_baseLt.js'; * @since 4.0.0 * @category Math * @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. * @example * @@ -20,14 +19,10 @@ import baseLt from './_baseLt.js'; * * _.minBy(objects, function(o) { return o.n; }); * // => { 'n': 1 } - * - * // The `_.property` iteratee shorthand. - * _.minBy(objects, 'n'); - * // => { 'n': 1 } */ function minBy(array, iteratee) { return (array && array.length) - ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt) + ? baseExtremum(array, iteratee, baseLt) : undefined; } diff --git a/overArgs.js b/overArgs.js index 187c9e11b..f8942f991 100644 --- a/overArgs.js +++ b/overArgs.js @@ -1,7 +1,5 @@ import apply from './_apply.js'; -import arrayMap from './_arrayMap.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. */ const nativeMin = Math.min; @@ -38,7 +36,6 @@ const nativeMin = Math.min; * // => [100, 10] */ function overArgs(func, ...transforms) { - transforms = arrayMap(transforms, transform => baseIteratee(transform)); const funcsLength = transforms.length; return function(...args) { let index = -1; diff --git a/partition.js b/partition.js index 5993de0df..f7babe6da 100644 --- a/partition.js +++ b/partition.js @@ -11,7 +11,7 @@ import createAggregator from './_createAggregator.js'; * @since 3.0.0 * @category Collection * @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. * @example * @@ -23,18 +23,6 @@ import createAggregator from './_createAggregator.js'; * * _.partition(users, function(o) { return o.active; }); * // => 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) => result[key ? 0 : 1].push(value), () => [[], []]); diff --git a/pickBy.js b/pickBy.js index 3e8680c05..286e18c4b 100644 --- a/pickBy.js +++ b/pickBy.js @@ -1,5 +1,4 @@ import arrayMap from './_arrayMap.js'; -import baseIteratee from './_baseIteratee.js'; import basePickBy from './_basePickBy.js'; import getAllKeysIn from './_getAllKeysIn.js'; @@ -12,7 +11,7 @@ import getAllKeysIn from './_getAllKeysIn.js'; * @since 4.0.0 * @category 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. * @example * @@ -26,7 +25,6 @@ function pickBy(object, predicate) { return {}; } const props = arrayMap(getAllKeysIn(object), prop => [prop]); - predicate = baseIteratee(predicate); return basePickBy(object, props, (value, path) => predicate(value, path[0])); } diff --git a/pullAllBy.js b/pullAllBy.js index 2f9e41573..142d5e7de 100644 --- a/pullAllBy.js +++ b/pullAllBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import basePullAll from './_basePullAll.js'; /** @@ -14,7 +13,7 @@ import basePullAll from './_basePullAll.js'; * @category Array * @param {Array} array The array to modify. * @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`. * @example * @@ -26,7 +25,7 @@ import basePullAll from './_basePullAll.js'; */ function pullAllBy(array, values, iteratee) { return (array && array.length && values && values.length) - ? basePullAll(array, values, baseIteratee(iteratee, 2)) + ? basePullAll(array, values, iteratee) : array; } diff --git a/reduce.js b/reduce.js index 64e6da631..645dfce81 100644 --- a/reduce.js +++ b/reduce.js @@ -1,6 +1,5 @@ import arrayReduce from './_arrayReduce.js'; import baseEach from './_baseEach.js'; -import baseIteratee from './_baseIteratee.js'; import baseReduce from './_baseReduce.js'; import isArray from './isArray.js'; @@ -24,7 +23,7 @@ import isArray from './isArray.js'; * @since 0.1.0 * @category Collection * @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. * @returns {*} Returns the accumulated value. * @see _.reduceRight @@ -44,8 +43,7 @@ import isArray from './isArray.js'; function reduce(collection, iteratee, accumulator) { const func = isArray(collection) ? arrayReduce : baseReduce; const initAccum = arguments.length < 3; - - return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach); + return func(collection, iteratee, accumulator, initAccum, baseEach); } export default reduce; diff --git a/reduceRight.js b/reduceRight.js index 954c7bdc9..241adf6d2 100644 --- a/reduceRight.js +++ b/reduceRight.js @@ -1,6 +1,5 @@ import arrayReduceRight from './_arrayReduceRight.js'; import baseEachRight from './_baseEachRight.js'; -import baseIteratee from './_baseIteratee.js'; import baseReduce from './_baseReduce.js'; import isArray from './isArray.js'; @@ -13,7 +12,7 @@ import isArray from './isArray.js'; * @since 0.1.0 * @category Collection * @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. * @returns {*} Returns the accumulated value. * @see _.reduce @@ -29,8 +28,7 @@ import isArray from './isArray.js'; function reduceRight(collection, iteratee, accumulator) { const func = isArray(collection) ? arrayReduceRight : baseReduce; const initAccum = arguments.length < 3; - - return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); + return func(collection, iteratee, accumulator, initAccum, baseEachRight); } export default reduceRight; diff --git a/reject.js b/reject.js index 9e395bbcc..d3452b055 100644 --- a/reject.js +++ b/reject.js @@ -1,6 +1,5 @@ import arrayFilter from './_arrayFilter.js'; import baseFilter from './_baseFilter.js'; -import baseIteratee from './_baseIteratee.js'; import isArray from './isArray.js'; import negate from './negate.js'; @@ -13,7 +12,7 @@ import negate from './negate.js'; * @since 0.1.0 * @category Collection * @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. * @see _.filter * @example @@ -25,22 +24,10 @@ import negate from './negate.js'; * * _.reject(users, function(o) { return !o.active; }); * // => 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) { const func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, negate(baseIteratee(predicate, 3))); + return func(collection, negate(predicate)); } export default reject; diff --git a/remove.js b/remove.js index f705cbe7e..cf9e12dca 100644 --- a/remove.js +++ b/remove.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import basePullAt from './_basePullAt.js'; /** @@ -14,7 +13,7 @@ import basePullAt from './_basePullAt.js'; * @since 2.0.0 * @category Array * @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. * @example * @@ -38,7 +37,6 @@ function remove(array, predicate) { const indexes = []; const length = array.length; - predicate = baseIteratee(predicate, 3); while (++index < length) { const value = array[index]; if (predicate(value, index, array)) { diff --git a/some.js b/some.js index f998bebcb..311eeeb73 100644 --- a/some.js +++ b/some.js @@ -1,5 +1,4 @@ import arraySome from './_arraySome.js'; -import baseIteratee from './_baseIteratee.js'; import baseSome from './_baseSome.js'; import isArray from './isArray.js'; import isIterateeCall from './_isIterateeCall.js'; @@ -14,7 +13,7 @@ import isIterateeCall from './_isIterateeCall.js'; * @since 0.1.0 * @category Collection * @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`. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. @@ -22,30 +21,13 @@ import isIterateeCall from './_isIterateeCall.js'; * * _.some([null, 0, 'yes', false], Boolean); * // => 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) { const func = isArray(collection) ? arraySome : baseSome; if (guard && isIterateeCall(collection, predicate, guard)) { predicate = undefined; } - return func(collection, baseIteratee(predicate, 3)); + return func(collection, predicate); } export default some; diff --git a/sortedIndexBy.js b/sortedIndexBy.js index b5ee6db89..790497174 100644 --- a/sortedIndexBy.js +++ b/sortedIndexBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseSortedIndexBy from './_baseSortedIndexBy.js'; /** @@ -12,7 +11,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js'; * @category Array * @param {Array} array The sorted array to inspect. * @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 * into `array`. * @example @@ -21,13 +20,9 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js'; * * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); * // => 0 - * - * // The `_.property` iteratee shorthand. - * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); - * // => 0 */ function sortedIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2)); + return baseSortedIndexBy(array, value, iteratee); } export default sortedIndexBy; diff --git a/sortedLastIndexBy.js b/sortedLastIndexBy.js index bb84f81b0..9eea27364 100644 --- a/sortedLastIndexBy.js +++ b/sortedLastIndexBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseSortedIndexBy from './_baseSortedIndexBy.js'; /** @@ -12,7 +11,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js'; * @category Array * @param {Array} array The sorted array to inspect. * @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 * into `array`. * @example @@ -21,13 +20,9 @@ import baseSortedIndexBy from './_baseSortedIndexBy.js'; * * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); * // => 1 - * - * // The `_.property` iteratee shorthand. - * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); - * // => 1 */ function sortedLastIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true); + return baseSortedIndexBy(array, value, iteratee, true); } export default sortedLastIndexBy; diff --git a/sortedUniqBy.js b/sortedUniqBy.js index 48894fe51..6fa7c422d 100644 --- a/sortedUniqBy.js +++ b/sortedUniqBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseSortedUniq from './_baseSortedUniq.js'; /** @@ -10,7 +9,7 @@ import baseSortedUniq from './_baseSortedUniq.js'; * @since 4.0.0 * @category Array * @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. * @example * @@ -19,7 +18,7 @@ import baseSortedUniq from './_baseSortedUniq.js'; */ function sortedUniqBy(array, iteratee) { return (array && array.length) - ? baseSortedUniq(array, baseIteratee(iteratee, 2)) + ? baseSortedUniq(array, iteratee) : []; } diff --git a/sumBy.js b/sumBy.js index 6828c16b7..c740733e1 100644 --- a/sumBy.js +++ b/sumBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseSum from './_baseSum.js'; /** @@ -11,7 +10,7 @@ import baseSum from './_baseSum.js'; * @since 4.0.0 * @category Math * @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. * @example * @@ -19,14 +18,10 @@ import baseSum from './_baseSum.js'; * * _.sumBy(objects, function(o) { return o.n; }); * // => 20 - * - * // The `_.property` iteratee shorthand. - * _.sumBy(objects, 'n'); - * // => 20 */ function sumBy(array, iteratee) { return (array && array.length) - ? baseSum(array, baseIteratee(iteratee, 2)) + ? baseSum(array, iteratee) : 0; } diff --git a/takeRightWhile.js b/takeRightWhile.js index 642454336..7a3f1b02e 100644 --- a/takeRightWhile.js +++ b/takeRightWhile.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseWhile from './_baseWhile.js'; /** @@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js'; * @since 3.0.0 * @category Array * @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`. * @example * @@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js'; * * _.takeRightWhile(users, function(o) { return !o.active; }); * // => 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) { return (array && array.length) - ? baseWhile(array, baseIteratee(predicate, 3), false, true) + ? baseWhile(array, predicate, false, true) : []; } diff --git a/takeWhile.js b/takeWhile.js index f220a6e5e..a16518768 100644 --- a/takeWhile.js +++ b/takeWhile.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseWhile from './_baseWhile.js'; /** @@ -11,7 +10,7 @@ import baseWhile from './_baseWhile.js'; * @since 3.0.0 * @category Array * @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`. * @example * @@ -23,22 +22,10 @@ import baseWhile from './_baseWhile.js'; * * _.takeWhile(users, function(o) { return !o.active; }); * // => 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) { return (array && array.length) - ? baseWhile(array, baseIteratee(predicate, 3)) + ? baseWhile(array, predicate) : []; } diff --git a/times.js b/times.js index 935985a53..c301f0fe2 100644 --- a/times.js +++ b/times.js @@ -1,5 +1,4 @@ import baseTimes from './_baseTimes.js'; -import castFunction from './_castFunction.js'; import toInteger from './toInteger.js'; /** Used as references for various `Number` constants. */ @@ -20,7 +19,7 @@ const nativeMin = Math.min; * @memberOf _ * @category Util * @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. * @example * @@ -37,11 +36,9 @@ function times(n, iteratee) { } let index = MAX_ARRAY_LENGTH; const length = nativeMin(n, MAX_ARRAY_LENGTH); - - iteratee = castFunction(iteratee); - n -= MAX_ARRAY_LENGTH; - const result = baseTimes(length, iteratee); + + n -= MAX_ARRAY_LENGTH; while (++index < n) { iteratee(index); } diff --git a/transform.js b/transform.js index ef743a3b1..7cd105a41 100644 --- a/transform.js +++ b/transform.js @@ -1,7 +1,6 @@ import arrayEach from './_arrayEach.js'; import baseCreate from './_baseCreate.js'; import baseForOwn from './_baseForOwn.js'; -import baseIteratee from './_baseIteratee.js'; import getPrototype from './_getPrototype.js'; import isArray from './isArray.js'; import isBuffer from './isBuffer.js'; @@ -23,7 +22,7 @@ import isTypedArray from './isTypedArray.js'; * @since 1.3.0 * @category Object * @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. * @returns {*} Returns the accumulated value. * @example @@ -43,7 +42,6 @@ function transform(object, iteratee, accumulator) { const isArr = isArray(object); const isArrLike = isArr || isBuffer(object) || isTypedArray(object); - iteratee = baseIteratee(iteratee, 4); if (accumulator == null) { const Ctor = object && object.constructor; if (isArrLike) { diff --git a/unionBy.js b/unionBy.js index 9e0491c99..6b7061468 100644 --- a/unionBy.js +++ b/unionBy.js @@ -1,5 +1,4 @@ import baseFlatten from './_baseFlatten.js'; -import baseIteratee from './_baseIteratee.js'; import baseUniq from './_baseUniq.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -16,23 +15,19 @@ import last from './last.js'; * @since 4.0.0 * @category Array * @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. * @example * * _.unionBy([2.1], [1.2, 2.3], Math.floor); * // => [2.1, 1.2] - * - * // The `_.property` iteratee shorthand. - * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] */ function unionBy(...arrays) { let iteratee = last(arrays); if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)); + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), iteratee); } export default unionBy; diff --git a/uniqBy.js b/uniqBy.js index e08603d24..fa59a364a 100644 --- a/uniqBy.js +++ b/uniqBy.js @@ -1,4 +1,3 @@ -import baseIteratee from './_baseIteratee.js'; import baseUniq from './_baseUniq.js'; /** @@ -13,19 +12,15 @@ import baseUniq from './_baseUniq.js'; * @since 4.0.0 * @category Array * @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. * @example * * _.uniqBy([2.1, 1.2, 2.3], Math.floor); * // => [2.1, 1.2] - * - * // The `_.property` iteratee shorthand. - * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] */ function uniqBy(array, iteratee) { - return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : []; + return (array && array.length) ? baseUniq(array, iteratee) : []; } export default uniqBy; diff --git a/unzipWith.js b/unzipWith.js index a4b83a8c3..2c7b68cef 100644 --- a/unzipWith.js +++ b/unzipWith.js @@ -12,7 +12,7 @@ import unzip from './unzip.js'; * @since 3.8.0 * @category Array * @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. * @returns {Array} Returns the new array of regrouped elements. * @example @@ -28,9 +28,6 @@ function unzipWith(array, iteratee) { return []; } const result = unzip(array); - if (iteratee == null) { - return result; - } return arrayMap(result, group => apply(iteratee, undefined, group)); } diff --git a/update.js b/update.js index c4b10036b..68005e87b 100644 --- a/update.js +++ b/update.js @@ -1,5 +1,4 @@ import baseUpdate from './_baseUpdate.js'; -import castFunction from './_castFunction.js'; /** * This method is like `_.set` except that accepts `updater` to produce the @@ -29,7 +28,7 @@ import castFunction from './_castFunction.js'; * // => 0 */ 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; diff --git a/updateWith.js b/updateWith.js index 190b092b8..2cb4e9517 100644 --- a/updateWith.js +++ b/updateWith.js @@ -1,5 +1,4 @@ import baseUpdate from './_baseUpdate.js'; -import castFunction from './_castFunction.js'; /** * 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) { 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; diff --git a/xorBy.js b/xorBy.js index 32ca346a5..e9d67787f 100644 --- a/xorBy.js +++ b/xorBy.js @@ -1,5 +1,4 @@ import arrayFilter from './_arrayFilter.js'; -import baseIteratee from './_baseIteratee.js'; import baseXor from './_baseXor.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -16,23 +15,19 @@ import last from './last.js'; * @since 4.0.0 * @category Array * @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. * @example * * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); * // => [1.2, 3.4] - * - * // The `_.property` iteratee shorthand. - * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] */ function xorBy(...arrays) { let iteratee = last(arrays); if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2)); + return baseXor(arrayFilter(arrays, isArrayLikeObject), iteratee); } export default xorBy; diff --git a/zipWith.js b/zipWith.js index 581294405..72de687c9 100644 --- a/zipWith.js +++ b/zipWith.js @@ -10,7 +10,7 @@ import unzipWith from './unzipWith.js'; * @since 3.8.0 * @category Array * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee=_.identity] The function to combine + * @param {Function} iteratee The function to combine * grouped values. * @returns {Array} Returns the new array of grouped elements. * @example @@ -23,7 +23,6 @@ import unzipWith from './unzipWith.js'; function zipWith(...arrays) { const length = arrays.length; let iteratee = length > 1 ? arrays[length - 1] : undefined; - iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; return unzipWith(arrays, iteratee); }