'line' 事件
每当 input
流接收到行尾输入(\n
、 \r
或 \r\n
)时就会触发 'line'
事件。
这种情况通常发生在当用户按下 Enter 或 Return。
调用监听器函数时会带上包含接收到的那一行输入的字符串。
rl.on('line', (input) => {
console.log(`接收到:${input}`);
});
The 'line'
event is emitted whenever the input
stream receives an
end-of-line input (\n
, \r
, or \r\n
). This usually occurs when the user
presses Enter or Return.
The listener function is called with a string containing the single line of received input.
rl.on('line', (input) => {
console.log(`Received: ${input}`);
});