@@ -105,6 +105,7 @@ Converter.prototype._transform = function (data, encoding, cb) {
105
105
* The code below is to check if a single utf8 char (which could be multiple bytes) being split.
106
106
* If the char being split, the buffer from two chunk needs to be concat
107
107
* check how utf8 being encoded to understand the code below.
108
+ * If anyone has any better way to do this, please let me know.
108
109
*/
109
110
if ( ( data [ idx ] & 1 << 7 ) != 0 ) {
110
111
while ( ( data [ idx ] & 3 << 6 ) === 128 ) {
@@ -307,6 +308,9 @@ Converter.prototype.processHead = function (fileLine, cb) {
307
308
}
308
309
configIgnoreIncludeColumns ( params ) ;
309
310
params . _headers = require ( "./filterRow" ) ( params . _headers , params ) ;
311
+ if ( this . _needEmitHeader && this . param . _headers ) {
312
+ this . emit ( "header" , this . param . _headers ) ;
313
+ }
310
314
var lines = fileLineToCSVLine ( fileLine , params ) ;
311
315
this . setPartialData ( lines . partial ) ;
312
316
if ( this . param . workerNum > 1 ) {
@@ -386,9 +390,6 @@ Converter.prototype.emitResult = function (r) {
386
390
this . transform ( resultJson , row , index ) ;
387
391
resultStr = null ;
388
392
}
389
- if ( this . _needEmitHeader && this . param . _headers && index === 0 ) {
390
- this . emit ( "header" , this . param . _headers ) ;
391
- }
392
393
if ( this . _needEmitJson ) {
393
394
this . emit ( "json" , resultJson , index ) ;
394
395
}
0 commit comments