Skip to content

cakecatz/ansi-parser

Repository files navigation

ansi-parser

Parser for string that include ansi codes.

Install

npm i @cakecatz/ansi-parser

Usage

const { parseAnsi } = require("@cakecatz/ansi-parser");
const cells = parseAnsi("\u001b[31mhello\u001b[39m");

cells will be like this.

[
  {
    bg: 0, // COLOR_CODES.BLACK
    fg: 1, // COLOR_CODES.RED
    content: "hello",
    bold: false,
    dim: false,
    inverse: false,
    italic: false,
    underline: false
  }
];