Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Add ReadonlyUint8Array to codecs + allow decoding from it #2391

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

mcintyre94
Copy link
Contributor

@mcintyre94 mcintyre94 commented Mar 28, 2024

This PR adds the proposed ReadonlyUint8Array type to codecs-core. The Decoder interface is modified to allow decoding from a ReadonlyUint8Array | Uint8Array. This will allow us to use ReadonlyUint8Array for various byte encodings, while still being able to decode them as normal byte arrays.

The only place where I needed to add an extra copy is in reverseCodec, which was reversing the input bytes in place. It now creates and reverses a new Uint8Array from the input bytes.

Addresses #2362.

Copy link

changeset-bot bot commented Mar 28, 2024

⚠️ No Changeset found

Latest commit: 6d5b8ef

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mcintyre94 mcintyre94 changed the title refactor(experimental): Allow decoding with a ReadonlyUint8Array Add ReadonlyUint8Array to codecs + allow decoding from it Mar 28, 2024
@mcintyre94 mcintyre94 marked this pull request as ready for review March 28, 2024 17:10
@mcintyre94 mcintyre94 force-pushed the codecs-decode-readonly branch 2 times, most recently from 1030568 to a89252f Compare March 28, 2024 17:23
Copy link
Contributor

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

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

I'm pretty amazed that this is all that's required on the codecs side to support ReadonlyUint8Arrays. Thanks!

Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Added via Giphy

packages/codecs-core/src/reverse-codec.ts Show resolved Hide resolved
@mcintyre94 mcintyre94 force-pushed the add-new-transaction branch 4 times, most recently from 9e0e647 to da2fc12 Compare April 2, 2024 14:12
@mcintyre94 mcintyre94 force-pushed the codecs-decode-readonly branch from a89252f to f6d9e8e Compare April 2, 2024 14:20
@mcintyre94 mcintyre94 force-pushed the add-new-transaction branch 2 times, most recently from 9445912 to 39f3321 Compare April 2, 2024 14:55
Base automatically changed from add-new-transaction to master April 2, 2024 15:03
@mcintyre94 mcintyre94 force-pushed the codecs-decode-readonly branch from f6d9e8e to 6d5b8ef Compare April 2, 2024 15:04
@mcintyre94 mcintyre94 merged commit 78fda87 into master Apr 2, 2024
8 checks passed
@mcintyre94 mcintyre94 deleted the codecs-decode-readonly branch April 2, 2024 16:09
Copy link
Contributor

github-actions bot commented Apr 3, 2024

🎉 This PR is included in version 1.91.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants