n-ary

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
6
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
982 B
Wraps a function of any arity (including nullary) in a function that accepts exactly `n` parameters.
1 contributor
Install n-ary as a package?
Copied
npm i @bit/justin-capalbo.ramda.n-ary
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
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
const takesTwoArgs = (a, b) => [a, b];

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

     const 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`.

Help and resources