From 52c45d79060eecf3aa18ba1d1f8fe9238bfe3b13 Mon Sep 17 00:00:00 2001 From: rowan Date: Sat, 24 May 2025 21:40:34 -0500 Subject: [PATCH] add ivisitor to readme --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1063f69..63722d1 100644 --- a/README.md +++ b/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 { `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 { + 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