File tree 7 files changed +41
-11
lines changed
7 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -1324,15 +1324,18 @@ class Parser extends stream.Transform {
1324
1324
this . info = this . api . info ;
1325
1325
}
1326
1326
// Implementation of `Transform._transform`
1327
- _transform ( buf , encoding , callback ) {
1327
+ _transform ( buf , _ , callback ) {
1328
1328
if ( this . state . stop === true ) {
1329
1329
return ;
1330
1330
}
1331
1331
const err = this . api . parse ( buf , false , ( record ) => {
1332
1332
this . push ( record ) ;
1333
1333
} , ( ) => {
1334
1334
this . push ( null ) ;
1335
- this . on ( 'end' , this . destroy ) ;
1335
+ this . end ( ) ;
1336
+ this . destroy ( ) ;
1337
+ // Note 231005, end wasnt used and destroy was called as:
1338
+ // this.on('end', this.destroy);
1336
1339
} ) ;
1337
1340
if ( err !== undefined ) {
1338
1341
this . state . stop = true ;
Original file line number Diff line number Diff line change @@ -6446,15 +6446,18 @@ class Parser extends Transform {
6446
6446
this . info = this . api . info ;
6447
6447
}
6448
6448
// Implementation of `Transform._transform`
6449
- _transform ( buf , encoding , callback ) {
6449
+ _transform ( buf , _ , callback ) {
6450
6450
if ( this . state . stop === true ) {
6451
6451
return ;
6452
6452
}
6453
6453
const err = this . api . parse ( buf , false , ( record ) => {
6454
6454
this . push ( record ) ;
6455
6455
} , ( ) => {
6456
6456
this . push ( null ) ;
6457
- this . on ( 'end' , this . destroy ) ;
6457
+ this . end ( ) ;
6458
+ this . destroy ( ) ;
6459
+ // Note 231005, end wasnt used and destroy was called as:
6460
+ // this.on('end', this.destroy);
6458
6461
} ) ;
6459
6462
if ( err !== undefined ) {
6460
6463
this . state . stop = true ;
Original file line number Diff line number Diff line change @@ -6449,15 +6449,18 @@ var csv_parse = (function (exports) {
6449
6449
this . info = this . api . info ;
6450
6450
}
6451
6451
// Implementation of `Transform._transform`
6452
- _transform ( buf , encoding , callback ) {
6452
+ _transform ( buf , _ , callback ) {
6453
6453
if ( this . state . stop === true ) {
6454
6454
return ;
6455
6455
}
6456
6456
const err = this . api . parse ( buf , false , ( record ) => {
6457
6457
this . push ( record ) ;
6458
6458
} , ( ) => {
6459
6459
this . push ( null ) ;
6460
- this . on ( 'end' , this . destroy ) ;
6460
+ this . end ( ) ;
6461
+ this . destroy ( ) ;
6462
+ // Note 231005, end wasnt used and destroy was called as:
6463
+ // this.on('end', this.destroy);
6461
6464
} ) ;
6462
6465
if ( err !== undefined ) {
6463
6466
this . state . stop = true ;
Original file line number Diff line number Diff line change 6452
6452
this . info = this . api . info ;
6453
6453
}
6454
6454
// Implementation of `Transform._transform`
6455
- _transform ( buf , encoding , callback ) {
6455
+ _transform ( buf , _ , callback ) {
6456
6456
if ( this . state . stop === true ) {
6457
6457
return ;
6458
6458
}
6459
6459
const err = this . api . parse ( buf , false , ( record ) => {
6460
6460
this . push ( record ) ;
6461
6461
} , ( ) => {
6462
6462
this . push ( null ) ;
6463
- this . on ( 'end' , this . destroy ) ;
6463
+ this . end ( ) ;
6464
+ this . destroy ( ) ;
6465
+ // Note 231005, end wasnt used and destroy was called as:
6466
+ // this.on('end', this.destroy);
6464
6467
} ) ;
6465
6468
if ( err !== undefined ) {
6466
6469
this . state . stop = true ;
Original file line number Diff line number Diff line change @@ -24,15 +24,18 @@ class Parser extends Transform {
24
24
this . info = this . api . info ;
25
25
}
26
26
// Implementation of `Transform._transform`
27
- _transform ( buf , encoding , callback ) {
27
+ _transform ( buf , _ , callback ) {
28
28
if ( this . state . stop === true ) {
29
29
return ;
30
30
}
31
31
const err = this . api . parse ( buf , false , ( record ) => {
32
32
this . push ( record ) ;
33
33
} , ( ) => {
34
34
this . push ( null ) ;
35
- this . on ( 'end' , this . destroy ) ;
35
+ this . end ( ) ;
36
+ this . destroy ( ) ;
37
+ // Note 231005, end wasnt used and destroy was called as:
38
+ // this.on('end', this.destroy);
36
39
} ) ;
37
40
if ( err !== undefined ) {
38
41
this . state . stop = true ;
Original file line number Diff line number Diff line change 1
1
2
2
import * as stream from ' node:stream/promises'
3
- import { Readable } from ' stream'
4
3
import { generate } from ' csv-generate'
5
4
import { parse } from ' ../lib/index.js'
6
5
Original file line number Diff line number Diff line change 1
1
2
+ import { Readable } from ' stream'
3
+ import { finished } from ' node:stream/promises'
2
4
import { parse } from ' ../lib/index.js'
5
+ import { generate } from ' csv-generate'
3
6
4
7
describe ' Option `to_line`' , ->
5
8
@@ -97,3 +100,16 @@ describe 'Option `to_line`', ->
97
100
[ ' d' ,' e' ,' f' ]
98
101
] unless err
99
102
next err
103
+
104
+ it ' resolved with `to_line`' , ->
105
+ # Prevent `Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close`
106
+ reader = new Readable
107
+ highWaterMark : 100
108
+ read : (size ) ->
109
+ setImmediate =>
110
+ for i in [0 ... size]
111
+ this .push " #{ size} ,#{ i} \n "
112
+ parser = reader .pipe parse to_line : 3
113
+ parser .on ' readable' , () =>
114
+ while parser .read () isnt null then true
115
+ await finished parser
You can’t perform that action at this time.
0 commit comments