https://github.com/shellscape/once-and-again
Resettable _.once()
https://github.com/shellscape/once-and-again
Last synced: 5 months ago
JSON representation
Resettable _.once()
- Host: GitHub
- URL: https://github.com/shellscape/once-and-again
- Owner: shellscape
- Created: 2014-01-09T22:13:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-06T19:38:55.000Z (over 12 years ago)
- Last Synced: 2025-05-14T14:33:26.263Z (8 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
once-and-again
==============
Resettable _.once()
Overrides _.prototype.once to return a function which accepts an argument to force a reset on the function, letting it run again. To reset the function:
var runOnceFunction = _(function () {
console.log('only run once');
}).once();
var initialResult = runOnceFunction(); // true result
var memoResult = runOnceFunction(); // memoized result, function not run
var newResult = runOnceFunction(true); // true result