> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 固定毫秒数的休眠

`Bun.sleep` 方法提供了一种方便的方式来创建一个在固定毫秒数后解决的 void `Promise`。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
// 休眠 1 秒
await Bun.sleep(1000);
```

***

在内部，这等价于以下使用 [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) 的代码片段。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
await new Promise(resolve => setTimeout(resolve, ms));
```

***

更多实用工具请参见 [文档 > API > Utils](/runtime/utils)。
