Created
September 26, 2017 08:18
-
-
Save n1ru4l/dfa958c4e5819f0441bd162a7dfc5574 to your computer and use it in GitHub Desktop.
Tiny Flow Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const once = (func: Function): Function => { | |
| let called = false | |
| let cachedValue = undefined | |
| return (...args) => { | |
| if (!called) { | |
| cachedValue = func(...args) | |
| called = true | |
| } | |
| return cachedValue | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment