modArgs source npm

_.modArgs(func, [transforms])

Creates a function that invokes func with arguments modified by corresponding transforms.

Arguments

  1. func (Function)

    The function to wrap.

  2. [transforms] (...(Function|Function[])

    The functions to transform arguments, specified individually or in arrays.

Returns (Function)

Returns the new function.

Example

function doubled(n) {
  return n * 2;
}

function square(n) {
  return n * n;
}

var modded = _.modArgs(function(x, y) {
  return [x, y];
}, square, doubled);

modded(9, 3);
// => [81, 6]

modded(10, 5);
// => [100, 10]