subshape
subshape copied to clipboard
composable shapes for cohesive code
While an all-encompassing union codec (such as that described in #152) might be excessive, we may benefit from an `$.exactUnion` codec, which would be used to describe exact discriminated unions....
Ideally one could extract the native types of specific members of tagged unions. Let's say we want to extract the `$capiBinary` variant-specific type: ```ts const $pathBinary = $.variant("path", $.str) const...
See https://github.com/paritytech/scale-ts/issues/129#issuecomment-1452929923
```ts export function encoded($inner: Codec): $.Codec ``` Should encode compatibly with `$inner`. For encoding, it just inserts the array, and for decoding, it should call `$inner._decode` to determine the length...
Name TBD – `srpc`? `scalar`? ```ts // api.ts import { $func } from "srpc" export const $api = $.object( $.field("a", $func($.tuple(), $.str)), $.field("b", $func($.tuple(), $.str)), $.field("c", $func($.tuple($.str, $.i8), $.field("some", $.str)))...
Feature idea: utils for manipulating existing codecs for the sake of versioning. Let's say we're using the following codec to model an event. `v1.ts` ```ts export const $superhero = $.object(...