Skip to content

Commit

Permalink
docs(readme): Add Features section, plus small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Aug 19, 2021
1 parent 720a36d commit 3f66dd6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "entities",
"version": "3.0.1",
"description": "Encode & decode XML and HTML entities with ease",
"description": "Encode & decode XML and HTML entities with ease & speed",
"author": "Felix Boehm <me@feedic.com>",
"funding": "https://github.com/fb55/entities?sponsor=1",
"sideEffects": false,
Expand Down
29 changes: 21 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Encode & decode HTML & XML entities with ease & speed.

## Features

- ⚔️ Battle tested: `entities` is used by many popular libraries; eg.
[`htmlparser2`](https://github.com/fb55/htmlparser2), the official
[AWS SDK](https://github.com/aws/aws-sdk-js-v3) and
[`commonmark`](https://github.com/commonmark/commonmark.js) use it to
process HTML entities.
- ⚡️ Fast: `entities` is the fastes library for decoding HTML entities (as of
August 2021); see [performance](#performance).
- 🎛 Configurable: Get an output tailored for your needs. You are fine with
UTF8? That'll safe you some bytes. Prefer to only have ASCII characters? We
can do that as well!

## How to…

### …install `entities`
Expand All @@ -26,14 +39,14 @@ entities.decodeHTML("asdf &amp; &yuml; &uuml; &apos;"); // "asdf & ÿ ü '"
## Performance

This is how `entities` compares to other libraries on a very basic benchmark
(see `scripts/benchmark.ts`, for 10,000,000 iterations):
(see `scripts/benchmark.ts`, for 10,000,000 iterations; **lower is better**):

| Library | `decode` perf | `encode` perf | `escape` perf | Bundle size |
| -------------- | ------------- | ------------- | ------------- | -------------------------------------------------------------------------- |
| entities | 1.418s | 6.786s | 2.196s | ![npm bundle size](https://img.shields.io/bundlephobia/min/entities) |
| html-entities | 2.530s | 6.829s | 2.415s | ![npm bundle size](https://img.shields.io/bundlephobia/min/html-entities) |
| he | 5.800s | 24.237s | 3.624s | ![npm bundle size](https://img.shields.io/bundlephobia/min/he) |
| parse-entities | 9.660s | N/A | N/A | ![npm bundle size](https://img.shields.io/bundlephobia/min/parse-entities) |
| Library | Version | `decode` perf | `encode` perf | `escape` perf |
| -------------- | ------- | ------------- | ------------- | ------------- |
| entities | `3.0.1` | 1.418s | 6.786s | 2.196s |
| html-entities | `2.3.2` | 2.530s | 6.829s | 2.415s |
| he | `1.2.0` | 5.800s | 24.237s | 3.624s |
| parse-entities | `3.0.0` | 9.660s | N/A | N/A |

---

Expand All @@ -54,7 +67,7 @@ As of August 2021, `entities` is a bit faster than other modules. Still, this is
not a very differentiated space and other modules can catch up.

**More importantly**, you might already have `entities` in your dependency graph
(as a dependency of eg. cheerio, or htmlparser2), and including it directly
(as a dependency of eg. `cheerio`, or `htmlparser2`), and including it directly
might not even increase your bundle size. The same is true for other entity
libraries, so have a look through your `node_modules` directory!

Expand Down

0 comments on commit 3f66dd6

Please sign in to comment.