Bun 提供了一个兼容浏览器和 Node.js 的 console
全局对象。本页仅记录 Bun 原生的 API。
对象检查深度
Bun 允许你配置在console.log() 输出中嵌套对象的显示深度:
- 命令行参数:使用
--console-depth <number>为单次运行设置深度 - 配置文件:在
bunfig.toml中设置console.depth以进行持久化配置 - 默认值:对象默认被检查到
2层深度
从标准输入读取
在 Bun 中,console 对象可以作为一个 AsyncIterable,用于顺序读取 process.stdin 中的行。
terminal