Add an inbuilt sleep() #49636
Closed
mikemaccana
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
You can do this: const sleep = require('timers/promises').setTimeout;
await sleep(5000); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Nearly every JS codebase I've seen since ES2017 has something like:
copypasted everywhere or, if they're a little better:
Yes, people often should be using async functions,
Promise.race()
etc for many cases where they are usingsleep()
, but people can and do have legitimate reasons forsleep()
ing. It would be great for node to be 'batteries included' and shipsleep()
.I had a look through the API to find the best place to put this. Maybe in the
timers
API?Beta Was this translation helpful? Give feedback.
All reactions