Socket
Socket
Sign inDemoInstall

is-css-unit

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-css-unit

Check if a given value contains a valid CSS unit


Version published
Weekly downloads
890
increased by6.71%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

is-css-unit

Check if a given value contains a valid CSS unit

Installation

npm install --save is-css-unit

Usage

const isCSSUnit = require('is-css-unit').isCSSUnit;

console.log(isCSSUnit('300px'))
// => true

console.log(isCSSUnit('10bark'))
// => false

If you need more specific checks, you can require different functions:

  • isFontUnit: checks for all relative font units (em, ex, ch, rem)
  • isViewportUnit: checks for all viewport units (vw, vh, vmin, vmax)
  • isAbsoluteUnit: checks for all absolute units (cm, mm, q, in, pt, pc, px)
  • isAngleUnit: checks for all angle units (deg, grad, rad, turn)
  • isDurationUnit: checks for all duration units (s, ms)
  • isFrequencyUnit: checks for all frequency units (Hz, kHz)
  • isResolutionUnit: checks for all resolution units (dpi, dpcm, dppx)

License

is-css-unit is licensed under the MIT License

Keywords

FAQs

Last updated on 30 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc