Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "xy-parser", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Parse a text-file and convert it to an array of XY points", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
{ | ||
"name": "xy-parser", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Parse a text-file and convert it to an array of XY points", | ||
@@ -26,18 +26,10 @@ "keywords": [ | ||
"test": "mocha --require should --reporter mocha-better-spec-reporter --recursive", | ||
"build": "gulp build" | ||
"build": "cheminfo build" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^8.1.3", | ||
"del": "^1.1.1", | ||
"gulp": "^3.8.11", | ||
"gulp-header": "^1.2.2", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-sourcemaps": "^1.3.0", | ||
"gulp-uglify": "^1.1.0", | ||
"mocha": "latest", | ||
"mocha-better-spec-reporter": "latest", | ||
"should": "latest", | ||
"vinyl-buffer": "^1.0.0", | ||
"vinyl-source-stream": "^1.0.0" | ||
"cheminfo-tools": "^1.0.2", | ||
"mocha": "^2.2.5", | ||
"mocha-better-spec-reporter": "^2.1.1", | ||
"should": "^7.0.2" | ||
} | ||
} |
@@ -11,4 +11,13 @@ # XY text file parser | ||
## Example of use: | ||
``` | ||
var result=XYParser.parse(realValue, {normalize: true}) | ||
``` | ||
## Options | ||
* normalize : will set the maximal value to 1 | ||
* arrayType : | ||
* 'xxyy' [[x1,x2,x3,...],[y1,y2,y2,...]] | ||
* 'xyxy' [[x1,y1],[x2,y2],[x3,y3], ...]] (default) | ||
@@ -15,0 +24,0 @@ ## License |
@@ -8,3 +8,15 @@ 'use strict'; | ||
var maxY = Number.MIN_VALUE; | ||
var result = []; | ||
var counter=0; | ||
var xxyy= (options.arrayType==='xxyy') ? true : false; | ||
if (xxyy) { | ||
var result = [ | ||
new Array(lines.length), | ||
new Array(lines.length) | ||
]; | ||
} else { | ||
var result = new Array(lines.length); | ||
} | ||
for (var i = 0; i < lines.length; i++) { | ||
@@ -19,3 +31,8 @@ var line = lines[i]; | ||
if (y > maxY) maxY = y; | ||
result.push([x, y]); | ||
if (xxyy) { | ||
result[0][counter]=x; | ||
result[1][counter++]=y; | ||
} else { | ||
result[counter++]=[x, y]; | ||
} | ||
} | ||
@@ -25,7 +42,20 @@ } | ||
if (xxyy) { | ||
result[0].length=counter; | ||
result[1].length=counter; | ||
} else { | ||
result.length=counter; | ||
} | ||
if (options.normalize) { | ||
maxY /= 100; | ||
for (var i = 0; i < result.length; i++) { | ||
result[i][1] /= maxY; | ||
if (xxyy) { | ||
for (var i = 0; i < counter; i++) { | ||
result[1][i] /= maxY; | ||
} | ||
} else { | ||
for (var i = 0; i < counter; i++) { | ||
result[i][1] /= maxY; | ||
} | ||
} | ||
} | ||
@@ -35,1 +65,3 @@ | ||
}; | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
35
5191
8
78
1