use-with

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
3
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Accepts a function `fn` and a list of transformer functions and returns a new curried function.
1 contributor
Install use-with as a package?
Copied
npm i @bit/justin-capalbo.ramda.use-with
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
useWith (
fn:Function,
transformers:Array
) : Function

Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.

If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to fn as additional parameters. If you expect additional arguments that don’t need to be transformed, although you can ignore them, it’s best to pass an identity function so that the new function reports the correct arity.

Example
R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81
     R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81
     R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
     R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32
Arguments
fn: Function

The function to wrap.

transformers: Array

A list of transformer functions

Returns
Function

The wrapped function.

Help and resources