Skip to content

Commit 91a2700

Browse files
DannyNemerMylesBorins
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 d0c2d67 commit 91a2700

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
@@ -39,7 +39,7 @@ function Interface(input, output, completer, terminal) {
3939

4040
EventEmitter.call(this);
4141
var historySize;
42-
var deDupeHistory = false;
42+
var removeHistoryDuplicates = false;
4343
let crlfDelay;
4444
let prompt = '> ';
4545

@@ -49,7 +49,7 @@ function Interface(input, output, completer, terminal) {
4949
completer = input.completer;
5050
terminal = input.terminal;
5151
historySize = input.historySize;
52-
deDupeHistory = input.deDupeHistory;
52+
removeHistoryDuplicates = input.removeHistoryDuplicates;
5353
if (input.prompt !== undefined) {
5454
prompt = input.prompt;
5555
}
@@ -82,7 +82,7 @@ function Interface(input, output, completer, terminal) {
8282
this.output = output;
8383
this.input = input;
8484
this.historySize = historySize;
85-
this.deDupeHistory = !!deDupeHistory;
85+
this.removeHistoryDuplicates = !!removeHistoryDuplicates;
8686
this.crlfDelay = Math.max(kMincrlfDelay,
8787
Math.min(kMaxcrlfDelay, crlfDelay >>> 0));
8888

@@ -260,7 +260,7 @@ Interface.prototype._addHistory = function() {
260260
if (this.line.trim().length === 0) return this.line;
261261

262262
if (this.history.length === 0 || this.history[0] !== this.line) {
263-
if (this.deDupeHistory) {
263+
if (this.removeHistoryDuplicates) {
264264
// Remove older history line if identical to new one
265265
const dupIndex = this.history.indexOf(this.line);
266266
if (dupIndex !== -1) this.history.splice(dupIndex, 1);

test/parallel/test-readline-interface.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ function isWarned(emitter) {
305305
return false;
306306
});
307307

308-
// duplicate lines are removed from history when `options.deDupeHistory`
309-
// is `true`
308+
// duplicate lines are removed from history when
309+
// `options.removeHistoryDuplicates` is `true`
310310
fi = new FakeInput();
311311
rli = new readline.Interface({
312312
input: fi,
313313
output: fi,
314314
terminal: true,
315-
deDupeHistory: true
315+
removeHistoryDuplicates: true
316316
});
317317
expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
318318
callCount = 0;
@@ -335,14 +335,14 @@ function isWarned(emitter) {
335335
assert.strictEqual(callCount, 0);
336336
rli.close();
337337

338-
// duplicate lines are not removed from history when `options.deDupeHistory`
339-
// is `false`
338+
// duplicate lines are not removed from history when
339+
// `options.removeHistoryDuplicates` is `false`
340340
fi = new FakeInput();
341341
rli = new readline.Interface({
342342
input: fi,
343343
output: fi,
344344
terminal: true,
345-
deDupeHistory: false
345+
removeHistoryDuplicates: false
346346
});
347347
expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
348348
callCount = 0;

0 commit comments

Comments
 (0)