Skip to content

Commit c8eec76

Browse files
DannyNemerjasnell
authored andcommitted
readline: rename deDupeHistory option
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: #11950 Ref: #2982 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e26b6c6 commit c8eec76

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

doc/api/readline.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ changes:
370370
`crlfDelay` milliseconds, both `\r` and `\n` will be treated as separate
371371
end-of-line input. Default to `100` milliseconds.
372372
`crlfDelay` will be coerced to `[100, 2000]` range.
373-
* `deDupeHistory` {boolean} If `true`, when a new input line added to the
374-
history list duplicates an older one, this removes the older line from the
375-
list. Defaults to `false`.
373+
* `removeHistoryDuplicates` {boolean} If `true`, when a new input line added
374+
to the history list duplicates an older one, this removes the older line
375+
from the list. Defaults to `false`.
376376

377377
The `readline.createInterface()` method creates a new `readline.Interface`
378378
instance.

lib/readline.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function Interface(input, output, completer, terminal) {
6060

6161
EventEmitter.call(this);
6262
var historySize;
63-
var deDupeHistory = false;
63+
var removeHistoryDuplicates = false;
6464
let crlfDelay;
6565
let prompt = '> ';
6666

@@ -70,7 +70,7 @@ function Interface(input, output, completer, terminal) {
7070
completer = input.completer;
7171
terminal = input.terminal;
7272
historySize = input.historySize;
73-
deDupeHistory = input.deDupeHistory;
73+
removeHistoryDuplicates = input.removeHistoryDuplicates;
7474
if (input.prompt !== undefined) {
7575
prompt = input.prompt;
7676
}
@@ -103,7 +103,7 @@ function Interface(input, output, completer, terminal) {
103103
this.output = output;
104104
this.input = input;
105105
this.historySize = historySize;
106-
this.deDupeHistory = !!deDupeHistory;
106+
this.removeHistoryDuplicates = !!removeHistoryDuplicates;
107107
this.crlfDelay = Math.max(kMincrlfDelay,
108108
Math.min(kMaxcrlfDelay, crlfDelay >>> 0));
109109

@@ -281,7 +281,7 @@ Interface.prototype._addHistory = function() {
281281
if (this.line.trim().length === 0) return this.line;
282282

283283
if (this.history.length === 0 || this.history[0] !== this.line) {
284-
if (this.deDupeHistory) {
284+
if (this.removeHistoryDuplicates) {
285285
// Remove older history line if identical to new one
286286
const dupIndex = this.history.indexOf(this.line);
287287
if (dupIndex !== -1) this.history.splice(dupIndex, 1);

test/parallel/test-readline-interface.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,14 @@ function isWarned(emitter) {
326326
return false;
327327
});
328328

329-
// duplicate lines are removed from history when `options.deDupeHistory`
330-
// is `true`
329+
// duplicate lines are removed from history when
330+
// `options.removeHistoryDuplicates` is `true`
331331
fi = new FakeInput();
332332
rli = new readline.Interface({
333333
input: fi,
334334
output: fi,
335335
terminal: true,
336-
deDupeHistory: true
336+
removeHistoryDuplicates: true
337337
});
338338
expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
339339
callCount = 0;
@@ -356,14 +356,14 @@ function isWarned(emitter) {
356356
assert.strictEqual(callCount, 0);
357357
rli.close();
358358

359-
// duplicate lines are not removed from history when `options.deDupeHistory`
360-
// is `false`
359+
// duplicate lines are not removed from history when
360+
// `options.removeHistoryDuplicates` is `false`
361361
fi = new FakeInput();
362362
rli = new readline.Interface({
363363
input: fi,
364364
output: fi,
365365
terminal: true,
366-
deDupeHistory: false
366+
removeHistoryDuplicates: false
367367
});
368368
expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
369369
callCount = 0;

0 commit comments

Comments
 (0)