Replace ansi escape sequences with tokens indicating what they are

Overview

visualize-ansi-codes

Replace ansi escape sequences with tokens indicating what they are.

Usage

hello // To change the tokens or add other escape sequences, pass in a different codes map: const input2 = "\u001b[32mhello\u001b[39m"; const output2 = visualizeAnsiCodes(input2, { "\u001b[32m": "[GREEN]", "\u001b[39m": "[RESET]", }); console.log(output2); // [GREEN]hello[RESET] // It may be useful to base your codes object on the default code object: const input3 = "\u001b[32mhello\u001b[39m"; const output3 = visualizeAnsiCodes(input3, { ...defaultCodes, "\u001b[32m": "[GREEN]", }); console.log(output3); // [GREEN]hello ">
const { visualizeAnsiCodes, defaultCodes } = require("visualize-ansi-codes");

const input = "\u001b[32mhello\u001b[39m";
const output = visualizeAnsiCodes(input);

console.log(output); // 
      
       hello
       
      

// To change the tokens or add other escape sequences, pass in a different codes map:

const input2 = "\u001b[32mhello\u001b[39m";
const output2 = visualizeAnsiCodes(input2, {
  "\u001b[32m": "[GREEN]",
  "\u001b[39m": "[RESET]",
});

console.log(output2); // [GREEN]hello[RESET]

// It may be useful to base your codes object on the default code object:
const input3 = "\u001b[32mhello\u001b[39m";
const output3 = visualizeAnsiCodes(input3, {
  ...defaultCodes,
  "\u001b[32m": "[GREEN]",
});

console.log(output3); // [GREEN]hello
      

License

MIT

You might also like...

Find in note Trilium widget to replace the crappy ctrl+f search.

Trilium-FindWidget Find in note Trilium widget to replace the crappy ctrl+f search. Video sandbox.-.Trilium.Notes.2022-04-22.15-41-19_rescaled.mp4 Fea

Nov 22, 2022

Easily add emoji support to your website! Replace keywords with emoji's :yum:

Emoji-Parser.js 🔎 A emoji parser to easily add emoji support to your website Show your support! Features: Use's the same style GitHub does! TON's of

Sep 9, 2022

It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm and toast with the library.

asteroid-alert It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm with the library. It has also e

Mar 12, 2021

Ethereum Smart Contracts for locking your Ether and ERC20 tokens based on time and price conditions

SmartHold - a simple way to lock and hold your ETH or ERC20 in a smart contract This is a BETA software that has not been audited for security. USE AT

May 5, 2022

Base62-token.js - Generate & Verify GitHub-style & npm-style Base62 Tokens

base62-token.js Generate & Verify GitHub-style & npm-style Secure Base62 Tokens Works in Vanilla JS (Browsers), Node.js, and Webpack. Online Demo See

Jun 11, 2022

Vesting contract with multiple beneficiaries, tokens, and lock schedules.

⚠️ This code has not been audited, use at your own risk Vesting Contract This contract handles the vesting of ERC20 tokens for multiple beneficiaries.

Mar 14, 2022

A time-locked vault that distributes erc-20 tokens to owners of an nft-collection at expiry

A time-locked vault that distributes erc-20 tokens to owners of an nft-collection at expiry

Apr 10, 2022

Subgraph to query Doodles NFT tokens along with the traits and owners.

Doodles Subgraph API Subgraph to query Doodles NFT tokens along with the traits and owners. How to use the API Try it out here Example query: { toke

Sep 19, 2022

Pull sensitive data from users on windows including discord tokens and chrome data.

Pull sensitive data from users on windows including discord tokens and chrome data.

⭐ For a 🍪 Pegasus Pull sensitive data from users on windows including discord tokens and chrome data. Features 🟩 Discord tokens 🟩 Geolocation data

Dec 24, 2022
Owner
Lily Scott
Former Prettier Core Team member, Former Babel team member. Interested in JavaScript, Rust, Unity, VR, Dev Tooling, Dev Experience, React, and more.
Lily Scott
zkPoB is a mobile compatible tool that lets anyone prove they own a Bufficorn (or any NFT) without revealing which Buffi they own or the address they are verifying themselves with

zkPoB is a mobile compatible tool that lets anyone prove they own a Bufficorn (or any NFT) without revealing which Buffi they own or the address they are verifying themselves with

Marto.eth 10 Aug 25, 2022
🦕. A type-check utility function to indicating that the code is unreachable

unreachable A type-check utility function to indicating that the code is unreachable. Usage For example, the following code passed type checking. impo

Alisue 6 Oct 2, 2022
Execute obsidian commands with short key sequences. For example, 'tp' for 'Toggle Preview' and 'tb' for 'Toggle Sidebar'. Easier to remember.

Key Sequence Shortcut Key Sequence Shortcut is an obsidian plugin, allow binding key sequences to an obsidian command. For example If we assume "t" st

Yu Wang 26 Dec 26, 2022
Slime jumper game is a simple game that requires you to escape from the enemies that come your way.

Slime Jumper What is this game? The slime jumper game is a game with a simple logic (but it was not so easy to do) where you have to escape from the e

Fatih 2 Mar 1, 2022
Construct ANSI colors strings from object descriptors.

ansi-construct Construct ANSI colors strings from object descriptors. Usage import { ansi } from 'ansi-construct' const item = ansi({ text: 'foo', co

Anthony Fu 22 Sep 8, 2022
It shows how to escape cross-origin issues for web client and API server using CloudFront routing.

AWS CloudFront의 URL Routing을 이용한 Web Client 및 API Server 구현 여기서는 CliendFront의 URL Routing을 이용하여 Web Client와 API Server를 구현하고자 합니다. Web Client는 Amazon

John Park 4 Nov 20, 2022
Receive crypto payments from anywhere around the world, options including native tokens (MATIC, ETHER,BUSD), Tokens (USDT,BUSD), NFTs and more.

Receive payments for service rendered in crypto using different options. Go borderless with bonpay, gain access to varities of crypto assets, safe and

Johnson awah Alfred 6 Nov 11, 2022
Loops through a list of Discord tokens in a file to check if they are valid/invalid

Discord Token Checker Loops through a list of Discord tokens in a file to check if they are valid/invalid. Click here to report bugs. Usage Download Z

null 319 Dec 31, 2022
A superfast and easy to use knowledge base to help your customers get the info they need, when they need it most.

A superfast and easy to use knowledge base to help your customers get the info they need, when they need it most. helpkb is an open-source Next.js (A

Mark Moffat 11 Dec 5, 2022
Bootstrap5-tags - Replace select[multiple] with nices badges

Tags for Bootstrap 4/5 How to use An ES6 native replacement for select using standards Bootstrap 5 (and 4) styles. No additional CSS needed! Supports

Thomas Portelange 75 Jan 9, 2023