meo-forkcy-colors

1.0.9 • Public • Published

meo-forkcy-colors.js

🧪 A custom fork of colors by Marak Squires, maintained by meo-forkcy for educational and non-commercial use.

npm version

📍 Check out the ROADMAP for upcoming features. 💬 Feel free to open issues for feedback or contribute via the develop branch.


📦 Installation

npm i meo-forkcy-colors

🎨 Features

✅ Text Colors

black, red, green, yellow, blue, magenta, cyan, white, gray/grey
orange, lightOrange, lightYellow, lime, teal, skyBlue, lightBlue, pink, purple, lightGray

🌟 Bright Text Colors

brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite

🎨 Background Colors

bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray/bgGrey

💡 Bright Background Colors

bgBrightRed, bgBrightGreen, bgBrightYellow, bgBrightBlue, bgBrightMagenta, bgBrightCyan, bgBrightWhite

✨ Styles

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

🌈 Extras

rainbow, zebra, america, trap, random, gradient

🚀 Usage

1. Extend String.prototype

const colors = require('colors');

console.log('hello'.green);
console.log('i like cake'.underline.red);
console.log('inverse'.inverse);
console.log('OMG Rainbows!'.rainbow);
console.log('Trap music!'.trap);

2. Safe Mode (no prototype pollution)

const colors = require('colors/safe');

console.log(colors.green('hello'));
console.log(colors.red.underline('i like cake'));
console.log(colors.inverse('inverse'));
console.log(colors.rainbow('OMG Rainbows!'));
console.log(colors.trap('Trap music!'));

🔧 Enable/Disable Colors

CLI Flags

node app.js --no-color
node app.js --color=false
node app.js --color
node app.js --color=always

# or using environment variable
FORCE_COLOR=1 node app.js

In Code

colors.enable();
colors.disable();

📜 String Substitution

const name = 'Marak';
console.log(colors.green('Hello %s'), name);
// -> Hello Marak

🎯 Custom Themes

Standard API

colors.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'cyan',
  warn: 'yellow',
  debug: 'blue',
  error: 'red',
  link: 'grey',
  love: 'pink'
});

console.log('this is an error'.error);
console.log('this is a warning'.warn);

Safe API

const colors = require('colors/safe');

colors.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'cyan',
  warn: 'yellow',
  debug: 'blue',
  error: 'red',
  link: 'grey',
  love: 'pink'
});

console.log(colors.error('this is an error'));
console.log(colors.warn('this is a warning'));

🎨 Combining Styles

colors.setTheme({
  custom: ['red', 'underline'],
});

console.log('styled text'.custom);

🌈 Gradient Text

// Custom gradient
console.log(colors.gradient('Sunset!', [196, 202, 208, 214, 220, 226]));

// Random preset
console.log(colors.gradient('Random Gradient!'));

🖼 Preview ANSI 256 Colors: Check examples/ansi256-colors.js or 🔗 Wikipedia: ANSI Escape Codes


🕵️ Protip: There’s a hidden undocumented style. If you find it, you can summon him...

Package Sidebar

Install

npm i meo-forkcy-colors

Weekly Downloads

588

Version

1.0.9

License

MIT

Unpacked Size

48.4 kB

Total Files

24

Last publish

Collaborators

  • meoforkcy