Leon4gr45's picture
Include updated package-lock.json (part 11)
2a1c46d verified
|
Raw
History Blame Contribute Delete
966 Bytes
# @nodable/entities
Fast, zero-dependency XML/HTML entity encoder and decoder for Node.js.
## Install
```bash
npm install @nodable/entities
```
## Quick start
```js
import { EntityEncoder, EntityDecoder, ALL_ENTITIES } from '@nodable/entities';
// Encode: plain text β†’ entity references
const enc = new EntityEncoder();
enc.encode('Hello Β© 2024 & <stuff>');
// β†’ 'Hello &copy; 2024 &amp; &lt;stuff&gt;'
// Decode: entity references β†’ plain text
const dec = new EntityDecoder({ namedEntities: ALL_ENTITIES });
dec.decode('Hello &copy; 2024 &amp; &lt;stuff&gt;');
// β†’ 'Hello Β© 2024 & <stuff>'
```
## Performance
| | encode | decode |
|---|---|---|
| `entities` (npm) | 3.65 M req/s | 1.76 M req/s |
| `@nodable/entities` | 3.33 M req/s | **5.19 M req/s** |
## Documentation
- [EntityEncoder](docs/EntityEncoder.md) β€” options, API, recipes
- [EntityDecoder](docs/EntityDecoder.md) β€” options, API, security limits, entity sets
## License
MIT