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

@s-a/digital-colors

v1.1.0

Published

colorize stdin

Readme

Digital Colors (dc)

dc is a command-line utility that enhances terminal output by adding colorization. It's designed to highlight common data formats like XML and JSON, as well as patterns such as log levels and timestamps.

You can use dc in two main ways:

  1. As a command wrapper: dc your_command [args...]
    • dc executes your_command and colorizes its standard output.
  2. As a pipe processor: your_command | dc
    • dc reads data from standard input (stdin), colorizes it, and prints it to standard output (stdout).

Installation

npm i -g @s-a/digital-colors

Usage Modes

Mode 1: Executing a Command and Colorizing its Output

(dc your_command [args...])

When you provide dc with a command to run, it executes that command, captures its standard output, and applies colorization before printing it to your terminal.

Key Characteristics:

  • The first argument after dc is the command to be executed (e.g., tail, ls, cat).
  • Any subsequent arguments are passed directly to that command.
  • This mode is ideal for colorizing the output of commands directly, including long-running processes like tail -f.

Examples:

  • Live Log Monitoring (most common use case): To monitor a log file with tail -f and have its output colorized:

    dc tail -f /path/to/your/logfile.log

    (For Windows, use appropriate paths like D:\\log\\api.log)

  • Colorizing Output of Short-Lived Commands:

    dc ls -la
    dc cat /etc/hosts

Mode 2: Processing Piped Input from Another Command

(your_command | dc)

dc can also process data piped to its standard input. This allows you to colorize the output of any command that writes to stdout.

Key Characteristics:

  • dc reads data line by line (or in chunks) from stdin.
  • It applies colorization to the received data.
  • The colorized data is then printed to stdout.
  • This mode is useful when you want to take the output of an existing command and pass it through dc for colorization.

Examples:

  • Colorizing the output of cat:
    cat myapplication.log | dc
  • Colorizing the output of grep:
    grep "ERROR" system.log | dc
  • Colorizing a JSON string from echo:
    echo '{"name": "example", "value": 123}' | dc

Understanding dc Behavior in Pipes

It's important to understand how dc behaves when used in command pipelines to avoid confusion:

  1. dc your_command [args...] | another_command (Piping from dc when dc wraps a command):

    • dc first executes your_command and colorizes its output.
    • This colorized output (including ANSI escape codes) is then piped to another_command.
    • Example: dc tail -f my.log | grep "ERROR" will pass colorized lines to grep. This might be useful if another_command can handle ANSI codes (like less -R), but often grep would be better used before dc if you want to filter first, then colorize (see Mode 2).
  2. dc | another_command (Piping from dc when dc has no command to run):

    • If dc is used as the first command in a pipeline without being given its own command to execute (e.g., dc | grep foo), it defaults to Mode 2 behavior: it will read from its standard input.
    • If stdin is your terminal, dc will wait for you to type something. What you type will be colorized and then passed to another_command.
    • This is why dc | tail -f /path/to/logfile.log does not work as expected for live log monitoring. In this case, dc waits for stdin, and tail -f would attempt to process whatever (if anything) dc outputs, rather than dc processing tail -f's file monitoring output.
    • Correct for live log monitoring: dc tail -f /path/to/logfile.log (Mode 1).
  3. your_command | dc | another_command (Piping through dc):

    • your_command sends its output to dc.
    • dc colorizes this output (Mode 2).
    • The colorized output from dc is then piped to another_command.
    • Example: cat my.log | dc | grep "ERROR" (again, grep will operate on colorized text).

General Tip for Piping: If you want to filter or process text before colorization, do it before piping to dc (e.g., grep "ERROR" my.log | dc). If you want to filter or process the colorized text, pipe from dc (e.g., dc tail -f my.log | less -R).