unit-parse

1.1.1 • Public • Published

Unit Parse

NPM Version Build Status

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 developers@centagon.com. All security vulnerabilities will be promptly addressed.

License

This package is available under the MIT license.

Copyright (c) 2018 Centagon, B.V.

Readme

Keywords

Package Sidebar

Install

npm i unit-parse

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

28 kB

Total Files

15

Last publish

Collaborators

  • renecentagon