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 🙏

© 2024 – Pkg Stats / Ryan Hefner

easy-console-color

v1.0.0

Published

Easily add color and style to console output in both web and shell environments using intuitive placeholders.

Downloads

64

Readme

easy-console-color

Easily add colors and styles to your console.log output with simple placeholders. easy-console-color translates readable, placeholder-based syntax into ANSI color codes, making your console output both eye-catching and easy to customize.

Console Colorize Basic Example

Features

  • Works seamlessly in both web and shell environments.
  • Simple placeholders for text color, background color, and text styles.
  • No complex ANSI codes — just intuitive placeholders.
  • Lightweight and fast, with seamless integration.

Installation

Install easy-console-color:

  npm install easy-console-color
  yarn add easy-console-color

Usage

easy-console-color works with console.log(), console.error(), console.warn(), and console.info() to easily colorize and style your console outputs. Simply add placeholders within the console message string to apply colors and effects.

Basic Example

import "easy-console-color";

console.log("$(bright)Hello, $(fgCyan)world$(reset)! $(fgYellow)Colorful$(reset) console output made easy.");

Code Output

Console Colorize Basic Example

This example demonstrates how easy-console-color interprets placeholders, applying the specified colors and styles to your message. Here’s what each placeholder does:

  • bright: Brightens or bolds the text.
  • fgCyan: Changes text color to cyan.
  • fgYellow: Changes text color to yellow.
  • reset: Resets all styles.

Available Colors and Styles

Foreground Text Colors

bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite

Background Colors

bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite

Text Styles

  • bright: Makes text bright or bold.
  • dim: Dims the text brightness.
  • underscore: Underlines the text.
  • blink: Makes text blink (may not work in all terminals**.
  • reverse: Reverses the foreground and background colors.
  • hidden: Hides the text.
  • reset: Resets all styles and colors.

Realistic Examples

Here are some more complex and realistic examples to see easy-console-color in action:

Example 1: Styled Warning Message

console.log("$(bright)$(fgRed)Warning:$(reset) $(fgYellow)Disk space is running low!$(reset)");

Code Output

Console Colorize Example 1

Example 2: Success Message with Background

console.log("$(bright)$(fgWhite)$(bgGreen) SUCCESS $(reset) $(fgGreen)Operation completed successfully!$(reset)");

Code Output

Console Colorize Example 2

Example 3: Error Message with Reverse Style

console.log("$(reverse)$(fgRed) ERROR $(reset) $(bright)$(fgRed)File not found!$(reset)");

Code Output

Console Colorize Example 3

Example 4: Information Message with Multiple Styles

console.log("$(fgBlue)INFO:$(reset) $(dim)$(fgCyan)Connecting to the database...$(reset)");

Code Output

Console Colorize Example 4

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! If you have any suggestions or find any issues, feel free to open an issue or submit a pull request on GitHub.

Author

Created by Abdullah Dalgıç.

Acknowledgements

Special thanks to all the contributors and open-source projects that made this package possible.