No bells or whistles parsing of ANSI escape sequences.
# Using yarn
yarn add @jamesdphillips/ansi-escape
# Using npm
npm install --save @jamesdphillips/ansi-escape
import parse from "@jamesdphillips/ansi-escape";
const content = "\x1B[38;5;1mred\x1B[0m";
const parsedContent = parse(myContent);
// ...
Parser largely borrowed from anser.