mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
DISABLE_THIRD_PARTY_CHECK=Updates package.json Bug: 1041811 Change-Id: I9493880aed334f02e5899efed3fc8bb964d0bbb0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1998770 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
onetime 
Ensure a function is only called once
When called multiple times it will return the return value from the first call.
Unlike the module once, this one isn't naughty extending Function.prototype.
Install
$ npm install --save onetime
Usage
let i = 0;
const foo = onetime(() => i++);
foo(); //=> 0
foo(); //=> 0
foo(); //=> 0
const foo = onetime(() => {}, {throw: true});
foo();
foo();
//=> Error: Function `foo` can only be called once
API
onetime(fn, [options])
Returns a function that only calls fn once.
fn
Type: Function
Function that should only be called once.
options
Type: Object
throw
Type: boolean
Default: false
Throw an error when called more than once.
License
MIT © Sindre Sorhus