1.4.4 • Published 2 years ago

simple-ansi-string-format v1.4.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

A simple way to format strings using ANSI.

TYPESCRIPT AND ESM SUPPORT ARE HERE!

It is required to install 1.4.1 for the maximum bug-free experience, especially if you're using ESM.

Examples

Init

CJS

const Format = require("simple-ansi-string-format");
let s = new Format("Let's format this thing!");
console.log(`Woah, a format thing: "${s}"!`); // this object without any methods is a plain string-able object

ESM

import Format from "simple-ansi-string-format";
...

Note

From now on, we assume the following code was used:

const Format = require("simple-ansi-string-format");
let s = new Format("Let's format this thing!");

Colors

console.log(`let's a-format this! ${s.Red}`); // red text

Background Colors

console.log(`let's a-format this! ${s.bgRed}`); // text with red background

Formats

console.log(`let's a-format this! ${s.Bold}`); // bold text

Multiple

console.log(`let's a-format this! ${s.Red.Bold}`); // red and bold text

Nesting

let outer = new Format(`red inside: ${s.Red}`);
console.log(`bold inside: ${outer.Bold}`); // red and bold text inside bold text inside normal text

Static Values

console.log(`${Format.red}red text${Format.reset}plain text`);// self-explanatory

Features

new Format

This is the base class.

Properties

  • Colors
    • prototype.Red
    • prototype.Yellow
    • prototype.Green
    • prototype.Cyan
    • prototype.Blue
    • prototype.Magenta
    • prototype.White
    • prototype.Black
  • Background Colors
    • prototype.bgRed
    • prototype.bgYellow
    • prototype.bgGreen
    • prototype.bgCyan
    • prototype.bgBlue
    • prototype.bgMagenta
    • prototype.bgWhite
    • prototype.bgBlack
  • Style
    • prototype.Bold
    • prototype.Italic
    • prototype.Underline
    • prototype.Strikethrough
  • Other
    • prototype.Blink
    • prototype.Inverse
    • prototype.Hidden
    • prototype.Reset

Static ANSI variables are also available, which are identical to the prototype properties, except that it's all lowercase.

Updates

1.4.4

Replaced class static variables with standard assignment, since the feature doesn't exist.

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.6

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago