JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q46945F
  • License MIT

Convert ANSI strings into JSON output.

Package Exports

  • ansi-to-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ansi-to-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ansi-to-json

PayPal AMA Version Downloads Get help on Codementor

Convert ANSI strings into JSON output.

☁️ Installation

$ npm i --save ansi-to-json

📋 Example

const ansiToJson = require("ansi-to-json");
console.log(JSON.stringify(ansiToJson("\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m"), null, 4));
// [
//     {
//         "content": "Hello",
//         "fg": "255, 0, 0",
//         "bg": null,
//         "fg_truecolor": null,
//         "bg_truecolor": null,
//         "was_processed": true
//     },
//     {
//         "content": " ",
//         "fg": null,
//         "bg": null,
//         "fg_truecolor": null,
//         "bg_truecolor": null,
//         "was_processed": false
//     },
//     {
//         "content": "World",
//         "fg": null,
//         "bg": "255, 255, 0",
//         "fg_truecolor": null,
//         "bg_truecolor": null,
//         "was_processed": true
//     }
// ]

console.log(JSON.stringify(ansiToJson("\x1b[30mblack\x1b[37mwhite"), null, 4));
// [
//     {
//         "content": "black",
//         "fg": "0, 0, 0",
//         "bg": null,
//         "fg_truecolor": null,
//         "bg_truecolor": null,
//         "was_processed": true
//     },
//     {
//         "content": "white",
//         "fg": "255,255,255",
//         "bg": null,
//         "fg_truecolor": null,
//         "bg_truecolor": null,
//         "was_processed": true
//     }
// ]

📝 Documentation

ansiToJson(input)

Convert ANSI strings into JSON output.

Params

  • String input: The input string.

Return

  • Array The parsed input.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

📜 License

MIT © Ionică Bizău