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

node-colorify

v2.0.1

Published

Node library to print colored texts in terminal.

Downloads

161

Readme

node-colorify

Build Status NPM Version NPM Downloads

(color & style texts in console)

A node library for printing colored and styled texts in terminal. Uses ANSI color and style codes to format the color and style printed on console. node-colorify is easy to use and supports additional text formatting.

Install

$ npm install node-colorify

Require as follows:

var color = require('node-colorify');

Usage Example

var color = require('node-colorify');

//colorIt - Synchronously
console.log(color.colorItSync('Hello World', {'fColor': 'green'}));
console.log(color.colorItSync('Hello World', {'bColor': 'green', 'fColor': 'red'}));

//colorIt - Asynchronously
color.colorIt('Hello World', {'fColor': 'green'}, function(coloredText) {
                console.log(coloredText);
            });
color.colorIt('Hello World', {'bColor': 'green', 'fColor': 'red'}, function(coloredText) {
    console.log(coloredText);
            });
            
//styleIt - Synchronously
console.log(color.styleItSync('hello', ['bold']));
console.log(color.styleItSync('hello', ['bold', 'blink', 'inverse']));

//styleIt - Asynchronously
color.styleIt('Hello World', ['bold'], function(coloredText) {
                console.log(coloredText);
            });
color.styleIt('Hello World', ['bold', 'blink', 'inverse'], function(coloredText) {
    console.log(coloredText);
            });

Output

alt text

API Documentation

colorIt(text, color, callback) - Asynchronous

This function will return the ANSI formatted string of given color asynchronously.

color

Color format can be specified as follows

bColor - Background Color

fColor - Foreground Color

Foreground alone:
{ 'fColor': 'black'}
Background alone:
{ 'bColor': 'red'}
Mixed format:
{ 'fColor': 'black', 'bColor': 'red'}

Supported list of colors:

1. BLACK (DEFAULT)
2. RED
3. GREEN
4. YELLOW
5. BLUE
6. MAGENTA
7. CYAN
8. WHITE

colorItSync(text, color) - Synchronous

Same as that of colorit functionality, returns the ANSI formatted string of given color synchronously.

styleIt(text, styles, callback) - Asynchronous

This function will return the ANSI formatted string of given style asynchronously.

styles

Style can be specified as follows

Single style
["bold"]
Multiple styles
["bold", "blink", "inverse"]

Supported list of styles:

1. BOLD
2. LIGHT
3. ULINE (UNDERLINE)
4. BLINK
5. INVERSE
6. HIDE

styleItSync(text, styles) - Synchronous

Same as that of styleIt functionality, returns the ANSI style formatted string of given style synchronously.

Releases

v1.0.0 - Initial Release. Function to print color text.
v1.0.1 - Bug Fixes
v2.0.0 - Added styling functionality and background color.

Thanks for checking out this library. Feel free to create issues regarding bugs or features and contribute to the project by forking dev branch and submitting a pull request.

Fork it before you Spoon it.

Contributors:

raghu