Skip to content

LuKks/tiny-crayon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-crayon

Terminal string styling

npm i tiny-crayon

image

Usage

const crayon = require('tiny-crayon')

console.log(
  crayon.italic('hey'),
  crayon.underline('hey'),
  crayon.overline('hey'),
  crayon.inverse('hey'),
  crayon.strikethrough('hey')
)

console.log(
  crayon.red(crayon.bold('hey')),
  crayon.red('hey'),
  crayon.redBright('hey'),
  crayon.bgRed('hey'),
  crayon.bgRedBright('hey')
)

console.log(
  crayon.green(crayon.bold('hey')),
  crayon.green('hey'),
  crayon.greenBright('hey'),
  crayon.bgGreen('hey'),
  crayon.bgGreenBright('hey')
)

console.log(
  crayon.blue(crayon.bold('hey')),
  crayon.blue('hey'),
  crayon.blueBright('hey'),
  crayon.bgBlue('hey'),
  crayon.bgBlueBright('hey')
)

console.log(Object.keys(crayon)) // Print all methods

Custom stream

It's only used to check if colors are available on that stream, that's it.
By default it checks on process.stdout which is enough.

const { Crayon } = require('tiny-crayon')
const crayon = new Crayon(process.stderr)
console.error(crayon.green('hey'))

License

MIT