UNPKG

wix-style-react

Version:
18 lines (15 loc) 508 B
module.exports = function (expression) { var units = expression.match(/[a-z%]+/g); // All values are unitless, reduce to a single number. if (!units) { return eval(expression).toString(); } // All values have the same unit, reduce to a single number // followed by the unit. if (units.every(u => u === units[0])) { return eval(expression.split(units[0]).join(' ')) + units[0]; } // Fallback on native calc. return 'calc(' + expression + ')'; }; //# sourceMappingURL=calc.js.map