Skip to content

isansi checks whether a string uses ANSI color and style.

License

Notifications You must be signed in to change notification settings

thenativeweb/isansi

Repository files navigation

isansi

isansi checks whether a string uses ANSI color and style.

Status

Category Status
Version npm
Dependencies David
Dev dependencies David
Build GitHub Actions
License GitHub

Installation

$ npm install isansi

Quick start

First you need to add a reference to isansi in your application:

const { isAnsi } = require('isansi');

If you use TypeScript, use the following code instead:

import { isAnsi } from 'isAnsi';

To check a string for a specific color or style, use the appropriate function of the isAnsi object:

const text = chalk.green.bold('foo');

console.log(isAnsi.green(text));  // => true
console.log(isAnsi.bold(text));   // => true

console.log(isAnsi.red(text));    // => false
console.log(isAnsi.italic(text)); // => false

The module supports all colors and styles that are supported by chalk.

Running quality assurance

To run quality assurance for this module use roboter:

$ npx roboter

About

isansi checks whether a string uses ANSI color and style.

Resources

License

Stars

Watchers

Forks

Packages