事件:'SIGINT'


\Event: 'SIGINT'

新增于: v0.3.0

每当 input 流接收到 Ctrl+C 输入(通常称为 SIGINT)时,就会触发 'SIGINT' 事件。如果在 input 流接收到 SIGINT 时没有注册 'SIGINT' 事件监听器,则将触发 'pause' 事件。

\The 'SIGINT' event is emitted whenever the input stream receives a Ctrl+C input, known typically as SIGINT. If there are no 'SIGINT' event listeners registered when the input stream receives a SIGINT, the 'pause' event will be emitted.

调用监听器函数时不传入任何参数。

\The listener function is invoked without passing any arguments.

rl.on('SIGINT', () => {
 rl.question('Are you sure you want to exit? ', (answer) => {
 if (answer.match(/^y(es)?$/i)) rl.pause();
 });
}); 

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