@@ -40,14 +40,25 @@ function isWarned(emitter) {
40
40
}
41
41
42
42
{
43
- // Maximum crlfDelay is 2000ms
43
+ // set crlfDelay to float 100.5ms
44
44
const fi = new FakeInput ( ) ;
45
45
const rli = new readline . Interface ( {
46
46
input : fi ,
47
47
output : fi ,
48
- crlfDelay : 1 << 30
48
+ crlfDelay : 100.5
49
49
} ) ;
50
- assert . strictEqual ( rli . crlfDelay , 2000 ) ;
50
+ assert . strictEqual ( rli . crlfDelay , 100.5 ) ;
51
+ rli . close ( ) ;
52
+ }
53
+
54
+ {
55
+ const fi = new FakeInput ( ) ;
56
+ const rli = new readline . Interface ( {
57
+ input : fi ,
58
+ output : fi ,
59
+ crlfDelay : 5000
60
+ } ) ;
61
+ assert . strictEqual ( rli . crlfDelay , 5000 ) ;
51
62
rli . close ( ) ;
52
63
}
53
64
@@ -225,7 +236,7 @@ function isWarned(emitter) {
225
236
rli . close ( ) ;
226
237
227
238
// Emit two line events when the delay
228
- // between \r and \n exceeds crlfDelay
239
+ // between \r and \n exceeds crlfDelay
229
240
{
230
241
const fi = new FakeInput ( ) ;
231
242
const delay = 200 ;
@@ -247,8 +258,55 @@ function isWarned(emitter) {
247
258
} ) , delay * 2 ) ;
248
259
}
249
260
261
+ // Emit one line events when the delay between \r and \n is
262
+ // over the default crlfDelay but within the setting value
263
+ {
264
+ const fi = new FakeInput ( ) ;
265
+ const delay = 200 ;
266
+ const crlfDelay = 500 ;
267
+ const rli = new readline . Interface ( {
268
+ input : fi ,
269
+ output : fi ,
270
+ terminal : terminal ,
271
+ crlfDelay
272
+ } ) ;
273
+ let callCount = 0 ;
274
+ rli . on ( 'line' , function ( line ) {
275
+ callCount ++ ;
276
+ } ) ;
277
+ fi . emit ( 'data' , '\r' ) ;
278
+ setTimeout ( common . mustCall ( ( ) => {
279
+ fi . emit ( 'data' , '\n' ) ;
280
+ assert . strictEqual ( callCount , 1 ) ;
281
+ rli . close ( ) ;
282
+ } ) , delay ) ;
283
+ }
284
+
285
+ // set crlfDelay to `Infinity` is allowed
286
+ {
287
+ const fi = new FakeInput ( ) ;
288
+ const delay = 200 ;
289
+ const crlfDelay = Infinity ;
290
+ const rli = new readline . Interface ( {
291
+ input : fi ,
292
+ output : fi ,
293
+ terminal : terminal ,
294
+ crlfDelay
295
+ } ) ;
296
+ let callCount = 0 ;
297
+ rli . on ( 'line' , function ( line ) {
298
+ callCount ++ ;
299
+ } ) ;
300
+ fi . emit ( 'data' , '\r' ) ;
301
+ setTimeout ( common . mustCall ( ( ) => {
302
+ fi . emit ( 'data' , '\n' ) ;
303
+ assert . strictEqual ( callCount , 1 ) ;
304
+ rli . close ( ) ;
305
+ } ) , delay ) ;
306
+ }
307
+
250
308
// \t when there is no completer function should behave like an ordinary
251
- // character
309
+ // character
252
310
fi = new FakeInput ( ) ;
253
311
rli = new readline . Interface ( { input : fi , output : fi , terminal : true } ) ;
254
312
called = false ;
@@ -494,7 +552,7 @@ function isWarned(emitter) {
494
552
assert . strictEqual ( isWarned ( process . stdout . _events ) , false ) ;
495
553
}
496
554
497
- //can create a new readline Interface with a null output arugument
555
+ // can create a new readline Interface with a null output arugument
498
556
fi = new FakeInput ( ) ;
499
557
rli = new readline . Interface ( { input : fi , output : null , terminal : terminal } ) ;
500
558
0 commit comments