add ivisitor to readme
This commit is contained in:
parent
c7b21894f5
commit
52c45d7906
1 changed files with 16 additions and 1 deletions
17
README.md
17
README.md
|
@ -20,7 +20,7 @@ this library makes no assumptions about formats and loosely follows the architec
|
|||
|
||||
with the exception of iterables and classes, these types were chosen as they are the ones provided by Javascript's native `typeof` operator which is used internally for type checking.
|
||||
|
||||
there are four interfaces which are relevant to `serde-ts` users.
|
||||
there are five interfaces which are relevant to `serde-ts` users.
|
||||
|
||||
## `Serializer`
|
||||
|
||||
|
@ -76,6 +76,21 @@ interface Deserialize<T> {
|
|||
|
||||
`Deserialize` is responsible for transforming a value *from* the internal data model. it is the inverse of `Serialize`. depending on the `Deserialize` target, it may accept an iterable of numbers and produce a `Vector2`.
|
||||
|
||||
## `Visitor`
|
||||
```ts
|
||||
interface IVisitor<T> {
|
||||
visitBoolean(value: boolean): T
|
||||
visitNumber(value: number): T
|
||||
visitBigInt(value: bigint): T
|
||||
visitString(value: string): T
|
||||
visitSymbol(value: symbol): T
|
||||
visitNull(): T
|
||||
visitObject(access: IMapAccess): T
|
||||
visitIterable(access: IIterableAccess): T
|
||||
}
|
||||
```
|
||||
|
||||
a `Visitor` is part of the deserialization process and is how each data type is mapped from the internal data model to whatever the end structure is. `Deserialize` is responsible for creating a `Visitor` and giving it to a `Deserializer`. that `Visitor` will then be given every value once it has been deserialized into `serde-ts`'s internal model.
|
||||
|
||||
# Example
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue