Skip to content

Commit e9f33e3

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 <vsemozhetbyt@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8bd6ab7 commit e9f33e3

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Diff for: doc/api/readline.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ added: v0.1.98
363363
`crlfDelay` milliseconds, both `\r` and `\n` will be treated as separate
364364
end-of-line input. Default to `100` milliseconds.
365365
`crlfDelay` will be coerced to `[100, 2000]` range.
366-
* `deDupeHistory` {boolean} If `true`, when a new input line added to the
367-
history list duplicates an older one, this removes the older line from the
368-
list. Defaults to `false`.
366+
* `removeHistoryDuplicates` {boolean} If `true`, when a new input line added
367+
to the history list duplicates an older one, this removes the older line
368+
from the list. Defaults to `false`.
369369

370370
The `readline.createInterface()` method creates a new `readline.Interface`
371371
instance.

Diff for: 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

@@ -252,7 +252,7 @@ Interface.prototype._addHistory = function() {
252252
if (this.line.trim().length === 0) return this.line;
253253

254254
if (this.history.length === 0 || this.history[0] !== this.line) {
255-
if (this.deDupeHistory) {
255+
if (this.removeHistoryDuplicates) {
256256
// Remove older history line if identical to new one
257257
const dupIndex = this.history.indexOf(this.line);
258258
if (dupIndex !== -1) this.history.splice(dupIndex, 1);

Diff for: test/parallel/test-readline-interface.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,14 @@ function isWarned(emitter) {
303303
return false;
304304
});
305305

306-
// duplicate lines are removed from history when `options.deDupeHistory`
307-
// is `true`
306+
// duplicate lines are removed from history when
307+
// `options.removeHistoryDuplicates` is `true`
308308
fi = new FakeInput();
309309
rli = new readline.Interface({
310310
input: fi,
311311
output: fi,
312312
terminal: true,
313-
deDupeHistory: true
313+
removeHistoryDuplicates: true
314314
});
315315
expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
316316
callCount = 0;
@@ -333,14 +333,14 @@ function isWarned(emitter) {
333333
assert.strictEqual(callCount, 0);
334334
rli.close();
335335

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

0 commit comments

Comments
 (0)