once

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
860 B
Accepts a function `fn` and returns a function that guards invocation of
1 contributor
Install once as a package?
Copied
npm i @bit/justin-capalbo.ramda.once
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
once (
fn:Function
) : Function

Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be called once, no matter how many times the returned function is invoked. The first value calculated is returned in subsequent invocations.

Example
const addOneOnce = R.once(x => x + 1);
     addOneOnce(10); //=> 11
     addOneOnce(addOneOnce(50)); //=> 11
Argument
fn: Function

The function to wrap in a call-only-once wrapper.

Returns
Function

The wrapped function.

Help and resources