_.overArgs

_.overArgs(func, [transforms=[_.identity]])

source npm package

Creates a function that invokes func with its arguments transformed.

Since

4.0.0

Arguments

  1. func (Function): The function to wrap.
  2. [transforms=[_.identity]] (…(Function|Function[])): The argument transforms.

Returns

(Function): Returns the new function.

Example

function doubled(n) {
  return n * 2;
}
 
function square(n) {
  return n * n;
}
 
var func = _.overArgs(function(x, y) {
  return [x, y];
}, [square, doubled]);
 
func(9, 3);
// => [81, 6]
 
func(10, 5);
// => [100, 10]