事件:'line'


\Event: 'line'

新增于: v0.1.98

每当 input 流接收到行尾输入(\n\r\r\n)时,则会触发 'line' 事件。这通常在用户按 EnterReturn 时发生。

\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.

如果从流中读取了新数据并且该流在没有最终行尾标记的情况下结束,也会触发 '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}`);
}); 

AltStyle によって変換されたページ (->オリジナル) /