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

colorts

v0.1.63

Published

Colors in node Js console

Downloads

4,196

Readme

Colors.ts Build Status

Get colors and style in your node.js console

Installation

npm install colorts

colors and styles!

text colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • grey

background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite

styles

  • reset
  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough

Usage methods

1. TypeScript

i. Normal String extension.
import 'colorts/lib/string';

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
ii. Direct color method
import color from 'colorts';
import {echo} from 'colorts';

console.log(colors('hello').green + "");                           // outputs green text
console.log(colors('i like cake and pies').red.underline.toString) // outputs red underlined text
echo(colors('inverse the color').inverse);                         // you can use echo to console.log safe colorts

2. JavaScript

i. Normal String extension.
require('colorts/lib/string');

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
ii. Direct color method
let color = require('colorts');
let echo = require('colorts').echo;

console.log(colors('hello').green + "");                           // outputs green text
console.log(colors('i like cake and pies').red.underline.toString) // outputs red underlined text
echo(colors('inverse the color').inverse);                         // you can use echo to console.log safe colorts

I prefer the first way. Some people seem to be afraid of extending String.prototype and prefer the second way.

If you are writing good code you will never have an issue with the first approach. If you really don't want to touch String.prototype, the second usage will not touch String native object.

Disabling Colors

To disable colors you can pass the following arguments in the command line to your application:

node myapp.js --no-color

Bonus String Letter case Methods

  • capitalize
    "james is a nice guy.".capitalize // James is nice guy.
    " no one home.".capitalize       //  No one home.
    "typescript".capitalize         // Typescript
    "1st january 2018".capitalize  // 1st january 2018
  • titleCase
    "james is a nice guy.".titleCase // James Is Nice Guy.
    " no one home.".titleCase       //  No One Home.
    "tYpe scrIpt".titleCase        // Type Script
    "1st january".titleCase       // 1st January 2018
  • camelCase
    "james is a nice guy.".camelCase // jamesIsANiceGuy.
    " no one home.".camelCase       //  nOneHome.
    "type script".camelCase        // typeScript
  • upperCamelCase
    "james is a nice guy.".upperCamelCase // JamesIsANiceGuy.
    " no one home.".upperCamelCase       //  NOneHome.
    "type script".upperCamelCase        // TypeScript
  • lowerCamelCase
    "james is a nice guy.".lowerCamelCase // jamesIsANiceGuy.
    " no one home.".lowerCamelCase       //  nOneHome.
    "type script".lowerCamelCase        // typeScript
  • snakeCase
    "james is a nice guy.".snakeCase // james_is_nice_guy.
    " no one home.".snakeCase //  no_one_home.
    "super type script".snakeCase  // super_type_script
  • kebabCase
    "James is a nice guy.".kebabCase // james-is-nice-guy.
    " no one home.".kebabCase //  no-one-home.
    "super type script".kebabCase  // super-type-script
  • studlyCaps
    "james is a nice guy.".studlyCaps // JaMeSiSnIcEgUy.
    " no one home.".studlyCaps //  NoOnEhOmE.
    "super type script".studlyCaps  // SuPeRtYpEsCrIpT