You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,54 +4,34 @@ var Readable = require("stream").Readable;
4
4
varResult=require("./Result");
5
5
varos=require("os");
6
6
vareol=os.EOL;
7
-
varProcessor=require("./Processor.js");
8
-
varWorker=require("./Worker.js");
7
+
// var Processor = require("./Processor.js");
9
8
varutils=require("./utils.js");
10
9
varasync=require("async");
11
-
10
+
vardefParam=require("./defParam");
11
+
varcsvline=require("./csvline");
12
+
varfileline=require("./fileline");
13
+
vardataToCSVLine=require("./dataToCSVLine");
14
+
varlinesToJson=require("./linesToJson");
12
15
functionConverter(params,options){
13
16
Transform.call(this,options);
14
-
var_param={
15
-
constructResult: true,//set to false to not construct result in memory. suitable for big csv data
16
-
delimiter: ',',// change the delimiter of csv columns. It is able to use an array to specify potencial delimiters. e.g. [",","|",";"]
17
-
quote: '"',//quote for a column containing delimiter.
18
-
trim: true,//trim column's space charcters
19
-
checkType: true,//whether check column type
20
-
toArrayString: false,//stream down stringified json array instead of string of json. (useful if downstream is file writer etc)
21
-
ignoreEmpty: false,//Ignore empty value while parsing. if a value of the column is empty, it will be skipped parsing.
22
-
workerNum: 1,//number of parallel workers. If multi-core CPU available, increase the number will get better performance for large csv data.
23
-
fork: false,//use another CPU core to convert the csv stream
24
-
noheader: false,//indicate if first line of CSV file is header or not.
25
-
headers: null,//an array of header strings. If noheader is false and headers is array, csv header will be ignored.
26
-
flatKeys: false,// Don't interpret dots and square brackets in header fields as nested object or array identifiers at all.
27
-
maxRowLength: 0,//the max character a csv row could have. 0 means infinite. If max number exceeded, parser will emit "error" of "row_exceed". if a possibly corrupted csv data provided, give it a number like 65535 so the parser wont consume memory. default: 0
28
-
checkColumn: false//whether check column number of a row is the same as headers. If column number mismatched headers number, an error of "mismatched_column" will be emitted.. default: false
29
-
};
30
-
if(params&&typeofparams==="object"){
31
-
for(varkeyinparams){
32
-
if(params.hasOwnProperty(key)){
33
-
_param[key]=params[key];
34
-
}
35
-
}
36
-
}elseif(typeofparams==="boolean"){//backcompatible with older version
37
-
console.warn("Parameter should be a JSON object like {'constructResult':false}");
38
-
_param.constructResult=params;
39
-
}
17
+
_param=defParam(params);
40
18
this._options=options||{};
41
19
this.param=_param;
42
20
this.param._options=this._options;
43
21
this.resultObject=newResult(this);
44
22
this.pipe(this.resultObject);// it is important to have downstream for a transform otherwise it will stuck
45
-
this.started=false;
23
+
this.started=false;//indicate if parsing has started.
0 commit comments