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 <[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 8bd6ab7 commit e9f33e3

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

‎doc/api/readline.md‎

Lines changed: 3 additions & 3 deletions
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.

‎lib/readline.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function Interface(input, output, completer, terminal){
3939

4040
EventEmitter.call(this);
4141
varhistorySize;
42-
vardeDupeHistory=false;
42+
varremoveHistoryDuplicates=false;
4343
letcrlfDelay;
4444
letprompt='> ';
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)returnthis.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
constdupIndex=this.history.indexOf(this.line);
258258
if(dupIndex!==-1)this.history.splice(dupIndex,1);

‎test/parallel/test-readline-interface.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,14 @@ function isWarned(emitter){
303303
returnfalse;
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=newFakeInput();
309309
rli=newreadline.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=newFakeInput();
339339
rli=newreadline.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)