new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · all subjects

runtime/console

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

console.depth configuration and CLI flag

The depth of nested object inspection in console.log() can be configured in two ways. Use the CLI flag --console-depth <number> to set the depth for a single run, or set console.depth in bunfig.toml to persist it across runs. The CLI flag takes precedence over the configuration file setting. The default depth is 2 levels.

console object inspection depth example

With default depth of 2, the object { a: { b: { c: { d: "deep" } } } } prints as { a: { b: { c: [Object ...] } } }. With depth 4, it prints as { a: { b: { c: { d: 'deep' } } } }.

console as AsyncIterable for stdin

In Bun, the console object is an AsyncIterable that reads from process.stdin line by line. You can iterate over console using a for await...of loop to process input line by line.

console.write() method

The console object has a write() method that outputs text without a newline. This is useful for prompts and interactive programs.

Reading stdin with console AsyncIterable example

To read lines from stdin using console as an AsyncIterable: ```ts for await (const line of console) { console.log(line); } ``` This example shows iterating over each line from process.stdin and logging it.

Interactive console program example

Here is a complete example of an interactive program that reads numbers from stdin: ```ts 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> `); } ``` This demonstrates using console.write() for prompts and the AsyncIterable pattern to process user input.

Give your agent this brain