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

colour

v0.7.1

Published

A cored, fixed, documented and optimized version of the popular `colors.js`: Get colors in your node.js console like what...

Downloads

903,503

Readme

colour.js - ANSI terminal colors

A cored, fixed, documented and optimized version of the popular colors.js. Can be used as a drop-in replacement, also works correctly in the browser, provides a CSS mode and has been compiled through Closure Compiler using advanced optimizations. Additionally, nearly every issue and pull request on the original has been incorporated.

Installation

npm install colour

Usage

This package extends the global String prototype with additional getters that apply terminal colors to your texts. Available styles are:

  • Emphasis: bold, italic, underline, inverse
  • Colors: yellow, cyan, white, magenta, green, red, grey, blue
  • Sequencers: rainbow, zebra, random

Example

var colour = require('colour');
console.log('hello'.green); // outputs green text
console.log('i like cake and pies'.underline.red) // outputs red underlined text
console.log('inverse the color'.inverse); // inverses the color
console.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)

Or: As a drop-in replacement for colors

var /* just name it */ colors = require('colour');
...

Custom themes

Its also possible to define your own themes by creating new getters on the String object. Example:

var colour = require('colour');
colour.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'cyan',
  warn: ['yellow', 'underline'], // Applies two styles at once
  debug: 'blue',
  error: 'red bold' // Again, two styles
});

console.log("this is an error".error); // outputs bold red text
console.log("this is a warning".warn); // outputs underlined yellow text

console.log(colour.green("this is green")); // Alternatively

Console, browser and browser-css mode

var colour = require('colour');
...
colour.mode = 'none'; // No colors at all
colour.mode = 'console'; // Adds terminal colors (default on node.js)
colour.mode = 'browser'; // Adds HTML colors (default in browsers)
colour.mode = 'browser-css'; // Adds special CSS (see examples/example.css)

Uninstalling / reinstalling on the global scope

If you have a reason to use a fresh String prototype in your application, you may also revert all extensions made.

var colour = require('colour');
...
colour.uninstall(); // Removes all custom properties from the String prototype
...
colour.install(); // Re-installs them
...

More features

  • node.js/CommonJS compatible
  • RequireJS/AMD compatible
  • Browser/shim compatible
  • Closure Compiler externs included
  • Zero dependencies

Credits

Based on work started by Marak (Marak Squires), cloudhead (Alexis Sellier), mmalecki (Maciej Małecki), nicoreed (Nico Reed), morganrallen (Morgan Allen), JustinCampbell (Justin Campbell) and ded (Dustin Diaz).

License

The MIT-License (MIT)