13:29
<eemeli>

I just now came across CSSNumericValue spec, which already has the following work in browsers:

const pct = CSSNumericValue.parse('42.0%')
[pct.value, pct.unit] // [42, 'percent']

new CSSUnitValue(5, 'deg') // CSSUnitValue { value: 5, unit: 'deg', … }
CSS.kHz(2.6) // CSSUnitValue { value: 2.6, unit: 'khz', … }

CSS.px(10).mul(10).value // 100
CSS.px(23).add(CSS.cm(4)).toString() // 'calc(23px + 4cm)'

CSS.px(23).to('cm').value // 0.6085416666666668
13:31
<eemeli>
It holds the values as numbers and is limited to CSS units, but does (somewhat) support arithmetic and unit conversions.