concol-utiln
v1.0.1
Published
A simple Node.js module for generating ANSI color escape sequences for terminal text styling.
Readme
concol-utiln
A simple Node.js module for generating ANSI color escape sequences for terminal text styling.
Installation
npm install concol-utilnUsage
const { escseq, f, b, s } = require('concol-utiln');
// Basic usage
console.log(`${escseq(ansi.f.red, b.white, s.bold)}Red on white bold text${ansi.escseq()}`);
// Using style constants
console.log(`${escseq(f.green)}Green text${escseq()}`);
console.log(`${escseq(f.blue, b.yellow)}Blue on yellow${escseq()}`);
console.log(`${escseq(f.pink, '_', s.underline)}Pink underlined text${escseq()}`);API
escseq([foreground], [background], [style])
Generates an ANSI escape sequence for the specified formatting.
Parameters:
foreground: Foreground color (default: white)background: Background color (default: black)style: Text style (default: reset)
Returns: ANSI escape sequence string
Constants
Text Styles (s)
reset: Reset all attributesbold: Bold textunderline: Underlined textblink: Blinking textreverse: Reverse video (swap foreground and background)hidden: Hidden textstrikethrough: Strikethrough text
Foreground Colors (f)
blackredgreenyellowbluepinkcyanwhite
Background Colors (b)
blackredgreenyellowbluepinkcyanwhite
Special Values
- Use
_as a parameter to use the default value for that attribute - Call
escseq()with no parameters to reset all formatting
License
MIT
