Skip to content

Commit b73aad5

Browse files
committed
Refactor: Fix messy spaces and missing semicolonsl
1 parent 2007658 commit b73aad5

31 files changed

Lines changed: 677 additions & 596 deletions

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = function(grunt) {
2424
client: {
2525
options: {
2626
mangle: true,
27-
banner:"/*Automatically Generated. Do not modify.*/\n"
27+
banner: "/*Automatically Generated. Do not modify.*/\n"
2828
},
2929
src: "./dist/csvtojson.js",
3030
dest: "./dist/csvtojson.min.js",

bin/benchmark.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
#!/usr/bin/env node
2-
var path=process.argv[2];
3-
var fs=require('fs');
4-
if (!fs.existsSync(path)){
2+
var path = process.argv[2];
3+
var fs = require('fs');
4+
if (!fs.existsSync(path)) {
55
console.log("Run: benchmark [csvpath]");
6-
console.log("File not found: ",path);
6+
console.log("File not found: ", path);
77
process.exit(1);
88
}
9-
function testCSVLine(coreNum,checkType,cb){
10-
console.log("WorkerNum:",coreNum,"Check Type: ",checkType);
11-
var Converter=require("../libs/core/Converter");
12-
var rs=fs.createReadStream(path);
13-
var converter=new Converter({
14-
workerNum:coreNum,
15-
checkType:checkType,
16-
constructResult:false
9+
function testCSVLine(coreNum, checkType, cb){
10+
console.log("WorkerNum:", coreNum, "Check Type: ", checkType);
11+
var Converter = require("../libs/core/Converter");
12+
var rs = fs.createReadStream(path);
13+
var converter = new Converter({
14+
workerNum: coreNum,
15+
checkType: checkType,
16+
constructResult: false
1717
// fork:true
1818
});
19-
var totalLines=0;
20-
var secLines=0;
21-
converter.on("data",function(){
22-
totalLines++;
23-
secLines++;
19+
var totalLines = 0;
20+
var secLines = 0;
21+
converter.on("data", function() {
22+
totalLines++;
23+
secLines++;
2424
});
25-
converter.on("end",function(){
25+
converter.on("end", function() {
2626
clearInterval(timer);
2727
console.log("");
28-
var t=new Date()-start;
29-
console.log("Time elapsed: ",t, " ms");
30-
console.log("Total lines: "+totalLines);
31-
console.log("Average Speed: "+Math.round(totalLines/t*1000)+" Lines / Sec");
28+
var t = new Date() - start;
29+
console.log("Time elapsed: ", t, " ms");
30+
console.log("Total lines: " + totalLines);
31+
console.log("Average Speed: " + Math.round(totalLines / t * 1000) + " Lines / Sec");
3232
cb();
33-
})
34-
var timer=setInterval(function(){
35-
process.stdout.write("\r"+secLines+" CSV Lines/Sec");
36-
secLines=0;
37-
},1000);
38-
var start=new Date();
33+
});
34+
var timer = setInterval(function() {
35+
process.stdout.write("\r" + secLines + " CSV Lines/Sec");
36+
secLines = 0;
37+
}, 1000);
38+
var start = new Date();
3939

40-
var stream=rs.pipe(converter);
40+
var stream = rs.pipe(converter);
4141
}
4242

4343
// testCSVLine(1,false,false,function(){

bin/csvtojson.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function csvtojson() {
6868
}
6969
}
7070
process.exit(1);
71-
})
71+
});
7272
is.pipe(conv).pipe(process.stdout);
7373
// is.pipe(conv);
7474
}

libs/core/CSVError.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
var util=require("util");
2-
module.exports=CSVError;
3-
function CSVError(err,index,extra){
4-
Error.call(this,"");
5-
this.err=err;
6-
this.line=index;
7-
this.extra=extra;
8-
this.message="Error: "+err+". JSON Line number: "+index+ (extra?" near: "+extra:"");
9-
this.name="CSV Error";
1+
var util = require("util");
2+
module.exports = CSVError;
3+
function CSVError(err, index, extra) {
4+
Error.call(this, "");
5+
this.err = err;
6+
this.line = index;
7+
this.extra = extra;
8+
this.message = "Error: " + err + ". JSON Line number: " + index + (extra ? " near: " + extra : "");
9+
this.name = "CSV Error";
1010
}
11-
util.inherits(CSVError,Error);
11+
util.inherits(CSVError, Error);
1212

13-
CSVError.prototype.toString=function(){
14-
return JSON.stringify([this.err,this.line,this.extra]);
15-
}
13+
CSVError.prototype.toString = function() {
14+
return JSON.stringify([this.err, this.line, this.extra]);
15+
};
1616

17-
CSVError.column_mismatched=function(index,extra){
18-
return new CSVError("column_mismatched",index,extra);
19-
}
17+
CSVError.column_mismatched = function(index, extra) {
18+
return new CSVError("column_mismatched", index, extra);
19+
};
2020

21-
CSVError.unclosed_quote=function(index,extra){
22-
return new CSVError("unclosed_quote",index,extra);
23-
}
21+
CSVError.unclosed_quote = function(index, extra) {
22+
return new CSVError("unclosed_quote", index, extra);
23+
};
2424

25-
CSVError.fromArray=function(arr){
26-
return new CSVError(arr[0],arr[1],arr[2]);
27-
}
25+
CSVError.fromArray = function(arr) {
26+
return new CSVError(arr[0], arr[1], arr[2]);
27+
};

0 commit comments

Comments
 (0)