MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiwkmq8
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
Show parent comments
4
A synchronous blocking sleep variation:
const sleep = ms => { const desired = Date.now() + ms; while(Date.now() < desired) {} };
5 u/spacejack2114 Mar 20 '19 delet this 1 u/EllisLloyd Mar 19 '19 Yeah this is more in line with what sleep usually means in other languages I mentioned, i.e. preventing the thread from running any other operation for a given duration. 1 u/[deleted] Mar 20 '19 [removed] — view removed comment 2 u/BenZed Mar 25 '19 It definitely does not invoke a system call.
5
delet this
1
Yeah this is more in line with what sleep usually means in other languages I mentioned, i.e. preventing the thread from running any other operation for a given duration.
[removed] — view removed comment
2 u/BenZed Mar 25 '19 It definitely does not invoke a system call.
2
It definitely does not invoke a system call.
4
u/GBcrazy Mar 19 '19
A synchronous blocking sleep variation: