https://github.com/chalk/has-ansi
Check if a string has ANSI escape codes
https://github.com/chalk/has-ansi
Last synced: 7 months ago
JSON representation
Check if a string has ANSI escape codes
- Host: GitHub
- URL: https://github.com/chalk/has-ansi
- Owner: chalk
- License: mit
- Created: 2014-06-14T19:33:02.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2025-09-08T15:08:55.000Z (10 months ago)
- Last Synced: 2025-12-01T11:16:59.941Z (7 months ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 50
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
README
# has-ansi
> Check if a string has [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
npm install has-ansi
```
## Usage
```js
import hasAnsi from 'has-ansi';
hasAnsi('\u001B[4mUnicorn\u001B[0m');
//=> true
hasAnsi('cake');
//=> false
```
## Related
- [has-ansi-cli](https://github.com/chalk/has-ansi-cli) - CLI for this module
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right