Conversation
ChALkeR
commented
Feb 21, 2026
|
|
||
| export function isomorphicEncode(str) { | ||
| const res = latin1fromString(str) | ||
| // match new Uint8Array, which is non-pooled |
Collaborator
Author
There was a problem hiding this comment.
See #64, but this is a safeguard for now
ChALkeR
commented
Feb 21, 2026
| * Same as `@exodus/bytes/encoding.js`, but in browsers instead of polyfilling just uses whatever the | ||
| * browser provides, drastically reducing the bundle size (to less than 2 KiB gzipped). | ||
| * | ||
| * Does not provide `isomorphicDecode` and `isomorphicEncode` exports. |
Collaborator
Author
There was a problem hiding this comment.
Perhaps will add later, unsure
076f2ac to
c1090ba
Compare
There was a problem hiding this comment.
Pull request overview
Adds WHATWG Infra “isomorphic encode/decode” APIs to the library’s encoding entrypoints to reduce confusion around the overloaded “latin1”/“iso-8859-1” terminology (see #55), and documents preferred usage accordingly.
Changes:
- Introduce
isomorphicDecode()/isomorphicEncode()in the fallback encoding implementation and re-export them fromencoding.jsandencoding-lite.js. - Update TypeScript declarations and README to document the new APIs and recommend them over
latin1toString/latin1fromString. - Adjust
encoding-browser*exports so browser bundles do not expose the isomorphic helpers (per docs), keeping the lightweight surface area.
Reviewed changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| single-byte.d.ts | Doc updates recommending the new isomorphic helpers over “latin1” helpers. |
| fallback/encoding.js | Implements isomorphicDecode/isomorphicEncode using existing single-byte helpers + input normalization. |
| encoding.js | Re-exports isomorphicDecode/isomorphicEncode from fallback. |
| encoding.d.ts | Adds TS declarations and docs for the new isomorphic APIs. |
| encoding-lite.js | Re-exports the new isomorphic APIs. |
| encoding-lite.d.ts | Docs/examples updated to include the new isomorphic APIs. |
| encoding-browser.native.js | Switches to explicit named re-exports to intentionally omit isomorphic APIs. |
| encoding-browser.js | Routes exports through encoding-browser.native.js (so isomorphic APIs aren’t exposed). |
| encoding-browser.d.ts | Documents and enforces that isomorphic APIs are not exported from encoding-browser. |
| README.md | Documents the new APIs and recommends them over latin1* helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #55
Refs:
This is validating and throws on attempting to encode a non-isomorphic string.