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

print-colors

v1.0.1

Published

Print colors to the console with nice and easy to use syntax

Downloads

2,846

Readme

print-colors

print-colors is a very lightweight library for printing colors to the console using a nice and easy to use syntax.

Import the module to your project:

const c = require('print-colors');

To print to your console some "How to use" examples you can use the example(), docs() or help() functions available with the library to print some example to the console.

const c = require('print-colors');

c.example();

In order to affect the color of the text printed to the console with the built in console.log() function, you need to follow the following template:

console.log(c.(background or foreground).(light or dark).(color) + 'Some Text' + c.end);

Examples:

const c = require('print-colors');

console.log(c.foreground.light.red + 'This text will be printed in light red color' + c.end);

console.log(c.foreground.dark.green + 'This text will be printed in dark green color' + c.end);

console.log(c.background.dark.blue + 'This text will be printed with dark blue background color' + c.end);

You can also have combinations of background and foreground colors like so:

console.log(c.background.light.yellow + c.foreground.dark.blue + 'This text will be blue with yellow background color' + c.end);

You can use this set of shortcuts for having a better syntax:

  • bg = background
  • fg = foreground
  • l = light
  • d = dark
  • e = end

So in practice, the above examples can be shortted as follow:

console.log(c.fg.l.red + 'This text will be printed in light red color' + c.e);

console.log(c.fg.d.green + 'This text will be printed in dark green color' + c.e);

console.log(c.bg.d.blue + 'This text will be printed with dark blue background color' + c.e);

console.log(c.bg.l.yellow + c.fg.d.blue + 'This text will be blue with yellow background color' + c.e);

Supported colors:

  • gray
  • red
  • green
  • yellow
  • blue
  • pink
  • cyan
  • white

Note

The following library was tested with Windows CMD.exe. Colors might look different from one console to another since the console colors are many time can be configured by the user...