Socket
Socket
Sign inDemoInstall

ansi

Package Overview
Dependencies
2
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ansi

ANSI formatting tool for Node.js


Version published
Weekly downloads
506K
decreased by-5.97%
Maintainers
1
Install size
87.5 kB
Created
Weekly downloads
 

Readme

Source

ansi.js

ANSI formatting tool for Node.js

ansi.js is a module for Node.js that writes provides an easy-to-use API for writing ANSI escape codes to Stream instances. ANSI escape codes are used to do fancy things in a terminal window, like render text in colors, delete characters, lines, the entire window, or hide and show the cursor, and lots more!

The code for the example in the screenshot above can be found in the examples directory.

Features:
  • 256 color support for the terminal!
  • Works with any writable Stream instance.
  • Allows you to move the cursor anywhere on the terminal window.
  • Allows you to delete existing contents from the terminal window.
  • Allows you to hide and show the cursor.
  • Converts CSS color codes and RGB values into ANSI escape codes.
  • Low-level; you are in control of when escape codes are used, it's not abstracted.
  • Optional automatic cleanup of stream by before closing (still TODO).

Installation

Install with npm:

$ npm install ansi

Example

var ansi = require('ansi')
  , cursor = ansi(process.stdout);

// Set the font color to rgb(22, 254, 109)
cursor.rgb(22, 254, 109);

console.log('this will be colored text!');

// Set the background color to bright red
cursor.bg.rgb(255, 0, 0);

console.log('this will be colored text with a red background!');

cursor.reset();

console.log('this will be regular text');

Keywords

FAQs

Last updated on 26 Jan 2012

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc