Skip to content

Commit

Permalink
update the trigger time of header
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyang committed Sep 30, 2017
1 parent 1914abe commit d4dd7d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libs/core/Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Converter.prototype._transform = function (data, encoding, cb) {
* The code below is to check if a single utf8 char (which could be multiple bytes) being split.
* If the char being split, the buffer from two chunk needs to be concat
* check how utf8 being encoded to understand the code below.
* If anyone has any better way to do this, please let me know.
*/
if ((data[idx] & 1<<7) !=0){
while ((data[idx] & 3<<6) === 128){
Expand Down Expand Up @@ -307,6 +308,9 @@ Converter.prototype.processHead = function (fileLine, cb) {
}
configIgnoreIncludeColumns(params);
params._headers = require("./filterRow")(params._headers, params);
if (this._needEmitHeader && this.param._headers) {
this.emit("header", this.param._headers);
}
var lines = fileLineToCSVLine(fileLine, params);
this.setPartialData(lines.partial);
if (this.param.workerNum > 1) {
Expand Down Expand Up @@ -386,9 +390,6 @@ Converter.prototype.emitResult = function (r) {
this.transform(resultJson, row, index);
resultStr = null;
}
if (this._needEmitHeader && this.param._headers && index === 0) {
this.emit("header", this.param._headers);
}
if (this._needEmitJson) {
this.emit("json", resultJson, index);
}
Expand Down
1 change: 1 addition & 0 deletions libs/core/workerMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function workerMgr() {
}

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

0 comments on commit d4dd7d5

Please sign in to comment.