invoke-once
v1.0.0
Published
Restrict the given function only be invoked once. Repeat calls to the function return the value of the first invocation.
Downloads
2
Maintainers
Readme
invoke-once
Restrict the given function only be invoked once. Repeat calls to the function return the value of the first invocation.
Install
$ npm install --save invoke-once
Usage
For more use-cases see the tests
var invokeOnce = require('invoke-once');
var c = 0;
var fn = invokeOnce(function () {
return ++c;
});
fn(); // => 1
fn(); // => 1
fn(); // => 1
Related
- invoke-fn - A faster alternative to
Function#apply
. - invoke-before - Returns a function that will only be executed before being called N times.
- invoke-after - Returns a function that will only be executed after being called N times.
- try-invoke - Attempts to invoke the given function, returning either the result or the caught error object.
- is-native - Checks if the given value is a native function.
- to-source-code - Converts function to its source code.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.