UNPKG

css-math

Version:

Simple library for performing math operations on CSS properties

34 lines (27 loc) 636 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _parser = require('../parser'); /** * Parse the values and return a list of raw values and the unit * * @param values * @return string */ exports.default = function (values) { var unit = ''; var parsed = values.map(function (v) { var result = (0, _parser.findAndReplaceUnits)(v); if (!unit) { unit = result.unit; } else if (Number(result.value) && unit !== result.unit) { throw 'values cannot be mixed unit types'; } return Number(result.value); }); return { values: parsed, unit: unit }; };