Skip to content

Commit 23d4c36

Browse files
committed
docs: update readme
1 parent fd33a4d commit 23d4c36

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

README.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ Ansis is focused on [small size](#compare-size) and [speed](#benchmark) while pr
4141
- [ANSI 16 colors](#base-colors): `red`, `redBright`, `bgRed`, `bgRedBright`, ...
4242
- [ANSI 256 colors](#256-colors): `fg()`, `bg()`
4343
- [Truecolor](#truecolor) (**RGB & HEX**): `rgb()`, `bgRgb()`, `hex()`, `bgHex()`
44+
- Auto-detects [color support](#color-support): Truecolor, 256 colors, 16 colors, no colors
4445
- Automatic [fallback](#fallback): Truecolor → 256 colors → 16 colors → no colors
45-
- [Extend base colors](#extend-colors) with named Truecolor values
46+
- Allows [extending base colors](#extend-colors) with named Truecolor values
4647
- Raw ANSI escape codes: ``` `foo ${red.open}red{red.close} bar` ```
4748
- Strip ANSI escape codes with `ansis.strip()`
48-
- Auto-detects [color support](#color-support) across a wide range of [environments](#color-support)
4949
- Supports [ENV variables](#cli-vars) and [flags](#cli-flags): [`NO_COLOR`](using-env-no-color), [`FORCE_COLOR`](#using-env-force-color), [`COLORTERM`](#using-env-colorterm), `--no-color`, `--color`
50-
- Reliable [CLI testing](#cli-testing) by forcing specific [color levels](#color-levels): no color, 16, 256 or truecolor
50+
- Enables reliable [CLI testing](#cli-testing) with forced [color levels](#color-levels): no color, 16, 256 or Truecolor
5151
- Replacement for [`chalk`](#replacing-chalk) [`ansi-colors`](#replacing-ansi-colors) [`colorette`](#replacing-colorette) [`picocolors`](#replacing-picocolors) and others [alternatives](#alternatives)
5252

5353
<a id="install" name="install"></a>
@@ -97,7 +97,7 @@ The most popular ANSI libraries, similar to Ansis:
9797
## [Why use Ansis](#switch-to-ansis)
9898

9999
As of 2025, two of the [smallest](#compare-size) and [fastest](#benchmark) ANSI libraries are **Ansis** and **Picocolors**.
100-
Both are [recommended](https://github.com/es-tooling/module-replacements/blob/main/docs/modules/chalk.md) by the [ES Tooling](https://github.com/es-tooling) community as modern replacements for older, larger libraries.
100+
Both are [recommended](https://github.com/es-tooling/module-replacements/blob/main/docs/modules/chalk.md) by the e18e community as modern replacements for older, larger libraries.
101101

102102

103103
### 📦 Unpacked size
@@ -108,24 +108,25 @@ The package size in `node_modules` directory:
108108
- `аnsis`: [5.7 kB][npm-ansis] (minimized) - A powerful library with a rich set of features.
109109
- `chalk`: [44.2 kB][npm-chalk] (not minimized) - Provides similar functionality to Ansis.
110110

111+
See [Compare package sizes](#compare-size).
112+
111113
### ⚡ Performance
112114

113115
- `picocolors`: The [fastest](#bench-simple) when applying a single style (e.g., `red`) only.
114116
- `аnsis`: The [fastest](#bench-2-styles) when applying two or more styles (e.g., `red` + `bgWhite`).
115117
- `chalk`: Slower than both **Ansis** and **Picocolors** in all use cases.
116118

119+
See [Benchmarks](#benchmark).
120+
117121
> [!CAUTION]
118-
> **Picocolors** doesn't handle important **edge cases**, so it is the fastest.
119-
>
120-
> **Picocolors** is faster only in a [simple](#bench-simple) micro-benchmark, which does not reflect real world usage.\
121-
> In a more complex benchmark, **Ansis** is much [closer](#bench-picocolors-complex) to **Picocolors** results or even [faster](#bench-3-styles).
122+
> **Picocolors** is the fastest in a [simple micro-benchmark](#bench-simple) because it doesn't handle important edge cases.
123+
> However, that benchmark doesn't reflect real-world usage.
124+
> In more complex and realistic benchmarks, Ansis performance is [comparable to Picocolors](#bench-picocolors-complex), or even [faster](#bench-3-styles).
122125
123126
<a id="edge-cases" name="edge-cases"></a>
124127
### 🧩 Edge cases
125128

126-
#### Absent, `undefined` or `null` arguments
127-
128-
**Ansis** handles these cases correctly.
129+
#### Handling falsy arguments
129130

130131
```js
131132
ansis.red() // ✅ ''
@@ -140,24 +141,17 @@ ansis.red(null) // ✅ ''
140141
chalk.red(null) // ❌ \e[31mnull\e[39m
141142
pico.red(null) // ❌ \e[31mnull\e[39m
142143

144+
ansis.red('') // ✅ ''
145+
chalk.red('') // ✅ ''
146+
pico.red('') // ❌ \e[31m\e[39m
147+
143148
ansis.reset() // ✅ \e[0m
144149
chalk.reset() // ❌ ''
145150
pico.reset() // ❌ \e[0mundefined\e[0m
146151
```
147152

148153
See more details about [handling input arguments](#handling-input-arguments) in various libraries.
149154

150-
#### Empty string
151-
152-
**Ansis** and **Chalk** handle this case and return an empty string without ANSI codes as expected.\
153-
However, **Picocolors** doesn't handle this case.
154-
155-
```js
156-
ansis.red('') // ✅ ''
157-
chalk.red('') // ✅ ''
158-
pico.red('') // ❌ \e[31m\e[39m
159-
```
160-
161155
#### Break style at New Line
162156

163157
**Ansis** and **Chalk** add a style break at each `new line` to correctly display multi-line text.\
@@ -203,8 +197,7 @@ As of 2025, only **Ansis**, **Chalk**, and **Picocolors** are actively maintaine
203197
- If you only use a single style, e.g., `red('foo')`, **Picocolors** is the best solution.
204198

205199
- However, if you need more, like combining multiple styles (e.g., `red` + `bold` + `bgWhite`),\
206-
[256 colors](#256-colors), [Truecolor](#truecolor),
207-
or support for a wide range of [environments](#color-support),
200+
[256 colors](#256-colors) or [Truecolor](#truecolor)
208201
then **Ansis** is the better choice.
209202

210203
#### Checklist:

0 commit comments

Comments
 (0)