@std/io

Overview

Terminal streams, pretty-printing, line input, and raw mode.

io owns the terminal: standard streams, color-aware pretty-printing, line input, size queries, and raw mode. File I/O stays in @std/fs. Every item uses the export keyword. There is no ambient Console class. print stays in the prelude as a shim over io.write.

.rnx
import io, { ColorLevel } from "@std/io";

The default import is the module namespace holding the free functions below. Streams are stdin() / stdout() / stderr() calls returning File handles built by File.fromHandle; each call duplicates the descriptor, so closing the handle never touches descriptors 0, 1, or 2. write targets a single value, pretty-printed by the shared renderer (arrays as [a, b], maps as {k: v}, class instances as Name{field: value}, depth cap 3, cycles as <cycle>, colors when stdout is a terminal). print forwards each argument through the same renderer and joins with spaces. colorProfile reads NO_COLOR through Env.get, which cannot tell an empty value from an unset one, so an explicitly empty NO_COLOR is treated as unset until a presence check exists.

When to use it

Reach for @std/io when a program talks to the terminal: write and writeError for color-aware pretty-printing with newlines, writeRaw for exact bytes, read and readLine for input, width and height for layout, colorProfile for the ColorLevel tier, setRawMode for character-at-a-time input. File I/O stays in @std/fs.

Capabilities

  • Color-aware pretty-printing
  • stdin/stdout/stderr handles
  • Line input and size queries
  • Raw mode toggling

Symbols

  • enum ColorLevel
  • fn clear()
  • fn colorProfile()
  • fn height()
  • fn isTTY()
  • fn read()
  • fn readLine()
  • fn setRawMode()
  • fn stderr()
  • fn stdin()
  • fn stdout()
  • fn width()
  • fn write()
  • fn writeError()
  • fn writeRaw()