Skip to content

Commit

Permalink
chore: reduce unpacked size by ~ 1 KB
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Jul 12, 2024
1 parent a581710 commit d1be810
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log

## 3.2.1 (2024-07-12)

- chore: reduce unpacked size by ~ 1 KB
- docs: optimize README for NPM

## 3.2.0 (2024-04-24)

- feat: add `ansis.isSupported()` method to detect color support
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
[![Test](https://github.com/webdiscus/ansis/actions/workflows/test.yml/badge.svg)](https://github.com/webdiscus/ansis/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/webdiscus/ansis/branch/master/graph/badge.svg?token=H7SFJONX1X)](https://codecov.io/gh/webdiscus/ansis)
[![downloads](https://img.shields.io/npm/dm/ansis)](https://www.npmjs.com/package/ansis)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/ansis@3.2.0)](https://bundlephobia.com/package/ansis@3.2.0)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/ansis)](https://bundlephobia.com/package/ansis)

Colorize terminal with ANSI colors & styles, **smaller** and **faster** alternative to [Chalk][chalk] with additional useful [features](#features).

#### Usage
🚀 [Install and Quick Start](#install)

## Usage

```js
import ansis, { red, green, cyan, black, ansi256, hex } from 'ansis';
Expand All @@ -28,8 +30,6 @@ ansi256(214)`Orange`
hex('#E0115F').bold.underline('TrueColor!')
```

🚀 [Install and Quick Start](#install)

<a id="top" name="top"></a>

## 👀 Why yet one lib?
Expand Down Expand Up @@ -63,7 +63,7 @@ See the [features comparison](#compare) and [benchmarks](#benchmark) of most pop
- Supports both **ESM** and **CommonJS**
- Supports **TypeScript**
- Supports **Bun**, **Deno**, **Next.JS** runtimes
- [Standard API](#base-colors) compatible with **Chalk**, switch from **Chalk** to **Ansis** without changing your code
- [Standard API](#base-colors), drop-in replacement for **Chalk**
```diff
- import chalk from 'chalk';
+ import chalk, { red } from 'ansis';
Expand All @@ -75,18 +75,18 @@ See the [features comparison](#compare) and [benchmarks](#benchmark) of most pop
```
- Default and [named import](#named-import) `import ansis, { red, bold, ansi256, hex } from 'ansis'`
- [Chained syntax](#chained-syntax) `red.bold.underline('text')`
- [Nested **template strings**](#nested-syntax) ``` red`RED text ${green`GREEN text`} RED text` ```
- [Base ANSI styles](#base-colors) `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s>
- [Base ANSI 16 colors](#base-colors) ``` red`Error!` ``` ``` redBright`Error!` ``` ``` bgRed`Error!` ``` ``` bgRedBright`Error!` ```
- [Nested **template strings**](#nested-syntax) ``` red`RED ${green`GREEN`} RED` ```
- [ANSI styles](#base-colors) `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s>
- [ANSI 16 colors](#base-colors) ``` red`Error!` ``` ``` redBright`Error!` ``` ``` bgRed`Error!` ``` ``` bgRedBright`Error!` ```
- [ANSI 256 colors](#256-colors) ``` fg(56)`violet` ``` ``` bg(208)`orange` ```
- [TrueColor](#truecolor) (**RGB**, **HEX**) ``` rgb(224, 17, 95)`Ruby` ```, ``` hex('#96C')`Amethyst` ```
- [TrueColor](#truecolor) (**RGB**, **HEX**) ``` rgb(224, 17, 95)`Ruby` ``` ``` hex('#96C')`Amethyst` ```
- [Fallback](#fallback) to supported [color space](#color-support): TrueColor → 256 colors → 16 colors → no colors
- [Extending of base colors](#extend-colors) with named **True Colors**
- [ANSI codes](#escape-codes) as `open` and `close` properties ``` `Hello ${red.open}World${red.close}!` ```
- [Raw ANSI codes](#escape-codes) as `open` and `close` properties ``` `foo ${red.open}red{red.close} bar` ```
- [Strip ANSI codes](#strip) method `ansis.strip()`
- [Correct style break](#new-line) at the `end of line` when used `\n` in string
- Supports [environment variables](#cli-vars) `NO_COLOR` `FORCE_COLOR` and flags `--no-color` `--color`
- Detect [color support](#color-support) using `ansis.isSupported()` method
- Supports [environment variables](#cli-vars) `NO_COLOR` `FORCE_COLOR` and flags `--no-color` `--color`
- [Correct style break](#new-line) at the `end of line` when used `\n` in string
- Doesn't extend `String.prototype`
- Zero dependencies

Expand Down
58 changes: 26 additions & 32 deletions README.npm.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<p align="center">
<a href="https://github.com/webdiscus/ansis">
<img width="323" src="docs/img/ansis-logo.png" alt="ansis"><br>
<img width="323" src="https://github.com/webdiscus/ansis/raw/master/docs/img/ansis-logo.png" alt="ansis"><br>
ANSI Styling
</a>
</p>

---
[![node](https://img.shields.io/node/v/ansis)](https://nodejs.org)
[![Test](https://github.com/webdiscus/ansis/actions/workflows/test.yml/badge.svg)](https://github.com/webdiscus/ansis/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/webdiscus/ansis/branch/master/graph/badge.svg?token=H7SFJONX1X)](https://codecov.io/gh/webdiscus/ansis)
[![node](https://img.shields.io/npm/dm/ansis)](https://www.npmjs.com/package/ansis)
[![size](https://img.shields.io/bundlephobia/minzip/ansis)](https://bundlephobia.com/package/ansis)

Colorize terminal with ANSI colors & styles, **smaller** and **faster** alternative to [Chalk](https://github.com/chalk/chalk).
Colorize terminal with ANSI colors & styles, smaller and faster alternative to Chalk.

#### Usage example
🚀 [Install and Quick Start](https://github.com/webdiscus/ansis#install)

📖 [Read full docs on GitHub](https://github.com/webdiscus/ansis)

## Usage

```js
import ansis, { red, green, black, ansi256, hex } from 'ansis';
Expand All @@ -23,41 +26,32 @@ green('Succeful!')
red`Error!`
black.bgYellow`Warning!`
ansi256(214)`Orange`
hex('#E0115F').bold.underline('Hello TrueColor!')
hex('#E0115F').bold.underline('TrueColor')
```

🚀 [Install and Quick Start](https://github.com/webdiscus/ansis#install)\
📖 [Read full docs on GitHub](https://github.com/webdiscus/ansis)

## 🏆 Compare & Benchmark

See the [features comparison](https://github.com/webdiscus/ansis#compare) and [benchmarks](https://github.com/webdiscus/ansis#benchmark) of most popular terminal colors libraries:\
`ansis` `chalk` `kleur` `kolorist` `colors.js` `colorette` `picocolors` `ansi-colors` `cli-color` `colors-cli`.

## 💡 Highlights

![ANSI demo](docs/img/ansis-demo.png)

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/stackblitz-starters-gs2gve?file=index.js)

- Supports **ESM**, **CommonJS**, **TypeScript**, **Bun**, **Deno**, **Next.JS**
- [Standard API](https://github.com/webdiscus/ansis#base-colors) compatible with **Chalk**
- Default and [named import](https://github.com/webdiscus/ansis#named-import) `import ansis, { red, green, bold, underline } from 'ansis'`
- [Chained syntax](https://github.com/webdiscus/ansis#chained-syntax) `red.bold.underline('text')`
- [Nested **template strings**](https://github.com/webdiscus/ansis#nested-syntax) ``` red`RED text ${green`GREEN text`} RED text` ```
- [Base ANSI styles](https://github.com/webdiscus/ansis#base-colors) `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s>
- [Base ANSI 16 colors](https://github.com/webdiscus/ansis#base-colors) ``` red`Error!` ``` ``` redBright`Error!` ``` ``` bgRed`Error!` ``` ``` bgRedBright`Error!` ```
- [ANSI 256 colors](https://github.com/webdiscus/ansis#256-colors) ``` fg(56)`violet` ``` ``` bg(208)`orange` ```
- [TrueColor](https://github.com/webdiscus/ansis#truecolor) (**RGB**, **HEX**) ``` rgb(224, 17, 95)`Ruby` ```, ``` hex('#96C')`Amethyst` ```
- [Fallback](https://github.com/webdiscus/ansis#fallback) to supported color space: TrueColor → 256 colors → 16 colors → no colors
- [ANSI codes](https://github.com/webdiscus/ansis#escape-codes) as `open` and `close` properties ``` `Hello ${red.open}World${red.close}!` ```
- [Strip ANSI codes](https://github.com/webdiscus/ansis#strip) method `ansis.strip()`
- [Correct style break](https://github.com/webdiscus/ansis#new-line) at the `end of line` when used `\n` in string
- Detect [color support](https://github.com/webdiscus/ansis#color-support) using `ansis.isSupported()` method
- Supports [CLI](https://github.com/webdiscus/ansis#cli-vars) `NO_COLOR` `FORCE_COLOR` `--no-color` `--color`
![ANSI demo](https://github.com/webdiscus/ansis/raw/master/docs/img/ansis-demo.png)

- Supports ESM, CommonJS, TypeScript, Bun, Deno, Next.JS
- [Standard API](https://github.com/webdiscus/ansis#base-colors), drop-in replacement for Chalk
- Default and named import: `import ansis, { red, bold, hex } from 'ansis'`
- Chained syntax: `red.bold.underline('text')`
- Nested template strings: ``` red`RED ${green`GREEN`} RED` ```
- ANSI styles: `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s>
- ANSI 16 colors: ``` red`Error!` ``` ``` redBright`Error!` ``` ``` bgRed`Error!` ``` ``` bgRedBright`Error!` ```
- ANSI 256 colors: ``` fg(56)`violet` ``` ``` bg(208)`orange` ```
- TrueColor: ``` rgb(224, 17, 95)`Ruby` ``` ``` hex('#96C')`Amethyst` ```
- Color fallback: TrueColor → 256 colors → 16 colors → no colors
- Raw ANSI codes: ``` `foo ${red.open}red{red.close} bar` ```
- Strip ANSI codes: `ansis.strip()`
- Detect color support: `ansis.isSupported()`
- Supports CLI: `NO_COLOR` `FORCE_COLOR` `--no-color` `--color`
- Correct style break at the `end of line` when used `\n`
- Doesn't extend `String.prototype`
- Zero dependencies

## License

[ISC](https://github.com/webdiscus/ansis/blob/master/LICENSE)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansis",
"version": "3.2.0",
"version": "3.2.1",
"description": "Colorize terminal with ANSI colors & styles",
"keywords": [
"ansi",
Expand Down
2 changes: 1 addition & 1 deletion package.npm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansis",
"version": "3.2.0",
"version": "3.2.1",
"description": "Colorize terminal with ANSI colors & styles",
"keywords": [
"ansi",
Expand Down

0 comments on commit d1be810

Please sign in to comment.