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 🙏

© 2025 – Pkg Stats / Ryan Hefner

colorscalc

v1.0.0

Published

Type-safe color conversion utilities for TypeScript/JavaScript.

Readme

colorsCalc

A simple, type-safe npm package for color conversions and calculations in TypeScript/JavaScript.

Features

  • Convert between HEX, RGB, HSL, and LCH color spaces
  • Type-safe color objects with runtime validation
  • Utility functions for color manipulation

Installation

npm install colorscalc

Usage Example

import {
  hexToRgb,
  rgbToHex,
  hexToHsl,
  hslToHex,
  hexToLch,
  lchToHex,
} from "colorscalc";

const rgb = hexToRgb("#ff0000"); // { r, g, b }
const hex = rgbToHex(rgb); // "#ff0000"
const hsl = hexToHsl("#ff0000"); // { h, s, l }
const hex2 = hslToHex(hsl); // "#ff0000"
const lch = hexToLch("#ff0000"); // { l, c, h }
const hex3 = lchToHex(lch); // "#ff0000"

API

Color Conversion Functions

  • hexToRgb(hex: HEX): RGB — Convert HEX to RGB
  • rgbToHex(rgb: RGB): HEX — Convert RGB to HEX
  • hexToHsl(hex: HEX): HSL — Convert HEX to HSL
  • hslToHex(hsl: HSL): HEX — Convert HSL to HEX
  • hexToLch(hex: HEX): LCH — Convert HEX to LCH
  • lchToHex(lch: LCH): HEX — Convert LCH to HEX

Validation & Creation Helpers

  • createHEX(value: string): HEX — Validate and create a HEX color
  • createRGBValue(value: number): RGBValue — Validate and create an RGB channel value
  • createHue(value: number): Hue — Validate and create a Hue value
  • createPercentage(value: number): Percentage — Validate and create a Percentage value
  • createLCHLightness(value: number): LCHLightness — Validate and create LCH lightness
  • createLCHChroma(value: number): LCHChroma — Validate and create LCH chroma
  • createHSL(h: number, s: number, l: number): HSL — Create a validated HSL object
  • createRGB(r: number, g: number, b: number): RGB — Create a validated RGB object
  • createLCH(l: number, c: number, h: number): LCH — Create a validated LCH object

Type Guards

  • isHue(value: number): value is Hue — Check if a number is a valid Hue
  • isPercentage(value: number): value is Percentage — Check if a number is a valid Percentage
  • isRGBValue(value: number): value is RGBValue — Check if a number is a valid RGB channel
  • isValidHEX(value: string): value is HEX — Check if a string is a valid HEX color

Types

  • HEX — Branded string type for hex colors (e.g., "#ff0000")
  • RGB — Object: { r, g, b } (0-255)
  • HSL — Object: { h, s, l } (h: 0-360, s/l: 0-100)
  • LCH — Object: { l, c, h } (l: 0-100, c: 0+, h: 0-360)

License

MIT