Created
July 11, 2017 17:53
-
-
Save thomasmichaelwallace/d7a31d083ab9598c8ce1db7914db8640 to your computer and use it in GitHub Desktop.
A promise wrapper for mocking asynchronous functions with a bit of chaos.
This file contains 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
const chaosPromise = result => ( | |
Math.random() >= 0.5 | |
? Promise.resolve(result) | |
: new Promise(res => setTimeout(() => res(result), Math.random() * 1000)) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment