0.5.1 • Published 2 months ago
colorize-node v0.5.1
colorize-node
A lightweight library to color Node.js terminal output.
- Zero dependencies
- TypeScript support
- Node >= 18.12.0
- ESM bundle size: 193 bytes (minified & gzipped)
- CJS bundle size: 200 bytes (minified & gzipped)
Installation
npm install --save-dev colorize-node
Usage
// use named export, no default export
import { colorize } from 'colorize-node'
colorize.red('This string is red')
colorize.green(colorize.bold('This string is green & bold'))
colorize.bgGreen(`This string has green background and ${colorize.bold('this string is bold')}`)
Supported colors
Uses modifiers, foreground & background colors from nodes util.inspect.colors
.
Taken from the Node.js docs:
Foreground colors | Background colors | Modifiers |
---|---|---|
black | bgBlack | reset |
red | bgRed | bold |
green | bgGreen | italic |
yellow | bgYellow | underline |
blue | bgBlue | strikethrough |
magenta | bgMagenta | hidden |
cyan | bgCyan | dim |
white | bgWhite | overlined |
gray | bgGray | blink |
redBright | bgRedBright | inverse |
greenBright | bgGreenBright | doubleunderline |
yellowBright | bgYellowBright | framed |
blueBright | bgBlueBright | |
magentaBright | bgMagentaBright | |
cyanBright | bgCyanBright | |
whiteBright | bgWhiteBright |
License
This project is under MIT license.
The colorize.test.ts
file bundles portions of picocolors (ISC License).