Skip to content

Commit

Permalink
feat: 🎸 add sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
l246804 committed Aug 15, 2023
1 parent 41ac852 commit 1db4104
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/sleep/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 睡眠 `n` 毫秒
*
* @example
* ```ts
* async run() {
* console.log(Date.now())
* await sleep(1000)
* console.log(Date.now())
* }
* ```
*/
export default function sleep(ms = 0) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, ms)
})
}

0 comments on commit 1db4104

Please sign in to comment.