invoker

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
5
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
4 KB
Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.
1 contributor
Install invoker as a package?
Copied
npm i @bit/justin-capalbo.ramda.invoker
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
invoker (
arity:Number,
method:String
) : Function

Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.

The returned function is curried and accepts arity + 1 parameters where the final parameter is the target object.

Example
const sliceFrom = R.invoker(1, 'slice');
     sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
     const sliceFrom6 = R.invoker(2, 'slice')(6);
     sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'
Arguments
arity: Number

Number of arguments the returned function should take before the target object.

method: String

Name of the method to call.

Returns
Function

A new curried function.

Help and resources