2.0.0 • Published 4 years ago
@fabiospampinato/once v2.0.0
Once
Wraps a function so that it's only ever executed once.
Note: this is always set to undefined and only functions that don't accept any arguments are supported, as using those with a function that's only ever executed once is practically just a footgun. If you need different this or different arguments you should probably use memoization instead.
Install
npm install --save once@npm:@fabiospampinato/onceUsage
import once from 'once';
const rand = once (() => Math.random ());
rand (); // => 0.3344627371267874
rand (); // => 0.3344627371267874License
MIT © Fabio Spampinato