Standard library / readline · on the one-page reference

readline

Experimental — new, manually tested rather than conformance-suite covered.

A practical subset of Node's readline module: one blocking function, not Node's event-based readline.createInterface()/ .on('line', cb) — every stdio primitive this is built on (.read()/.write()/.readLine()) is a blocking call, not an event-driven one, so a synchronous question() fits the shape already there rather than needing a background line-pump the language doesn't have.

readline.question(prompt) Experimental

string → string — writes prompt to process.stdout(), then blocks reading one line from process.stdin(). Deviation from ReadableStream.readLine(): the trailing \n/\r\n is stripped before returning, matching Node's own question() callback value — readLine() keeps it for its own blank-line-vs-EOF safety, which question() doesn't need. Every call shares one underlying stdin reader internally, so consecutive calls see consecutive lines rather than each silently discarding the next line's already-buffered bytes. Returns "" at true end-of-stream (piped input exhausted).

const name = readline.question("Name: ");
console.log("Hi " + name);