unit-parse
v1.1.1
Published
Parse numbers and units from css values.
Readme
Unit Parse
Given an value, unit-parse will be able to parse the following units:
- rem, em, %, px
- vh, vw, vmin, vmax
- cm, mm, in, pt, pc, ch, ex
- s
const parseUnit = require('unit-parse');
parseUnit('20px'); // { value: '20', unit: 'px' }
parseUnit('15%'); // { value: '15', unit: '%' }
parseUnit('-1.5s'); // { value: '-1.5', unit: 's' }
parseUnit('20px', true); // 'px'
parseUnit('15%', true); // '%'
parseUnit('-1.5s', true); // 's'Contributing
Have a bug? Please create an issue here on GitHub that conforms with our contributing guidelines. You can also browse the Help Wanted tag in our issue tracker to find things to do.
Security
If you discover a security vulnerability within this package, please send an e-mail directly to the Centagon Developers at [email protected]. All security vulnerabilities will be promptly addressed.
License
This package is available under the MIT license.
Copyright (c) 2018 Centagon, B.V.
