From b14b01287b779e6a755b776f047c4182c4ccd3f3 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 20 Jul 2026 16:13:24 +0800 Subject: [PATCH] docs: document color methods --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9081da..9359f8a 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,9 @@ logger.info('server started'); You can import `color` directly from `rslog` to style your own output: -It is a small wrapper around Node.js `styleText`, with a simpler API for common styling. +It is a small wrapper around Node.js +[`styleText`](https://nodejs.org/api/util.html#utilstyletextformat-text-options), +with a simpler API for common styling. ```js import { color, logger } from 'rslog'; @@ -196,6 +198,26 @@ logger.info(color.bold(color.blue('build complete'))); logger.error(color.red('something went wrong')); ``` +Each method accepts a `string` or `number` and returns a styled string. You can +combine multiple styles by nesting method calls. + +| Method | Effect | +| --------------------------- | ------------------------------ | +| `color.bold(text)` | Makes the text bold | +| `color.dim(text)` | Makes the text dim | +| `color.underline(text)` | Underlines the text | +| `color.strikethrough(text)` | Adds a strikethrough | +| `color.black(text)` | Colors the text black | +| `color.red(text)` | Colors the text red | +| `color.green(text)` | Colors the text green | +| `color.yellow(text)` | Colors the text yellow | +| `color.blue(text)` | Colors the text blue | +| `color.magenta(text)` | Colors the text magenta | +| `color.cyan(text)` | Colors the text cyan | +| `color.white(text)` | Colors the text white | +| `color.gray(text)` | Colors the text gray | +| `color.reset(text)` | Resets all styles for the text | + ## Environment Rslog supports Node.js `^20.19.0 || >=22.12.0`.