Skip to content

Commit 5a25fd5

Browse files
Raoofrefack
authored andcommitted
lib: rewrite the same code for the third time
1 parent fb1ce38 commit 5a25fd5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

doc/api/readline.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ changes:
379379
character (when reading an ambiguous key sequence in milliseconds one that
380380
can both form a complete key sequence using the input read so far and can
381381
take additional input to complete a longer key sequence).
382+
**Default:** `500`.
382383

383384
The `readline.createInterface()` method creates a new `readline.Interface`
384385
instance.

lib/readline.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ function Interface(input, output, completer, terminal) {
101101
prompt = input.prompt;
102102
}
103103
if (input.escapeCodeTimeout !== undefined) {
104-
this.escapeCodeTimeout = input.escapeCodeTimeout;
104+
if (Number.isFinite(input.escapeCodeTimeout)) {
105+
this.escapeCodeTimeout = input.escapeCodeTimeout;
106+
} else {
107+
throw new ERR_INVALID_OPT_VALUE(
108+
'escapeCodeTimeout',
109+
this.escapeCodeTimeout
110+
);
111+
}
105112
}
106113
crlfDelay = input.crlfDelay;
107114
input = input.input;
108115
}
109116

110-
if (!Number.isFinite(this.escapeCodeTimeout)) {
111-
throw new ERR_INVALID_OPT_VALUE(
112-
'escapeCodeTimeout',
113-
this.escapeCodeTimeout
114-
);
115-
}
116-
117117
if (completer && typeof completer !== 'function') {
118118
throw new ERR_INVALID_OPT_VALUE('completer', completer);
119119
}

0 commit comments

Comments
 (0)