Comparing version 0.6.2 to 0.6.3
{ | ||
"name": "mf-parser", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "", | ||
@@ -21,6 +21,6 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"atom-sorter": "^0.6.2", | ||
"chemical-elements": "^0.6.2", | ||
"mf-utilities": "^0.6.2" | ||
"atom-sorter": "^0.6.3", | ||
"chemical-elements": "^0.6.3", | ||
"mf-utilities": "^0.6.3" | ||
} | ||
} |
@@ -16,3 +16,3 @@ 'use strict'; | ||
* @param {*} parts | ||
* @param {*} options | ||
* @param {*} [options={}] | ||
*/ | ||
@@ -19,0 +19,0 @@ module.exports = function getInfo(parts, options = {}) { |
@@ -15,5 +15,3 @@ 'use strict'; | ||
module.exports = function toParts(lines, options = {}) { | ||
const { | ||
expand: shouldExpandGroups = true | ||
} = options; | ||
const { expand: shouldExpandGroups = true } = options; | ||
let parts = []; | ||
@@ -53,2 +51,4 @@ | ||
break; | ||
case Kind.TEXT: | ||
break; | ||
default: | ||
@@ -84,4 +84,9 @@ throw new Error(`Can not process mf having: ${line.kind}`); | ||
if (currentPart.currentMultiplier !== 1) { | ||
for (let i = currentPart.currentMultiplier.fromIndex; i < currentPart.lines.length; i++) { | ||
currentPart.lines[i].multiplier *= currentPart.currentMultiplier.value; | ||
for ( | ||
let i = currentPart.currentMultiplier.fromIndex; | ||
i < currentPart.lines.length; | ||
i++ | ||
) { | ||
currentPart.lines[i].multiplier *= | ||
currentPart.currentMultiplier.value; | ||
} | ||
@@ -96,3 +101,7 @@ } | ||
function globalPartMultiplier(currentPart) { | ||
for (let i = currentPart.multipliers[0].fromIndex; i < currentPart.lines.length; i++) { | ||
for ( | ||
let i = currentPart.multipliers[0].fromIndex; | ||
i < currentPart.lines.length; | ||
i++ | ||
) { | ||
currentPart.lines[i].multiplier *= currentPart.multipliers[0].value; | ||
@@ -105,6 +114,11 @@ } | ||
// need to apply to everything till the previous parenthesis | ||
for (let i = currentPart.currentMultiplier.fromIndex; i < currentPart.lines.length; i++) { | ||
for ( | ||
let i = currentPart.currentMultiplier.fromIndex; | ||
i < currentPart.lines.length; | ||
i++ | ||
) { | ||
currentPart.lines[i].multiplier *= value; | ||
} | ||
} else { // just applies to the previous element | ||
} else { | ||
// just applies to the previous element | ||
currentPart.lines[currentPart.lines.length - 1].multiplier *= value; | ||
@@ -154,3 +168,4 @@ } | ||
} else { | ||
result[result.length - 1].value += key.value.value * key.value.multiplier; | ||
result[result.length - 1].value += | ||
key.value.value * key.value.multiplier; | ||
} | ||
@@ -161,3 +176,4 @@ } else { | ||
} else { | ||
result[result.length - 1].multiplier += key.value.multiplier; | ||
result[result.length - 1].multiplier += | ||
key.value.multiplier; | ||
} | ||
@@ -203,3 +219,3 @@ } | ||
switch (line.kind) { | ||
case (Kind.CHARGE): | ||
case Kind.CHARGE: | ||
break; | ||
@@ -223,2 +239,1 @@ default: | ||
} | ||
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
55710
1455
Updatedatom-sorter@^0.6.3
Updatedchemical-elements@^0.6.3
Updatedmf-utilities@^0.6.3