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

mf-parser

Package Overview
Dependencies
Maintainers
6
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-parser - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

src/__tests__/MF.js

4

package.json
{
"name": "mf-parser",
"version": "0.0.4",
"version": "0.1.0",
"description": "Parse molecular formula",

@@ -34,3 +34,3 @@ "main": "./src/index.js",

"codecov": "^3.0.0",
"eslint": "^4.11.0",
"eslint": "^4.12.0",
"eslint-config-cheminfo": "^1.8.0",

@@ -37,0 +37,0 @@ "eslint-plugin-no-only-tests": "^2.0.0",

@@ -26,3 +26,2 @@ 'use strict';

'(CH(CH3)2)3N.2HCl': [{kind: 'openingParenthesis', value: '('}, {kind: 'atom', value: 'C'}, {kind: 'atom', value: 'H'}, {kind: 'openingParenthesis', value: '('}, {kind: 'atom', value: 'C'}, {kind: 'atom', value: 'H'}, {kind: 'multiplier', value: 3}, {kind: 'closingParenthesis', value: ')'}, {kind: 'multiplier', value: 2}, {kind: 'closingParenthesis', value: ')'}, {kind: 'multiplier', value: 3}, {kind: 'atom', value: 'N'}, {kind: 'salt', value: '.'}, {kind: 'preMultiplier', value: 2}, {kind: 'atom', value: 'H'}, {kind: 'atom', value: 'Cl'}],
'C(2': [{kind: 'atom', value: 'C'}, {kind: 'openingParenthesis', value: '('}, {kind: 'preMultiplier', value: 2}],
};

@@ -37,2 +36,7 @@

test('not same opening and closing parenthesis', function () {
expect(() => {
parse('C(');
}).toThrowError(/.*opening and closing.*/);
});

@@ -39,0 +43,0 @@ function check(mf, result) {

@@ -25,2 +25,3 @@ 'use strict';

parseToHtml,
MF: require('./MF'),
};

@@ -93,5 +93,19 @@ 'use strict';

}
this.checkParenthesis();
return this.result;
}
checkParenthesis() {
let counter = 0;
for (let line of this.result) {
if (line.kind === Kind.OPENING_PARENTHESIS) counter++;
if (line.kind === Kind.CLOSING_PARENTHESIS) counter--;
}
if (counter !== 0) {
throw new MFError(this.mf, this.i, 'number of opening and closing parenthesis not equal');
}
}
getNumber(ascii) {

@@ -98,0 +112,0 @@ let number = '';

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

kind: Format.TEXT,
value: '•'
value: ' • '
};

@@ -85,0 +85,0 @@ results.push(result);

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