MCPcopy
hub / github.com/styled-components/polished / math

Function math

src/math/math.js:134–147  ·  view source on GitHub ↗
(formula: string, additionalSymbols?: Object)

Source from the content-addressed store, hash-verified

132 * }
133 */
134export 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}

Callers 2

math.test.jsFile · 0.50
_errors.test.jsFile · 0.50

Calls 2

reverseStringFunction · 0.70
calculateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…