事件:'line'
【Event: 'line'】
'line' 事件会在 input 流接收到换行输入(\n、\r 或 \r\n)时触发。这通常发生在用户按下 回车 或 Return键时。
如果从流中读取了新数据,并且该流在没有最终换行符的情况下结束,则也会触发 'line' 事件。
【The 'line' event is also emitted if new data has been read from a stream and
that stream ends without a final end-of-line marker.】
监听函数会被调用,并传入一个包含收到的单行输入的字符串。
【The listener function is called with a string containing the single line of received input.】
rl.on('line', (input) => {
console.log(`Received: ${input}`);
});