-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(experimental): add getConstantCodec to @solana/codecs-data-structures #2400
Conversation
🦋 Changeset detectedLatest commit: 2e26dc2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/codecs-core/src/bytes.ts
Outdated
* Returns true if and only if the provided `data` byte array contains | ||
* the provided `bytes` byte array at the specified `offset`. | ||
*/ | ||
export function containsBytes(data: Uint8Array, bytes: Uint8Array, offset: number): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will return true
if both data
and bytes
are of zero length. I don't know how you feel about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does nothing not contain nothing? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be9cd7d
to
0f4a813
Compare
de07627
to
a12ceaf
Compare
0f4a813
to
2637627
Compare
a12ceaf
to
38e77a3
Compare
2637627
to
1b06158
Compare
38e77a3
to
d83ae42
Compare
Merge activity
|
1b06158
to
8b0af35
Compare
d83ae42
to
2e26dc2
Compare
🎉 This PR is included in version 1.91.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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. |
This PR adds two new helpers:
containsBytes
andgetConstantCodec
.The
containsBytes
helper checks if aUint8Array
contains anotherUint8Array
at a given offset.The
getConstantCodec
function accepts anyUint8Array
and returns aCodec<void>
. When encoding, it will set the providedUint8Array
as-is. When decoding, it will assert that the next bytes contain the providedUint8Array
and move the offset forward.