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

@flex-development/colors

v2.0.0

Published

Style messages in the terminal and browser

Readme

:rainbow: colors

ci github release npm npm downloads install size codecov module type: esm license conventional commits typescript vitest yarn

Style messages in the terminal and browser

Contents

What is this?

This is a small, but useful, library for creating colorful messages in the terminal and browser consoles that support ANSI colors.

Features

  • FORCE_COLOR, NO_COLOR, and NODE_DISABLE_COLORS friendly
  • automatic color support detection
  • no dependencies
  • typescript support

Install

This package is ESM only.

In Node.js with yarn:

yarn add @flex-development/colors

In Deno with esm.sh:

import { colors } from 'https://esm.sh/@flex-development/colors'

In browsers with esm.sh:

<script type="module">
  import { createColors } from 'https://esm.sh/@flex-development/colors'
</script>

With bun:

bun add @flex-development/colors

Use

import c from '@flex-development/colors'

console.log(c.red(c.bold('Hello World!')))

API

This package exports the following identifiers:

The default export is colors.

colors

(Colors) The default colorizer.

createColors([options])

Create a colorizer.

Parameters

  • options (ColorizerOptions | boolean, optional) — boolean indicating if color output should be enabled, or an options object to create a custom colorizer

Returns

(Colors) Colorizer object

isColorSupported()

Check if color output is supported.

Returns

(boolean) true if color output is supported, false otherwise

Types

This package is fully typed with TypeScript.

ColorConfig

List, where the first value is the numeric code for an ANSI escape sequence, and the second is the numeric code for the reset sequence. The last value is an optional replacement for the reset sequence (used in complex cases to nest styles without breaking existing color sequences).

type ColorConfig = [
  open: number,
  close: number,
  replace?: string | null | undefined
]

ColorConfigs

Record, where each key is a Color and each value is the configuration for a color function.

type ColorConfigs = Record<Color, ColorConfig>

ColorFunction

Colorize value (TypeScript interface).

Parameters

  • value (unknown) — the thing to colorize

Properties

  • close (string) — the reset sequence
  • open (string) — the sequence used to set styles
  • replace (string, optional) — the reset sequence replacement

Returns

(string) Colorized string value

ColorFunctions

Registry of color functions (TypeScript interface).

Color

Union of color names.

type Color = keyof ColorFunctions

To register custom colors, augment ColorFunctions. They will be added to this union automatically.

declare module '@flex-development/colors' {
 interface ColorFunctions {
   blink: ColorFunction
 }
}

ColorizerOptions

Options for creating a colorizer (TypeScript interface).

Properties

  • color (boolean, optional) — whether color output should be enabled
  • colors (Partial<ColorConfigs>, optional) — record, where each key is a the name of a color or style and each value is the configuration for that color or style

Colors

also exported as Colorizer

A colorizer (TypeScript interface).

Colorizers contain Color functions. Each function corresponds to a terminal color or style. The color property is an accessor that can be used to disable or enable color output.

Extends

Properties

  • get color(): boolean — color output enabled?
  • set color(color: boolean | null | undefined)
    • enable or disable color output
      👉 note: color output will be disabled if not supported
  • styles (ColorConfigs) — record, where each key is the name of a color or style and each value is the configuration for a color function (readonly)
  • supported (boolean) — whether color output is supported (readonly)

Contribute

See CONTRIBUTING.md.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.