hasAnsi
functionfunction hasAnsi(input: string): boolean
Check if string contains ANSI escape codes This is a fast check for the 7-bit ESC introducer and supported 8-bit C1 introducers/terminators. It intentionally does not perform full parsing.
Parameters
input
stringInput string to checkReturns
booleantrue if the string contains ESC or a supported C1 controlExample
hasAnsi('\x1b[31mRed\x1b[0m') // => true
hasAnsi('Plain text') // => false
hasAnsi('') // => false