ColorTerm
Bring colors into your Terminal
Usage
ColorTerm supports CommonJs and ESM :
ESM :
import { Color, Prepare } from 'colorterm'
CommonJs:
var Color = requite('colorterm').Color
var Prepare = require('colorterm').Prepare
ColorTerm provides two main functions:
Color
Color function gets three arguments:
- the value as a string
- the color as an RGB colors array [30,144,255] or hex string "#1e90ff" , short hex is also supported "#f0f"
- optional options, refer to options section
console.log(Color('my text', '#f0f'))
console.log(Color('my text', '#1e90ff', { bold: true }))
console.log(Color('my text', [30, 144, 255], { bold: true }))
Prepare
Prepare is a curried version of Color funtion
it prepares your color and options arguments and returns a function that accepts your text value.
const myStyle1 = Prepare('#ff00ff', { italic: true, underlined: true })
const myStyle2 = Prepare('#1e90ff', { bold: true })
const myStyle3 = Prepare([0, 0, 0], { strikeThrough: true, bold: true, background: '#E3B505' })
console.log(myStyle1('my text'))
console.log(myStyle2('my text'))
console.log(myStyle3('my text'))
options
- bold : boolean
- faint : boolean
- italic : boolean
- underlined : boolean
- inverse : boolean
- strikeThrough : boolean
- background : hex "#E3B505" , short hex "#6a4" or RGB array [219, 80, 74]