Comparing version 1.1.7 to 1.1.8
@@ -6,2 +6,14 @@ # Change Log | ||
## 1.1.8 (2021-03-15) | ||
# 0.60.0 (2021-03-15) | ||
**Note:** Version bump only for package mf-parser | ||
## 1.1.7 (2021-03-12) | ||
@@ -8,0 +20,0 @@ |
{ | ||
"name": "mf-parser", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "", | ||
@@ -21,9 +21,10 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"atom-sorter": "^1.1.6", | ||
"chemical-elements": "^1.1.6", | ||
"chemical-groups": "^1.1.1" | ||
"atom-sorter": "^1.1.7", | ||
"chemical-elements": "^1.1.7", | ||
"chemical-groups": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"jest-matcher-deep-close-to": "^2.0.1" | ||
} | ||
}, | ||
"gitHead": "edbce8dcb4f58223096d13c4cbaa1fb7a448283c" | ||
} |
@@ -203,2 +203,15 @@ 'use strict'; | ||
], | ||
'CaCO3 . 3/2H2O': [ | ||
{ kind: 'atom', value: 'Ca' }, | ||
{ kind: 'atom', value: 'C' }, | ||
{ kind: 'atom', value: 'O' }, | ||
{ kind: 'multiplier', value: 3 }, | ||
{ kind: 'text', value: ' ' }, | ||
{ kind: 'salt', value: '.' }, | ||
{ kind: 'text', value: ' ' }, | ||
{ kind: 'preMultiplier', value: 1.5 }, | ||
{ kind: 'atom', value: 'H' }, | ||
{ kind: 'multiplier', value: 2 }, | ||
{ kind: 'atom', value: 'O' }, | ||
], | ||
}; | ||
@@ -205,0 +218,0 @@ |
@@ -175,3 +175,8 @@ 'use strict'; | ||
ascii = this.mf.charCodeAt(this.i); | ||
} while ((ascii > 47 && ascii < 58) || ascii === 46 || ascii === 45); // number, . or - | ||
} while ( | ||
(ascii > 47 && ascii < 58) || | ||
ascii === 46 || | ||
ascii === 45 || | ||
ascii === 47 | ||
); // number . - / | ||
// we need to deal with the case there is a from / to | ||
@@ -183,7 +188,7 @@ if (previous === 46) this.i--; | ||
return { | ||
from: Number(number.substr(0, indexOfDash)), | ||
to: Number(number.substr(indexOfDash + 1)), | ||
from: parseNumberWithDivision(number.substr(0, indexOfDash)), | ||
to: parseNumberWithDivision(number.substr(indexOfDash + 1)), | ||
}; | ||
} | ||
return { from: Number(number) }; | ||
return { from: parseNumberWithDivision(number) }; | ||
} | ||
@@ -270,1 +275,13 @@ | ||
} | ||
function parseNumberWithDivision(string) { | ||
if (string.includes('/')) { | ||
let parts = string.split('/'); | ||
if (parts.length !== 2) { | ||
throw new TypeError('Can not parse MF with number like: ', string); | ||
} | ||
return Number(parts[0]) / Number(parts[1]); | ||
} else { | ||
return Number(string); | ||
} | ||
} |
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
65125
2120
Updatedatom-sorter@^1.1.7
Updatedchemical-elements@^1.1.7
Updatedchemical-groups@^1.1.2