A simple, fully typed ANSI text-styling library with an ergonomic, chainable DSL.
- Inner styles restore their surrounding styles for predictable composition.
- Works without
Proxyor tagged-template syntax when necessary. - Provides Node.js entry points with automatic non-TTY handling and custom inspection.
npm i ansi-escape-code
# TypeScript projects
npm i -D @ansi-escape-code/typeUse the Proxy entry point for the chainable DSL:
import{ansi}from"ansi-escape-code/proxy";console.log(ansi.red.bold`Error`.toString());console.log(`${ansi.red`Hello ${ansi.bold.green`Beautiful`} World`}`);consterrorName=ansi.red.bold;functionformatError(ruleName: string,message: string): string{return`${errorName(`RULE-${ruleName}`)}: ${message}`;}Use ansi-escape-code/proxy-node for Node.js-specific non-TTY handling and custom inspection.
See the generated TypeDoc documentation for the complete API reference, exported types, entry points, and behavior details.
MIT