Skip to content

Commit

Permalink
code reworks, bitHound fixes, attached eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Delagen committed Mar 5, 2018
1 parent 354aab9 commit b0b12a0
Show file tree
Hide file tree
Showing 31 changed files with 12,009 additions and 5,280 deletions.
17 changes: 17 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"presets": [
"@babel/preset-env"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "@babel/runtime"
}
]
],
"compact": true
}
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ ratings:
- "**.py"
- "**.rb"
exclude_paths:
- spec/
- lib/**/*
- spec/
- lib/**/*
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": "eslint:recommended",
"env": {
"node": true,
"jasmine": true
}
}
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.xml eol=lf
*.xml eol=lf
*.js eol=lf
23 changes: 10 additions & 13 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Unrelevant files and folders
benchmark
coverage
test
spec
.travis.yml
.codeclimate.yml
todo
index.html
static/*
.github
lib
.vscode
# Unrelevant files and folders
benchmark
coverage
spec
src/*
!src/read.js
static
.*
index.html
webpack*
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: node_js
node_js:
- 4
- 5
- 6
- 7
- 8
- 9
script: npm run coverage
cache: yarn
cache:
directories:
- "node_modules"
addons:
code_climate:
repo_token: ca31e4b1924e441790988993f307af5359d99d164d8308c39f81c81b8121f30f
Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

80 changes: 41 additions & 39 deletions benchmark/perfTest.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite("XML Parser benchmark");
"use strict";

var parser = require("../src/parser");
var xml2js = require("xml2js");
const Benchmark = require("benchmark");
const suite = new Benchmark.Suite("XML Parser benchmark");

var fs = require("fs");
var path = require("path");
var fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");
var xmlData = fs.readFileSync(fileNamePath).toString();
const parser = require("../src/parser");
//const xml2js = require("xml2js");

const fs = require("fs");
const path = require("path");
const fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");
const xmlData = fs.readFileSync(fileNamePath).toString();

suite
.add('validate', function() {
parser.validate(xmlData);
})
.add('parse', function() {
parser.parse(xmlData);
})
/* .add('xml2js ', function() {
xml2js.parseString(xmlData,function(err,result){
if (err) throw err;
});
}) */
.add("validate", function() {
parser.validate(xmlData);
})
.add("parse", function() {
parser.parse(xmlData);
})
/* .add('xml2js ', function() {
xml2js.parseString(xmlData,function(err,result){
if (err) throw err;
});
}) */

.on('start',function(){
console.log("Running Suite: " + this.name);
})
.on('error',function(e){
console.log("Error in Suite: " + this.name);
})
.on('abort',function(e){
console.log("Aborting Suite: " + this.name);
})
/*.on('cycle',function(event){
console.log("Suite ID:" + event.target.id);
})*/
// add listeners
.on('complete', function() {
for (var j = 0; j < this.length; j++) {
console.log(this[j].name + " : " + this[j].hz + " requests/second");
}
})
// run async
.run({ 'async': true });
.on("start", function() {
console.log("Running Suite: " + this.name);
})
.on("error", function(e) {
console.log("Error in Suite: " + this.name);
})
.on("abort", function(e) {
console.log("Aborting Suite: " + this.name);
})
/*.on('cycle',function(event){
console.log("Suite ID:" + event.target.id);
})*/
// add listeners
.on("complete", function() {
for (let j = 0; j < this.length; j++) {
console.log(this[j].name + " : " + this[j].hz + " requests/second");
}
})
// run async
.run({"async": true});
116 changes: 60 additions & 56 deletions benchmark/perfTest3.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite("XML Parser benchmark");
"use strict";

var parser = require("../src/parser");
var xml2js = require("xml2js");
const Benchmark = require("benchmark");
const suite = new Benchmark.Suite("XML Parser benchmark");

var fs = require("fs");
var path = require("path");
//var fileNamePath = path.join(__dirname, "../spec/assets/ptest.xml");//with CDATA
//var fileNamePath = path.join(__dirname, "../spec/assets/ptest_with_prolog.xml");//with CDATA
var fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");//1.5k
//var fileNamePath = path.join(__dirname, "../spec/assets/midsize.xml");//13m
var xmlData = fs.readFileSync(fileNamePath).toString();
const parser = require("../src/parser");
const xml2js = require("xml2js");

const fs = require("fs");
const path = require("path");
//const fileNamePath = path.join(__dirname, "../spec/assets/ptest.xml");//with CDATA
//const fileNamePath = path.join(__dirname, "../spec/assets/ptest_with_prolog.xml");//with CDATA
const fileNamePath = path.join(__dirname, "../spec/assets/sample.xml");//1.5k
//const fileNamePath = path.join(__dirname, "../spec/assets/midsize.xml");//13m
const xmlData = fs.readFileSync(fileNamePath).toString();
//xmlData=`<root>${xmlData.repeat(1000)}</root>`;

suite
.add('validation', function() {
var result = parser.validate(xmlData);
})
.add('xml to json V1', function() {
parser.parse(xmlData);
})
.add('xml2js ', function() {
xml2js.parseString(xmlData,function(err,result){
if (err) throw err;
// 2 for sample, 18432 for midsize
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
//if(18432 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
});
})
/* .add('xml2js', {
'defer': true,
'fn' : function(deferred) {
xml2js.parseString(xmlData,function(err,result){
console.log("err", err);
if (err) throw err;
deferred.resolve();
});
}
}) */
.add("validation", function() {
parser.validate(xmlData);
})
.add("xml to json V1", function() {
parser.parse(xmlData);
})
.add("xml2js ", function() {
xml2js.parseString(xmlData, function(err, result) {
if (err) {
throw err;
}
// 2 for sample, 18432 for midsize
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
//if(18432 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
//if(2 !== result["any_name"]["person"].length) console.log("incorrect length", result["any_name"]["person"].length);
});
})
/* .add('xml2js', {
'defer': true,
'fn' : function(deferred) {
xml2js.parseString(xmlData,function(err,result){
console.log("err", err);
if (err) throw err;
deferred.resolve();
});
}
}) */

.on('start',function(){
console.log("Running Suite: " + this.name);
})
.on('error',function(e){
console.log("Error in Suite: ",e);
})
.on('abort',function(e){
console.log("Aborting Suite: " + this.name);
})
/*.on('cycle',function(event){
console.log("Suite ID:" + event.target.id);
})*/
// add listeners
.on('complete', function() {
for (var j = 0; j < this.length; j++) {
console.log(this[j].name + " : " + this[j].hz + " requests/second");
}
})
// run async
.run({ 'async': true });
.on("start", function() {
console.log("Running Suite: " + this.name);
})
.on("error", function(e) {
console.log("Error in Suite: ", e);
})
.on("abort", function(e) {
console.log("Aborting Suite: " + this.name);
})
/*.on('cycle',function(event){
console.log("Suite ID:" + event.target.id);
})*/
// add listeners
.on("complete", function() {
for (let j = 0; j < this.length; j++) {
console.log(this[j].name + " : " + this[j].hz + " requests/second");
}
})
// run async
.run({'async': true});
Loading

0 comments on commit b0b12a0

Please sign in to comment.