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

lighter-colors

v1.0.0

Published

A lightweight JavaScript terminal color utility.

Downloads

24

Readme

lighter-colors

Chat Version Downloads Build Coverage Style

The lighter-colors module is a lightweight terminal color utility.

Installation

From your project directory, install and save as a dependency:

npm install --save lighter-colors

Usage

Upon requiring lighter-colors, the String prototype is modified so that all strings have access to color properties which output color versions of themselves:

require('lighter-colors')

console.log('Error'.red)
console.log('Warning'.yellow)
console.log('Confirmation'.green)

If you would like to disable color, you can use a --no-color argument, use the disable method:

var colors = require('lighter-colors')

colors.disable()
console.log('This will be colorless.'.magenta)

colors.enable()
console.log('This will become magenta.'.magenta)

Here's the full list of exported colors:

{
  reset: '\u001b[0m',
  base: '\u001b[39m',
  bgBase: '\u001b[49m',
  bold: '\u001b[1m',
  normal: '\u001b[2m',
  italic: '\u001b[3m',
  underline: '\u001b[4m',
  inverse: '\u001b[7m',
  hidden: '\u001b[8m',
  strike: '\u001b[9m',
  black: '\u001b[30m',
  red: '\u001b[31m',
  green: '\u001b[32m',
  yellow: '\u001b[33m',
  blue: '\u001b[34m',
  magenta: '\u001b[35m',
  cyan: '\u001b[36m',
  white: '\u001b[37m',
  gray: '\u001b[90m',
  bgBlack: '\u001b[40m',
  bgRed: '\u001b[41m',
  bgGreen: '\u001b[42m',
  bgYellow: '\u001b[43m',
  bgBlue: '\u001b[44m',
  bgMagenta: '\u001b[45m',
  bgCyan: '\u001b[46m',
  bgWhite: '\u001b[47m'
}

In addition to the getter properties for the colors in the list above, there's also a plain getter property which removes colors from a colorful string:

require('lighter-colors')

var colorful = 'Blue'.blue
var colorless = colorful.plain

And if you would like to use the color sequences without invoking getter properties, lighter-colors exports them for you:

var colors = require('lighter-colors')
var red = colors.red
var white = colors.white
var blue = colors.blue
var base = colors.base
console.log(red + 'Red' + white + 'White' + blue + 'Blue' + base)

More on lighter-colors...