mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Consolidate over modules.
This commit is contained in:
11
overArgs.js
11
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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user