dessert
Classes
Interfaces
Argument()<Required, ReturnMultiple, IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:79
Type Parameters
| Type Parameter | Default type |
|---|---|
Required extends boolean | false |
ReturnMultiple extends boolean | false |
IgnoreInvalid extends boolean | false |
Argument():
ArgumentReturnType<Primitive,Required,ReturnMultiple,false>
Defined in: src/dessert/deserialization/types.d.ts:87
Return the next argument, if there is a next argument
Returns
ArgumentReturnType<Primitive, Required, ReturnMultiple, false>
Argument<
T>(...types):ArgumentReturnType<TypeOf<T>,Required,ReturnMultiple,IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:94
Return the next argument, if there is a next argument, requiring the argument to be of the given type
Type Parameters
| Type Parameter |
|---|
T extends [PrimitiveType, ...PrimitiveType[]] |
Parameters
| Parameter | Type |
|---|---|
...types | T |
Returns
ArgumentReturnType<TypeOf<T>, Required, ReturnMultiple, IgnoreInvalid>
Throws
If the next argument does not match any of the given types
Properties
if
if:
IgnoreInvalidextendsfalse?Argument<Required,ReturnMultiple,true> :never
Defined in: src/dessert/deserialization/types.d.ts:123
Return undefined instead of throwing if the next argument doesn't match the given types or enum values
required
required:
Requiredextendsfalse?Argument<true,ReturnMultiple,IgnoreInvalid> :never
Defined in: src/dessert/deserialization/types.d.ts:110
Throw if there is no next argument, rather than return undefined
rest
rest:
ReturnMultipleextendsfalse?Argument<Required,true,IgnoreInvalid> :never
Defined in: src/dessert/deserialization/types.d.ts:117
Return all remaining arguments rather than only the next argument
Methods
enum()
enum<
T>(...values):ArgumentReturnType<T[number],Required,ReturnMultiple,IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:103
Return the next argument, if there is a next argument, requiring the argument to be one of the given enum values
Type Parameters
| Type Parameter |
|---|
T extends Primitive[] |
Parameters
| Parameter | Type |
|---|---|
...values | T |
Returns
ArgumentReturnType<T[number], Required, ReturnMultiple, IgnoreInvalid>
Throws
If the next argument does not equal any of the given values
Child()<Required, Single>
Defined in: src/dessert/deserialization/types.d.ts:228
Type Parameters
| Type Parameter | Default type |
|---|---|
Required extends boolean | false |
Single extends boolean | false |
Child<
T,P>(name,deserializer, ...parameters):T|Requiredextendsfalse?undefined:never
Defined in: src/dessert/deserialization/types.d.ts:237
Returns the next child with the given name, if there is any
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
T | Required extends false ? undefined : never
Throws
If the deserializer fails
Properties
required
required:
Requiredextendsfalse?Child<true,Single> :never
Defined in: src/dessert/deserialization/types.d.ts:246
Throw if there is no next child with the given name, instead of returning undefined
single
single:
Singleextendsfalse?Child<Required,true> :never
Defined in: src/dessert/deserialization/types.d.ts:251
Throw if there are multiple nodes left with the given name
Children()
Defined in: src/dessert/deserialization/types.d.ts:254
Children<
T,P>(name,deserializer, ...parameters):T[]
Defined in: src/dessert/deserialization/types.d.ts:260
Returns all remaining children with the given name
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
T[]
Throws
If the deserializer fails
Properties
entries()
entries: <
T,P>(deserializer, ...parameters) => [string,T][]
Defined in: src/dessert/deserialization/types.d.ts:278
Returns all remaining children with their name
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[string, T][]
Throws
If the deserializer fails
filtered()
filtered: <
T,P>(filter,deserializer, ...parameters) => [string,T][]
Returns all remaining children with their name if that name matches the given filter
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
filter | RegExp |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[string, T][]
Throws
If the deserializer fails
filtered.unique()
Returns all remaining children with their name if that name matches the given filter, requiring all matching names to be unique
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
filter | RegExp |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[string, T][]
Throws
If the deserializer fails
Throws
If a duplicate name is encountered
unique()
unique: <
T,P>(deserializer, ...parameters) => [string,T][]
Returns all remaining children with their name, requiring all names to be unique
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[string, T][]
Throws
If the deserializer fails
Throws
If a duplicate name is encountered
unique.filtered()
Returns all remaining children with their name if that name matches the given filter, requiring all matching names to be unique
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
filter | RegExp |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[string, T][]
Throws
If the deserializer fails
Throws
If a duplicate name is encountered
Methods
required()
required<
T,P>(name,deserializer, ...parameters): [T,...T[]]
Defined in: src/dessert/deserialization/types.d.ts:272
Returns all remaining children with the given name, requiring at least one such child
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
deserializer | Deserializer<T, P> |
...parameters | P |
Returns
[T, ...T[]]
Throws
If the deserializer fails
Throws
If there are no remaining children with the given name
DeserializationContext
Defined in: src/dessert/deserialization/types.d.ts:409
Wrapper around a Node to help deserializing a single Node into a value
Properties
argument
readonlyargument:Argument
Defined in: src/dessert/deserialization/types.d.ts:423
Helper to access the node's arguments
child
readonlychild:Child
Defined in: src/dessert/deserialization/types.d.ts:432
Helper to access the node's children
children
readonlychildren:Children
Defined in: src/dessert/deserialization/types.d.ts:436
Helper to access the node's children
json
readonlyjson:Json
Defined in: src/dessert/deserialization/types.d.ts:441
Helper for processing the node as JSON
name
readonlyname:string
Defined in: src/dessert/deserialization/types.d.ts:413
Name of the node being deserialized
property
readonlyproperty:Property
Defined in: src/dessert/deserialization/types.d.ts:427
Helper to access the node's properties
run()
readonlyrun: <T,P>(deserializer, ...parameters) =>T
Defined in: src/dessert/deserialization/types.d.ts:446
Run the given deserializer
Type Parameters
| Type Parameter |
|---|
T |
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
deserializer | DeserializerFromContext<T, P> |
...parameters | P |
Returns
T
tag
readonlytag:null|string
Defined in: src/dessert/deserialization/types.d.ts:418
Tag of the node being deserialized
DocumentSerializationContext
Defined in: src/dessert/serialization/types.d.ts:133
Wrapper around a Document to help serializing a value or values into a Document
Properties
child()
readonlychild: <P>(name,serializer, ...params) =>void
Defined in: src/dessert/serialization/types.d.ts:149
Run the given serializer to create a node with the given name and add that node as child to the document being serialized
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
serializer | Serializer<P> |
...params | P |
Returns
void
tagged()
Run the given serializer to create a node with the given name and tag and add that node as child to the document being serialized
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
tag | string |
name | string |
serializer | Serializer<P> |
...params | P |
Returns
void
json()
readonlyjson: (value) =>void
Defined in: src/dessert/serialization/types.d.ts:175
Serialize a JSON value
The allowed values are limited to only values that can be entirely serialized into nodes placed inside the document. For example, a string value would be added as argument but a document can't have arguments.
Parameters
| Parameter | Type |
|---|---|
value | JsonObject | JsonValue[] |
Returns
void
run()
readonlyrun: <P>(serializer, ...parameters) =>void
Defined in: src/dessert/serialization/types.d.ts:180
Run the given serializer
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
serializer | DocumentSerializer<P> |
...parameters | P |
Returns
void
source()
readonlysource: (sourceCtx) =>void
Defined in: src/dessert/serialization/types.d.ts:145
Link this serialization to a prior deserialization
Attaching a deserialization context as source to this serialization allows the serialization to keep track of metadata in the original text. For example, an effort is made to preserve formatting and comments.
Parameters
| Parameter | Type |
|---|---|
sourceCtx | undefined | null | DeserializationContext |
Returns
void
target
readonlytarget:"document"
Defined in: src/dessert/serialization/types.d.ts:137
Marker property that can be used to distinguish between a DocumentSerializationContext and SerializationContext.
Json()
Defined in: src/dessert/deserialization/types.d.ts:362
Json():
undefined|JsonValue
Defined in: src/dessert/deserialization/types.d.ts:371
Turn the remaining arguments, properties, and children into a JSON value
After calling this function, all remaining arguments, properties, and children of the context have been consumed. Further calls to any of the context's utilities will return undefined or throw, depending on how the utility handles an empty context.
Returns
undefined | JsonValue
Throws
If the context doesn't contain a valid JSON value
Json<
T>(...types):undefined|JsonTypeOf<T>
Defined in: src/dessert/deserialization/types.d.ts:381
Turn the remaining arguments, properties, and children into a JSON value matching any of the given types
After calling this function, all remaining arguments, properties, and children of the context have been consumed. Further calls to any of the context's utilities will return undefined or throw, depending on how the utility handles an empty context.
Type Parameters
| Type Parameter |
|---|
T extends [JsonType, ...JsonType[]] |
Parameters
| Parameter | Type |
|---|---|
...types | T |
Returns
undefined | JsonTypeOf<T>
Throws
If the context doesn't contain a valid JSON value
Throws
If the deserialized value doesn't match any of the given types
Methods
required()
Call Signature
required():
JsonValue
Defined in: src/dessert/deserialization/types.d.ts:392
Turn the remaining arguments, properties, and children into a JSON value
After calling this function, all remaining arguments, properties, and children of the context have been consumed. Further calls to any of the context's utilities will return undefined or throw, depending on how the utility handles an empty context.
Returns
Throws
If the context doesn't contain a valid JSON value
Throws
If the context is empty
Call Signature
required<
T>(...types):JsonTypeOf<T>
Defined in: src/dessert/deserialization/types.d.ts:403
Turn the remaining arguments, properties, and children into a JSON value matching any of the given types
After calling this function, all remaining arguments, properties, and children of the context have been consumed. Further calls to any of the context's utilities will return undefined or throw, depending on how the utility handles an empty context.
Type Parameters
| Type Parameter |
|---|
T extends [JsonType, ...JsonType[]] |
Parameters
| Parameter | Type |
|---|---|
...types | T |
Returns
JsonTypeOf<T>
Throws
If the context doesn't contain a valid JSON value
Throws
If the context is empty
Throws
If the deserialized value doesn't match any of the given types
Property()<Required, IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:145
Type Parameters
| Type Parameter | Default type |
|---|---|
Required extends boolean | false |
IgnoreInvalid extends boolean | false |
Property(
name):Primitive|Requiredextendsfalse?undefined:never
Defined in: src/dessert/deserialization/types.d.ts:152
Return the property with the given name if it exists and it hasn't been returned yet
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Primitive | Required extends false ? undefined : never
Property<
T>(name, ...types):Requiredextendsfalse?undefined:never|IgnoreInvalidextendstrue?undefined:never|TypeOf<T>
Defined in: src/dessert/deserialization/types.d.ts:159
Return the property with the given name if it exists and it hasn't been returned yet
Type Parameters
| Type Parameter |
|---|
T extends [PrimitiveType, ...PrimitiveType[]] |
Parameters
| Parameter | Type |
|---|---|
name | string |
...types | T |
Returns
Required extends false ? undefined : never | IgnoreInvalid extends true ? undefined : never | TypeOf<T>
Throws
If the property value does not match any of the given types
Properties
if
if:
IgnoreInvalidextendsfalse?Property<Required,true> :never
Defined in: src/dessert/deserialization/types.d.ts:187
Return undefined instead of throwing if the property doesn't match the given types or enum values
required
required:
Requiredextendsfalse?Property<true,IgnoreInvalid> :never
Defined in: src/dessert/deserialization/types.d.ts:177
Throw if there is no property with the given name, rather than return undefined
rest
rest:
RestProperty<Required,IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:182
Return all remaining properties rather than only a single named property
Methods
enum()
enum<
T>(name, ...values):Requiredextendsfalse?undefined:never|IgnoreInvalidextendstrue?undefined:never|T[number]
Defined in: src/dessert/deserialization/types.d.ts:169
Return the property with the given name if it exists and it hasn't been returned yet
Type Parameters
| Type Parameter |
|---|
T extends Primitive[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
...values | T |
Returns
Required extends false ? undefined : never | IgnoreInvalid extends true ? undefined : never | T[number]
Throws
If the property value does not equal any of the given values
RestProperty()<Required, IgnoreInvalid>
Defined in: src/dessert/deserialization/types.d.ts:190
Type Parameters
| Type Parameter | Default type |
|---|---|
Required extends boolean | false |
IgnoreInvalid extends boolean | false |
RestProperty():
Map<string,Primitive>
Defined in: src/dessert/deserialization/types.d.ts:197
Return all remaining properties
Returns
Map<string, Primitive>
RestProperty<
T>(...types):Map<string,TypeOf<T>>
Defined in: src/dessert/deserialization/types.d.ts:204
Return all remaining properties
Type Parameters
| Type Parameter |
|---|
T extends [PrimitiveType, ...PrimitiveType[]] |
Parameters
| Parameter | Type |
|---|---|
...types | T |
Returns
Map<string, TypeOf<T>>
Throws
If any remaining property value does not match any of the given types
Properties
if
if:
IgnoreInvalidextendsfalse?RestProperty<Required,true> :never
Defined in: src/dessert/deserialization/types.d.ts:225
Return undefined instead of throwing if the property doesn't match the given types or enum values
required
required:
Requiredextendsfalse?RestProperty<true,IgnoreInvalid> :never
Defined in: src/dessert/deserialization/types.d.ts:220
Throw if there is no property with the given name, rather than return undefined
Methods
enum()
enum<
T>(...values):Map<string,T[number]>
Defined in: src/dessert/deserialization/types.d.ts:213
Return all remaining properties
Type Parameters
| Type Parameter |
|---|
T extends Primitive[] |
Parameters
| Parameter | Type |
|---|---|
...values | T |
Returns
Map<string, T[number]>
Throws
If any remaining property value does not equal any of the given values
SerializationContext
Defined in: src/dessert/serialization/types.d.ts:51
Wrapper around a Node to help serializing a value into a single Node
Properties
argument()
readonlyargument: (value) =>void
Defined in: src/dessert/serialization/types.d.ts:67
Add an argument to the serialized node
Parameters
| Parameter | Type |
|---|---|
value | Primitive |
Returns
void
tagged()
Add an argument with a tag to the serialized node
Parameters
| Parameter | Type |
|---|---|
tag | string |
value | Primitive |
Returns
void
child()
readonlychild: <P>(name,serializer, ...params) =>void
Defined in: src/dessert/serialization/types.d.ts:96
Serialize a child node and add it to this serialized node
Run the given serializer to create a node with the given name and add that node as child to the node being serialized
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
name | string |
serializer | Serializer<P> |
...params | P |
Returns
void
tagged()
Run the given serializer to create a node with the given name and tag and add that node as child to the node being serialized
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
tag | string |
name | string |
serializer | Serializer<P> |
...params | P |
Returns
void
json()
readonlyjson: (value) =>void
Defined in: src/dessert/serialization/types.d.ts:119
Serialize a JSON value
Parameters
| Parameter | Type |
|---|---|
value | JsonValue |
Returns
void
property()
readonlyproperty: (name,value) =>void
Defined in: src/dessert/serialization/types.d.ts:78
Set a property on the serialized node
If the same property was already set previously, the previous value is overwritten.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | Primitive |
Returns
void
tagged()
Set a property with a tag on the serialized node
If the same property was already set previously, the previous value is overwritten.
Parameters
| Parameter | Type |
|---|---|
tag | string |
name | string |
value | Primitive |
Returns
void
run()
readonlyrun: <P>(serializer, ...parameters) =>void
Defined in: src/dessert/serialization/types.d.ts:124
Run the given serializer
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type |
|---|---|
serializer | SerializerFromContext<P> |
...parameters | P |
Returns
void
source()
readonlysource: (sourceCtx) =>void
Defined in: src/dessert/serialization/types.d.ts:63
Link this serialization to a prior deserialization
Attaching a deserialization context as source to this serialization allows the serialization to keep track of metadata in the original text. For example, an effort is made to preserve formatting and comments.
Parameters
| Parameter | Type |
|---|---|
sourceCtx | undefined | null | DeserializationContext |
Returns
void
target
readonlytarget:"node"
Defined in: src/dessert/serialization/types.d.ts:55
Marker property that can be used to distinguish between a DocumentSerializationContext and SerializationContext.
Type Aliases
ArgumentReturnType<T, Required, ReturnMultiple, IgnoreInvalid>
ArgumentReturnType<
T,Required,ReturnMultiple,IgnoreInvalid>:ReturnMultipleextendsfalse?T|Requiredextendsfalse?undefined:never|IgnoreInvalidextendstrue?undefined:never:Requiredextendstrue?IgnoreInvalidextendsfalse? [T,...T[]] :T[] :T[]
Defined in: src/dessert/deserialization/types.d.ts:63
Return type of the DeserializationContext's argument
The actual type depends on whether you're using ctx.argument()
with or without .if, .required, and/or .rest.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | - |
Required extends boolean | - |
ReturnMultiple extends boolean | - |
IgnoreInvalid extends boolean | false |
Deserialized<T>
Deserialized<
T>:TextendsDeserializer<infer V,any[]> ?V:never
Defined in: src/dessert/deserialization/types.d.ts:54
Helper type to extract the type a deserializer supports
Type Parameters
| Type Parameter |
|---|
T extends Deserializer<unknown, any[]> |
Deserializer<T, P>
Deserializer<
T,P>:DeserializerFromContext<T,P> | {deserializeFromNode:T; }
Defined in: src/dessert/deserialization/types.d.ts:44
Function or object capable of deserializing objects of type T
There are three types of deserializers:
- Functions that are given a DeserializationContext
- A value (usually a class) with a
deserializefunction that is given a DeserializationContext - A value (usually a class) with a
deserializeFromNodefunction that is given a Node
All three variants can be parameterized.
Parameters can be passed via deserialize or any of the child/children functions on a DeserializationContext
Type Parameters
| Type Parameter | Default type |
|---|---|
T | - |
P extends unknown[] | [] |
Type declaration
DeserializerFromContext<T, P>
{ deserializeFromNode: T; }
deserializeFromNode()
Function that is given a Node
Parameters
| Parameter | Type |
|---|---|
node | Node |
...parameters | P |
Returns
T
DeserializerFromContext<T, P>
DeserializerFromContext<
T,P>: (ctx, ...parameters) =>T| {deserialize:T; }
Defined in: src/dessert/deserialization/types.d.ts:26
Function or object capable of deserializing objects of type T using a DeserializationContext
Type Parameters
| Type Parameter | Default type |
|---|---|
T | - |
P extends unknown[] | [] |
Type declaration
(ctx, ...parameters) => T
Parameters
| Parameter | Type |
|---|---|
ctx | DeserializationContext |
...parameters | P |
Returns
T
{ deserialize: T; }
deserialize()
Function that is given a DeserializationContext
Parameters
| Parameter | Type |
|---|---|
ctx | DeserializationContext |
...parameters | P |
Returns
T
DocumentSerializer<P>
DocumentSerializer<
P>: (ctx, ...parameters) =>void| {serialize:void; }
Defined in: src/dessert/serialization/types.d.ts:41
Function or object capable of serializing a Document
There are three types of serializers:
- Functions that are given a SerializationContext
- A value (usually a class instance) with a
serializefunction that is given a SerializationContext
Both types can accept parameters, in which case these parameters have to be passed when calling serialize.
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Type declaration
(ctx, ...parameters) => void
Parameters
| Parameter | Type |
|---|---|
ctx | DocumentSerializationContext |
...parameters | P |
Returns
void
{ serialize: void; }
serialize()
Function that is given a DocumentSerializationContext
Parameters
| Parameter | Type |
|---|---|
ctx | DocumentSerializationContext |
...parameters | P |
Returns
void
JsonType
JsonType:
PrimitiveType|"object"|"array"
Defined in: src/dessert/deserialization/types.d.ts:342
String representation of the JsonValue types
JsonTypeOf<T>
JsonTypeOf<
T>:object[T[number]]
Defined in: src/dessert/deserialization/types.d.ts:347
Helper type to turn JsonTypes into the corresponding JsonValue types
Type Parameters
| Type Parameter |
|---|
T extends JsonType[] |
PrimitiveType
PrimitiveType:
"boolean"|"null"|"number"|"string"
Defined in: src/dessert/deserialization/types.d.ts:7
String representation of the Primitive types
PropertyReturnType<T, Required, ReturnMultiple, IgnoreInvalid>
PropertyReturnType<
T,Required,ReturnMultiple,IgnoreInvalid>:ReturnMultipleextendsfalse?T|Requiredextendsfalse?undefined:never|IgnoreInvalidextendstrue?undefined:never:Map<string,T>
Defined in: src/dessert/deserialization/types.d.ts:133
Return type of the DeserializationContext's property
The actual type depends on whether you're using ctx.property
with or without .if, .required, and/or .rest.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | - |
Required extends boolean | - |
ReturnMultiple extends boolean | - |
IgnoreInvalid extends boolean | false |
Serializer<P>
Serializer<
P>:SerializerFromContext<P> | {serializeToNode:Node; }
Defined in: src/dessert/serialization/types.d.ts:25
Function or object capable of serializing a Node
There are three types of serializers:
- Functions that are given a SerializationContext
- A value (usually a class instance) with a
serializefunction that is given a SerializationContext - A value (usually a class instance) with a
serializeTNodefunction that returns a Node
All three of these types can accept parameters, in which case these parameters have to be passed when calling serialize.
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Type declaration
{ serializeToNode: Node; }
serializeToNode()
Function to serialize a Node of the given name
Parameters
| Parameter | Type |
|---|---|
name | string |
...parameters | P |
Returns
SerializerFromContext<P>
SerializerFromContext<
P>: (ctx, ...parameters) =>void| {serialize:void; }
Defined in: src/dessert/serialization/types.d.ts:8
Function or object capable of serializing via a SerializationContext
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Type declaration
(ctx, ...parameters) => void
Parameters
| Parameter | Type |
|---|---|
ctx | SerializationContext |
...parameters | P |
Returns
void
{ serialize: void; }
serialize()
Function that is given a SerializationContext
Parameters
| Parameter | Type |
|---|---|
ctx | SerializationContext |
...parameters | P |
Returns
void
TypeOf<T>
TypeOf<
T>:object[T[number]]
Defined in: src/dessert/deserialization/types.d.ts:12
Helper type to turn a list of PrimitiveTypes into matching Primitive types
Type Parameters
| Type Parameter |
|---|
T extends PrimitiveType[] |
Functions
concat()
concat(...
docsAndNodes):Document
Defined in: src/dessert/serialization/public-utils.js:12
Create a document containing the given nodes in order
If documents are passed, all nodes from those documents will be inserted in order into the returned document.
Parameters
Returns
deserialize()
deserialize<
T,P>(node,deserializer, ...parameters):T
Defined in: src/dessert/deserialization/deserialize.js:728
Deserialize the given Document or Node using the given deserializer.
If this function is given a Document, it will be wrapped with a nameless node (using "-" as name) without any arguments or properties.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T | - | |
P extends unknown[] | [] |
Parameters
| Parameter | Type | Description |
|---|---|---|
node | Node | Document | |
deserializer | Deserializer<T, P> | |
...parameters | P |
Returns
T
firstMatchingDeserializer()
firstMatchingDeserializer<
T>(...deserializers):Deserializer<Deserialized<T[number]>>
Defined in: src/dessert/deserialization/public-utils.js:59
Create a deserializer that tries all of the given deserializers until it finds one that doesn't throw an error.
The returned deserializer throws an AggregateError if all of the given deserializers throw on a certain node.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Deserializer<unknown>[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
...deserializers | T |
Returns
Deserializer<Deserialized<T[number]>>
format()
format<
P>(serializer, ...parameters):string
Defined in: src/dessert/serialization/serialize.js:181
Serialize a KDL document and format it to a string
Type Parameters
| Type Parameter | Description |
|---|---|
P extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
serializer | DocumentSerializer<P> | |
...parameters | P |
Returns
string
parse()
parse<
T>(text,deserializer):T
Defined in: src/dessert/deserialization/deserialize.js:857
Parse the given KDL text as a document and run it through the given deserializer
The deserializer will only have access to children, as a document has no arguments or properties.
This is a small function that runs parse and then runs the resulting Document through deserialize.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | |
deserializer | Deserializer<T, []> |
Returns
T
repeat()
repeat<
A,T>(fn, ...args):undefined| [T,...T[]]
Defined in: src/dessert/deserialization/public-utils.js:20
Call the given function with the given arguments until it returns undefined
This function returns all return values apart from the final undefined. If the given function returned undefined on the first call, this function returns undefined.
Type Parameters
| Type Parameter | Description |
|---|---|
A extends unknown[] | |
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (...args) => undefined | T | |
...args | A |
Returns
undefined | [T, ...T[]]
serialize()
Call Signature
serialize<
P>(name,serializer, ...params):Node
Defined in: src/dessert/serialization/types.d.ts:193
Create a node with the given name using the given serializer
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the node |
serializer | Serializer<P> | Serializer to call |
...params | P | Parameters to pass along to the serializer |
Returns
Call Signature
serialize<
P>(name,serializer, ...params):Document
Defined in: src/dessert/serialization/types.d.ts:208
Create a document using the given serializer
The first parameter can be null or typeof Document.
Passing null is easiest, but it won't work when using TypeScript with "strictNullChecks" disabled.
Type Parameters
| Type Parameter |
|---|
P extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | null | typeof Document | Null or a refernece to the Document class |
serializer | DocumentSerializer<P> | Serializer to call |
...params | P | Parameters to pass along to the serializer |