sleep.js 231 B

12345678910111213141516
  1. function sleep(ms) {
  2. return new Promise((resolve) => {
  3. setTimeout(resolve, ms)
  4. })
  5. }
  6. function nextTick() {
  7. return new Promise((resolve) => {
  8. process.nextTick(resolve)
  9. })
  10. }
  11. module.exports = {
  12. sleep,
  13. nextTick,
  14. }