ansiWrap()function

ansiWrap(input: string, ...wrappers: ImmutableArray<string>): void
ParamType
inputstring
The string to wrap in ANSI codes. required
wrappersImmutableArray<string>
Any number of ANSI escape codes (e.g. ANSI_RED, ANSI_BOLD) to prepend before input. required
Return
unknown
The wrapped string, or input unchanged when colour is not supported (see precedence above).

Wrap a string in the ANSI color/style codes (at the start), and ANSI_RESET at the end.

  • Colour is only emitted when the runtime supports it, resolved once at module load into _USES_COLORFORCE_COLOR > NO_COLOR > TTY detection > default-off.
  • The default is off for non-interactive sinks (files, log aggregators, Workers), so escape codes never pollute non-TTY output unless FORCE_COLOR opts back in.