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

sourcenpm package

Creates a function that invokes func with its arguments transformed.

Since

4.0.0

Arguments

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

Returns

(Function): Returns the new function.

Example

  1. 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]