convert-css-length
Convert between css lengths e.g. em->px or px->rem
Conversions between em, ex, rem, px are supported. PRs welcome if
you need support for more esoteric length units.
[Note: algorithm was originally ported from Compass] (https://github.com/Compass/compass/blob/master/core/stylesheets/compass/typography/_units.scss)
Install
npm install convert-css-length
Usage
var convertLength = require('convert-css-length');
var convert = convertLength('21px');
convert('1rem', 'px');
convert('30px', 'em');
convert('1em', 'px', '14px')