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

1.0.1 • Public • Published

parse-size-with-unit

A helper to parse 'size like' value into a valid size with unit.

Install

yarn add @lawrence_ch/parse-size-with-unit

# or

npm install --save @lawrence_ch/parse-size-with-unit

Usage

import parseSize from '@lawrence_ch/parse-size-with-unit'

parseSize(50) // '50px'
parseSize('50') // '50px'
parseSize('50px') // '50px'
parseSize('50%') // '50%'
parseSize('50.5px') // '50.5px'
parseSize('50.5%') // '50.5%'
parseSize('a') // null

// Default unit. Supports all CSS valid unit.
parseSize(50, 'em') // '50em'

Readme

Keywords

none

Package Sidebar

Install

npm i @lawrence_ch/parse-size-with-unit

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

1.89 kB

Total Files

4

Last publish

Collaborators

  • lawrence_ch