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.
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"