Bun 提供了一个兼容浏览器和 Node.js 的 console 全局对象。此页面仅记录 Bun 原生 API。
对象检查深度
您可以配置console.log() 打印嵌套对象的深度:
- CLI 标志:使用
--console-depth <number>为单次运行设置深度 - 配置:在
bunfig.toml中设置console.depth以在多次运行中持久化 - 默认值:对象默认检查到
2层深度
从 stdin 读取
在 Bun 中,console 对象也是一个 AsyncIterable,可以逐行读取 process.stdin。
adder.ts
adder.ts
terminal