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

jcampconverter

Package Overview
Dependencies
Maintainers
6
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.8.0 to 2.9.1

History.md

8

package.json
{
"name": "jcampconverter",
"version": "2.8.0",
"version": "2.9.1",
"description": "Parse and convert JCAMP data",

@@ -41,8 +41,8 @@ "main": "./src/index.js",

"codecov": "^2.3.0",
"eslint": "^4.4.1",
"eslint": "^4.6.1",
"eslint-config-cheminfo": "^1.8.0",
"eslint-plugin-no-only-tests": "^2.0.0",
"jest": "^20.0.4",
"npm-run-all": "^4.0.2"
"jest": "^21.0.2",
"npm-run-all": "^4.1.1"
}
}

@@ -860,4 +860,55 @@ 'use strict';

function createTree(jcamp) {
if (typeof jcamp !== 'string') {
throw new TypeError('the JCAMP should be a string');
}
var lines = jcamp.split(/[\r\n]+/);
var stack = [];
var result = [];
var current;
var ntupleLevel = 0;
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (line.substring(0, 9) === '##NTUPLES') {
ntupleLevel++;
}
if (line.substring(0, 7) === '##TITLE') {
stack.push({
title: line.substring(8).trim(),
jcamp: line + '\n',
children: []
});
current = stack[stack.length - 1];
} else if (line.substring(0, 5) === '##END' && ntupleLevel === 0) {
current.jcamp += line + '\n';
var finished = stack.pop();
if (stack.length !== 0) {
current = stack[stack.length - 1];
current.children.push(finished);
} else {
current = undefined;
result.push(finished);
}
} else if (current && current.jcamp) {
current.jcamp += line + '\n';
if (line.substring(0, 10) === '##DATATYPE') {
current.dataType = line.substring(11).trim();
}
}
if (line.substring(0, 5) === '##END' && ntupleLevel > 0) {
ntupleLevel--;
}
}
return result;
}
module.exports = {
convert: JcampConverter
convert: JcampConverter,
createTree: createTree
};
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