From d1be810a1143abc081c350cad3b421a9760babeb Mon Sep 17 00:00:00 2001 From: biodiscus Date: Fri, 12 Jul 2024 12:07:35 +0200 Subject: [PATCH] chore: reduce unpacked size by ~ 1 KB --- CHANGELOG.md | 5 +++++ README.md | 24 ++++++++++---------- README.npm.md | 58 ++++++++++++++++++++++-------------------------- package.json | 2 +- package.npm.json | 2 +- 5 files changed, 45 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7209a79..2ad7023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 92afd4f..0696194 100644 --- a/README.md +++ b/README.md @@ -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'; @@ -28,8 +30,6 @@ ansi256(214)`Orange` hex('#E0115F').bold.underline('TrueColor!') ``` -🚀 [Install and Quick Start](#install) - ## 👀 Why yet one lib? @@ -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'; @@ -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`_ `underline` `strikethrough` -- [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`_ `underline` `strikethrough` +- [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 diff --git a/README.npm.md b/README.npm.md index a7b885c..6194957 100644 --- a/README.npm.md +++ b/README.npm.md @@ -1,19 +1,22 @@

- ansis
+ ansis
ANSI Styling

--- -[![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'; @@ -23,12 +26,9 @@ 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:\ @@ -36,28 +36,22 @@ See the [features comparison](https://github.com/webdiscus/ansis#compare) and [b ## 💡 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`_ `underline` `strikethrough` -- [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`_ `underline` `strikethrough` +- 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) diff --git a/package.json b/package.json index d9cb81a..28c1f8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ansis", - "version": "3.2.0", + "version": "3.2.1", "description": "Colorize terminal with ANSI colors & styles", "keywords": [ "ansi", diff --git a/package.npm.json b/package.npm.json index a4cb542..a1ddeb2 100644 --- a/package.npm.json +++ b/package.npm.json @@ -1,6 +1,6 @@ { "name": "ansis", - "version": "3.2.0", + "version": "3.2.1", "description": "Colorize terminal with ANSI colors & styles", "keywords": [ "ansi",