parse-css-number
Parses a CSS <number>
, being either an integer or a number with a fractional component.
Installation
$ npm install parse-css-number [--save[-dev]]
Usage
const parseCSSNumber = // Valid numbers// https://developer.mozilla.org/en-US/docs/Web/CSS/number#Valid_numbers // A raw <integer> is also a <number>. // Positive fraction // Negative fraction // Zero // Zero, with a leading + // Zero, with a leading - // Fractional number without a leading zero // Scientific notation // Complicated scientific notation // Invalid numbers// https://developer.mozilla.org/en-US/docs/Web/CSS/number#Invalid_numbers // Decimal points must be followed by at least one digit. // Only one leading +/- is allowed. // Only one decimal point is allowed.
See the tests for more scenarios.
ES6/2015 import
Testing
$ npm test
This will run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.