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