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

eight-colors

v1.3.3

Published

Eight colors for the console

Readme

Eight Colors

A tiny ANSI color helper for terminal output.

Install

npm i eight-colors

Features

  • Eight basic colors: black, red, green, yellow, blue, magenta, cyan, white
  • Background colors via EC.bg.*
  • Bright colors via EC.br.*
  • Bright background colors via EC.br.bg.*
  • Text styles: reset, bold, faint, italic, underline, inverse, hidden, strike
  • Remove ANSI escape sequences with EC.remove()
  • Colored logging helpers such as EC.logRed()
  • CJS, ESM, TypeScript types, and browser bundle
  • Supports NO_COLOR, FORCE_COLOR, --no-color, and --color
  • Zero dependencies

Quick Start

CommonJS

const EC = require('eight-colors');

console.log(EC.red('red string'));
console.log(EC.bg.red('red background'));
console.log(EC.br.red('bright red string'));
console.log(EC.br.bg.red('bright red background'));
console.log(EC.italic('italic text'));
console.log(EC.underline('underline text'));
console.log(EC.green(EC.underline('green underline text')));

ESM

import EC from 'eight-colors';

console.log(EC.red('red string'));
console.log(EC.br.bg.red('bright red background'));

More Examples

// remove ANSI escape sequences
const redString = EC.red('red string');
const plainString = EC.remove(redString);
console.assert(plainString === 'red string');

// color log helpers: print and return the colored string
const logged = EC.logRed('string1', 'string2');
console.assert(EC.remove(logged) === 'string1 string2');

EC.logRed('log red');
EC.logGreen('log green');
EC.logYellow('log yellow');
EC.logCyan('log cyan');
EC.logWhite('log white');

// log with multiple arguments
EC.log('log 2 arguments', EC.red('2'));
EC.logGreen('logGreen 2 arguments', '2');
EC.logMagenta('logMagenta 3 arguments', EC.red('2'), '3');

Color Control

EC.disabled controls whether ANSI escape sequences are added at runtime:

EC.disabled = true;   // all color functions return plain strings
EC.disabled = false;  // back to normal

On module initialization, eight-colors also reads environment variables and CLI flags:

  • NO_COLOR or --no-color: disable colors
  • FORCE_COLOR or --color: enable colors
  • If both disabled and forced options are present, disabled takes precedence

The environment check is based on key presence, not on a specific value.

API

Text colors:

EC.black(str)
EC.red(str)
EC.green(str)
EC.yellow(str)
EC.blue(str)
EC.magenta(str)
EC.cyan(str)
EC.white(str)

Background colors:

EC.bg.black(str)
EC.bg.red(str)
EC.bg.green(str)
EC.bg.yellow(str)
EC.bg.blue(str)
EC.bg.magenta(str)
EC.bg.cyan(str)
EC.bg.white(str)

Bright colors:

EC.br.black(str)
EC.br.red(str)
EC.br.green(str)
EC.br.yellow(str)
EC.br.blue(str)
EC.br.magenta(str)
EC.br.cyan(str)
EC.br.white(str)

Bright background colors:

EC.br.bg.black(str)
EC.br.bg.red(str)
EC.br.bg.green(str)
EC.br.bg.yellow(str)
EC.br.bg.blue(str)
EC.br.bg.magenta(str)
EC.br.bg.cyan(str)
EC.br.bg.white(str)

Styles:

EC.reset(str)
EC.bold(str)
EC.faint(str)
EC.italic(str)
EC.underline(str)
EC.inverse(str)
EC.hidden(str)
EC.strike(str)

Helpers:

EC.remove(str)
EC.log(...args)

EC.logBlack(...args)
EC.logRed(...args)
EC.logGreen(...args)
EC.logYellow(...args)
EC.logBlue(...args)
EC.logMagenta(...args)
EC.logCyan(...args)
EC.logWhite(...args)

Property:

EC.disabled  // boolean, default: false

Notes:

  • EC.log() joins multiple arguments with spaces before printing (no return value)
  • EC.logRed(...args) and other color log methods print the result and also return the colored string
  • Color log methods remove existing ANSI sequences from arguments before applying the new color

Browser

The package also provides a UMD bundle in dist/eight-colors.js.

<script src="path-to/eight-colors/dist/eight-colors.js"></script>
<script>
    const EC = window['eight-colors'];
    console.log(EC.red('red string'));
</script>

Note: Most browser consoles do not render ANSI escape sequences as colors (Firefox DevTools ignores them entirely; Chrome has limited support). The browser bundle is mainly useful when you want the same API shape across environments or need EC.remove() to strip ANSI sequences.

Links

  • https://en.wikipedia.org/wiki/ANSI_escape_code
  • https://handwiki.org/wiki/ANSI_escape_code