Comparing version 0.0.4 to 0.1.0
{ | ||
"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); |
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
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
32031
23
773
0