某些 Web API 在以服务器为先的运行时环境(如 Bun)中不适用,例如 DOM API 或 History API。但许多其他 API 在浏览器环境之外同样广泛有用;Bun 尽可能实现这些 Web 标准 API,而不是引入新的 API。 以下 Web API 得到部分或完全支持。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.
| 分类 | API |
|---|---|
| HTTP | fetch,Response,Request,Headers,AbortController,AbortSignal |
| URL | URL,URLSearchParams |
| Web Workers | Worker,self.postMessage,structuredClone,MessagePort,MessageChannel,BroadcastChannel |
| Streams | ReadableStream,WritableStream,TransformStream,ByteLengthQueuingStrategy,CountQueuingStrategy 及相关类 |
| Blob | Blob |
| WebSockets | WebSocket |
| 编解码 | atob,btoa,TextEncoder,TextDecoder |
| JSON | JSON |
| 定时器 | setTimeout,clearTimeout |
| 间隔定时器 | setInterval,clearInterval |
| 加密 | crypto,SubtleCrypto,CryptoKey |
| 调试 | console,performance |
| 微任务 | queueMicrotask |
| 错误处理 | reportError |
| 用户交互 | alert,confirm,prompt(用于交互式命令行界面) |
| Realms | ShadowRealm |
| 事件 | EventTarget,Event,ErrorEvent,CloseEvent,MessageEvent |