•  


GitHub - jorgebucaran/colorette: ??Easily set your terminal text color & styles
Skip to content

??Easily set your terminal text color & styles

License

Notifications You must be signed in to change notification settings

jorgebucaran/colorette

Folders and files

Name Name
Last commit message
Last commit date

Latest commit

 

History

356 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

??Colorette

Easily set your terminal text color & styles.

  • No dependecies
  • Automatic color support detection
  • Up to 2x faster than alternatives
  • TypeScript support
  • NO_COLOR friendly
  • Node >= 10

Upgrading from Colorette 1.x ?

Quickstart

import
 {
 blue
,
 bold
,
 underline
 }
 from
 "colorette"


console
.
log
(

  blue
(
"I'm blue"
)
,

  bold
(
blue
(
"da ba dee"
)
)
,

  underline
(
bold
(
blue
(
"da ba daa"
)
)
)

)

Here's an example using template literals .

console
.
log
(
`

  There's a 
${
underline
(
blue
(
"house"
)
)
}
,

  With a 
${
bold
(
blue
(
"window"
)
)
}
,

  And a 
${
blue
(
"corvette"
)
}

  And everything is blue

`
)

You can also nest styles without breaking existing color sequences.

console
.
log
(
bold
(
`I'm 
${
blue
(
`da ba 
${
underline
(
"dee"
)
}
 da ba`
)
}
 daa`
)
)

Need to override terminal color detection? You can do that too.

import
 {
 createColors
 }
 from
 "colorette"


const
 {
 blue 
}
 =
 createColors
(
{
 useColor
: 
false
 }
)


console
.
log
(
blue
(
"Blue? Nope, nah"
)
)

Installation

npm install colorette

API

<color>()

See all supported colors .

import
 {
 blue
 }
 from
 "colorette"


blue
(
"I'm blue"
)
 //=> \x1b[34mI'm blue\x1b[39m

createColors()

Override terminal color detection via createColors({ useColor }) .

import
 {
 createColors
 }
 from
 "colorette"


const
 {
 blue 
}
 =
 createColors
(
{
 useColor
: 
false
 }
)

isColorSupported

true if your terminal supports color, false otherwise. Used internally, but exposed for convenience.

Environment

You can override color detection from the CLI by setting the --no-color or --color flags.

$ 
./example.js --no-color 
|
 ./consumer.js

Or if you can't use CLI flags, by setting the NO_COLOR= or FORCE_COLOR= environment variables.

$ 
NO_COLOR= ./example.js 
|
 ./consumer.js

Supported colors

Colors Background Colors Bright Colors Bright Background Colors Modifiers
black bgBlack blackBright bgBlackBright dim
red bgRed redBright bgRedBright bold
green bgGreen greenBright bgGreenBright hidden
yellow bgYellow yellowBright bgYellowBright italic
blue bgBlue blueBright bgBlueBright underline
magenta bgMagenta magentaBright bgMagentaBright strikethrough
cyan bgCyan cyanBright bgCyanBright reset
white bgWhite whiteBright bgWhiteBright
gray
npm --prefix bench start
  chalk         1,786,703 ops/sec
  kleur         1,618,960 ops/sec
  colors          646,823 ops/sec
  ansi-colors     786,149 ops/sec
  picocolors    2,871,758 ops/sec
+
 colorette     3,002,751 ops/sec

Acknowledgments

Colorette started out in 2015 by @jorgebucaran as a lightweight alternative to Chalk and was introduced originally as Clor . Our terminal color detection logic borrows heavily from @sindresorhus and @Qix- work on Chalk. The idea of slicing strings to clear bleeding sequences was adapted from a similar technique used by @alexeyraspopov in picocolors . Thank you to all our contributors! <3

License

MIT

- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본