1.1.0 • Published 1 year ago
@onurege3467/easycolor v1.1.0
EasyColor
A simple Node.js package and command-line tool for coloring terminal outputs.
Features
- Text coloring with a simple API
- 16 different text colors and 16 different background colors
- Text styles like bold, italic, underline
- Rainbow and random coloring effects
- Both programmatic and command-line usage
- Apply multiple styles with chain methods
Installation
npm install @onurege3467/easycolor --globalTo use only in your project:
npm install @onurege3467/easycolor --saveCommand-Line Usage
# Text coloring
easycolor text red "This is red text"
# Rainbow effect
easycolor rainbow "Rainbow text"
# Random color
easycolor random "This is randomly colored text"
# Bold text
easycolor text bold "This is bold text"
# Using pipes
echo "Hello World" | easycolor text green
# Demo display
easycolor demo
# Help
easycolor helpProgrammatic Usage
const easycolor = require('@onurege3467/easycolor');
// Simple coloring
console.log(easycolor.colorize('Red text','red'));
console.log(easycolor.colorize('Text with yellow background','bgYellow'));
console.log(easycolor.colorize('Bold text','bold'));
// Apply multiple styles with chain methods
console.log(
easycolor.chain('Blue and bold text')
.blue()
.bold()
.toString()
);
// Rainbow effect
console.log(easycolor.rainbow('Rainbow text'));
// Random color
console.log(easycolor.random('Randomly colored text'));
// Colored console logging
console.log(easycolor.colorize('✓ Operation successful','green'));
console.log(easycolor.colorize('✗ An error occurred','red'));
console.log(easycolor.colorize('⚠ Warning message','yellow'));Supported Colors and Styles
Text Colors
blackredgreenyellowbluemagentacyanwhitebrightBlackbrightRedbrightGreenbrightYellowbrightBluebrightMagentabrightCyanbrightWhite
Background Colors
bgBlackbgRedbgGreenbgYellowbgBluebgMagentabgCyanbgWhitebgBrightBlackbgBrightRedbgBrightGreenbgBrightYellowbgBrightBluebgBrightMagentabgBrightCyanbgBrightWhite
Text Styles
bolddimitalicunderlineblinkinversehiddenstrikethrough
API Reference
Chain Method
easycolor.chain(text)
.color1()
.color2()
.style()
.toString()Special Effects
easycolor.rainbow(text)
easycolor.random(text)Terminal Support
// Check terminal color support
const isSupported = easycolor.isSupported();
// Disable colors
easycolor.disable();
// Enable colors
easycolor.enable();