From 91a27007214b28fd350d154d2c764243a9f22bbc Mon Sep 17 00:00:00 2001 From: Danny Nemer Date: Mon, 20 Mar 2017 18:30:41 -0400 Subject: [PATCH] readline: rename `deDupeHistory` option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renames `options.deDupeHistory` → `options.removeHistoryDuplicates` for `readline.createInterface(options)`. The option name `removeHistoryDuplicates` is preferable to the semantically identical name `deDupeHistory` because "dedupe" (short for "deduplication") is obscure and neologistic while `removeHistoryDuplicates` is clear, though verbose. Updates tests and documentation for this option accordingly. PR-URL: https://github.com/nodejs/node/pull/11950 Ref: https://github.com/nodejs/node/pull/2982 Reviewed-By: Vse Mozhet Byt Reviewed-By: Ben Noordhuis Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- doc/api/readline.md | 6 +++--- lib/readline.js | 8 ++++---- test/parallel/test-readline-interface.js | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index e471daecae3f5a..acd052bb1a5a68 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -370,9 +370,9 @@ changes: `crlfDelay` milliseconds, both `\r` and `\n` will be treated as separate end-of-line input. Default to `100` milliseconds. `crlfDelay` will be coerced to `[100, 2000]` range. - * `deDupeHistory` {boolean} If `true`, when a new input line added to the - history list duplicates an older one, this removes the older line from the - list. Defaults to `false`. + * `removeHistoryDuplicates` {boolean} If `true`, when a new input line added + to the history list duplicates an older one, this removes the older line + from the list. Defaults to `false`. The `readline.createInterface()` method creates a new `readline.Interface` instance. diff --git a/lib/readline.js b/lib/readline.js index 04cc0f718a5f07..0590b1c299b623 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -39,7 +39,7 @@ function Interface(input, output, completer, terminal) { EventEmitter.call(this); var historySize; - var deDupeHistory = false; + var removeHistoryDuplicates = false; let crlfDelay; let prompt = '> '; @@ -49,7 +49,7 @@ function Interface(input, output, completer, terminal) { completer = input.completer; terminal = input.terminal; historySize = input.historySize; - deDupeHistory = input.deDupeHistory; + removeHistoryDuplicates = input.removeHistoryDuplicates; if (input.prompt !== undefined) { prompt = input.prompt; } @@ -82,7 +82,7 @@ function Interface(input, output, completer, terminal) { this.output = output; this.input = input; this.historySize = historySize; - this.deDupeHistory = !!deDupeHistory; + this.removeHistoryDuplicates = !!removeHistoryDuplicates; this.crlfDelay = Math.max(kMincrlfDelay, Math.min(kMaxcrlfDelay, crlfDelay >>> 0)); @@ -260,7 +260,7 @@ Interface.prototype._addHistory = function() { if (this.line.trim().length === 0) return this.line; if (this.history.length === 0 || this.history[0] !== this.line) { - if (this.deDupeHistory) { + if (this.removeHistoryDuplicates) { // Remove older history line if identical to new one const dupIndex = this.history.indexOf(this.line); if (dupIndex !== -1) this.history.splice(dupIndex, 1); diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 09ace7824ec525..04419b4d4907fa 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -305,14 +305,14 @@ function isWarned(emitter) { return false; }); - // duplicate lines are removed from history when `options.deDupeHistory` - // is `true` + // duplicate lines are removed from history when + // `options.removeHistoryDuplicates` is `true` fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: true, - deDupeHistory: true + removeHistoryDuplicates: true }); expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; callCount = 0; @@ -335,14 +335,14 @@ function isWarned(emitter) { assert.strictEqual(callCount, 0); rli.close(); - // duplicate lines are not removed from history when `options.deDupeHistory` - // is `false` + // duplicate lines are not removed from history when + // `options.removeHistoryDuplicates` is `false` fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: true, - deDupeHistory: false + removeHistoryDuplicates: false }); expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; callCount = 0;