Package Exports
- @artiq/stylize
- @artiq/stylize/package.json
Readme
artiq stylize
A terminal text stylizer with ANSI color support and modular styling system — supports chaining, style composition, proxy-based API, and multiple styling modes.
✨ Features
- 🖍️ Terminal text styling: bold, italic, underline, foreground/background color
- 🎲 Supports
randomandsequencemodes for applying styles - 🔗 Proxy-style chaining API (
stylize.bold.red('text')) - 🧱 Modular design: separate functions for proxy, wrapping, resolving, parsing
- 🧪 Style validation and text-splitting modes
- 📁 Supports structure modes:
char,word,line, andsentence
📦 Installation
npm install @artiq/stylize🚀 Usage
Direct Styling Mode
import stylize from '@artiq/stylize'
const styled = stylize('Hello Artiq!', [
['bold', 'red'],
['italic', 'blue'],
['underline', 'green']
], { style: 'word' });
console.log(styled);const output = stylize("Colorful Text!", [
['red', 'green', 'blue'],
['yellow', 'magenta']
], { style: 'char', randomize: true });
console.log(output);Using Proxy Chaining API
import stylize from '@artiq/stylize'
console.log(stylize.bold.red('Bold Red'))
console.log(stylize.italic.bgGreen('Italic with Green Background'))🎨 Supported Styles
- Text styles:
bold,italic,underline,dim,strikethrough - Foreground colors:
red,blue,green,yellow,magenta, etc. - Background colors:
bgRed,bgBlue,bgYellow, etc. - Bright variants:
brightRed,bgBrightBlue, etc. - RGB/HEX:
rgb(255,0,0),#FF0000,bg#00FF00
📘 Quick API
stylize(text, styleSets, options?)
text: the string to be styledstyleSets: 2D array of style namesoptions: optional object{ style: 'char'|'word'|'line'|'full', randomize: boolean }
createStylizeProxy()
Creates a proxy-style chaining API.
applyStyles(text, styles[])
Applies a specific set of styles to the text directly.
🧪 StyleSet Example
const styleSets = [
['bold', 'red'],
['italic', 'blue'],
['underline', 'green']
];👤 Author
⚖️ License
This project is licensed under the MIT License – see the LICENSE file for details.