Value-type representation of common CSS units plus a conversion function.
Get it:
npm install css-units
Require it:
var unit = require('css-units');
Create a new object with the given numeric value
and string unit
(one of in
, cm
, pc
, mm
, pt
, px
, deg
, rad
, s
, ms
, %
, em
or ex
).
Returns a CSS-compatible string representation of the value.
Convert value
to otherUnit
. Returns a new instance of unit.Value
on success, throws an error when no conversion is possible.
Convert the number value
from fromUnit
to toUnit
. Returns a number on success, throws an error when no conversion is possible. Note the reversed argument order; this is to promote use of partial-application in FP applications.
Converts Value
instance value
to toUnit
, returning a new instance on success or throwing an error when no conversion is possible. Note the reversed argument order; this is to promote use of partial-application in FP applications.
© 2014 Jason Frame [ @jaz303 / jason@onehackoranother.com ]
Released under the ISC license.