Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-units-from-string

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-units-from-string

Gets all occurrences of css units from a string. Supports px, mm, cm, in, pt, pc, mozmm, em, ex, ch, rem, vh, vw, vmin, vmax, %, and unitless.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

CSS units from string

Just like the name, gets all occurrences of css units from a string.

  • absolute - px, mm, cm, in, pt, pc, mozmm
  • relative - em, ex, ch, rem
  • viewport - vh, vw, vmin, vmax
  • percentage
  • unitless

Installation

npm install css-units-from-string --save

Usage

var unitsFromString = require('css-units-from-string');
var results = unitsFromString('200px 100% 1.25 2.75em');
// results
// [
//   {
//     match: '200px',
//     unit: 'px',
//     type: 'absolute',
//     value: 200,
//     index: 0
//   },
//   {
//     match: '100%',
//     unit: '%',
//     type: 'percentage',
//     value: 100,
//     index: 6
//   },
//   {
//     match: '1.25',
//     unit: null,
//     type: 'unitless',
//     value: 1.25,
//     index: 11
//   },
//   {
//     match: '2.75em',
//     unit: 'em',
//     type: 'relative',
//     value: 2.75,
//     index: 16
//   },
// ]

Building

Install

npm install

Dev

npm run watch

Test

npm run test

then go to: http://localhost:8080/webpack-dev-server

Build

npm run build

FAQs

Package last updated on 08 Jan 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc