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

pigmy

v1.0.8

Published

A simple and expressive terminal color library for Node.js.

Readme

Pigmy

Pigmy — a tiny, expressive terminal color helper for Node.js.

Elegant, chainable APIs let you style CLI output with readable, composable calls. Pigmy ships TypeScript declarations so consumers get great typing out of the box.

Why Pigmy?

  • Minimal API surface, easy to learn.
  • Chainable getters for styles (e.g. pigmy.bold.underline.red('text')).
  • 24-bit color helpers (hex / rgb) and background variants.
  • Ships TypeScript declarations for excellent DX.

Install

Install from npm:

npm install pigmy

Quick start

Works the same in JavaScript and TypeScript.

import pigmy from 'pigmy';

console.log(pigmy.red('This is red text'));
console.log(pigmy.bold.cyan('Important'));
console.log(pigmy.hex('#C200FF')('Purple by hex'));
console.log(pigmy.rgb(255, 160, 0)('Orange by rgb'));

// Chaining styles (getter-based):
console.log(pigmy.bold.underline.magenta('Bold, underlined, magenta'));

API at a glance

  • Colors: pigmy.black, pigmy.red, pigmy.green, pigmy.yellow, pigmy.blue, pigmy.magenta, pigmy.cyan, pigmy.white, pigmy.gray — each accepts a string: pigmy.red('text').
  • Backgrounds: pigmy.bgBlack, pigmy.bgRed, pigmy.bgGreen, ... (same naming with bg prefix).
  • Styles (getter properties returning a builder you can chain): pigmy.bold, pigmy.italic, pigmy.underline, pigmy.reset, etc.
  • 24-bit color helpers:
    • pigmy.hex('#rrggbb')('text') — hex color
    • pigmy.rgb(r, g, b)('text') — RGB color
    • pigmy.bgHex('#rrggbb')('text') and pigmy.bgRgb(r,g,b)('text') for backgrounds

Examples:

console.log(pigmy.hex('#00ff88')('Hex color'));
console.log(pigmy.bgHex('#001122')('Background with hex'));
console.log(pigmy.rgb(123,45,67)('RGB color'));

Reference — Modifiers, Colors & Backgrounds

This section lists only the features implemented in the codebase. Pigmy also provides 24-bit helpers (hex, rgb, bgHex, bgRgb) and runtime registration methods (addColor, addBgColor, addStyle).

Modifiers (available as getter properties)

  • reset — Reset the current style (used automatically by builders).
  • bold — Make the text bold.
  • dim — Make the text have lower opacity.
  • italic — Make the text italic. (Not widely supported)
  • underline — Put a horizontal line below the text. (Not widely supported)
  • inverse — Invert background and foreground colors.
  • hidden — Print the text but make it invisible.
  • strikethrough — Put a horizontal line through the center of the text. (Not widely supported)

Colors (foreground)

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray

Background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite

24-bit color helpers

  • hex('#rrggbb')('text') — 24-bit foreground hex color
  • rgb(r, g, b)('text') — 24-bit foreground RGB
  • bgHex('#rrggbb')('text') — 24-bit background hex color
  • bgRgb(r, g, b)('text') — 24-bit background RGB

Runtime API (on the Pigmy class)

  • addColor(name, code) — register a new foreground color code; new name becomes available on future builders created with createAnsi().
  • addBgColor(name, code) — register a new background color (builders expose it as bgName).
  • addStyle(name, code) — register a new style (getter) that can be chained.

Notes

  • The default pigmy instance is created in lib/index.ts using new Pigmy().createAnsi().
  • Builders capture current style codes and return functions that wrap text in ANSI sequences and append the reset code.

TypeScript support

Pigmy ships declaration files (dist/index.d.ts) so TypeScript projects get types automatically when you import pigmy from 'pigmy'.

If you maintain the project and prefer generating .d.ts from JSDoc/TS, run the TypeScript build locally:

npm run build:tsc

Note: The repository keeps source .d.ts under lib/ and the published dist/ contains the bundled JS and index.d.ts.

Testing the distributed bundle locally

A small test harness lives in test/ to exercise the built bundles. From the project root:

npm run build

Or run test scripts directly with Node (see test/ for details).

Build & publish

Build the package (produces dist/ and copies .d.ts):

npm run build

Development notes

  • The published package contains both ESM and CJS bundles and dist/index.d.ts.
  • To regenerate .d.ts from sources, keep a local TypeScript install and run npm run build:tsc.

License

MIT

Maintainers

  • Pscodium — https://github.com/Pscodium