source: imaps-frontend/node_modules/colorette/README.md

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 4.1 KB
Line 
1# 🌈Colorette
2
3> Easily set your terminal text color & styles.
4
5- No dependecies
6- Automatic color support detection
7- Up to [2x faster](#benchmarks) than alternatives
8- TypeScript support
9- [`NO_COLOR`](https://no-color.org) friendly
10- Node >= `10`
11
12> [**Upgrading from Colorette `1.x`?**](https://github.com/jorgebucaran/colorette/issues/70)
13
14## Quickstart
15
16```js
17import { blue, bold, underline } from "colorette"
18
19console.log(
20 blue("I'm blue"),
21 bold(blue("da ba dee")),
22 underline(bold(blue("da ba daa")))
23)
24```
25
26Here's an example using [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).
27
28```js
29console.log(`
30 There's a ${underline(blue("house"))},
31 With a ${bold(blue("window"))},
32 And a ${blue("corvette")}
33 And everything is blue
34`)
35```
36
37You can also nest styles without breaking existing color sequences.
38
39```js
40console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`))
41```
42
43Need to override terminal color detection? You can do that too.
44
45```js
46import { createColors } from "colorette"
47
48const { blue } = createColors({ useColor: false })
49
50console.log(blue("Blue? Nope, nah"))
51```
52
53## Installation
54
55```console
56npm install colorette
57```
58
59## API
60
61### \<color\>()
62
63> See all [supported colors](#supported-colors).
64
65```js
66import { blue } from "colorette"
67
68blue("I'm blue") //=> \x1b[34mI'm blue\x1b[39m
69```
70
71### createColors()
72
73Override terminal color detection via `createColors({ useColor })`.
74
75```js
76import { createColors } from "colorette"
77
78const { blue } = createColors({ useColor: false })
79```
80
81### isColorSupported
82
83`true` if your terminal supports color, `false` otherwise. Used internally, but exposed for convenience.
84
85## Environment
86
87You can override color detection from the CLI by setting the `--no-color` or `--color` flags.
88
89```console
90$ ./example.js --no-color | ./consumer.js
91```
92
93Or if you can't use CLI flags, by setting the `NO_COLOR=` or `FORCE_COLOR=` environment variables.
94
95```console
96$ NO_COLOR= ./example.js | ./consumer.js
97```
98
99## Supported colors
100
101| Colors | Background Colors | Bright Colors | Bright Background Colors | Modifiers |
102| ------- | ----------------- | ------------- | ------------------------ | ----------------- |
103| black | bgBlack | blackBright | bgBlackBright | dim |
104| red | bgRed | redBright | bgRedBright | **bold** |
105| green | bgGreen | greenBright | bgGreenBright | hidden |
106| yellow | bgYellow | yellowBright | bgYellowBright | _italic_ |
107| blue | bgBlue | blueBright | bgBlueBright | <u>underline</u> |
108| magenta | bgMagenta | magentaBright | bgMagentaBright | ~~strikethrough~~ |
109| cyan | bgCyan | cyanBright | bgCyanBright | reset |
110| white | bgWhite | whiteBright | bgWhiteBright | |
111| gray | | | | |
112
113## [Benchmarks](https://github.com/jorgebucaran/colorette/actions/workflows/bench.yml)
114
115```console
116npm --prefix bench start
117```
118
119```diff
120 chalk 1,786,703 ops/sec
121 kleur 1,618,960 ops/sec
122 colors 646,823 ops/sec
123 ansi-colors 786,149 ops/sec
124 picocolors 2,871,758 ops/sec
125+ colorette 3,002,751 ops/sec
126```
127
128## Acknowledgments
129
130Colorette started out in 2015 by [@jorgebucaran](https://github.com/jorgebucaran) as a lightweight alternative to [Chalk](https://github.com/chalk/chalk) and was introduced originally as [Clor](https://github.com/jorgebucaran/colorette/commit/b01b5b9961ceb7df878583a3002e836fae9e37ce). Our terminal color detection logic borrows heavily from [@sindresorhus](https://github.com/sindresorhus) and [@Qix-](https://github.com/Qix-) work on Chalk. The idea of slicing strings to clear bleeding sequences was adapted from a similar technique used by [@alexeyraspopov](https://github.com/alexeyraspopov) in [picocolors](https://github.com/alexeyraspopov/picocolors). Thank you to all our contributors! <3
131
132## License
133
134[MIT](LICENSE.md)
Note: See TracBrowser for help on using the repository browser.