Share your code. Components are building blocks, you are the architect.

utils/n-ary
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
1     DEPENDENCIES
Build: fail
BuildFail
Build Status: fail
Wraps a function of any arity (including nullary) in a function that accepts

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/n-ary in your project
npm i @bit/bit.ramda.utils.n-ary
Copied

nAry (n:Number, fn:Function) : Function

Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.

Example

var takesTwoArgs = (a, b) => [a, b];

     takesTwoArgs.length; //=> 2
     takesTwoArgs(1, 2); //=> [1, 2]

     var takesOneArg = R.nAry(1, takesTwoArgs);
     takesOneArg.length; //=> 1
     // Only `n` arguments are passed to the wrapped function
     takesOneArg(1, 2); //=> [1, undefined]

Arguments

n: Number

The desired arity of the new function.

fn: Function

The function to wrap.

Returns

Function

A new function wrapping `fn`. The new function is guaranteed to be of arity `n`.