MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiv5hzh
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
Show parent comments
19
If we're going there, why not:
const sleep = ms => data => new Promise(resolve => setTimeout(resolve, ms, data))
😉
3 u/higherpublic Mar 19 '19 edited Mar 19 '19 No way. Such elegance!! How is data from the api call not getting passed in as the ms though?Edit: never mind I see it now 1 u/TheKingdutch Mar 19 '19 TIL: about extra parameters for setTimeout. Thanks!
3
No way. Such elegance!! How is data from the api call not getting passed in as the ms though?
Edit: never mind I see it now
1
TIL: about extra parameters for setTimeout. Thanks!
19
u/tjoskar Mar 19 '19
If we're going there, why not:
const sleep = ms => data => new Promise(resolve => setTimeout(resolve, ms, data))😉