Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

binary

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
21
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
8 months ago
SIZE
1 KB
Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters.
1 contributor
Use binary in your project ?
Copied
npm i @bit/ramda.ramda.binary
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
takesTwoArgs(1, 2, 3);
modifieddraft
chevron_left
chevron_right
binary (
fn:Function
) : Function

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

Example
const takesThreeArgs = function(a, b, c) {
       return [a, b, c];
     };
     takesThreeArgs.length; //=> 3
     takesThreeArgs(1, 2, 3); //=> [1, 2, 3]

     const takesTwoArgs = R.binary(takesThreeArgs);
     takesTwoArgs.length; //=> 2
     // Only 2 arguments are passed to the wrapped function
     takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
Argument
fn: Function

The function to wrap.

Returns
Function

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