Socket
Socket
Sign inDemoInstall

has-ansi

Package Overview
Dependencies
2
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    has-ansi

Check if a string has ANSI escape codes


Version published
Weekly downloads
12M
decreased by-2.05%
Maintainers
2
Install size
9.63 kB
Created
Weekly downloads
 

Package description

What is has-ansi?

The has-ansi npm package is used to check if a string contains ANSI escape codes. These codes are often used to format output in terminal applications, such as changing colors, styles, or other text attributes. This package provides a simple way to detect the presence of these codes in a given string.

What are has-ansi's main functionalities?

Check for ANSI escape codes in a string

This feature allows you to check if a string contains ANSI escape codes. The function `hasAnsi` returns `true` if the string contains any ANSI escape codes, and `false` otherwise. This is useful for determining whether text formatting needs to be stripped or processed differently.

"const hasAnsi = require('has-ansi');\nconsole.log(hasAnsi('\u001B[4mUnicorn\u001B[0m')); // true\nconsole.log(hasAnsi('Unicorn')); // false"

Other packages similar to has-ansi

Readme

Source

has-ansi Build Status

Check if a string has ANSI escape codes

Install

$ npm install --save has-ansi

Usage

var hasAnsi = require('has-ansi');

hasAnsi('\u001b[4mcake\u001b[0m');
//=> true

hasAnsi('cake');
//=> false

CLI

$ npm install --global has-ansi
$ has-ansi --help

  Usage
    has-ansi <string>
    echo <string> | has-ansi

  Exits with code 0 if input has ANSI escape codes and 1 if not

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 13 Aug 2014

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