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

@v3rse/chroma

v1.1.0

Published

Colors for your terminal app

Downloads

4

Readme

Chroma: Colors for your terminal app

Intro

Screenshot

Why?

I started writing more and more Node apps for the terminal and guess what? I liked them in color. So I decided I'd write a module to add colors to text for stuff that's printed to stdout

Yh I know there are other color packages....but this is just MINE!!

Install

npm install --save @v3rse/chroma

Design and Usage

It can be used in the following ways:

chroma.<color>(string);
chroma.<format>(string);
chroma.<format>.<color|bgcolor>(string);

Styles

Colors

  • normal (default color)
  • black
  • red
  • blue
  • green
  • yellow
  • magenta
  • cyan
  • lgray (light gray)
  • dgray (dark gray)
  • lred
  • lblue
  • lgreen
  • lyellow
  • lmagenta
  • lcyan
  • white

Background Colours

  • bgblack
  • bgred
  • bggreen
  • bgyellow
  • bgblue
  • bgmagenta
  • bgcyan
  • bgwhite

Formats

  • underline
  • bold
  • dim
  • italics(not supported on all terminal emulators)
  • strikethrough (not supported on all terminal emulators)

To use, it copy it into your project and do:

var chroma = require('@v3rse/chroma');

Test

node test.js

Some reading

Terminal code (ANSI/VT100) introduction

Long list of codes

  • Terminal codes help you issue commands to your terminal itself.
  • If the codes are understood they won't be printed but instead cause the terminal to perform an action
  • Action may include changing text color or moving the cursor.
  • You can use echo to test these codes manually.
  • Escape characters are prefixed with 0x1B or 033 in octal form. This is written as \x1b when using echo.
  • The code then follows the prefix ( \x1b[2m ) which is followed by whatever text stream.
echo "a\x1b[2mb\x1b[0m"

Tput

  • Due to varying terminal control languages you may use a tool like tput as an intermediary to the terminal.
  • It detects the terminal and generates necessary escape codes by looking them up the terminfo database.
  • It uses acronyms called capability names and parameters to do this.
echo "a$(tput dim)b$(tput sgr0)"

Color codes

  • Basic foreground colors start from 30m to 39m
  • Basic background colors start from 40m to 49m
  • Reset is 0m and tells the terminal where to stop the effects of the previous code. NB: getting more colors depends on your terminal type.

Text formatting

  • Underline is 4m and 24m for unsetting.
  • Bold is 1m
  • Emphasis ("Italics") is 3m
  • Dim is 2m

TODO

  • [x] Make it work more like chroma.underline.red("Hello Word"); (Thanks to @oddoye-david )
  • [x] Make an npm module.
  • [x] Add background color feature.(Thanks to @oddoye-david )