'history' 事件


每当历史数组发生更改时,则会触发 'history' 事件。

使用包含历史数组的数组调用监听器函数。 它将反映由于 historySizeremoveHistoryDuplicates 引起的所有更改、添加的行和删除的行。

主要目的是允许监听器保留历史记录。 监听器也可以更改历史对象。 这可能有助于防止将某些行添加到历史记录中,例如密码。

rl.on('history', (history) => {
  console.log(`Received: ${history}`);
});

The 'history' event is emitted whenever the history array has changed.

The listener function is called with an array containing the history array. It will reflect all changes, added lines and removed lines due to historySize and removeHistoryDuplicates.

The primary purpose is to allow a listener to persist the history. It is also possible for the listener to change the history object. This could be useful to prevent certain lines to be added to the history, like a password.

rl.on('history', (history) => {
  console.log(`Received: ${history}`);
});