🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

units-css

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

units-css

Parse length and angle CSS values and convert between units

0.4.0
latest
Source
npm
Version published
Maintainers
1
Created

What is units-css?

The units-css npm package provides utilities for converting and manipulating CSS units. It simplifies the process of working with different units in CSS, such as pixels, ems, rems, percentages, and more.

What are units-css's main functionalities?

Convert units

This feature allows you to convert one CSS unit to another. In the example, 16 pixels are converted to ems based on a base size of 16 pixels.

const units = require('units-css');
const pxToEm = units.convert('16px', 'em', { base: '16px' });
console.log(pxToEm); // '1em'

Parse units

This feature parses a CSS unit string into an object containing the numeric value and the unit. In the example, '16px' is parsed into an object with value 16 and unit 'px'.

const units = require('units-css');
const parsed = units.parse('16px');
console.log(parsed); // { value: 16, unit: 'px' }

Stringify units

This feature converts an object with a value and unit back into a CSS unit string. In the example, an object with value 16 and unit 'px' is converted back to '16px'.

const units = require('units-css');
const stringified = units.stringify({ value: 16, unit: 'px' });
console.log(stringified); // '16px'

Other packages similar to units-css

Keywords

unit

FAQs

Package last updated on 10 Oct 2015

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