Skip to main content

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
// 休眠 1 秒
await Bun.sleep(1000);

在内部,这等价于以下使用 setTimeout 的代码片段。
await new Promise(resolve => setTimeout(resolve, ms));

更多实用工具请参见 文档 > API > Utils