<< All versions
Skill v1.0.1
currentAutomated scan100/100jarle/bun-skills/bun-runtime-console
2 files
──Details
PublishedJune 2, 2026 at 08:52 AM
Content Hashsha256:3659f5c9ca0a84c1...
Git SHAf3601051c277
Bump Typepatch
──Files
Files (1 file, 2.1 KB)
SKILL.md2.1 KBactive
SKILL.md · 73 lines · 2.1 KB
version: "1.0.1" name: Bun Console description: The console object in Bun
Console
The console object in Bun
<Note> Bun provides a browser- and Node.js-compatible console global. This page only documents Bun-native APIs. </Note>
Object inspection depth
Bun allows you to configure how deeply nested objects are displayed in console.log() output:
- CLI flag: Use
--console-depth <number>to set the depth for a single run - Configuration: Set
console.depthin yourbunfig.tomlfor persistent configuration - Default: Objects are inspected to a depth of
2levels
js theme={"theme":{"light":"github-light","dark":"dracula"}}
const nested = { a: { b: { c: { d: "deep" } } } };console.log(nested);// Default (depth 2): { a: { b: [Object] } }// With depth 4: { a: { b: { c: { d: 'deep' } } } }
The CLI flag takes precedence over the configuration file setting.
Reading from stdin
In Bun, the console object can be used as an AsyncIterable to sequentially read lines from process.stdin.
ts adder.ts icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
for await (const line of console) {console.log(line);}
This is useful for implementing interactive programs, like the following addition calculator.
ts adder.ts icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
console.log(`Let's add some numbers!`);console.write(`Count: 0\n> `);let count = 0;for await (const line of console) {count += Number(line);console.write(`Count: ${count}\n> `);}
To run the file:
bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun adder.tsLet's add some numbers!Count: 0> 5Count: 5> 5Count: 10> 5Count: 15