2022-10-09 10:10:43 +02:00
|
|
|
# trmclr
|
|
|
|
|
2024-08-09 13:40:55 +02:00
|
|
|
Easy terminal colors.
|
2024-08-09 13:37:40 +02:00
|
|
|
|
2024-08-09 13:40:55 +02:00
|
|
|
- Supports browsers, [Node.js](https://nodejs.org), [Deno](https://deno.com), [Bun](https://bun.sh), and probably some other environments.
|
2022-10-09 10:10:43 +02:00
|
|
|
- Comes with 45 colors and helpers.
|
2024-08-09 14:03:36 +02:00
|
|
|
- Respects [`NO_COLOR`](https://no-color.org/).
|
2022-10-09 10:10:43 +02:00
|
|
|
- No dependencies.
|
2024-08-09 13:37:40 +02:00
|
|
|
- Tree-shakeable.
|
2022-10-09 10:10:43 +02:00
|
|
|
|
|
|
|
## Colors and helpers
|
|
|
|
|
|
|
|
bgBlack, bgBlue, bgBrightBlack, bgBrightBlue, bgBrightCyan, bgBrightGreen, bgBrightMagenta, bgBrightRed, bgBrightWhite, bgBrightYellow, bgCyan, bgGreen, bgMagenta, bgRed, bgRgb24, bgRgb8, bgWhite, bgYellow, black, blue, bold, brightBlack, brightBlue, brightCyan, brightGreen, brightMagenta, brightRed, brightWhite, brightYellow, cyan, dim, getColorEnabled, gray, green, hidden, inverse, italic, magenta, red, reset, strikethrough, stripColor, underline, white, yellow
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2024-08-09 13:37:40 +02:00
|
|
|
import { cyan, bgMagenta } from 'trmclr';
|
2022-10-09 10:10:43 +02:00
|
|
|
|
|
|
|
console.log(cyan(bgMagenta('Some text')));
|
|
|
|
```
|
|
|
|
|
2024-08-09 15:01:08 +02:00
|
|
|
### Enable or disable color
|
2022-10-09 10:10:43 +02:00
|
|
|
|
2024-08-09 15:01:08 +02:00
|
|
|
```js
|
|
|
|
import { getColorEnabled, setColorEnabled } from 'trmclr';
|
|
|
|
|
|
|
|
setColorEnabled(true);
|
|
|
|
setColorEnabled(false);
|
|
|
|
|
|
|
|
getColorEnabled(); // → false
|
|
|
|
```
|
|
|
|
|
|
|
|
### Remove colors and decorations
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { cyan, stripColor } from 'trmclr';
|
|
|
|
|
|
|
|
stripColor(cyan('Hi')); // → uncolored "Hi"
|
|
|
|
```
|
2022-10-09 10:10:43 +02:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2024-08-09 13:36:32 +02:00
|
|
|
(c) 2022-2024 [Romein van Buren](mailto:romein@vburen.nl). Licensed under the MIT license.
|
|
|
|
|
|
|
|
For the full copyright and license information, please see the [`LICENSE.md`](./LICENSE.md) file that was distributed with this source code.
|
|
|
|
|
2024-08-09 13:40:55 +02:00
|
|
|
Original implementation: (c) 2018-2022 [the Deno authors](https://github.com/denoland/std/blob/0.159.0/fmt/colors.ts).
|
|
|
|
|
2024-08-09 13:36:32 +02:00
|
|
|
[![Smart Yellow](https://code.smartyellow.net/smartyellow/meta/raw/branch/main/logo.png)](https://www.smartyellow.nl)
|