Custom tools for NodeJS
Custom Colors and Formats to be used in NodeJS or in a Terminal console.
- Compatible with both TypeScript and ES6 (I recommend to use TypeScript)
- Zero dependencies
npm v6+oryarn v1.17+NodeJS v8+
You have two options to install this repository.
By adding the dependency to your
package.jsonfile.{ "dependencies": { "custom-console-colors": "^0.0.4" } }# Install dependencies# NPM npm install # or Yarn yarn
By using a package manager
# NPM npm install --save custom-console-color # or Yarn yarn add @ialopezg/core
Usage
const{ Color }=require('custom-console-color')Colored text
console.log(Color.red('Red color text'));Mixed styles
console.log(Color.red().bold('Red color text with bold style'))Styled text with unstyled text
console.log(`${Color.red('Red color')} text with ${Color.bold('unstyled')} text`)Predefining colors
consterror=Color.red;constlog=Color.green;constnotice=Color.blue;constwarn=Color.yellow;console.log(error('Error!'));console.log(log('Log!'));console.log(notice('Notice!'));console.log(warn('Warning!'));Another awesome example
constappStarted=(host,port,proxy)=>{constdivider=Color.green('\n-----------------------------------')constip='127.0.0.1';console.log(`Server started! ${Color.green('✓')}`)if(proxy){console.log(`Proxy initialized! ${Color.green('✓')}`)}console.log(`${Color.bold('Access URLs:')}${divider}Localhost: ${Color.magenta(`http://${host}:${port}`)} LAN: ${Color.magenta(`http://${ip}:${port}`)+(proxy ? `\n Proxy: ${Color.magenta(proxy)}` : '')}${divider}${Color.blue(`Press ${Color.italic('CTRL-C')} to stop`)} `)};appStarted('localhost',3000,'192.168.0.255');- bold
- dim
- italic
- underline
- blink
- inverse
- hidden
- strike
| Normal (ANSI) | Bright (Extended) |
|---|---|
| black | brightBlack |
| red | brightRed |
| green | brightGreen |
| yellow | brightYellow |
| blue | brightBlue |
| magenta | brightMagenta |
| cyan | brightCyan |
| white | brightWhite |
| Normal (ANSI) | Bright (Extended) |
|---|---|
| bgBlack | bgBrightBlack |
| bgRed | bgBrightRed |
| bgGreen | bgBrightGreen |
| bgYellow | bgBrightYellow |
| bgBlue | bgBrightBlue |
| bgMagenta | bgBrightMagenta |
| bgCyan | bgBrightCyan |
| bgWhite | bgBrightWhite |
Author - Isidro A. Lopez G.
CustomConsoleColors is licensed under MIT license.
© Copyright 2019-present - CustomConsoleColors by Isidro A. López G.