isansi checks whether a string uses ANSI color and style.
| Category | Status |
|---|---|
| Version | |
| Dependencies | |
| Dev dependencies | |
| Build | |
| License |
$ npm install isansiFirst 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)); // => falseThe module supports all colors and styles that are supported by chalk.
To run quality assurance for this module use roboter:
$ npx roboter