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

chroma-palette

v1.2.2

Published

A light-weight utility for coloring your terminal. 0 dependencies. Default is a preselected color output from the 256 color palette, chosen to enhance legibility.

Downloads

49

Readme

Chroma-Palette

A light-weight utility for coloring your terminal. 0 dependencies. Default is a preselected color output from the 256 color palette, chosen to enhance legibility.

Features:

  • Chainable using the push() method without having to call chromaPalette more than once.
  • 0 dependencies.
  • Has internal function to print all 256 color options.
  • Fully customizable.
  • Has internal properties to provide easier formatting.
  • Has examples. Run node <path to node_modules>/chroma-palette/examples/<example>

Table of Contents

  1. Install
  2. Usage
  3. Properties
  4. Methods

Install

npm i chroma-palette 

Usage

Default (256-Color Set):

Default is a preselected color output from the 256 color palette, chosen to enhance legibility.

const chromaPalette = require('chroma-palette')

// chaining content with push()
console.log(
  chromaPalette
    .cyan.push('Hello')
    .space.magenta.paint('World!') // here space adds a literal space to elements
);
// chaining
console.log(
  chromaPalette
    .blue.whiteBg.bold.paint('Hello World!')
);
// combine
console.log(
  chromaPalette.blue.paint('Hello ') + chromaPalette.bold.paint('World') + '!'
);
// template literal
console.log(
  `${chromaPalette.blue.paint('Hello')} ${chromaPalette.bold.paint('World')}!`
);

16-Color Set Support:

If you need to alter the output of the colors to support the 16-color set.

const { ChromaPalette } = require('chroma-palette')
// change profile to 16
const chromaPalette = new ChromaPalette({ profile:'16' })

// output will be the cyan from the 16-color palette
console.log(
  chromaPalette
    .cyan.paint('Hello World!')
);

Custom-Color Set Support:

If you want to change the output of various colors.

const { ChromaPalette } = require('chroma-palette')
// change any color by { [COLOR]:'[NUMBER FROM 256]' }
const chromaPalette = new ChromaPalette({ red:'196' })

// output will be the custom red chosen
console.log(
  chromaPalette
    .red.paint('Hello World!')
);

View the 256 Color Palette:

Helpful when choosing custom colors.

const chromaPalette = require('chroma-palette')

// output the 256-color palette
console.log(
  chromaPalette
    .palette.paint()
);

Properties

Formatters:

  • space - Will output a space after calling paint().
  • enter - Will output a return character after calling paint().

Modifiers:

  • dim - Small amount of light.
  • underscore - Underline text.
  • blink - Blink.
  • reverse- Reverse.
  • hidden - Hides text.
  • bold - Bold text.

Color:

  • blue - Blue text.
  • cyan - Cyan text.
  • purple - Purple text.
  • magenta - Magenta text.
  • red - Red text.
  • orange - Orange text.
  • yellow - Yellow text.
  • green - Green text.
  • white - White text.
  • black - Black text.
  • blueBg - Blue background.
  • cyanBg - Cyan background.
  • purpleBg - Purple background.
  • magentaBg - Magenta background.
  • redBg - Red background.
  • orangeBg - Orange background.
  • yellowBg - Yellow background.
  • greenBg - Green background.
  • whiteBg - White background.
  • blackBg - Black background.

Methods

Functions:

  • push(string) - Pushes the string to the elements and resets colors | modifiers. Makes chromaPalette chainable without having to call chromaPalette multiple times.
  • paint(string) - Outputs the created string. Must be called after everything else to return the string.