1 var apply = require('./_apply'),
2 arrayMap = require('./_arrayMap'),
3 baseFlatten = require('./_baseFlatten'),
4 baseIteratee = require('./_baseIteratee'),
5 rest = require('./rest');
7 /* Built-in method references for those with the same name as other `lodash` methods. */
8 var nativeMin = Math.min;
11 * Creates a function that invokes `func` with arguments transformed by
12 * corresponding `transforms`.
17 * @param {Function} func The function to wrap.
18 * @param {...(Function|Function[])} [transforms] The functions to transform
19 * arguments, specified individually or in arrays.
20 * @returns {Function} Returns the new function.
23 * function doubled(n) {
27 * function square(n) {
31 * var func = _.overArgs(function(x, y) {
33 * }, square, doubled);
41 var overArgs = rest(function(func, transforms) {
42 transforms = arrayMap(baseFlatten(transforms), baseIteratee);
44 var funcsLength = transforms.length;
45 return rest(function(args) {
47 length = nativeMin(args.length, funcsLength);
49 while (++index < length) {
50 args[index] = transforms[index].call(this, args[index]);
52 return apply(func, this, args);
56 module.exports = overArgs;