Skip to content

Comments

feat: isomorphic encode/decode#68

Merged
ChALkeR merged 2 commits intomainfrom
chalker/isomorphic/0
Feb 23, 2026
Merged

feat: isomorphic encode/decode#68
ChALkeR merged 2 commits intomainfrom
chalker/isomorphic/0

Conversation

@ChALkeR
Copy link
Collaborator

@ChALkeR ChALkeR commented Feb 21, 2026


export function isomorphicEncode(str) {
const res = latin1fromString(str)
// match new Uint8Array, which is non-pooled
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #64, but this is a safeguard for now

* 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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps will add later, unsure

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from encoding.js and encoding-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.

@ChALkeR ChALkeR merged commit 593fe7e into main Feb 23, 2026
32 of 33 checks passed
@ChALkeR ChALkeR deleted the chalker/isomorphic/0 branch February 23, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant