Skip to content

API reference / @jsprismarine/color-parser

@jsprismarine/color-parser ​

Join the Discord Servernpm

Variables ​

toConsole ​

const toConsole: Record<string, string>

Defined in: Colors.ts:6

ANSI open sequences, keyed by Minecraft color code.

k (obfuscated) has no terminal equivalent and maps to an empty string.

Functions ​

Parser() ​

Parser(input, prefix?, clearAtEnd?): string

Defined in: Parser.ts:15

Parses a string with color codes.

Parameters ​

input ​

string

String to parse.

prefix? ​

string = '§'

The prefix to use for color codes.

clearAtEnd? ​

boolean = true

Whether to clear the color at the end of the string.

Returns ​

string

The parsed string.

Example ​

typescript
const res = Parser('§cHello §eworld§r!');
console.log(res); // 'Hello world!'