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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@microstack-dev/ms-chroma

v0.1.1

Published

Tiny, modern ANSI color utility

Readme

ms-chroma

npm version npm downloads License: MIT Node.js Version TypeScript

A minimal, chainable ANSI color utility for Node.js that provides type-safe terminal styling without dependencies.

Overview

ms-chroma solves terminal color output in Node.js by offering a simple, chainable API for ANSI escape codes. It focuses on core coloring and styling needs without feature creep.

It intentionally does not solve:

  • Browser compatibility
  • Advanced color spaces (RGB, truecolor)
  • Plugin systems
  • Non-terminal output formatting

Installation

npm install @microstack-dev/ms-chroma
pnpm add @microstack-dev/ms-chroma
yarn add @microstack-dev/ms-chroma

Usage

ESM

import { c } from '@microstack-dev/ms-chroma';

CommonJS

const { c } = require('@microstack-dev/ms-chroma');

Examples

Basic Colors

console.log(c.red('Error'));
console.log(c.green('Success'));
console.log(c.blue('Info'));

Modifiers

console.log(c.bold('Important'));
console.log(c.dim('Secondary'));
console.log(c.underline('Link'));
console.log(c.inverse('Inverted'));
console.log(c.hidden('Secret'));
console.log(c.visible('Text'));

Background Colors

console.log(c.bgRed('Alert'));
console.log(c.bgGreen('Good'));
console.log(c.bgBlue('Notice'));

Chaining

console.log(c.red.bold('Critical'));
console.log(c.green.underline('Highlighted'));
console.log(c.red.bold.reset('Plain'));

Nested Chaining

console.log(c.bgBlue.white.bold('Styled text'));

Template Literals

const level = 'error';
console.log(c`{red ${level}} occurred at ${new Date().toISOString()}`);
console.log(c`{hidden Secret} {visible Visible}`);

Template Literal Syntax

Template literals use {style text} blocks to apply styles inline.

  • {red Error} applies red color to "Error"
  • {bold Warning} applies bold to "Warning"
  • Styles can be chained: {red.bold Alert}
  • Reset styles: {reset Plain} clears all styles
  • Visibility: {hidden Secret} or {visible Text}
  • Interpolations work: {yellow ${variable}}
  • Unknown styles are ignored silently
  • No nesting of {} blocks within styled text

API Reference

c

A proxy-based color builder. Access properties to accumulate styles, call as a function to apply.

c.red('text')           // Red text
c.red.bold('text')      // Red bold text
c.red.bold.reset('text') // Plain text (reset clears styles)
c.red.bold.underline    // Builder for red bold underline
c.enable().red('text')  // Red text (force enable colors)
c.disable().red('text') // Plain text (force disable colors)

Edge cases:

  • Empty calls return empty string: c() === ''
  • Non-string inputs are coerced: c.red(123) === c.red('123')

strip(input: string): string

Removes all ANSI escape sequences from the input string.

import { strip } from '@microstack-dev/ms-chroma';

strip('\x1b[31mRed\x1b[39m text') // 'Red text'

Edge cases:

  • No ANSI codes: returns input unchanged
  • Malformed sequences: removes valid patterns only

isColorSupported: boolean

Indicates if ANSI colors are supported. True if process.stdout.isTTY is true and process.env.NO_COLOR is not '1'.

When false, all styling returns plain text.

Color Support

Support is detected automatically:

  • Enabled: TTY output and no NO_COLOR env var
  • Disabled: Non-TTY or NO_COLOR='1'

When disabled, methods return unmodified strings. No errors thrown.

You can manually override detection:

  • c.enable() forces color output
  • c.disable() forces plain text output

Design Philosophy

ms-chroma embodies microstack-dev's commitment to minimalism:

  • Small API surface (8 colors, 6 modifiers, 8 backgrounds)
  • Zero dependencies
  • Chainable, typed interface
  • ANSI-only (standard, reliable)
  • Stability prioritized over features

Comparison to Chalk

Compared to Chalk, ms-chroma has narrower scope:

  • No RGB/truecolor support
  • No plugin ecosystem
  • Smaller bundle size
  • Simpler maintenance

Philosophy: ms-chroma chooses depth in ANSI styling over breadth of features.

Performance & Size

  • ANSI escape codes: minimal runtime cost
  • Tree-shakable: unused styles excluded
  • Zero dependencies: no bloat
  • Node.js ≥18 required

License

MIT License. Maintained by microstack-dev.