0.5.1 • Published 2 months ago

colorize-node v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

colorize-node

npm node-current npm package minimized gzipped size (select exports)

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 colorsBackground colorsModifiers
blackbgBlackreset
redbgRedbold
greenbgGreenitalic
yellowbgYellowunderline
bluebgBluestrikethrough
magentabgMagentahidden
cyanbgCyandim
whitebgWhiteoverlined
graybgGrayblink
redBrightbgRedBrightinverse
greenBrightbgGreenBrightdoubleunderline
yellowBrightbgYellowBrightframed
blueBrightbgBlueBright
magentaBrightbgMagentaBright
cyanBrightbgCyanBright
whiteBrightbgWhiteBright

License

This project is under MIT license.

The colorize.test.ts file bundles portions of picocolors (ISC License).