nodejs使用promise实现sleep

/ 0 条评论 / 789人阅读
let sleep = function (delay) {
  return new Promise((resolve, reject) => { 
   setTimeout(() => { 
     try {
      resolve(1)
     } catch (e) {
      reject(0)
     }
   }, delay);
  })
 }

Responses /