package
parses number and unit, '20px' into [20, 'px']
npm install parse-unitGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Parses a number and unit string, eg "20px" into [20, "px"].
var unit = require('parse-unit')
//prints [50, "gold"]
console.log( unit("50 gold") ) parse(str[, out])Parses the string and its unit, returning an array containing the number and unit, separated.
"-20 foo" => [-20, "foo"]
"5.5%" => [5.5, "%"]
5 => [5, ""]
"5" => [5, ""]This will create a new array unless you specify an array to out, which allows you to re-use arrays.
MIT, see LICENSE.md for details.