npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nodable/entities

v3.0.0

Published

Entity parser for XML, HTML, External entites with security and NCR control

Readme

@nodable/entities

Fast, zero-dependency XML/HTML entity encoder and decoder for Node.js.

Install

npm install @nodable/entities

Quick start

import { EntityEncoder, EntityDecoder, ALL_ENTITIES } from '@nodable/entities';

// Encode: plain text → entity references
// v3 requires an explicit entity set when encoding named (non‑ASCII) characters
const enc = new EntityEncoder({ namedEntities: ALL_ENTITIES });
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>'

If you only need to encode XML‑unsafe characters (&, <, >, ", '), you can disable named‑entity encoding entirely and avoid importing any entity set:

const enc = new EntityEncoder({ encodeAllNamed: false });
enc.encode('© <stuff>'); // → '© &lt;stuff&gt;'  (copyright stays literal)

To encode only a specific subset of characters (e.g. common HTML entities), pass a custom map:

import { EntityEncoder, COMMON_HTML, CURRENCY } from '@nodable/entities';

const enc = new EntityEncoder({ namedEntities: { ...COMMON_HTML, ...CURRENCY } });
enc.encode('Price: 10 © 2024'); // only COMMON_HTML/CURRENCY entities are recognized

Migration from v2 to v3

Breaking change:
In v2, new EntityEncoder() automatically used the full built‑in entity set to encode non‑ASCII characters (like ©&copy;). This caused poor tree‑shaking: every consumer paid the cost of the entire entity table, even if they never used it.

In v3, EntityEncoder no longer includes a default entity set.
If you pass no options and encodeAllNamed is true (the default), the constructor will throw an error:

const enc = new EntityEncoder(); // throws: "encodeAllNamed is true but no `namedEntities` was provided"

How to update

| What you need | v2 code | v3 code | |---------------|---------|---------| | Full built‑in set (same as v2) | new EntityEncoder() | import { ALL_ENTITIES } from '@nodable/entities';new EntityEncoder({ namedEntities: ALL_ENTITIES }) | | Only XML‑unsafe chars (no named entities) | new EntityEncoder({ encodeAllNamed: false }) | Same – no change | | Custom subset | new EntityEncoder({ namedEntities: myMap }) | Same – but now your map is required for named‑entity encoding |

This change allows bundlers to tree‑shake unused entity categories – you only pay for the characters you actually encode.

Upgrading step‑by‑step

  1. Update to @nodable/[email protected].
  2. Find all new EntityEncoder() calls in your project.
  3. Decide:
    • If you need the full set: import ALL_ENTITIES and pass it as namedEntities.
    • If you only need XML‑unsafe escaping: add { encodeAllNamed: false }.
    • If you used a custom set: keep it as‑is – it already worked.
  4. Run your tests – the encoder should now behave as before, but with better bundle size.

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

License

MIT