colorize-node
v1.0.0
Published
A lightweight library to color Node.js terminal output
Downloads
110
Maintainers
Readme
colorize-node
A lightweight library to color Node.js terminal output.
- ✅ Zero dependencies
- ✅ TypeScript support
- ✅ Node.js v18.12.0+ support
- ✅ 3x smaller then
picocolors
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
Licensed under the MIT license.
The colorize.test.ts
file bundles portions of picocolors (ISC License).