Skip to content
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

feat: add assert method to codec #142

Merged
merged 3 commits into from Mar 12, 2023
Merged

feat: add assert method to codec #142

merged 3 commits into from Mar 12, 2023

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Mar 12, 2023

// using `$.assert` (no explicit typing required)
const a: unknown = 1
$.assert($.u8, a)
a // `number`

// using `Codec.assert` (explicit typing required)
const b: unknown = 2
const u8: $.Codec<number> = $.u8
u8.assert(b)
b // `number`

common/codec.ts Outdated Show resolved Hide resolved
common/codec.ts Outdated Show resolved Hide resolved
Co-authored-by: T6 <t6@t6.fyi>
@harrysolovay harrysolovay merged commit 12b671d into main Mar 12, 2023
@harrysolovay harrysolovay deleted the assert-method branch March 12, 2023 16:12
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.

None yet

3 participants