Narcoleptic Possum Mob

    @tinyfe/parse-unit
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.10 • Public • Published

    parse unit

    parses number and unit, eg: '100px' into [100, 'px'], also it include validate css value

    Usage

    import parseUnit, { isCssValue } from '@tinyfe/parse-unit';
    
    // judge the css value
    isCssValue('100px'); // true
    
    // parse unit by the value
    parseUnit('100px'); // [100, 'px']
    parseUnit('100%'); // [100, '%']
    parseUnit('100'); // [100, '']
    
    // CSS unit
    parseUnit('auto'); // ['auto', '']
    parseUnit('revert'); // ['revert', '']
    parseUnit('unset'); // ['unset', '']
    parseUnit('inherit'); // ['inherit', '']
    parseUnit('initial'); // ['initial', '']
    parseUnit('max-content'); // ['max-content', '']
    parseUnit('min-content'); // ['min-content', '']
    parseUnit('fit-content'); // ['fit-content', '']
    parseUnit('-webkit-fill-available'); // ['-webkit-fill-available', '']
    // etc...

    Install

    npm i @tinyfe/parse-unit

    DownloadsWeekly Downloads

    7

    Version

    0.0.10

    License

    MIT

    Unpacked Size

    10.4 kB

    Total Files

    15

    Last publish

    Collaborators

    • rain120