JSPM

@artiq/stylize

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q44367F
  • License MIT

A terminal text stylizer with ANSI color support and modular styling system — supports chaining, style composition, proxy-based API, and multiple styling modes.

Package Exports

  • @artiq/stylize
  • @artiq/stylize/package.json

Readme

artiq stylize

npm version Version License ESM Node.js

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 random and sequence modes 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, and sentence

📦 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 styled
  • styleSets: 2D array of style names
  • options: 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

Dimas Fajar


⚖️ License

This project is licensed under the MIT License – see the LICENSE file for details.