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