Repository navigation
Releases: fb55/entities
Release list
v8.1.0
Faster decoding & escaping, with smaller bundles. Encoding output stays compatible with v8.
Improvements
- Decoding:
decodeHTML1.19×,decodeHTMLStrict1.14×,decodeHTMLAttribute1.18×,decodeXML1.46×, defaultdecode1.44× as fast. #2248, #2348 - Escaping:
escapeUTF81.49×,escapeAttribute1.23×,escapeText1.33× as fast. #2247, #2348 - Encoding mostly ASCII 4 KiB prose:
encodeHTML1.70×,encodeNonAsciiHTML2.24×,encodeXML/escape2.46× as fast. On the short, dense benchmark input, HTML encoding is unchanged; XML encoding and defaultencodetake about 6% longer. #2246, #2348 - 19% smaller full bundle (18% gzipped), targeting ES2022.
Compared with v8.0.0; speedups are medians of nine runs on Node 26.8.1, Linux/x64. Short inputs use the repository benchmark fixtures; results vary with input.
Fixes
decodeHTMLAttributepreserves interrupted references such as¬in<, previously incorrectly decoded to¬in<. #2213decodeHTMLpreserves unterminated names such as&Xi$, previously incorrectly decoded toÂ. #2331decodeXMLand defaultdecodepreserve XML numeric code points:€now yields U+0080 instead of€. HTML decoding still yields€. By @adarshx01 in #2347.
Deprecations
- Use
String.prototype.codePointAtinstead ofgetCodePointfromentities/escape. #2268
Full Changelog: v8.0.0...v8.1.0
v8.0.0
What's Changed
- BREAKING CHANGE: entities is now ESM-only #2183
- BREAKING: Update engines to node >= 20.19.0
- Update tsconfig: target es2022
- BREAKING: Remove deprecated functions & polyfills
- BREAKING: Update engines to node >= 20.19.0
- Use shared eslint config #2157
Full Changelog: v7.0.1...v8.0.0
v7.0.1
v7.0.0
No changes in public API; a lot of internals changed though, for faster encoding & decoding and reduced memory usage.
Improvements
Reduced length of the encoded trie by 21% for HTML (from 15,242 words (uint16) to 12075), by:
- Adding a semicolon flag on value nodes, which means semicolons don't have to be encoded anymore.
- Compacting dict keys: two keys are now stored in each word, instead of one
- Compacting runs of 3 or more characters: successive characters are now also stored as two characters per word
Also reduces the size of the encoded table by 32% (after the previous change) by encoding it as base64.
Encodes the encode trie as a string, with a simple parser turning it into the previous structure on load. This leads to a 44% decrease in file size (from 24,034 to 13,392 bytes).
Uses bitmaps to replace regex when looking for ASCII code points that should be replaced with entities. Leads to a ~1.6x speed up for encodeHTML.
Miscellaneous
- Fix broken repository URL in package.json by @ExplodingCabbage in https://github.com/fb55/entities/pull/1919pull/1931
- Use Biome by @fb55 in #1953
New Contributors
- @ExplodingCabbage made their first contribution in #1919
Full Changelog: v6.0.1...v7.0.0
v6.0.1
v6.0.0
Features
- Improved bundler tree shaking by adding pure annotations by @Gravitonic in #1501
- BREAKING: Simplified deep import paths, to make entities work in old NodeJS versions by @fb55 in #1531
- If you are using deep imports, you will have to update them. Instead of importing
entities/dist/decode.js, importentities/decode. The same applies toescape.
- If you are using deep imports, you will have to update them. Instead of importing
- Automated publishes by @fb55 in #1532
entitiesis now available on both npm and JSR
- Enabled isolated declarations by @fb55 in #1522
Full Changelog: v5.0.0...v6.0.0
v5.0.0
What's Changed
- Improved code style (based on
eslint-plugin-unicorn) #1496 - Upgraded toolchain (to tshy, vitest, and tsx) #1497
Breaking Changes
⚠️ BREAKING: Thelibdirectory was renamed todistin #1497. Deep imports will have to be updated.
Full Changelog: v4.5.0...v5.0.0
v4.5.0
New Features
entities now features an EntityDecoder class that can be used to decode entities across multiple chunks. This is needed to parse streams, and will be the foundation for entity decoding in htmlparser2 and parse5.
For users of this library, the most welcome addition will be a new attribute decoding mode, which will ignore some entities that were previously parsed (eg. `foo=bar&=boo' will be left unchanged).
entities' decode functions all use the new decoder under the hood. There is a new decodeHTMLAttribute function for attribute parsing, and some rare edge-cases where entities diverged from the HTML spec have been eliminated.
Relevant PRs
- feat(decode): Add
EntityDecoderclass by @fb55 in #1136 - fix(decode): Handle chunks for numeric entities by @fb55 in #1146
Small Changes
- Typo fixes by @styfle #1032, @Jiralite #1060, and @sandeepkambham08 #1129
- Harden GitHub Actions by @step-security-bot in #928
Full Changelog: v4.4.0...v4.5.0
v4.4.0
- Smaller encode/decode maps by @sapphi-red in #909
- The encode and decode maps are now stored more space-efficiently, saving 44% in minified bundles, and cutting the size of the installed module by 52%.
Please note that some JavaScript minifiers, such as terser, will now produce non-ASCII output. If you use entities in the browser, please make sure you are set up to ship UTF-8 to clients, or set eg. terser's ascii_only option to false.
Full Changelog: v4.3.1...v4.4.0