Protocol API

April 2, 2020 ยท View on GitHub

Both interpreter and compiler extends from ProtocolInterface, thus have same methods.

ProtocolInterface

[constructor] ( data: { types: Object, ...namespaces } )

Constructs protocol and adds datatypes/namespaces if provided.

addType ( name: String, data: Function|Array|"native" ) : this

Adds datatypes to protocol. Chainable.

addNamespace ( name: String, data: Object ) : this

Adds namespaces sub-protocol. Chainable.

read / write / sizeRead / sizeWrite ( name: String, ...args )

Aliases for proto.get(name)[method](...args), see Datatypes

createSerializer ( name: String ) : Serializer

createDeserializer ( name: String ) : Deserializer

Serializer

[constructor] ( instance: Datatype )

A TransformStream to write serialized data

Deserializer

[constructor] ( instance: Datatype )

A TransformStream to read serialized data