diff --git a/.internal/createOver.js b/.internal/createOver.js deleted file mode 100644 index 30e14282c..000000000 --- a/.internal/createOver.js +++ /dev/null @@ -1,19 +0,0 @@ -import apply from './.internal/apply.js'; - -/** - * Creates a function like `over`. - * - * @private - * @param {Function} arrayFunc The function to iterate over iteratees. - * @returns {Function} Returns the new over function. - */ -function createOver(arrayFunc) { - return (...iteratees) => { - return function(...args) { - const thisArg = this; - return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args)); - }; - }; -} - -export default createOver; diff --git a/over.js b/over.js index e7ef33f33..530b33372 100644 --- a/over.js +++ b/over.js @@ -1,5 +1,5 @@ +import apply from './.internal/apply.js'; import arrayMap from './.internal/arrayMap.js'; -import createOver from './.internal/createOver.js'; /** * Creates a function that invokes `iteratees` with the arguments it receives @@ -7,7 +7,7 @@ import createOver from './.internal/createOver.js'; * * @since 4.0.0 * @category Util - * @param {...(Function|Function[])} [iteratees=[identity]] + * @param {Function[]} [iteratees=[identity]] * The iteratees to invoke. * @returns {Function} Returns the new function. * @example @@ -17,6 +17,11 @@ import createOver from './.internal/createOver.js'; * func(1, 2, 3, 4); * // => [4, 1] */ -const over = createOver(arrayMap); +function over(iteratees) { + return function(...args) { + const thisArg = this; + return arrayMap(iteratees, iteratee => apply(iteratee, thisArg, args)); + }; +} export default over; diff --git a/overArgs.js b/overArgs.js index 0757be965..3d7620bcb 100644 --- a/overArgs.js +++ b/overArgs.js @@ -1,8 +1,4 @@ import apply from './.internal/apply.js'; -import baseFlatten from './.internal/baseFlatten.js'; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeMin = Math.min; /** * Creates a function that invokes `func` with its arguments transformed. @@ -10,7 +6,7 @@ const nativeMin = Math.min; * @since 4.0.0 * @category Function * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms=[identity]] + * @param {Function[]} [transforms=[identity]] * The argument transforms. * @returns {Function} Returns the new function. * @example @@ -31,12 +27,11 @@ const nativeMin = Math.min; * func(10, 5); * // => [100, 10] */ -function overArgs(func, ...transforms) { +function overArgs(func, transforms) { const funcsLength = transforms.length; return function(...args) { let index = -1; - const length = nativeMin(args.length, funcsLength); - + const length = Math.min(args.length, funcsLength); while (++index < length) { args[index] = transforms[index].call(this, args[index]); } diff --git a/overEvery.js b/overEvery.js index 534702f3c..0715b9ad3 100644 --- a/overEvery.js +++ b/overEvery.js @@ -1,5 +1,5 @@ +import apply from './.internal/apply.js'; import arrayEvery from './.internal/arrayEvery.js'; -import createOver from './.internal/createOver.js'; /** * Creates a function that checks if **all** of the `predicates` return @@ -7,7 +7,7 @@ import createOver from './.internal/createOver.js'; * * @since 4.0.0 * @category Util - * @param {...(Function|Function[])} [predicates=[identity]] + * @param {Function[]} [predicates=[identity]] * The predicates to check. * @returns {Function} Returns the new function. * @example @@ -23,6 +23,11 @@ import createOver from './.internal/createOver.js'; * func(NaN); * // => false */ -const overEvery = createOver(arrayEvery); +function overEvery(iteratees) { + return function(...args) { + const thisArg = this; + return arrayEvery(iteratees, iteratee => apply(iteratee, thisArg, args)); + }; +} export default overEvery; diff --git a/overSome.js b/overSome.js index 93b98a3c8..6308c0890 100644 --- a/overSome.js +++ b/overSome.js @@ -1,5 +1,5 @@ +import apply from './.internal/apply.js'; import arraySome from './.internal/arraySome.js'; -import createOver from './.internal/createOver.js'; /** * Creates a function that checks if **any** of the `predicates` return @@ -7,7 +7,7 @@ import createOver from './.internal/createOver.js'; * * @since 4.0.0 * @category Util - * @param {...(Function|Function[])} [predicates=[identity]] + * @param {Function[]} [predicates=[identity]] * The predicates to check. * @returns {Function} Returns the new function. * @example @@ -23,6 +23,11 @@ import createOver from './.internal/createOver.js'; * func(NaN); * // => false */ -const overSome = createOver(arraySome); +function overSome(iteratees) { + return function(...args) { + const thisArg = this; + return arraySome(iteratees, iteratee => apply(iteratee, thisArg, args)); + }; +} export default overSome;