1.4.4 • Published 4 years ago
simple-ansi-string-format v1.4.4
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 objectESM
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 textBackground Colors
console.log(`let's a-format this! ${s.bgRed}`); // text with red backgroundFormats
console.log(`let's a-format this! ${s.Bold}`); // bold textMultiple
console.log(`let's a-format this! ${s.Red.Bold}`); // red and bold textNesting
let outer = new Format(`red inside: ${s.Red}`);
console.log(`bold inside: ${outer.Bold}`); // red and bold text inside bold text inside normal textStatic Values
console.log(`${Format.red}red text${Format.reset}plain text`);// self-explanatoryFeatures
new Format
This is the base class.
Properties
- Colors
prototype.Redprototype.Yellowprototype.Greenprototype.Cyanprototype.Blueprototype.Magentaprototype.Whiteprototype.Black
- Background Colors
prototype.bgRedprototype.bgYellowprototype.bgGreenprototype.bgCyanprototype.bgBlueprototype.bgMagentaprototype.bgWhiteprototype.bgBlack
- Style
prototype.Boldprototype.Italicprototype.Underlineprototype.Strikethrough
- Other
prototype.Blinkprototype.Inverseprototype.Hiddenprototype.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
4 years ago
1.4.3
4 years ago
1.4.2
4 years ago
1.4.1
4 years ago
1.4.0
4 years ago
1.3.0
4 years ago
1.2.0
4 years ago
1.1.6
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago