Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jcampconverter

Package Overview
Dependencies
Maintainers
3
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jcampconverter - npm Package Compare versions

Comparing version 2.0.8 to 2.1.0

4.1.0.21.flags.json

2

bower.json
{
"name": "jcampconverter",
"version": "2.0.8",
"version": "2.1.0",
"main": [

@@ -5,0 +5,0 @@ "dist/jcampconverter.js",

{
"name": "jcampconverter",
"version": "2.0.8",
"version": "2.1.0",
"description": "Parse and convert JCAMP data",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -5,3 +5,2 @@ # JCAMP converter

[![build status][travis-image]][travis-url]
[![David deps][david-image]][david-url]
[![npm download][download-image]][download-url]

@@ -42,3 +41,3 @@

####Node JS
#### Node JS

@@ -86,8 +85,6 @@ ```javascript

[npm-image]: https://img.shields.io/npm/v/jcampconverter.svg?style=flat-square
[npm-url]: https://npmjs.org/package/jcampconverter
[npm-url]: https://www.npmjs.com/package/jcampconverter
[travis-image]: https://img.shields.io/travis/cheminfo/jcampconverter/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/cheminfo/jcampconverter
[david-image]: https://img.shields.io/david/cheminfo/jcampconverter.svg?style=flat-square
[david-url]: https://david-dm.org/cheminfo/jcampconverter
[download-image]: https://img.shields.io/npm/dm/jcampconverter.svg?style=flat-square
[download-url]: https://npmjs.org/package/jcampconverter
[download-url]: https://www.npmjs.com/package/jcampconverter

@@ -51,3 +51,3 @@ 'use strict';

if (!(typeof jcamp == 'string')) return result;
if (!(typeof jcamp === 'string')) return result;
// console.time('start');

@@ -76,5 +76,5 @@

if (dataLabel == 'DATATABLE') {
if (dataLabel === 'DATATABLE') {
endLine = dataValue.indexOf('\n');
if (endLine == -1) endLine = dataValue.indexOf('\r');
if (endLine === -1) endLine = dataValue.indexOf('\r');
if (endLine > 0) {

@@ -86,3 +86,3 @@ var xIndex = -1;

infos = dataValue.substring(0, endLine).split(/[ ,;\t]{2,}/);
infos = dataValue.substring(0, endLine).split(/[ ,;\t]+/);
if (infos[0].indexOf('++') > 0) {

@@ -95,4 +95,4 @@ var firstVariable = infos[0].replace(/.*\(([a-zA-Z0-9]+)\+\+.*/, '$1');

if (xIndex == -1) xIndex = 0;
if (yIndex == -1) yIndex = 0;
if (xIndex === -1) xIndex = 0;
if (yIndex === -1) yIndex = 0;

@@ -129,5 +129,5 @@ if (ntuples.first) {

if (dataLabel == 'TITLE') {
if (dataLabel === 'TITLE') {
spectrum.title = dataValue;
} else if (dataLabel == 'DATATYPE') {
} else if (dataLabel === 'DATATYPE') {
spectrum.dataType = dataValue;

@@ -137,31 +137,31 @@ if (dataValue.indexOf('nD') > -1) {

}
} else if (dataLabel == 'XUNITS') {
} else if (dataLabel === 'XUNITS') {
spectrum.xUnit = dataValue;
} else if (dataLabel == 'YUNITS') {
} else if (dataLabel === 'YUNITS') {
spectrum.yUnit = dataValue;
} else if (dataLabel == 'FIRSTX') {
} else if (dataLabel === 'FIRSTX') {
spectrum.firstX = parseFloat(dataValue);
} else if (dataLabel == 'LASTX') {
} else if (dataLabel === 'LASTX') {
spectrum.lastX = parseFloat(dataValue);
} else if (dataLabel == 'FIRSTY') {
} else if (dataLabel === 'FIRSTY') {
spectrum.firstY = parseFloat(dataValue);
} else if (dataLabel == 'NPOINTS') {
} else if (dataLabel === 'NPOINTS') {
spectrum.nbPoints = parseFloat(dataValue);
} else if (dataLabel == 'XFACTOR') {
} else if (dataLabel === 'XFACTOR') {
spectrum.xFactor = parseFloat(dataValue);
} else if (dataLabel == 'YFACTOR') {
} else if (dataLabel === 'YFACTOR') {
spectrum.yFactor = parseFloat(dataValue);
} else if (dataLabel == 'DELTAX') {
} else if (dataLabel === 'DELTAX') {
spectrum.deltaX = parseFloat(dataValue);
} else if (dataLabel == '.OBSERVEFREQUENCY' || dataLabel == '$SFO1') {
} else if (dataLabel === '.OBSERVEFREQUENCY' || dataLabel === '$SFO1') {
if (!spectrum.observeFrequency) spectrum.observeFrequency = parseFloat(dataValue);
} else if (dataLabel == '.OBSERVENUCLEUS') {
} else if (dataLabel === '.OBSERVENUCLEUS') {
if (!spectrum.xType) result.xType = dataValue.replace(/[^a-zA-Z0-9]/g, '');
} else if (dataLabel == '$SFO2') {
} else if (dataLabel === '$SFO2') {
if (!result.indirectFrequency) result.indirectFrequency = parseFloat(dataValue);
} else if (dataLabel == '$OFFSET') { // OFFSET for Bruker spectra
} else if (dataLabel === '$OFFSET') { // OFFSET for Bruker spectra
result.shiftOffsetNum = 0;
if (!result.shiftOffsetVal) result.shiftOffsetVal = parseFloat(dataValue);
} else if (dataLabel == '$REFERENCEPOINT') { // OFFSET for Varian spectra
} else if (dataLabel === '$REFERENCEPOINT') { // OFFSET for Varian spectra

@@ -174,29 +174,29 @@

// result.shiftOffsetVal = parseFloat(parts[3].trim());
} else if (dataLabel == 'VARNAME') {
} else if (dataLabel === 'VARNAME') {
ntuples.varname = dataValue.split(/[, \t]{2,}/);
} else if (dataLabel == 'SYMBOL') {
} else if (dataLabel === 'SYMBOL') {
ntuples.symbol = dataValue.split(/[, \t]{2,}/);
} else if (dataLabel == 'VARTYPE') {
} else if (dataLabel === 'VARTYPE') {
ntuples.vartype = dataValue.split(/[, \t]{2,}/);
} else if (dataLabel == 'VARFORM') {
} else if (dataLabel === 'VARFORM') {
ntuples.varform = dataValue.split(/[, \t]{2,}/);
} else if (dataLabel == 'VARDIM') {
} else if (dataLabel === 'VARDIM') {
ntuples.vardim = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == 'UNITS') {
} else if (dataLabel === 'UNITS') {
ntuples.units = dataValue.split(/[, \t]{2,}/);
} else if (dataLabel == 'FACTOR') {
} else if (dataLabel === 'FACTOR') {
ntuples.factor = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == 'FIRST') {
} else if (dataLabel === 'FIRST') {
ntuples.first = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == 'LAST') {
} else if (dataLabel === 'LAST') {
ntuples.last = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == 'MIN') {
} else if (dataLabel === 'MIN') {
ntuples.min = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == 'MAX') {
} else if (dataLabel === 'MAX') {
ntuples.max = convertToFloatArray(dataValue.split(/[, \t]{2,}/));
} else if (dataLabel == '.NUCLEUS') {
} else if (dataLabel === '.NUCLEUS') {
if (result.twoD) {
result.yType = dataValue.split(/[, \t]{2,}/)[0];
}
} else if (dataLabel == 'PAGE') {
} else if (dataLabel === 'PAGE') {
spectrum.page = dataValue.trim();

@@ -210,8 +210,8 @@ spectrum.pageValue = parseFloat(dataValue.replace(/^.*=/, ''));

}
if (result.indirectFrequency && unit != 'PPM') {
if (result.indirectFrequency && unit !== 'PPM') {
spectrum.pageValue /= result.indirectFrequency;
}
} else if (dataLabel == 'RETENTIONTIME') {
} else if (dataLabel === 'RETENTIONTIME') {
spectrum.pageValue = parseFloat(dataValue);
} else if (dataLabel == 'XYDATA') {
} else if (dataLabel === 'XYDATA') {
prepareSpectrum(result, spectrum);

@@ -226,3 +226,3 @@ // well apparently we should still consider it is a PEAK TABLE if there are no '++' after

spectrum = {};
} else if (dataLabel == 'PEAKTABLE') {
} else if (dataLabel === 'PEAKTABLE') {
prepareSpectrum(result, spectrum);

@@ -271,3 +271,3 @@ parsePeakTable(spectrum, dataValue, result);

// maybe it is a GC (HPLC) / MS. In this case we add a new format
if (spectra.length > 1 && spectra[0].dataType && spectra[0].dataType.toLowerCase().match(/.*mass./)) {
if (spectra.length > 1 && (! spectra[0].dataType || spectra[0].dataType.toLowerCase().match(/.*mass./))) {
addGCMS(result);

@@ -319,3 +319,3 @@ if (result.profiling) result.profiling.push({

for (var i = 0; i < GC_MS_FIELDS.length; i++) {
if (dataLabel == GC_MS_FIELDS[i]) return true;
if (dataLabel === GC_MS_FIELDS[i]) return true;
}

@@ -335,2 +335,3 @@ return false;

}
if (existingGCMSFields.length===0) return;
var gcms = {};

@@ -348,3 +349,3 @@ gcms.gc = {};

}
if (spectrum.data) gcms.ms[i] = spectrum.data[0];
if (spectrum.data) gcms.ms[i] = spectrum.data[0];

@@ -359,3 +360,3 @@ }

if (spectrum.observeFrequency) {
if (spectrum.xUnit && spectrum.xUnit.toUpperCase() == 'HZ') {
if (spectrum.xUnit && spectrum.xUnit.toUpperCase() === 'HZ') {
spectrum.xUnit = 'PPM';

@@ -387,3 +388,3 @@ spectrum.xFactor = spectrum.xFactor / spectrum.observeFrequency;

values = lines[i].trim().replace(removeCommentRegExp, '').split(peakTableSplitRegExp);
if (values.length % 2 == 0) {
if (values.length % 2 === 0) {
for (j = 0, jj = values.length; j < jj; j = j + 2) {

@@ -425,3 +426,3 @@ // takes around 40% of the time to add and parse the 2 values nearly exclusively because of parseFloat

var expectedCurrentX = parseFloat(values[0] - spectrum.firstPoint) * spectrum.xFactor + spectrum.firstX;
if ((lastDif || lastDif == 0)) {
if ((lastDif || lastDif === 0)) {
expectedCurrentX += spectrum.deltaX;

@@ -432,3 +433,3 @@ }

for (var j = 1, jj = values.length; j < jj; j++) {
if (j == 1 && (lastDif || lastDif == 0)) {
if (j === 1 && (lastDif || lastDif === 0)) {
lastDif = null; // at the beginning of each line there should be the full value X / Y so the diff is always undefined

@@ -440,3 +441,3 @@ // we could check if we have the expected Y value

// + - . 0 1 2 3 4 5 6 7 8 9
if ((ascii == 43) || (ascii == 45) || (ascii == 46) || ((ascii > 47) && (ascii < 58))) {
if ((ascii === 43) || (ascii === 45) || (ascii === 46) || ((ascii > 47) && (ascii < 58))) {
expectedY = parseFloat(values[j]);

@@ -454,3 +455,3 @@ } else

}
if (expectedY != currentY) {
if (expectedY !== currentY) {
result.logs.push('Y value check error: Found: ' + expectedY + ' - Current: ' + currentY);

@@ -465,3 +466,3 @@ result.logs.push('Previous values: ' + previousValues.length);

// + - . 0 1 2 3 4 5 6 7 8 9
if ((ascii == 43) || (ascii == 45) || (ascii == 46) || ((ascii > 47) && (ascii < 58))) {
if ((ascii === 43) || (ascii === 45) || (ascii === 46) || ((ascii > 47) && (ascii < 58))) {
lastDif = null;

@@ -490,5 +491,5 @@ currentY = parseFloat(values[j]);

// DUP digits S T U V W X Y Z s (ascii 83-90, 115)
if (((ascii > 82) && (ascii < 91)) || (ascii == 115)) {
if (((ascii > 82) && (ascii < 91)) || (ascii === 115)) {
var dup = parseFloat(String.fromCharCode(ascii - 34) + values[j].substring(1)) - 1;
if (ascii == 115) {
if (ascii === 115) {
dup = parseFloat('9' + values[j].substring(1)) - 1;

@@ -505,3 +506,3 @@ }

// positive DIF digits % J K L M N O P Q R (ascii 37, 74-82)
if (ascii == 37) {
if (ascii === 37) {
lastDif = parseFloat('0' + values[j].substring(1));

@@ -545,3 +546,3 @@ currentY += lastDif;

if (z[i][j] > maxZ) maxZ = spectra[i].data[0][j * 2 + 1];
if (i != 0 && j != 0) {
if (i !== 0 && j !== 0) {
noise += Math.abs(z[i][j] - z[i][j - 1]) + Math.abs(z[i][j] - z[i - 1][j]);

@@ -609,3 +610,3 @@ }

var side = level % 2;
if (side == 0) {
if (side === 0) {
lineZValue = (maxZ - 5 * noise) * Math.exp(level / 2 - nbLevels) + 5 * noise;

@@ -635,3 +636,3 @@ } else {

// the segment
if (isOver[0] != isOver[1] && isOver[0] != isOver[2]) {
if (isOver[0] !== isOver[1] && isOver[0] !== isOver[2]) {
pAx = povar + (lineZValue - povarHeight[0]) / (povarHeight[1] - povarHeight[0]);

@@ -643,3 +644,3 @@ pAy = iSubSpectra;

}
if (isOver[3] != isOver[1] && isOver[3] != isOver[2]) {
if (isOver[3] !== isOver[1] && isOver[3] !== isOver[2]) {
pAx = povar + 1;

@@ -652,6 +653,6 @@ pAy = iSubSpectra + 1 - (lineZValue - povarHeight[3]) / (povarHeight[1] - povarHeight[3]);

// test around the diagonal
if (isOver[1] != isOver[2]) {
if (isOver[1] !== isOver[2]) {
pAx = povar + 1 - (lineZValue - povarHeight[1]) / (povarHeight[2] - povarHeight[1]);
pAy = iSubSpectra + (lineZValue - povarHeight[1]) / (povarHeight[2] - povarHeight[1]);
if (isOver[1] != isOver[0]) {
if (isOver[1] !== isOver[0]) {
pBx = povar + 1 - (lineZValue - povarHeight[1]) / (povarHeight[0] - povarHeight[1]);

@@ -661,3 +662,3 @@ pBy = iSubSpectra;

}
if (isOver[2] != isOver[0]) {
if (isOver[2] !== isOver[0]) {
pBx = povar;

@@ -667,3 +668,3 @@ pBy = iSubSpectra + 1 - (lineZValue - povarHeight[2]) / (povarHeight[0] - povarHeight[2]);

}
if (isOver[1] != isOver[3]) {
if (isOver[1] !== isOver[3]) {
pBx = povar + 1;

@@ -673,3 +674,3 @@ pBy = iSubSpectra + (lineZValue - povarHeight[1]) / (povarHeight[3] - povarHeight[1]);

}
if (isOver[2] != isOver[3]) {
if (isOver[2] !== isOver[3]) {
pBx = povar + (lineZValue - povarHeight[2]) / (povarHeight[3] - povarHeight[2]);

@@ -716,3 +717,3 @@ pBy = iSubSpectra + 1;

for (i = 0, ii = highResData.length; i < ii; i = i + 2) {
if (i % modulo == 0) {
if (i % modulo === 0) {
lowResData.push(highResData[i], highResData[i + 1])

@@ -719,0 +720,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc