Skip to content

Commit 78cf47b

Browse files
committed
https://leetcode.cn/problems/sleep
1 parent b4328ac commit 78cf47b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Step 2. Add the dependency
4949

5050
<summary>展开查看</summary>
5151

52+
https://leetcode.cn/problems/sleep
53+
5254
https://leetcode.cn/problems/array-prototype-last
5355

5456
https://leetcode.cn/problems/counter

sleep/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default async function sleep(millis: number): Promise<void> {
2+
await new Promise((s) => setTimeout(s, millis));
3+
}
4+
5+
/**
6+
* let t = Date.now()
7+
* sleep(100).then(() => console.log(Date.now() - t)) // 100
8+
*/

0 commit comments

Comments
 (0)