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

add oneOf #7

Merged
merged 1 commit into from
Sep 25, 2022
Merged

add oneOf #7

merged 1 commit into from
Sep 25, 2022

Conversation

azerum
Copy link
Contributor

@azerum azerum commented Sep 23, 2022

My try on generic function for use case #6

For the following structure:

const OneOf = sd.oneOf({
  a: sd.uint8,
  b: sd.array(sd.uint8, sd.uint8)
});

It will create Serdes<T> where T is:

type OneOf = {
  type: 'a';
  value: number;
} | { 
  type: 'b';
  value: number[];
}   

P.S. Thank you for such an elegant and nice to use library

@weisrc weisrc merged commit 2912a25 into weisrc:main Sep 25, 2022
@weisrc
Copy link
Owner

weisrc commented Sep 25, 2022

Thank you for contributing! Seems like it fails in automated tests. I will investigate why.

github-actions bot added a commit that referenced this pull request Sep 25, 2022
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.

2 participants