Skip to content

Commit d4dd7d5

Browse files
committedSep 30, 2017
update the trigger time of header
1 parent 1914abe commit d4dd7d5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎libs/core/Converter.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Converter.prototype._transform = function (data, encoding, cb) {
105105
* The code below is to check if a single utf8 char (which could be multiple bytes) being split.
106106
* If the char being split, the buffer from two chunk needs to be concat
107107
* check how utf8 being encoded to understand the code below.
108+
* If anyone has any better way to do this, please let me know.
108109
*/
109110
if ((data[idx] & 1<<7) !=0){
110111
while ((data[idx] & 3<<6) === 128){
@@ -307,6 +308,9 @@ Converter.prototype.processHead = function (fileLine, cb) {
307308
}
308309
configIgnoreIncludeColumns(params);
309310
params._headers = require("./filterRow")(params._headers, params);
311+
if (this._needEmitHeader && this.param._headers) {
312+
this.emit("header", this.param._headers);
313+
}
310314
var lines = fileLineToCSVLine(fileLine, params);
311315
this.setPartialData(lines.partial);
312316
if (this.param.workerNum > 1) {
@@ -386,9 +390,6 @@ Converter.prototype.emitResult = function (r) {
386390
this.transform(resultJson, row, index);
387391
resultStr = null;
388392
}
389-
if (this._needEmitHeader && this.param._headers && index === 0) {
390-
this.emit("header", this.param._headers);
391-
}
392393
if (this._needEmitJson) {
393394
this.emit("json", resultJson, index);
394395
}

‎libs/core/workerMgr.js

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function workerMgr() {
6868
}
6969

7070
function Worker(params) {
71+
var spawn = require("child_process").spawn;
7172
this.cp = spawn(process.execPath, [__dirname + "/worker.js"], {
7273
env: {
7374
child:true

0 commit comments

Comments
 (0)
Failed to load comments.