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

@jacob-z/chalk

v3.0.3

Published

Browser console coloring utilities compatible with alita/chalk behavior.

Readme

@jacob-z/chalk

Browser console coloring utilities — a modular, type-safe rewrite of @alita/chalk, themed with Catppuccin Macchiato.

Features

  • %c CSS tuple formatters for browser DevTools console output
  • 9 foreground colors: black, red, green, yellow, blue, magenta, cyan, white, gray
  • 8 background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
  • Mode switching (foreground / background) controls logger output style globally
  • bold() text formatting
  • add() for merging multiple formatted tuples
  • Logger methods: log, wait, error, warn, ready, info, event, debug
  • hello(title, version) version banner
  • image(url) console image
  • createChalk(options?) factory for dependency injection
  • Zero runtime dependencies, fully tree-shakeable

Install

pnpm add @jacob-z/chalk

Basic Usage

Color formatters return console.log-ready tuples:

import chalk from '@jacob-z/chalk'

chalk.red('text')
// → ['%ctext', 'color:#ed8796']

chalk.bgRed('text')
// → ['%ctext', 'padding: 2px 4px; border-radius: 3px; color: #24273a; font-weight: bold; background:#ed8796;']

chalk.bold('text')
// → ['%ctext', 'font-weight: bold;']

chalk.add(chalk.red('a'), chalk.blue('b'))
// → [' %ca %cb', 'color:#ed8796', 'color:#8aadf4']

Use with console.log spread:

console.log(...chalk.red('colored text'))
console.log(...chalk.add(chalk.red('error:'), chalk.bold(' not found')))

Foreground vs Background Methods

  • Foreground (red, green, blue, …) — pure color:<hex>, no background or padding
  • Background (bgRed, bgGreen, bgBlue, …) — background:<hex>; color:#24273a; font-weight: bold; padding: 2px 4px; border-radius: 3px;
  • bgBlack special case — dark base background with blue text #8aadf4

These are fixed regardless of the mode setting. Mode only affects logger output.

Mode Switching

createChalk({ mode }) controls how logger methods render. Default is 'background'.

import { createChalk } from '@jacob-z/chalk'

const bgChalk = createChalk({ console, mode: 'background' })
const fgChalk = createChalk({ console, mode: 'foreground' })

// background mode: label + message share same styled background
bgChalk.info('loaded')
// → %c[Info]%c loaded   (both segments use background style)

// foreground mode: label + message share same foreground color
fgChalk.info('loaded')
// → %c[Info]%c loaded   (both segments use color:<hex> only)

Logger label and message body use the same style — no separate styling for the tag vs the content.

Logger Methods

| Method | Label | Color | Console Method | | ------- | -------- | ------- | --------------- | | log | [Log] | black | console.log | | wait | [Wait] | cyan | console.log | | error | [Error]| red | console.error | | warn | [Warn] | yellow | console.warn | | ready | [Ready]| green | console.log | | info | [Info] | blue | console.info | | event | [Event]| magenta | console.log | | debug | [Debug]| gray | console.debug |

If a console method is unavailable, the logger falls back to console.log.

Custom Log Levels

Extend the logger with additional methods using built-in color names:

const chalk = createChalk({
  logLevels: [
    { name: 'trace', label: 'Trace', color: 'blue', method: 'debug' },
  ],
})

chalk.trace('details') // → [Trace] in blue via console.debug

color must be a built-in ColorName: black, red, green, yellow, blue, magenta, cyan, white, gray.

Banner & Image

chalk.hello('MyApp', '1.0.0') // styled title + version banner
chalk.image('https://example.com/logo.png') // console CSS background image

API

createChalk(options?)

| Option | Type | Default | Description | | ------------ | --------------------------- | ------------------------------- | ------------------------------------- | | console | Console | globalThis.console | Console instance for output | | mode | 'foreground' \| 'background' | 'background' | Logger output style | | logLevels | LogLevelDefinition[] | (built-in 8 levels) | Custom logger level definitions |

getStyle(colors, name, mode)

Low-level utility to get CSS style string for a given color name and mode:

import { getStyle, DEFAULT_COLORS } from '@jacob-z/chalk'

getStyle(DEFAULT_COLORS, 'red', 'foreground')
// → 'color:#ed8796'

getStyle(DEFAULT_COLORS, 'red', 'background')
// → 'padding: 2px 4px; border-radius: 3px; color: #24273a; font-weight: bold; background:#ed8796;'

Architecture

src/
  types.ts    → All public & internal types (ChalkMode, ColorName, LogLevelDefinition)
  colors.ts   → Macchiato palette, getStyle() (pure functions)
  format.ts   → %c format helpers, add(), bold(), coloredText()
  logger.ts   → Debug-gated logger factory (mode-aware)
  banner.ts   → hello(), image()
  create.ts   → createChalk() factory
  index.ts    → Default instance + re-exports

Design principles vs the original @alita/chalk:

  • No window dependency — uses globalThis with fallback
  • No global cache — no window.chalk mutation
  • No module-level side effects — factory pattern, pure functions
  • No any / @ts-ignore — strict TypeScript throughout
  • Mode-driven styling — single mode option controls all logger output
  • Dark-mode friendly — Catppuccin Macchiato palette with proper contrast

License

MIT