dessert

Classes

Interfaces

Argument()<Required, ReturnMultiple, IgnoreInvalid>

Defined in: src/dessert/deserialization/types.d.ts:79

Type Parameters

Type ParameterDefault type
Required extends booleanfalse
ReturnMultiple extends booleanfalse
IgnoreInvalid extends booleanfalse

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

ParameterType
...typesT

Returns

ArgumentReturnType<TypeOf<T>, Required, ReturnMultiple, IgnoreInvalid>

Throws

If the next argument does not match any of the given types

Properties

if

if: IgnoreInvalid extends false ? 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: Required extends false ? 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: ReturnMultiple extends false ? 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
ParameterType
...valuesT
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 ParameterDefault type
Required extends booleanfalse
Single extends booleanfalse

Child<T, P>(name, deserializer, ...parameters): T | Required extends false ? 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

ParameterType
namestring
deserializerDeserializer<T, P>
...parametersP

Returns

T | Required extends false ? undefined : never

Throws

If the deserializer fails

Properties

required

required: Required extends false ? 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: Single extends false ? 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

ParameterType
namestring
deserializerDeserializer<T, P>
...parametersP

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
ParameterType
deserializerDeserializer<T, P>
...parametersP
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
ParameterType
filterRegExp
deserializerDeserializer<T, P>
...parametersP
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
ParameterType
filterRegExp
deserializerDeserializer<T, P>
...parametersP
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
ParameterType
deserializerDeserializer<T, P>
...parametersP
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
ParameterType
filterRegExp
deserializerDeserializer<T, P>
...parametersP
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
ParameterType
namestring
deserializerDeserializer<T, P>
...parametersP
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

readonly argument: Argument

Defined in: src/dessert/deserialization/types.d.ts:423

Helper to access the node's arguments


child

readonly child: Child

Defined in: src/dessert/deserialization/types.d.ts:432

Helper to access the node's children


children

readonly children: Children

Defined in: src/dessert/deserialization/types.d.ts:436

Helper to access the node's children


json

readonly json: Json

Defined in: src/dessert/deserialization/types.d.ts:441

Helper for processing the node as JSON


name

readonly name: string

Defined in: src/dessert/deserialization/types.d.ts:413

Name of the node being deserialized


property

readonly property: Property

Defined in: src/dessert/deserialization/types.d.ts:427

Helper to access the node's properties


run()

readonly run: <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
ParameterType
deserializerDeserializerFromContext<T, P>
...parametersP
Returns

T


tag

readonly tag: 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()

readonly child: <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
ParameterType
namestring
serializerSerializer<P>
...paramsP
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
ParameterType
tagstring
namestring
serializerSerializer<P>
...paramsP
Returns

void


json()

readonly json: (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
ParameterType
valueJsonObject | JsonValue[]
Returns

void


run()

readonly run: <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
ParameterType
serializerDocumentSerializer<P>
...parametersP
Returns

void


source()

readonly source: (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
ParameterType
sourceCtxundefined | null | DeserializationContext
Returns

void


target

readonly target: "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

ParameterType
...typesT

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

JsonValue

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
ParameterType
...typesT
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 ParameterDefault type
Required extends booleanfalse
IgnoreInvalid extends booleanfalse

Property(name): Primitive | Required extends false ? 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

ParameterType
namestring

Returns

Primitive | Required extends false ? undefined : never

Property<T>(name, ...types): Required extends false ? undefined : never | IgnoreInvalid extends true ? 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

ParameterType
namestring
...typesT

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: IgnoreInvalid extends false ? 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: Required extends false ? 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): Required extends false ? undefined : never | IgnoreInvalid extends true ? 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
ParameterType
namestring
...valuesT
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 ParameterDefault type
Required extends booleanfalse
IgnoreInvalid extends booleanfalse

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

ParameterType
...typesT

Returns

Map<string, TypeOf<T>>

Throws

If any remaining property value does not match any of the given types

Properties

if

if: IgnoreInvalid extends false ? 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: Required extends false ? 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
ParameterType
...valuesT
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()

readonly argument: (value) => void

Defined in: src/dessert/serialization/types.d.ts:67

Add an argument to the serialized node

Parameters
ParameterType
valuePrimitive
Returns

void

tagged()

Add an argument with a tag to the serialized node

Parameters
ParameterType
tagstring
valuePrimitive
Returns

void


child()

readonly child: <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
ParameterType
namestring
serializerSerializer<P>
...paramsP
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
ParameterType
tagstring
namestring
serializerSerializer<P>
...paramsP
Returns

void


json()

readonly json: (value) => void

Defined in: src/dessert/serialization/types.d.ts:119

Serialize a JSON value

Parameters
ParameterType
valueJsonValue
Returns

void


property()

readonly property: (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
ParameterType
namestring
valuePrimitive
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
ParameterType
tagstring
namestring
valuePrimitive
Returns

void


run()

readonly run: <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
ParameterType
serializerSerializerFromContext<P>
...parametersP
Returns

void


source()

readonly source: (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
ParameterType
sourceCtxundefined | null | DeserializationContext
Returns

void


target

readonly target: "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>: ReturnMultiple extends false ? T | Required extends false ? undefined : never | IgnoreInvalid extends true ? undefined : never : Required extends true ? IgnoreInvalid extends false ? [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 ParameterDefault type
T-
Required extends boolean-
ReturnMultiple extends boolean-
IgnoreInvalid extends booleanfalse

Deserialized<T>

Deserialized<T>: T extends Deserializer<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:

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 ParameterDefault type
T-
P extends unknown[][]

Type declaration

DeserializerFromContext<T, P>

{ deserializeFromNode: T; }

deserializeFromNode()

Function that is given a Node

Parameters
ParameterType
nodeNode
...parametersP
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 ParameterDefault type
T-
P extends unknown[][]

Type declaration

(ctx, ...parameters) => T

Parameters

ParameterType
ctxDeserializationContext
...parametersP

Returns

T

{ deserialize: T; }

deserialize()

Function that is given a DeserializationContext

Parameters
ParameterType
ctxDeserializationContext
...parametersP
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:

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

ParameterType
ctxDocumentSerializationContext
...parametersP

Returns

void

{ serialize: void; }

serialize()

Function that is given a DocumentSerializationContext

Parameters
ParameterType
ctxDocumentSerializationContext
...parametersP
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>: ReturnMultiple extends false ? T | Required extends false ? undefined : never | IgnoreInvalid extends true ? 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 ParameterDefault type
T-
Required extends boolean-
ReturnMultiple extends boolean-
IgnoreInvalid extends booleanfalse

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 serialize function that is given a SerializationContext
  • A value (usually a class instance) with a serializeTNode function 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

SerializerFromContext<P>

{ serializeToNode: Node; }

serializeToNode()

Function to serialize a Node of the given name

Parameters
ParameterType
namestring
...parametersP
Returns

Node


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

ParameterType
ctxSerializationContext
...parametersP

Returns

void

{ serialize: void; }

serialize()

Function that is given a SerializationContext

Parameters
ParameterType
ctxSerializationContext
...parametersP
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

ParameterTypeDescription
...docsAndNodes(Node | Document)[]

Returns

Document


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 ParameterDefault typeDescription
T-
P extends unknown[][]

Parameters

ParameterTypeDescription
nodeNode | Document
deserializerDeserializer<T, P>
...parametersP

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 ParameterDescription
T extends Deserializer<unknown>[]

Parameters

ParameterTypeDescription
...deserializersT

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 ParameterDescription
P extends unknown[]

Parameters

ParameterTypeDescription
serializerDocumentSerializer<P>
...parametersP

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 ParameterDescription
T

Parameters

ParameterTypeDescription
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
deserializerDeserializer<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 ParameterDescription
A extends unknown[]
T

Parameters

ParameterTypeDescription
fn(...args) => undefined | T
...argsA

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
ParameterTypeDescription
namestringThe name of the node
serializerSerializer<P>Serializer to call
...paramsPParameters to pass along to the serializer
Returns

Node

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
ParameterTypeDescription
namenull | typeof DocumentNull or a refernece to the Document class
serializerDocumentSerializer<P>Serializer to call
...paramsPParameters to pass along to the serializer
Returns

Document