Created
September 23, 2019 10:20
-
-
Save Killavus/c0f9d48388d24459d3e6dcbc03ebd39a to your computer and use it in GitHub Desktop.
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
function asyncOnce(promiseFn) { | |
let data = null; | |
let promise = null; | |
return function returnOnce(...args) { | |
if (!promise) { | |
promise = promiseFn(...args).then((promiseReturn) => { data = promiseReturn; }) | |
} | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment