@lpm.dev/neo.ansi

Pool

ansi

Modern, zero-dependency ANSI escape code parser and stripper - beats strip-ansi by 10%+

install @lpm.dev/neo.ansi@v1.0.0

hasAnsi

function
function hasAnsi(input: string): boolean

Check if string contains ANSI escape codes This is a fast check that looks for ESC characters without doing full parsing. Useful for conditionally processing strings.

Parameters

inputstringInput string to check

Returns

booleantrue if string contains ESC characters

Example

hasAnsi('\x1b[31mRed\x1b[0m')  // => true
hasAnsi('Plain text')          // => false
hasAnsi('')                    // => false