Skip to content

Commit

Permalink
Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwoplaza committed Feb 29, 2024
1 parent 51214b9 commit b3ba0ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Serialise and deserialise typed schemas without the need for redundant interface

![Basic Type and Documentation Inference](/docs/media/basic-type-and-doc-inferrence.gif)

Above is a self-contained code snippet using typed-binary. The IDE can properly infer what `Dog` is. What's even more interesting, is that the "parsed" properties inherit the schema's **JSDocs** (seen on the gif above).
Above is a self-contained code snippet using typed-binary. The IDE can properly infer what `Dog` is.

## Highlight feature

Expand All @@ -39,7 +39,6 @@ The feature I am most proud of would have to be [recursive types](#recursive-typ
# Features:

- [Type-safe schema definition system](#defining-schemas) (your IDE will know what structure the parsed binary is in).
- [JSDoc inheritance](#prioritising-developer-experience)
- [Estimating the size of any resulting binary object (helpful for creating buffered storage)](#serialization-and-deserialization)

### Why Typed Binary over other libraries?
Expand Down
Binary file modified docs/media/basic-type-and-doc-inferrence.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/dog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//

import { object, tupleOf, string, i32, f32, Parsed } from 'typed-binary';

// Describing the Dog schema
const Dog = object({
name: string,
position: tupleOf([f32, f32, f32]),
age: i32,
});

// Creating a type-alias for ease-of-use.
type Dog = Parsed<typeof Dog>;

// Creating a 'Dog' object.
const dog: Dog = {
position: [0, 1, 2],
age: 123,
name: 'Spikey',
};

0 comments on commit b3ba0ba

Please sign in to comment.