Node.js module
readline
The 'node:readline' module provides an interface for reading data from a Readable stream (such as process.stdin) one line at a time. It includes the readline.Interface class with question, on('line'), and close events.
Use cases include building command-line tools, interactive prompts, and REPL-style applications.
Fully supported in Bun
Fully implemented.
Functions 6
- readline.clearLine()
The
readline.clearLine()method clears current line of given TTY stream in a specified direction identified bydir. - readline.clearScreenDown()
The
readline.clearScreenDown()method clears the given TTY stream from the current position of the cursor down. - readline.createInterface()
The
readline.createInterface()method creates a newreadline.Interfaceinstance. - readline.cursorTo()
The
readline.cursorTo()method moves cursor to the specified position in a given TTYstream. - readline.emitKeypressEvents()
The
readline.emitKeypressEvents()method causes the givenReadablestream to begin emitting'keypress'events corresponding to received input. - readline.moveCursor()
The
readline.moveCursor()method moves the cursor _relative_ to its current position in a given TTYstream.
Classes 1
- class readline.Interface
Instances of the
readline.Interfaceclass are constructed using thereadline.createInterface()method.