diff --git a/doc/api/readline.md b/doc/api/readline.md index ac6a8b9b14c529..d6f65b434ec8a5 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -88,6 +88,28 @@ rl.on('line', (input) => { }); ``` +### Event: `'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. + +```js +rl.on('history', (history) => { + console.log(`Received: ${history}`); +}); +``` + ### Event: `'pause'`