(formula: string, additionalSymbols?: Object)
| 132 | * } |
| 133 | */ |
| 134 | export default function math(formula: string, additionalSymbols?: Object): string { |
| 135 | const reversedFormula = reverseString(formula) |
| 136 | const formulaMatch = reversedFormula.match(unitRegExp) |
| 137 | |
| 138 | // Check that all units are the same |
| 139 | if (formulaMatch && !formulaMatch.every(unit => unit === formulaMatch[0])) { |
| 140 | throw new PolishedError(41) |
| 141 | } |
| 142 | |
| 143 | const cleanFormula = reverseString(reversedFormula.replace(unitRegExp, '')) |
| 144 | return `${calculate(cleanFormula, additionalSymbols)}${ |
| 145 | formulaMatch ? reverseString(formulaMatch[0]) : '' |
| 146 | }` |
| 147 | } |
no test coverage detected
searching dependent graphs…