Skip to content

Instantly share code, notes, and snippets.

@robinpokorny
Created May 3, 2017 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinpokorny/ad7c8a3f2a03bf193655dea1e03d638c to your computer and use it in GitHub Desktop.
Save robinpokorny/ad7c8a3f2a03bf193655dea1e03d638c to your computer and use it in GitHub Desktop.
Sleep that passes data
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