Skip to main content

Module tty

Module tty 

Source
Expand description

Node tty module.

tty.isatty(fd) queries whether a file descriptor is a terminal (via libc::isatty). tty.ReadStream/tty.WriteStream are exposed as native classes: a WriteStream carries fd/isTTY/columns/rows and the cursor/erase methods (cursorTo/moveCursor/clearLine/clearScreenDown/ getWindowSize/getColorDepth/hasColors), all routed — like process.stdout — through process::stream_instance_call; a ReadStream carries fd/isTTY/isRaw with a best-effort setRawMode.

Constants§

METHODS
READ_STREAM_METHODS
Instance methods of a tty.ReadStream.

Functions§

call
constant
require('tty').ReadStream / .WriteStream — expose the classes as constructible builtins (the parent routes new/instance calls by tag).
construct
new tty.ReadStream(fd) / new tty.WriteStream(fd).
instance_call
Dispatch a tty.ReadStream instance method. Terminal raw-mode toggling has no termios substrate here, so setRawMode just records the flag; the rest are chainable no-ops so .on('data')/.pause()/.resume() chains load.
read_stream
Build a tty.ReadStream object.
window_size
The terminal’s (columns, rows) via ioctl(TIOCGWINSZ); None when fd is not a terminal or the ioctl fails.
write_stream
Build a tty.WriteStream object (same shape as process.stdout).