77'use strict' ;
88
99const kHistorySize = 30 ;
10- const kcrlfDelayInMillis = 100 ;
10+ const kMincrlfDelay = 100 ;
11+ const kMaxcrlfDelay = 2000 ;
1112
1213const util = require ( 'util' ) ;
1314const debug = util . debuglog ( 'readline' ) ;
@@ -21,20 +22,18 @@ const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint;
2122const stripVTControlCharacters = internalReadline . stripVTControlCharacters ;
2223
2324
24- exports . createInterface = function ( input , output , completer , terminal ,
25- crlfDelay = kcrlfDelayInMillis ) {
25+ exports . createInterface = function ( input , output , completer , terminal ) {
2626 var rl ;
2727 if ( arguments . length === 1 ) {
2828 rl = new Interface ( input ) ;
2929 } else {
30- rl = new Interface ( input , output , completer , terminal , crlfDelay ) ;
30+ rl = new Interface ( input , output , completer , terminal ) ;
3131 }
3232 return rl ;
3333} ;
3434
3535
36- function Interface ( input , output , completer , terminal ,
37- crlfDelay = kcrlfDelayInMillis ) {
36+ function Interface ( input , output , completer , terminal ) {
3837 if ( ! ( this instanceof Interface ) ) {
3938 // call the constructor preserving original number of arguments
4039 const self = Object . create ( Interface . prototype ) ;
@@ -48,6 +47,7 @@ function Interface(input, output, completer, terminal,
4847
4948 EventEmitter . call ( this ) ;
5049 var historySize ;
50+ let crlfDelay ;
5151 let prompt = '> ' ;
5252
5353 if ( arguments . length === 1 ) {
@@ -59,9 +59,7 @@ function Interface(input, output, completer, terminal,
5959 if ( input . prompt !== undefined ) {
6060 prompt = input . prompt ;
6161 }
62- if ( input . crlfDelay !== undefined ) {
63- crlfDelay = input . crlfDelay ;
64- }
62+ crlfDelay = input . crlfDelay ;
6563 input = input . input ;
6664 }
6765
@@ -79,12 +77,6 @@ function Interface(input, output, completer, terminal,
7977 throw new TypeError ( 'Argument "historySize" must be a positive number' ) ;
8078 }
8179
82- if ( typeof crlfDelay !== 'number' ||
83- isNaN ( crlfDelay ) ||
84- crlfDelay <= 0 ) {
85- throw new TypeError ( 'Argument "crlfDelay" must be a positive number > 0' ) ;
86- }
87-
8880 // backwards compat; check the isTTY prop of the output stream
8981 // when `terminal` was not specified
9082 if ( terminal === undefined && ! ( output === null || output === undefined ) ) {
@@ -96,7 +88,8 @@ function Interface(input, output, completer, terminal,
9688 this . output = output ;
9789 this . input = input ;
9890 this . historySize = historySize ;
99- this . crlfDelay = crlfDelay ;
91+ this . crlfDelay = Math . max ( kMincrlfDelay ,
92+ Math . min ( kMaxcrlfDelay , crlfDelay >>> 0 ) ) ;
10093
10194 // Check arity, 2 - for async, 1 for sync
10295 if ( typeof completer === 'function' ) {
0 commit comments