Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pretty-ansi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty-ansi

Convert ANSI escape sequences to human readable text

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

pretty-ansi

version license packagephobia coverage

Convert ANSI escape sequences to human readable text.


This utility converts ANSI escape sequences to human readable text. It supports color, style and cursor control escapes and works with vanilla sequences as well as the output from libraries like chalk, colors, ansi-escapes, ansi-styles or terminal-kit.

Install

npm add -D pretty-ansi

Usage

For example, it can be useful to test the output of a command line tool:

import assert from "node:assert";
import test from "node:test";
import prettyAnsi from "pretty-ansi";

test("command output", () => {
  const commandOutput = "\u001b[3;32mSuccess!\u001b[0m";

  assert.strictEqual(prettyAnsi(commandOutput), "<italic, green>Success!</>");
});

Notes

Currently only 16 colors are all supported.

Keep in mind that the escape sequences are not validated. Unrecognized sequence will print as <ESC>[a1b2c3, or as <?> in case this is a color or style sequence.

jest-serializer-ansi-escapes — Jest snapshot serializer for ANSI escape sequences.

License

MIT

Keywords

FAQs

Package last updated on 26 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc