Package Exports
- css-get-unit
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (css-get-unit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
css-get-unit

Get unit from a CSS value
var unit = require('css-get-unit')
unit('1px')
// => 'px'
unit('30.5kHz')
// => 'kHz'
unit('auto')
// => null
This module gets unit from the CSS value without verifying. If there is no unit it will return null
. To get the number instead, just use parseFloat
:
var value = '100px'
// User css-get-unit to get unit:
var unit = unit(value)
// => 'px'
// Use parseFloat to get number:
var number = parseFloat(value)
// => 100
Installation
$ npm install --save css-get-unit
Usage
unit(value)
value
(String
): CSS value to get the unit from
unit('2px')
// => 'px'
unit('.5ms')
// => 'ms'
unit('100')
// => null
License
MIT © Jamen Marz