Skip to content

Commit

Permalink
refactor(experimental): Fix codecs-data-structure documentation (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva authored Mar 9, 2024
1 parent f886f55 commit 71d404f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/codecs-data-structures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ enum Direction {
}

getScalarEnumCodec(Direction).encode(Direction.Right); // 0x01
getScalarEnumCodec(Direction).encode(1); // 0x01
getScalarEnumCodec(Direction).encode('Right'); // 0x01
getScalarEnumCodec(Direction).encode('Right' as Direction); // 0x01
getScalarEnumCodec(Direction).encode('RIGHT'); // 0x01
```

Expand Down Expand Up @@ -270,7 +269,7 @@ It requires the name and codec of each variant as a first argument. Similarly to
Here is how we can create a data enum codec for our previous example.

```ts
const messageCodec = getDataEnumCodec<Message>([
const messageCodec = getDataEnumCodec([
// Empty variant.
['Quit', getUnitCodec()],

Expand Down Expand Up @@ -311,7 +310,7 @@ messageCodec.encode({ __kind: 'Move', x: 5, y: 6 });
However, you may provide a number codec as the `size` option of the `getDataEnumCodec` function to customise that behaviour.

```ts
const u32MessageCodec = getDataEnumCodec<Message>([...], {
const u32MessageCodec = getDataEnumCodec([...], {
size: getU32Codec(),
});

Expand Down

0 comments on commit 71d404f

Please sign in to comment.