@@ -19,8 +19,6 @@ class JSON2CSVTransform extends Transform {
19
19
20
20
if ( this . _readableState . objectMode ) {
21
21
this . initObjectModeParse ( ) ;
22
- } else if ( this . opts . ndjson ) {
23
- this . initNDJSONParse ( ) ;
24
22
} else {
25
23
this . initJSONParser ( ) ;
26
24
}
@@ -52,47 +50,6 @@ class JSON2CSVTransform extends Transform {
52
50
} ;
53
51
}
54
52
55
- /**
56
- * Init the transform with a parser to process NDJSON data.
57
- * It maintains a buffer of received data, parses each line
58
- * as JSON and send it to `pushLine for processing.
59
- */
60
- initNDJSONParse ( ) {
61
- const transform = this ;
62
-
63
- this . parser = {
64
- _data : '' ,
65
- write ( chunk ) {
66
- this . _data += chunk . toString ( ) ;
67
- const lines = this . _data
68
- . split ( '\n' )
69
- . map ( line => line . trim ( ) )
70
- . filter ( line => line !== '' ) ;
71
-
72
- let pendingData = false ;
73
- lines
74
- . forEach ( ( line , i ) => {
75
- try {
76
- transform . pushLine ( JSON . parse ( line ) ) ;
77
- } catch ( e ) {
78
- if ( i === lines . length - 1 ) {
79
- pendingData = true ;
80
- } else {
81
- e . message = `Invalid JSON (${ line } )`
82
- transform . emit ( 'error' , e ) ;
83
- }
84
- }
85
- } ) ;
86
- this . _data = pendingData
87
- ? this . _data . slice ( this . _data . lastIndexOf ( '\n' ) )
88
- : '' ;
89
- } ,
90
- getPendingData ( ) {
91
- return this . _data ;
92
- }
93
- } ;
94
- }
95
-
96
53
/**
97
54
* Init the transform with a parser to process JSON data.
98
55
* It maintains a buffer of received data, parses each as JSON
0 commit comments