jcampconverter
Advanced tools
Comparing version 2.0.5 to 2.0.6
{ | ||
"name": "jcampconverter", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "dist/jcampconverter.js", |
{ | ||
"name": "jcampconverter", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Parse and convert JCAMP data", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -36,3 +36,5 @@ # JCAMP converter | ||
* keepRecordsRegExp - regexp to select which records should be placed in the info field. By default: :/^[A-Za-z]+$/} | ||
* xy - instead of creating a 1D array containing [x1,y1,x2,y2, ...] create an object: {x:[], y:[]} | ||
### Use as a module | ||
@@ -39,0 +41,0 @@ |
@@ -24,2 +24,4 @@ 'use strict'; | ||
options.keepSpectra: keep the original spectra for a 2D | ||
options.xy: true // create x / y array instead of a 1D array | ||
options.keepRecordsRegExp: which fields do we keep | ||
*/ | ||
@@ -257,2 +259,24 @@ | ||
if (options.xy) { // the spectraData should not be a oneD array but an object with x and y | ||
if (spectra.length > 0) { | ||
for (var i=0; i<spectra.length; i++) { | ||
var spectrum=spectra[i]; | ||
if (spectrum.data.length>0) { | ||
for (var j=0; j<spectrum.data.length; j++) { | ||
var data=spectrum.data[j]; | ||
var newData={x:Array(data.length/2), y:Array(data.length/2)}; | ||
for (var k=0; k<data.length; k=k+2) { | ||
newData.x[k/2]=data[k]; | ||
newData.y[k/2]=data[k+1]; | ||
} | ||
spectrum.data[j]=newData; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (result.profiling) { | ||
@@ -259,0 +283,0 @@ result.profiling.push({action: 'Total time', time: new Date() - start}); |
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
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
38796
718
87