color-properties
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

color-properties

Extends the String prototype with color and text decoration attributes, allowing for easy styling of console output using ANSI escape codes.

Installation

npm install color-properties

Usage

First, import the colorize function:

const { colorize } = require('color-properties');

Next, run the colorize function to extend the String prototype with color and decoration properties:

colorize();

Alternatively you can also extend the string directly:

require('color-properties/colorize');

Now, you can use the color and decoration properties directly on string instances. Here's an example:

console.log('Hello World!'.green.bright); // prints "Hello World!" in green and bold style

Styles

The following styles are avainable:

  • reset
  • bright
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough
  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgGray

Refer to the example for combining multiple properties.

License

MIT

Package Sidebar

Install

npm i color-properties

Weekly Downloads

4

Version

0.0.3

License

MIT

Unpacked Size

5.25 kB

Total Files

7

Last publish

Collaborators

  • mrozio