@@ -63,14 +63,26 @@ function isWarned(emitter) {
63
63
}
64
64
65
65
{
66
- // Maximum crlfDelay is 2000ms
66
+ // set crlfDelay to float 100.5ms
67
67
const fi = new FakeInput ( ) ;
68
68
const rli = new readline . Interface ( {
69
69
input : fi ,
70
70
output : fi ,
71
- crlfDelay : 1 << 30
71
+ crlfDelay : 100.5
72
72
} ) ;
73
- assert . strictEqual ( rli . crlfDelay , 2000 ) ;
73
+ assert . strictEqual ( rli . crlfDelay , 100.5 ) ;
74
+ rli . close ( ) ;
75
+ }
76
+
77
+ {
78
+ // set crlfDelay to 5000ms
79
+ const fi = new FakeInput ( ) ;
80
+ const rli = new readline . Interface ( {
81
+ input : fi ,
82
+ output : fi ,
83
+ crlfDelay : 5000
84
+ } ) ;
85
+ assert . strictEqual ( rli . crlfDelay , 5000 ) ;
74
86
rli . close ( ) ;
75
87
}
76
88
@@ -248,7 +260,7 @@ function isWarned(emitter) {
248
260
rli . close ( ) ;
249
261
250
262
// Emit two line events when the delay
251
- // between \r and \n exceeds crlfDelay
263
+ // between \r and \n exceeds crlfDelay
252
264
{
253
265
const fi = new FakeInput ( ) ;
254
266
const delay = 200 ;
@@ -270,8 +282,55 @@ function isWarned(emitter) {
270
282
} ) , delay * 2 ) ;
271
283
}
272
284
285
+ // Emit one line events when the delay between \r and \n is
286
+ // over the default crlfDelay but within the setting value
287
+ {
288
+ const fi = new FakeInput ( ) ;
289
+ const delay = 200 ;
290
+ const crlfDelay = 500 ;
291
+ const rli = new readline . Interface ( {
292
+ input : fi ,
293
+ output : fi ,
294
+ terminal : terminal ,
295
+ crlfDelay
296
+ } ) ;
297
+ let callCount = 0 ;
298
+ rli . on ( 'line' , function ( line ) {
299
+ callCount ++ ;
300
+ } ) ;
301
+ fi . emit ( 'data' , '\r' ) ;
302
+ setTimeout ( common . mustCall ( ( ) => {
303
+ fi . emit ( 'data' , '\n' ) ;
304
+ assert . strictEqual ( callCount , 1 ) ;
305
+ rli . close ( ) ;
306
+ } ) , delay ) ;
307
+ }
308
+
309
+ // set crlfDelay to `Infinity` is allowed
310
+ {
311
+ const fi = new FakeInput ( ) ;
312
+ const delay = 200 ;
313
+ const crlfDelay = Infinity ;
314
+ const rli = new readline . Interface ( {
315
+ input : fi ,
316
+ output : fi ,
317
+ terminal : terminal ,
318
+ crlfDelay
319
+ } ) ;
320
+ let callCount = 0 ;
321
+ rli . on ( 'line' , function ( line ) {
322
+ callCount ++ ;
323
+ } ) ;
324
+ fi . emit ( 'data' , '\r' ) ;
325
+ setTimeout ( common . mustCall ( ( ) => {
326
+ fi . emit ( 'data' , '\n' ) ;
327
+ assert . strictEqual ( callCount , 1 ) ;
328
+ rli . close ( ) ;
329
+ } ) , delay ) ;
330
+ }
331
+
273
332
// \t when there is no completer function should behave like an ordinary
274
- // character
333
+ // character
275
334
fi = new FakeInput ( ) ;
276
335
rli = new readline . Interface ( { input : fi , output : fi , terminal : true } ) ;
277
336
called = false ;
@@ -517,7 +576,7 @@ function isWarned(emitter) {
517
576
assert . strictEqual ( isWarned ( process . stdout . _events ) , false ) ;
518
577
}
519
578
520
- //can create a new readline Interface with a null output arugument
579
+ // can create a new readline Interface with a null output arugument
521
580
fi = new FakeInput ( ) ;
522
581
rli = new readline . Interface ( { input : fi , output : null , terminal : terminal } ) ;
523
582
0 commit comments