JavaScript sleep Function

// https://zeit.co/blog/async-and-await
function sleep (time) {
  return new Promise((resolve) => setTimeout(resolve, time));
}

// Usage!
sleep(500).then(() => {
    // Do something after the sleep!
})

发表评论

电子邮件地址不会被公开。 必填项已用*标注