npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cmm-util

v1.0.3

Published

A utility used to obtain absolute CSS measurements in JavaScript

Downloads

13

Readme

cmm-util

Overview

cmm-util is a utility library that provides a convenient way to convert a given value into equivalent pixel values based on different measurement units. It supports a variety of units including viewport height (vh), viewport width (vw), pixels (px), ems (em), root ems (rem), dots per inch (dpi), inches, centimeters (cm), millimeters (mm), points (pt), and picas (pc).

Installation

You can install cmm-util using npm:

npm install cmm-util

Usage

Here's how you can use cmm-util in your JavaScript or TypeScript project:

import cmm from 'cmm-util';

const measurement = cmm(100);

console.log(measurement.vh);  // Outputs the pixel equivalent of the value in viewport height units
console.log(measurement.vw);  // Outputs the pixel equivalent of the value in viewport width units
console.log(measurement.px);  // Outputs the pixel equivalent of the value in pixels
console.log(measurement.em);  // Outputs the pixel equivalent of the value in ems
console.log(measurement.rem); // Outputs the pixel equivalent of the value in root ems
console.log(measurement.dpi); // Outputs the pixel equivalent of the value in dots per inch
console.log(measurement.inch); // Outputs the pixel equivalent of the value in inches
console.log(measurement.cm);  // Outputs the pixel equivalent of the value in centimeters
console.log(measurement.mm);  // Outputs the pixel equivalent of the value in millimeters
console.log(measurement.pt);  // Outputs the pixel equivalent of the value in points
console.log(measurement.pc);  // Outputs the pixel equivalent of the value in picas

API

The cmm function takes a number as input and returns an object with properties for each measurement unit. Each property is a getter that calculates the equivalent pixel value of the input based on the corresponding unit when accessed.

License

cmm-util is MIT licensed.