File tree 1 file changed +26
-14
lines changed
packages/@vue/cli-ui/src/graphql-api/connectors
1 file changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -429,26 +429,38 @@ function open (id, context) {
429
429
}
430
430
431
431
function logPipe ( action ) {
432
+ const maxTime = 100
433
+
432
434
let queue = ''
433
435
let size = 0
434
436
let time = Date . now ( )
437
+ let timeout
435
438
436
- return {
437
- add : ( string ) => {
438
- queue += string
439
- size ++
440
-
441
- if ( size === 20 || Date . now ( ) > time + 100 ) {
442
- action ( queue )
443
- queue = ''
444
- size = 0
445
- time = Date . now ( )
446
- }
447
- } ,
448
- flush : ( ) => {
449
- if ( size ) action ( queue )
439
+ const add = ( string ) => {
440
+ queue += string
441
+ size ++
442
+
443
+ if ( size === 20 || Date . now ( ) > time + maxTime ) {
444
+ flush ( )
445
+ } else {
446
+ clearTimeout ( timeout )
447
+ setTimeout ( flush , maxTime )
450
448
}
451
449
}
450
+
451
+ const flush = ( ) => {
452
+ clearTimeout ( timeout )
453
+ if ( ! size ) return
454
+ action ( queue )
455
+ queue = ''
456
+ size = 0
457
+ time = Date . now ( )
458
+ }
459
+
460
+ return {
461
+ add,
462
+ flush
463
+ }
452
464
}
453
465
454
466
module . exports = {
You can’t perform that action at this time.
0 commit comments