readline
readline reads input line by line. Here a stream stands in for the keyboard.
Example
const readline = require("readline");
const { Readable } = require("stream");
const rl = readline.createInterface({ input: Readable.from(["one\ntwo\nthree\n"]) });
let n = 0;
rl.on("line", (l) => console.log(++n, l));Result
1 one 2 two 3 three
Exercise
Line event.
rl.on("", fn)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.