Created
May 3, 2017 16:16
-
-
Save robinpokorny/ad7c8a3f2a03bf193655dea1e03d638c to your computer and use it in GitHub Desktop.
Sleep that passes data
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
const sleep = (dur) => (data) => | |
new Promise((res) => | |
setTimeout(() => res(data), dur) | |
) | |
const yay = () => Promise.resolve('sleepy') | |
.then(sleep(1000)) | |
.then((status) => console.log(`I am so ${status}!`)) | |
yay() | |
// -> I am so sleepy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment