Skip to content

Commit b0b12a0

Browse files
committed
code reworks, bitHound fixes, attached eslint
1 parent 354aab9 commit b0b12a0

31 files changed

+12009
-5280
lines changed

.babelrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
[
7+
"@babel/plugin-transform-runtime",
8+
{
9+
"helpers": false,
10+
"polyfill": false,
11+
"regenerator": true,
12+
"moduleName": "@babel/runtime"
13+
}
14+
]
15+
],
16+
"compact": true
17+
}

.codeclimate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ ratings:
2121
- "**.py"
2222
- "**.rb"
2323
exclude_paths:
24-
- spec/
25-
- lib/**/*
24+
- spec/
25+
- lib/**/*

.eslintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
5+
},
6+
"extends": "eslint:recommended",
7+
"env": {
8+
"node": true,
9+
"jasmine": true
10+
}
11+
}

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.xml eol=lf
1+
*.xml eol=lf
2+
*.js eol=lf

.npmignore

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
# Unrelevant files and folders
2-
benchmark
3-
coverage
4-
test
5-
spec
6-
.travis.yml
7-
.codeclimate.yml
8-
todo
9-
index.html
10-
static/*
11-
.github
12-
lib
13-
.vscode
1+
# Unrelevant files and folders
2+
benchmark
3+
coverage
4+
spec
5+
src/*
6+
!src/read.js
7+
static
8+
.*
9+
index.html
10+
webpack*

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
language: node_js
22
node_js:
3-
- 4
4-
- 5
53
- 6
64
- 7
75
- 8
6+
- 9
87
script: npm run coverage
9-
cache: yarn
8+
cache:
9+
directories:
10+
- "node_modules"
1011
addons:
1112
code_climate:
1213
repo_token: ca31e4b1924e441790988993f307af5359d99d164d8308c39f81c81b8121f30f

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

benchmark/perfTest.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
var Benchmark = require('benchmark');
2-
var suite = new Benchmark.Suite("XML Parser benchmark");
1+
"use strict";
32

4-
var parser = require("../src/parser");
5-
var xml2js = require("xml2js");
3+
const Benchmark = require("benchmark");
4+
const suite = new Benchmark.Suite("XML Parser benchmark");
65

7-
var fs = require("fs");
8-
var path = require("path");
9-
var fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");
10-
var xmlData = fs.readFileSync(fileNamePath).toString();
6+
const parser = require("../src/parser");
7+
//const xml2js = require("xml2js");
8+
9+
const fs = require("fs");
10+
const path = require("path");
11+
const fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");
12+
const xmlData = fs.readFileSync(fileNamePath).toString();
1113

1214
suite
13-
.add('validate', function() {
14-
parser.validate(xmlData);
15-
})
16-
.add('parse', function() {
17-
parser.parse(xmlData);
18-
})
19-
/* .add('xml2js ', function() {
20-
xml2js.parseString(xmlData,function(err,result){
21-
if (err) throw err;
22-
});
23-
}) */
15+
.add("validate", function() {
16+
parser.validate(xmlData);
17+
})
18+
.add("parse", function() {
19+
parser.parse(xmlData);
20+
})
21+
/* .add('xml2js ', function() {
22+
xml2js.parseString(xmlData,function(err,result){
23+
if (err) throw err;
24+
});
25+
}) */
2426

25-
.on('start',function(){
26-
console.log("Running Suite: " + this.name);
27-
})
28-
.on('error',function(e){
29-
console.log("Error in Suite: " + this.name);
30-
})
31-
.on('abort',function(e){
32-
console.log("Aborting Suite: " + this.name);
33-
})
34-
/*.on('cycle',function(event){
35-
console.log("Suite ID:" + event.target.id);
36-
})*/
37-
// add listeners
38-
.on('complete', function() {
39-
for (var j = 0; j < this.length; j++) {
40-
console.log(this[j].name + " : " + this[j].hz + " requests/second");
41-
}
42-
})
43-
// run async
44-
.run({ 'async': true });
27+
.on("start", function() {
28+
console.log("Running Suite: " + this.name);
29+
})
30+
.on("error", function(e) {
31+
console.log("Error in Suite: " + this.name);
32+
})
33+
.on("abort", function(e) {
34+
console.log("Aborting Suite: " + this.name);
35+
})
36+
/*.on('cycle',function(event){
37+
console.log("Suite ID:" + event.target.id);
38+
})*/
39+
// add listeners
40+
.on("complete", function() {
41+
for (let j = 0; j < this.length; j++) {
42+
console.log(this[j].name + " : " + this[j].hz + " requests/second");
43+
}
44+
})
45+
// run async
46+
.run({"async": true});

benchmark/perfTest3.js

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,66 @@
1-
var Benchmark = require('benchmark');
2-
var suite = new Benchmark.Suite("XML Parser benchmark");
1+
"use strict";
32

4-
var parser = require("../src/parser");
5-
var xml2js = require("xml2js");
3+
const Benchmark = require("benchmark");
4+
const suite = new Benchmark.Suite("XML Parser benchmark");
65

7-
var fs = require("fs");
8-
var path = require("path");
9-
//var fileNamePath = path.join(__dirname, "../spec/assets/ptest.xml");//with CDATA
10-
//var fileNamePath = path.join(__dirname, "../spec/assets/ptest_with_prolog.xml");//with CDATA
11-
var fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");//1.5k
12-
//var fileNamePath = path.join(__dirname, "../spec/assets/midsize.xml");//13m
13-
var xmlData = fs.readFileSync(fileNamePath).toString();
6+
const parser = require("../src/parser");
7+
const xml2js = require("xml2js");
8+
9+
const fs = require("fs");
10+
const path = require("path");
11+
//const fileNamePath = path.join(__dirname, "../spec/assets/ptest.xml");//with CDATA
12+
//const fileNamePath = path.join(__dirname, "../spec/assets/ptest_with_prolog.xml");//with CDATA
13+
const fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");//1.5k
14+
//const fileNamePath = path.join(__dirname, "../spec/assets/midsize.xml");//13m
15+
const xmlData = fs.readFileSync(fileNamePath).toString();
1416
//xmlData=`<root>${xmlData.repeat(1000)}</root>`;
1517

1618
suite
17-
.add('validation', function() {
18-
var result = parser.validate(xmlData);
19-
})
20-
.add('xml to json V1', function() {
21-
parser.parse(xmlData);
22-
})
23-
.add('xml2js ', function() {
24-
xml2js.parseString(xmlData,function(err,result){
25-
if (err) throw err;
26-
// 2 for sample, 18432 for midsize
27-
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
28-
//if(18432 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
29-
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
30-
});
31-
})
32-
/* .add('xml2js', {
33-
'defer': true,
34-
'fn' : function(deferred) {
35-
xml2js.parseString(xmlData,function(err,result){
36-
console.log("err", err);
37-
if (err) throw err;
38-
deferred.resolve();
39-
});
40-
}
41-
}) */
19+
.add("validation", function() {
20+
parser.validate(xmlData);
21+
})
22+
.add("xml to json V1", function() {
23+
parser.parse(xmlData);
24+
})
25+
.add("xml2js ", function() {
26+
xml2js.parseString(xmlData, function(err, result) {
27+
if (err) {
28+
throw err;
29+
}
30+
// 2 for sample, 18432 for midsize
31+
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
32+
//if(18432 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
33+
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
34+
});
35+
})
36+
/* .add('xml2js', {
37+
'defer': true,
38+
'fn' : function(deferred) {
39+
xml2js.parseString(xmlData,function(err,result){
40+
console.log("err", err);
41+
if (err) throw err;
42+
deferred.resolve();
43+
});
44+
}
45+
}) */
4246

43-
.on('start',function(){
44-
console.log("Running Suite: " + this.name);
45-
})
46-
.on('error',function(e){
47-
console.log("Error in Suite: ",e);
48-
})
49-
.on('abort',function(e){
50-
console.log("Aborting Suite: " + this.name);
51-
})
52-
/*.on('cycle',function(event){
53-
console.log("Suite ID:" + event.target.id);
54-
})*/
55-
// add listeners
56-
.on('complete', function() {
57-
for (var j = 0; j < this.length; j++) {
58-
console.log(this[j].name + " : " + this[j].hz + " requests/second");
59-
}
60-
})
61-
// run async
62-
.run({ 'async': true });
47+
.on("start", function() {
48+
console.log("Running Suite: " + this.name);
49+
})
50+
.on("error", function(e) {
51+
console.log("Error in Suite: ", e);
52+
})
53+
.on("abort", function(e) {
54+
console.log("Aborting Suite: " + this.name);
55+
})
56+
/*.on('cycle',function(event){
57+
console.log("Suite ID:" + event.target.id);
58+
})*/
59+
// add listeners
60+
.on("complete", function() {
61+
for (let j = 0; j < this.length; j++) {
62+
console.log(this[j].name + " : " + this[j].hz + " requests/second");
63+
}
64+
})
65+
// run async
66+
.run({'async': true});

0 commit comments

Comments
 (0)