Serialization¶

Encoding and decoding values: the high-level Value codecs, the named stream codecs behind them, byte-size prediction via sizers, and the raw/binary/token streams those codecs are built on.

Most code never touches a stream directly. To turn a Value into a blob and back you call Value.encode / Value.decode (binary), Value.toJsonString / Value.fromJsonString (JSON, for web and REST), Value.toXmlString / Value.fromXmlString (XML), or Value.dumps / Value.loads (the native format). Decoding always needs the Type and a const Definitions so the decoder knows the shape it is reading. The classes on this page are the machinery underneath: pick a named codec with Codec when you need a specific wire format, drive an encoder/decoder/sizer through StreamCodecInstancing, and reach for the StreamReaderFile / StreamWriterFile family for low-level file, blob, and shared-memory I/O.

When to use: reach for the Value.* codecs for ordinary serialization. Drop to Codec and the stream classes when you are implementing a custom protocol, predicting an encoded size ahead of time, or streaming straight to a file or shared-memory region.

Quick Start¶

A value survives a binary round-trip when the decoded copy .equals the original — never compare values with ==:

const { Value, ValueString, Type, Definitions } = require('@digitalsubstrate/dsviper');

// Const definitions tell the decoder the shape it is reading back.
const defs = new Definitions().const();

const value = new ValueString('hello');

// Binary: encode to a blob, decode it back with its type + definitions.
const blob = Value.encode(value);
const decoded = Value.decode(blob, Type.STRING, defs);
console.log(value.equals(decoded)); // true

// JSON: same round-trip, for web and REST integration.
const json = Value.toJsonString(value);
console.log(value.equals(Value.fromJsonString(json, Type.STRING, defs))); // true

// XML: the XML dialect of the same type-driven codec.
const xml = Value.toXmlString(value);
console.log(value.equals(Value.fromXmlString(xml, Type.STRING, defs))); // true

// Native dumps/loads: the same shape again.
console.log(value.equals(Value.loads(Value.dumps(value), Type.STRING, defs))); // true

Vectors and other containers round-trip the same way — build the vector from its type and an array of elements, then pass that type to decode:

const { Value, ValueVector, TypeVector, Type, Definitions } = require('@digitalsubstrate/dsviper');

const defs = new Definitions().const();
const t = new TypeVector(Type.INT64);
const vec = new ValueVector(t, [1n, 2n, 3n]); // 64-bit elements are bigint

const decoded = Value.decode(Value.encode(vec), t, defs);
console.log(vec.equals(decoded)); // true

To work below Value, resolve a named codec and drive its encoder, decoder, and sizer. The sizer predicts the exact encoded byte length without producing a blob:

const { Codec } = require('@digitalsubstrate/dsviper');

const codec = Codec.STREAM_BINARY;          // or Codec.check('StreamTokenBinary')

const encoder = codec.createEncoder();
encoder.writeBool(true);
encoder.writeUint32(42);
encoder.writeDouble(3.14);
const data = encoder.endEncoding();         // a ValueBlob

const decoder = codec.createDecoder(data);
console.log(decoder.readBool());            // true
console.log(decoder.readUint32());          // 42

// A sizer predicts the byte length the same writes would produce.
const sizer = codec.createSizer();
console.log(sizer.sizeOfBool() + sizer.sizeOfUint32() + sizer.sizeOfDouble());
console.log(data.size());                   // matches the prediction

An unknown codec name, or a token mismatch while decoding, throws a JS Error whose name is 'ViperError':

const { Codec } = require('@digitalsubstrate/dsviper');

try {
  Codec.check('an unknown codec');
} catch (err) {
  console.log(err.name); // 'ViperError'
}

Choosing the right approach¶

Use case

API

Note

Binary serialization

Value.encode / Value.decode

Default codec; decode needs type + const definitions

JSON for web / REST

Value.toJsonString / Value.fromJsonString

Web integration

XML for XML consumers

Value.toXmlString / Value.fromXmlString

Same type-driven codec, XML dialect

Native format

Value.dumps / Value.loads

Round-trips like the others

Specific wire format

Codec

STREAM_BINARY, STREAM_RAW, StreamTokenBinary, …

Encoder / decoder / sizer

StreamCodecInstancing

createEncoder / createDecoder / createSizer

Predict encoded size

createSizer().sizeOf*()

Byte length without building a blob

File / blob / shared-memory I/O

StreamReaderFile / StreamWriterFile

Low-level streaming

See also the serialization guide, the blobs reference for ValueBlob, and the equivalent Python serialization reference.

Generated from the @digitalsubstrate/dsviper TypeScript declarations (index.d.ts) by TypeDoc.

Codec¶

Class

Description

Codec

The registry of named codecs: ask for one by name with query() or check(), or take STREAM_RAW, STREAM_BINARY or STREAM_TOKEN_BINARY directly

StreamCodecInstancing

Creates the encoder, the decoder and the sizer of one codec

Fuzzer

Generates random values against a set of definitions

Binary Streams¶

Class

Description

StreamBinaryReader

Reads values in a fixed byte order, portable across machines

StreamBinaryWriter

Writes values in a fixed byte order, portable across machines

StreamTokenBinaryReader

Reads a portable binary stream that carries a type token per value

StreamTokenBinaryWriter

Writes a portable binary stream with a type token per value

Stream I/O¶

Class

Description

StreamReaderBlob

Reads data from a blob

StreamReaderFile

Reads data from a file

StreamReaderSharedMemory

Reads data from a shared memory region

StreamWriterBlob

Writes data to a blob

StreamWriterFile

Writes data to a file

StreamWriterSharedMemory

Writes data to a shared memory region

Protocols¶

Class

Description

StreamReading

The typed read interface

StreamWriting

The typed write interface

StreamEncoding

Writes typed values into a blob

StreamDecoding

Reads typed values back from a blob

StreamSizing

Computes how many bytes the fixed-width types occupy under one codec

Raw Streams¶

Class

Description

StreamRawReader

Reads values in the machine’s own byte order

StreamRawWriter

Writes values in the machine’s own byte order

StreamRawReading

An opaque handle on a byte source, whose one operation is size()

StreamRawWriting

An opaque handle on a byte sink, with no operation of its own

Reference¶

class Codec()¶
The registry of named codecs: ask for one by name with query() or check(),

or take STREAM_RAW, STREAM_BINARY or STREAM_TOKEN_BINARY directly. It resolves a codec, it does not create one.

Which one to take, and what each keeps:

STREAM_RAW writes each number in the byte order of the host that wrote

it. Its home is a transport that cannot leave the machine - shared memory above all, where both ends are the same host and swapping bytes buys nothing. The cheapest, for exactly that reason.

STREAM_BINARY same size, but the order is fixed little-endian whoever

writes. The one to take the moment the bytes can reach another machine: a file you ship, a socket, a blob a peer will read.

STREAM_TOKEN_BINARY adds one byte in front of each value, naming its type. That

byte is what a reader checks: reading a uint32 back as a uint16 THROWS here, where the two above answer a number built from the wrong bytes and report nothing.

Choosing the wrong one of the first two is not reported, and cannot be: on a little-endian host they write the SAME BYTES, so a stream carries no record of which produced it. The mistake is invisible where it is made and surfaces on the first big-endian peer, which may be years later. The two ends have to agree out of band - or use STREAM_TOKEN_BINARY, whose token makes a mismatched pair fail at the first read instead.

None of the three writes the shape of what you encoded: the reader calls the same reads in the same order, and a token only says a value is not the type asked for. Keep the definitions that describe the data, or use a database, which keeps them for you.

Note: Not directly instantiable.

exported from index.d

Codec.STREAM_BINARY¶

type: readonly StreamCodecInstancing

Codec.STREAM_RAW¶

type: readonly StreamCodecInstancing

Codec.STREAM_TOKEN_BINARY¶

type: readonly StreamCodecInstancing

static Codec.check(name)¶
Return the StreamCodecInstancing of the codec named name, or throw.

The names are StreamRaw, StreamBinary and StreamTokenBinary.

Arguments:
  • name (string)

Returns:

StreamCodecInstancing

static Codec.query(name)¶
Return the StreamCodecInstancing of the codec named name, or undefined.

The names are StreamRaw, StreamBinary and StreamTokenBinary.

Arguments:
  • name (string)

Returns:

StreamCodecInstancing | undefined

class StreamCodecInstancing()¶

Creates the encoder, the decoder and the sizer of one codec.

Note: Not directly instantiable.

exported from index.d

StreamCodecInstancing.createDecoder(blob)¶

Return a StreamDecoding reading blob with this codec.

Arguments:
  • blob (ValueBlob)

Returns:

StreamDecoding

StreamCodecInstancing.createEncoder()¶

Return a StreamEncoding writing a fresh blob with this codec.

Returns:

StreamEncoding

StreamCodecInstancing.createSizer()¶

Return a StreamSizing measuring what this codec would write.

Returns:

StreamSizing

StreamCodecInstancing.name()¶
Return the name of this codec - StreamRaw, StreamBinary or

StreamTokenBinary.

Returns:

string

class Fuzzer(definitions, seed)¶

Generates random values against a set of definitions.

Sizes of generated collections are configurable - map, set, vector, xarray, string, blob. Used to exercise codecs and round-trips.

exported from index.d

Arguments:
  • definitions (DefinitionsConst)

  • seed (number | bigint | null)

Fuzzer.blobId()¶

Return the ValueBlobId every generated blob will carry, or undefined if each gets its own.

Returns:

ValueBlobId | undefined

Fuzzer.blobSize()¶

Return the size of a generated blob, in bytes.

Returns:

number

Fuzzer.fuzz(type)¶

Generate and return a random value from the type.

Arguments:
  • type (Type)

Returns:

Value

Fuzzer.mapSize()¶

Return how many entries a generated map holds.

Returns:

number

Fuzzer.seed()¶

Return the seed used by the fuzzer.

Returns:

bigint

Fuzzer.setBlobId(blobId)¶

Make every generated blob carry blobId, or give each its own when it is undefined.

Arguments:
  • blobId (ValueBlobId | null)

Fuzzer.setBlobSize(value)¶

Generate blobs of value bytes from now on.

Arguments:
  • value (number)

Fuzzer.setMapSize(value)¶

Generate maps of value entries from now on.

Arguments:
  • value (number)

Fuzzer.setSetSize(value)¶

Generate sets of value elements from now on.

Arguments:
  • value (number)

Fuzzer.setSize()¶

Return how many elements a generated set holds.

Not a setter - setSetSize is.

Returns:

number

Fuzzer.setStringSize(value)¶

Generate strings of value characters from now on.

Arguments:
  • value (number)

Fuzzer.setVectorSize(value)¶

Generate vectors of value elements from now on.

Arguments:
  • value (number)

Fuzzer.setXarraySize(value)¶

Generate xarrays of value elements from now on.

Arguments:
  • value (number)

Fuzzer.stringSize()¶

Return the size of a generated string, in characters.

Returns:

number

Fuzzer.types()¶

Return the list of types.

Returns:

Type[]

Fuzzer.vectorSize()¶

Return the size of the generated vector.

Returns:

number

Fuzzer.xarraySize()¶

Return the size of the generated xarray.

Returns:

number

class StreamBinaryReader(streamRawReading)¶

Reads values in a fixed byte order, portable across machines.

Swaps on big-endian hosts so a stream written anywhere reads anywhere. Take it whenever the bytes can reach another machine.

exported from index.d

Arguments:
  • streamRawReading (StreamRawReading)

StreamBinaryReader.readBlob()¶

Read and return a blob.

Returns:

ValueBlob

StreamBinaryReader.readBlobId()¶

Read and return a blobId.

Returns:

ValueBlobId

StreamBinaryReader.readBool()¶

Read a bool and return it as a boolean.

Returns:

boolean

StreamBinaryReader.readCommitId()¶

Read and return a commitId.

Returns:

ValueCommitId

StreamBinaryReader.readDouble()¶

Read a double and return it as a number.

Returns:

number

StreamBinaryReader.readDoubles(size)¶
Read size double and return them as a vec<double, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readFloat()¶

Read a float and return it as a number.

Returns:

number

StreamBinaryReader.readFloats(size)¶
Read size float and return them as a vec<float, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readInt16()¶

Read a int16 and return it as a number.

Returns:

number

StreamBinaryReader.readInt16s(size)¶
Read size int16 and return them as a vec<int16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readInt32()¶

Read a int32 and return it as a number.

Returns:

number

StreamBinaryReader.readInt32s(size)¶
Read size int32 and return them as a vec<int32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readInt64()¶

Read an int64 and return it as a bigint.

Returns:

bigint

StreamBinaryReader.readInt64s(size)¶
Read size int64 and return them as a vec<int64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readInt8()¶

Read a int8 and return it as a number.

Returns:

number

StreamBinaryReader.readInt8s(size)¶
Read size int8 and return them as a vec<int8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readString()¶

Read and return a string.

Returns:

string

StreamBinaryReader.readUint16()¶

Read a uint16 and return it as a number.

Returns:

number

StreamBinaryReader.readUint16s(size)¶
Read size uint16 and return them as a vec<uint16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readUint32()¶

Read a uint32 and return it as a number.

Returns:

number

StreamBinaryReader.readUint32s(size)¶
Read size uint32 and return them as a vec<uint32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readUint64()¶

Read a uint64 and return it as a bigint.

Returns:

bigint

StreamBinaryReader.readUint64s(size)¶
Read size uint64 and return them as a vec<uint64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readUint8()¶

Read a uint8 and return it as a number.

Returns:

number

StreamBinaryReader.readUint8s(size)¶
Read size uint8 and return them as a vec<uint8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamBinaryReader.readUuid()¶

Read and return uuid.

Returns:

ValueUUId

StreamBinaryReader.remaining()¶

Return the number of bytes left to read.

Returns:

number

StreamBinaryReader.streamReading()¶

Return the StreamReading interface.

Returns:

StreamReading

class StreamBinaryWriter(streamRawWriting)¶

Writes values in a fixed byte order, portable across machines.

Swaps on big-endian hosts so a stream written anywhere reads anywhere. Take it whenever the bytes can reach another machine.

exported from index.d

Arguments:
  • streamRawWriting (StreamRawWriting)

StreamBinaryWriter.streamWriting()¶

Return the StreamWriting interface.

Returns:

StreamWriting

StreamBinaryWriter.writeBlob(value)¶

Write value as a blob.

A base64 string is accepted and decoded.

Arguments:
  • value (ValueBlob)

StreamBinaryWriter.writeBlobId(value)¶

Write value as a blobId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueBlobId)

StreamBinaryWriter.writeBool(value)¶

Write value as a bool.

Throw if value is not a boolean.

Arguments:
  • value (boolean)

StreamBinaryWriter.writeCommitId(value)¶

Write value as a commitId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueCommitId)

StreamBinaryWriter.writeDouble(value)¶

Write value as a double.

A bigint is accepted and converted.

Arguments:
  • value (number)

StreamBinaryWriter.writeDoubles(value, size)¶

Write value, a sequence of size double.

A bigint element is accepted and converted.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeFloat(value)¶

Write value as a float.

Throw if the value does not fit in 32 bits.

Arguments:
  • value (number)

StreamBinaryWriter.writeFloats(value, size)¶

Write value, a sequence of size float.

Throw if a value does not fit in 32 bits.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeInt16(value)¶

Write value as an int16.

value is a number or a bigint; throw if it is fractional, or out of range for an int16.

Arguments:
  • value (number)

StreamBinaryWriter.writeInt16s(value, size)¶

Write value, a sequence of size int16.

Throw if an element is fractional, or out of range for an int16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeInt32(value)¶

Write value as an int32.

value is a number or a bigint; throw if it is fractional, or out of range for an int32.

Arguments:
  • value (number)

StreamBinaryWriter.writeInt32s(value, size)¶

Write value, a sequence of size int32.

Throw if an element is fractional, or out of range for an int32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeInt64(value)¶

Write value as an int64.

value is a number or a bigint; throw if it is fractional, or out of range for an int64.

Arguments:
  • value (number | bigint)

StreamBinaryWriter.writeInt64s(value, size)¶

Write value, a sequence of size int64.

Throw if an element is fractional, or out of range for an int64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeInt8(value)¶

Write value as an int8.

value is a number or a bigint; throw if it is fractional, or out of range for an int8.

Arguments:
  • value (number)

StreamBinaryWriter.writeInt8s(value, size)¶

Write value, a sequence of size int8.

Throw if an element is fractional, or out of range for an int8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeString(value)¶

Write value as a string.

Throw if value is not a string.

Arguments:
  • value (string)

StreamBinaryWriter.writeUint16(value)¶

Write value as a uint16.

value is a number or a bigint; throw if it is fractional, or out of range for a uint16.

Arguments:
  • value (number)

StreamBinaryWriter.writeUint16s(value, size)¶

Write value, a sequence of size uint16.

Throw if an element is fractional, or out of range for a uint16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeUint32(value)¶

Write value as a uint32.

value is a number or a bigint; throw if it is fractional, or out of range for a uint32.

Arguments:
  • value (number)

StreamBinaryWriter.writeUint32s(value, size)¶

Write value, a sequence of size uint32.

Throw if an element is fractional, or out of range for a uint32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeUint64(value)¶

Write value as a uint64.

value is a number or a bigint; throw if it is fractional, or out of range for a uint64.

Arguments:
  • value (number | bigint)

StreamBinaryWriter.writeUint64s(value, size)¶

Write value, a sequence of size uint64.

Throw if an element is fractional, or out of range for a uint64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeUint8(value)¶

Write value as a uint8.

value is a number or a bigint; throw if it is fractional, or out of range for a uint8.

Arguments:
  • value (number)

StreamBinaryWriter.writeUint8s(value, size)¶

Write value, a sequence of size uint8.

Throw if an element is fractional, or out of range for a uint8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamBinaryWriter.writeUuid(value)¶

Write value as a uuid.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueUUId)

class StreamTokenBinaryReader(streamRawReading)¶

Reads a portable binary stream that carries a type token per value.

Each read checks the token before decoding, so reading a value as another type fails at that value instead of returning nonsense. The token names a type only: corrupted bytes inside a value of the right type still read. Larger and slower than StreamBinary.

exported from index.d

Arguments:
  • streamRawReading (StreamRawReading)

StreamTokenBinaryReader.readBlob()¶

Read and return a blob.

Returns:

ValueBlob

StreamTokenBinaryReader.readBlobId()¶

Read and return a blobId.

Returns:

ValueBlobId

StreamTokenBinaryReader.readBool()¶

Read a bool and return it as a boolean.

Returns:

boolean

StreamTokenBinaryReader.readCommitId()¶

Read and return a commitId.

Returns:

ValueCommitId

StreamTokenBinaryReader.readDouble()¶

Read a double and return it as a number.

Returns:

number

StreamTokenBinaryReader.readDoubles(size)¶
Read size double and return them as a vec<double, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readFloat()¶

Read a float and return it as a number.

Returns:

number

StreamTokenBinaryReader.readFloats(size)¶
Read size float and return them as a vec<float, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readInt16()¶

Read a int16 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readInt16s(size)¶
Read size int16 and return them as a vec<int16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readInt32()¶

Read a int32 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readInt32s(size)¶
Read size int32 and return them as a vec<int32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readInt64()¶

Read an int64 and return it as a bigint.

Returns:

bigint

StreamTokenBinaryReader.readInt64s(size)¶
Read size int64 and return them as a vec<int64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readInt8()¶

Read a int8 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readInt8s(size)¶
Read size int8 and return them as a vec<int8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readString()¶

Read and return a string.

Returns:

string

StreamTokenBinaryReader.readUint16()¶

Read a uint16 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readUint16s(size)¶
Read size uint16 and return them as a vec<uint16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readUint32()¶

Read a uint32 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readUint32s(size)¶
Read size uint32 and return them as a vec<uint32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readUint64()¶

Read a uint64 and return it as a bigint.

Returns:

bigint

StreamTokenBinaryReader.readUint64s(size)¶
Read size uint64 and return them as a vec<uint64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readUint8()¶

Read a uint8 and return it as a number.

Returns:

number

StreamTokenBinaryReader.readUint8s(size)¶
Read size uint8 and return them as a vec<uint8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamTokenBinaryReader.readUuid()¶

Read and return a uuid.

Returns:

ValueUUId

StreamTokenBinaryReader.remaining()¶

Return the number of bytes left to read.

Returns:

number

StreamTokenBinaryReader.streamReading()¶

Return the StreamReading interface.

Returns:

StreamReading

class StreamTokenBinaryWriter(streamRawWriting)¶

Writes a portable binary stream with a type token per value.

The token lets a reader check each value before decoding it, at the cost of size and speed. Its reader is StreamTokenBinaryReader.

exported from index.d

Arguments:
  • streamRawWriting (StreamRawWriting)

StreamTokenBinaryWriter.streamWriting()¶

Return the StreamWriting interface.

Returns:

StreamWriting

StreamTokenBinaryWriter.writeBlob(value)¶

Write value as a blob.

A base64 string is accepted and decoded.

Arguments:
  • value (ValueBlob)

StreamTokenBinaryWriter.writeBlobId(value)¶

Write value as a blobId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueBlobId)

StreamTokenBinaryWriter.writeBool(value)¶

Write value as a bool.

Throw if value is not a boolean.

Arguments:
  • value (boolean)

StreamTokenBinaryWriter.writeCommitId(value)¶

Write value as a commitId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueCommitId)

StreamTokenBinaryWriter.writeDouble(value)¶

Write value as a double.

A bigint is accepted and converted.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeDoubles(value, size)¶

Write value, a sequence of size double.

A bigint element is accepted and converted.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeFloat(value)¶

Write value as a float.

Throw if the value does not fit in 32 bits.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeFloats(value, size)¶

Write value, a sequence of size float.

Throw if a value does not fit in 32 bits.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeInt16(value)¶

Write value as an int16.

value is a number or a bigint; throw if it is fractional, or out of range for an int16.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeInt16s(value, size)¶

Write value, a sequence of size int16.

Throw if an element is fractional, or out of range for an int16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeInt32(value)¶

Write value as an int32.

value is a number or a bigint; throw if it is fractional, or out of range for an int32.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeInt32s(value, size)¶

Write value, a sequence of size int32.

Throw if an element is fractional, or out of range for an int32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeInt64(value)¶

Write value as an int64.

value is a number or a bigint; throw if it is fractional, or out of range for an int64.

Arguments:
  • value (number | bigint)

StreamTokenBinaryWriter.writeInt64s(value, size)¶

Write value, a sequence of size int64.

Throw if an element is fractional, or out of range for an int64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeInt8(value)¶

Write value as an int8.

value is a number or a bigint; throw if it is fractional, or out of range for an int8.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeInt8s(value, size)¶

Write value, a sequence of size int8.

Throw if an element is fractional, or out of range for an int8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeString(value)¶

Write value as a string.

Throw if value is not a string.

Arguments:
  • value (string)

StreamTokenBinaryWriter.writeUint16(value)¶

Write value as a uint16.

value is a number or a bigint; throw if it is fractional, or out of range for a uint16.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeUint16s(value, size)¶

Write value, a sequence of size uint16.

Throw if an element is fractional, or out of range for a uint16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeUint32(value)¶

Write value as a uint32.

value is a number or a bigint; throw if it is fractional, or out of range for a uint32.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeUint32s(value, size)¶

Write value, a sequence of size uint32.

Throw if an element is fractional, or out of range for a uint32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeUint64(value)¶

Write value as a uint64.

value is a number or a bigint; throw if it is fractional, or out of range for a uint64.

Arguments:
  • value (number | bigint)

StreamTokenBinaryWriter.writeUint64s(value, size)¶

Write value, a sequence of size uint64.

Throw if an element is fractional, or out of range for a uint64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeUint8(value)¶

Write value as a uint8.

value is a number or a bigint; throw if it is fractional, or out of range for a uint8.

Arguments:
  • value (number)

StreamTokenBinaryWriter.writeUint8s(value, size)¶

Write value, a sequence of size uint8.

Throw if an element is fractional, or out of range for a uint8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamTokenBinaryWriter.writeUuid(value)¶

Write value as a uuid.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueUUId)

class StreamReaderBlob(blob)¶

Reads data from a blob.

exported from index.d

Arguments:
  • blob (ValueBlob)

StreamReaderBlob.blob()¶

Return the blob being read.

Returns:

ValueBlob

StreamReaderBlob.offset()¶

Return how many bytes have been read so far.

Returns:

number

StreamReaderBlob.streamRawReading()¶

Return the StreamRawReading interface.

Returns:

StreamRawReading

class StreamReaderFile(path)¶

Reads data from a file.

exported from index.d

Arguments:
  • path (string)

StreamReaderFile.[Symbol․dispose]()¶

Release the resource at scope exit via using (TC39 disposable); delegates to close(). Idempotent.

StreamReaderFile.close()¶

Close the file.

StreamReaderFile.offset()¶

Return the current position in the file, in bytes.

Returns:

number

StreamReaderFile.streamRawReading()¶

Return the StreamRawReading interface.

Returns:

StreamRawReading

class StreamReaderSharedMemory(sharedMemory)¶

Reads data from a shared memory region.

exported from index.d

Arguments:
  • sharedMemory (SharedMemory)

StreamReaderSharedMemory.offset()¶

Return the current position in the region, in bytes.

Returns:

number

StreamReaderSharedMemory.rewind()¶

Rewind the stream.

StreamReaderSharedMemory.size()¶

Return the size of the shared region, in bytes.

Returns:

number

StreamReaderSharedMemory.streamRawReading()¶

Return the StreamRawReading interface.

Returns:

StreamRawReading

class StreamWriterBlob()¶

Writes data to a blob.

exported from index.d

StreamWriterBlob.blob()¶

Return the blob written so far.

Returns:

ValueBlob

StreamWriterBlob.streamRawWriting()¶

Return the StreamRawWriting interface.

Returns:

StreamRawWriting

class StreamWriterFile(path)¶

Writes data to a file.

The file is created, or truncated when it already exists, as soon as the writer is constructed; an unwritable path throws there.

The bytes are buffered, so close() is what puts them on disk - a file left unclosed is short or empty. The writer must outlive the codec writer built over its streamRawWriting().

exported from index.d

Arguments:
  • path (string)

StreamWriterFile.[Symbol․dispose]()¶

Release the resource at scope exit via using (TC39 disposable); delegates to close(). Idempotent.

StreamWriterFile.close()¶

Close the file.

StreamWriterFile.offset()¶

Return how many bytes have been written, counting those still buffered.

Returns:

number

StreamWriterFile.streamRawWriting()¶

Return the StreamRawWriting interface.

Returns:

StreamRawWriting

class StreamWriterSharedMemory(sharedMemory)¶

Writes data to a shared memory region.

exported from index.d

Arguments:
  • sharedMemory (SharedMemory)

StreamWriterSharedMemory.offset()¶

Return how many bytes have been written into the region.

Returns:

number

StreamWriterSharedMemory.rewind()¶

Rewind the stream.

StreamWriterSharedMemory.streamRawWriting()¶

Return the StreamRawWriting interface.

Returns:

StreamRawWriting

class StreamReading()¶

The typed read interface.

readBool, readString, readUuid and the rest, over the bytes a StreamRawReading supplies.

Note: Not directly instantiable.

exported from index.d

StreamReading.readBlob()¶

Read and return a blob.

Returns:

ValueBlob

StreamReading.readBlobId()¶

Read and return a blobId.

Returns:

ValueBlobId

StreamReading.readBool()¶

Read a bool and return it as a boolean.

Returns:

boolean

StreamReading.readCommitId()¶

Read and return a commitId.

Returns:

ValueCommitId

StreamReading.readDouble()¶

Read a double and return it as a number.

Returns:

number

StreamReading.readDoubles(size)¶
Read size double and return them as a vec<double, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readFloat()¶

Read a float and return it as a number.

Returns:

number

StreamReading.readFloats(size)¶
Read size float and return them as a vec<float, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readInt16()¶

Read a int16 and return it as a number.

Returns:

number

StreamReading.readInt16s(size)¶
Read size int16 and return them as a vec<int16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readInt32()¶

Read a int32 and return it as a number.

Returns:

number

StreamReading.readInt32s(size)¶
Read size int32 and return them as a vec<int32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readInt64()¶

Read an int64 and return it as a bigint.

Returns:

bigint

StreamReading.readInt64s(size)¶
Read size int64 and return them as a vec<int64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readInt8()¶

Read a int8 and return it as a number.

Returns:

number

StreamReading.readInt8s(size)¶
Read size int8 and return them as a vec<int8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readString()¶

Read and return a string.

Returns:

string

StreamReading.readUint16()¶

Read a uint16 and return it as a number.

Returns:

number

StreamReading.readUint16s(size)¶
Read size uint16 and return them as a vec<uint16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readUint32()¶

Read a uint32 and return it as a number.

Returns:

number

StreamReading.readUint32s(size)¶
Read size uint32 and return them as a vec<uint32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readUint64()¶

Read a uint64 and return it as a bigint.

Returns:

bigint

StreamReading.readUint64s(size)¶
Read size uint64 and return them as a vec<uint64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readUint8()¶

Read a uint8 and return it as a number.

Returns:

number

StreamReading.readUint8s(size)¶
Read size uint8 and return them as a vec<uint8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamReading.readUuid()¶

Read and return a uuid.

Returns:

ValueUUId

StreamReading.remaining()¶

Return the number of bytes left to read.

Returns:

number

class StreamWriting()¶

The typed write interface.

writeBool, writeString, writeUuid and the rest, onto the bytes a StreamRawWriting accepts.

Note: Not directly instantiable.

exported from index.d

StreamWriting.writeBlob(value)¶

Write value as a blob.

A base64 string is accepted and decoded.

Arguments:
  • value (ValueBlob)

StreamWriting.writeBlobId(value)¶

Write value as a blobId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueBlobId)

StreamWriting.writeBool(value)¶

Write value as a bool.

Throw if value is not a boolean.

Arguments:
  • value (boolean)

StreamWriting.writeCommitId(value)¶

Write value as a commitId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueCommitId)

StreamWriting.writeDouble(value)¶

Write value as a double.

A bigint is accepted and converted.

Arguments:
  • value (number)

StreamWriting.writeDoubles(value, size)¶

Write value, a sequence of size double.

A bigint element is accepted and converted.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeFloat(value)¶

Write value as a float.

Throw if the value does not fit in 32 bits.

Arguments:
  • value (number)

StreamWriting.writeFloats(value, size)¶

Write value, a sequence of size float.

Throw if a value does not fit in 32 bits.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeInt16(value)¶

Write value as an int16.

value is a number or a bigint; throw if it is fractional, or out of range for an int16.

Arguments:
  • value (number)

StreamWriting.writeInt16s(value, size)¶

Write value, a sequence of size int16.

Throw if an element is fractional, or out of range for an int16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeInt32(value)¶

Write value as an int32.

value is a number or a bigint; throw if it is fractional, or out of range for an int32.

Arguments:
  • value (number)

StreamWriting.writeInt32s(value, size)¶

Write value, a sequence of size int32.

Throw if an element is fractional, or out of range for an int32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeInt64(value)¶

Write value as an int64.

value is a number or a bigint; throw if it is fractional, or out of range for an int64.

Arguments:
  • value (number | bigint)

StreamWriting.writeInt64s(value, size)¶

Write value, a sequence of size int64.

Throw if an element is fractional, or out of range for an int64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeInt8(value)¶

Write value as an int8.

value is a number or a bigint; throw if it is fractional, or out of range for an int8.

Arguments:
  • value (number)

StreamWriting.writeInt8s(value, size)¶

Write value, a sequence of size int8.

Throw if an element is fractional, or out of range for an int8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeString(value)¶

Write value as a string.

Throw if value is not a string.

Arguments:
  • value (string)

StreamWriting.writeUint16(value)¶

Write value as a uint16.

value is a number or a bigint; throw if it is fractional, or out of range for a uint16.

Arguments:
  • value (number)

StreamWriting.writeUint16s(value, size)¶

Write value, a sequence of size uint16.

Throw if an element is fractional, or out of range for a uint16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeUint32(value)¶

Write value as a uint32.

value is a number or a bigint; throw if it is fractional, or out of range for a uint32.

Arguments:
  • value (number)

StreamWriting.writeUint32s(value, size)¶

Write value, a sequence of size uint32.

Throw if an element is fractional, or out of range for a uint32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeUint64(value)¶

Write value as a uint64.

value is a number or a bigint; throw if it is fractional, or out of range for a uint64.

Arguments:
  • value (number | bigint)

StreamWriting.writeUint64s(value, size)¶

Write value, a sequence of size uint64.

Throw if an element is fractional, or out of range for a uint64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeUint8(value)¶

Write value as a uint8.

value is a number or a bigint; throw if it is fractional, or out of range for a uint8.

Arguments:
  • value (number)

StreamWriting.writeUint8s(value, size)¶

Write value, a sequence of size uint8.

Throw if an element is fractional, or out of range for a uint8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamWriting.writeUuid(value)¶

Write value as a uuid.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueUUId)

class StreamEncoding()¶

Writes typed values into a blob.

One of the three a codec instantiates, with StreamDecoding to read them back and StreamSizing to predict the size of its fixed-width values.

Note: Not directly instantiable.

exported from index.d

StreamEncoding.endEncoding()¶

Return the blob and set the flag ended to true.

Returns:

ValueBlob

StreamEncoding.isEnded()¶

Return true if the stream is ended.

Returns:

boolean

StreamEncoding.streamWriting()¶

Return a StreamWriting interface.

Returns:

StreamWriting

StreamEncoding.writeBlob(value)¶

Write value as a blob.

A base64 string is accepted and decoded.

Arguments:
  • value (ValueBlob)

StreamEncoding.writeBlobId(value)¶

Write value as a blobId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueBlobId)

StreamEncoding.writeBool(value)¶

Write value as a bool.

Throw if value is not a boolean.

Arguments:
  • value (boolean)

StreamEncoding.writeCommitId(value)¶

Write value as a commitId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueCommitId)

StreamEncoding.writeDouble(value)¶

Write value as a double.

A bigint is accepted and converted.

Arguments:
  • value (number)

StreamEncoding.writeDoubles(value, size)¶

Write value, a sequence of size double.

A bigint element is accepted and converted.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeFloat(value)¶

Write value as a float.

Throw if the value does not fit in 32 bits.

Arguments:
  • value (number)

StreamEncoding.writeFloats(value, size)¶

Write value, a sequence of size float.

Throw if a value does not fit in 32 bits.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeInt16(value)¶

Write value as an int16.

value is a number or a bigint; throw if it is fractional, or out of range for an int16.

Arguments:
  • value (number)

StreamEncoding.writeInt16s(value, size)¶

Write value, a sequence of size int16.

Throw if an element is fractional, or out of range for an int16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeInt32(value)¶

Write value as an int32.

value is a number or a bigint; throw if it is fractional, or out of range for an int32.

Arguments:
  • value (number)

StreamEncoding.writeInt32s(value, size)¶

Write value, a sequence of size int32.

Throw if an element is fractional, or out of range for an int32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeInt64(value)¶

Write value as an int64.

value is a number or a bigint; throw if it is fractional, or out of range for an int64.

Arguments:
  • value (number | bigint)

StreamEncoding.writeInt64s(value, size)¶

Write value, a sequence of size int64.

Throw if an element is fractional, or out of range for an int64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeInt8(value)¶

Write value as an int8.

value is a number or a bigint; throw if it is fractional, or out of range for an int8.

Arguments:
  • value (number)

StreamEncoding.writeInt8s(value, size)¶

Write value, a sequence of size int8.

Throw if an element is fractional, or out of range for an int8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeString(value)¶

Write value as a string.

Throw if value is not a string.

Arguments:
  • value (string)

StreamEncoding.writeUint16(value)¶

Write value as a uint16.

value is a number or a bigint; throw if it is fractional, or out of range for a uint16.

Arguments:
  • value (number)

StreamEncoding.writeUint16s(value, size)¶

Write value, a sequence of size uint16.

Throw if an element is fractional, or out of range for a uint16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeUint32(value)¶

Write value as a uint32.

value is a number or a bigint; throw if it is fractional, or out of range for a uint32.

Arguments:
  • value (number)

StreamEncoding.writeUint32s(value, size)¶

Write value, a sequence of size uint32.

Throw if an element is fractional, or out of range for a uint32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeUint64(value)¶

Write value as a uint64.

value is a number or a bigint; throw if it is fractional, or out of range for a uint64.

Arguments:
  • value (number | bigint)

StreamEncoding.writeUint64s(value, size)¶

Write value, a sequence of size uint64.

Throw if an element is fractional, or out of range for a uint64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeUint8(value)¶

Write value as a uint8.

value is a number or a bigint; throw if it is fractional, or out of range for a uint8.

Arguments:
  • value (number)

StreamEncoding.writeUint8s(value, size)¶

Write value, a sequence of size uint8.

Throw if an element is fractional, or out of range for a uint8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamEncoding.writeUuid(value)¶

Write value as a uuid.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueUUId)

class StreamDecoding()¶

Reads typed values back from a blob.

Tracks its own position - offset, remaining, hasMore - so a blob can be consumed value by value. The reading half of what StreamEncoding wrote.

Note: Not directly instantiable.

exported from index.d

StreamDecoding.blob()¶

Return the blob being decoded.

Returns:

ValueBlob

StreamDecoding.hasMore()¶

Return true if there is something to read.

Returns:

boolean

StreamDecoding.offset()¶

Return the offset in the stream.

Returns:

number

StreamDecoding.readBlob()¶

Read and return a blob.

Returns:

ValueBlob

StreamDecoding.readBlobId()¶

Read and return a blobId.

Returns:

ValueBlobId

StreamDecoding.readBool()¶

Read a bool and return it as a boolean.

Returns:

boolean

StreamDecoding.readCommitId()¶

Read and return a commitId.

Returns:

ValueCommitId

StreamDecoding.readDouble()¶

Read a double and return it as a number.

Returns:

number

StreamDecoding.readDoubles(size)¶
Read size double and return them as a vec<double, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readFloat()¶

Read a float and return it as a number.

Returns:

number

StreamDecoding.readFloats(size)¶
Read size float and return them as a vec<float, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readInt16()¶

Read a int16 and return it as a number.

Returns:

number

StreamDecoding.readInt16s(size)¶
Read size int16 and return them as a vec<int16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readInt32()¶

Read a int32 and return it as a number.

Returns:

number

StreamDecoding.readInt32s(size)¶
Read size int32 and return them as a vec<int32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readInt64()¶

Read an int64 and return it as a bigint.

Returns:

bigint

StreamDecoding.readInt64s(size)¶
Read size int64 and return them as a vec<int64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readInt8()¶

Read a int8 and return it as a number.

Returns:

number

StreamDecoding.readInt8s(size)¶
Read size int8 and return them as a vec<int8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readString()¶

Read and return a string.

Returns:

string

StreamDecoding.readUint16()¶

Read a uint16 and return it as a number.

Returns:

number

StreamDecoding.readUint16s(size)¶
Read size uint16 and return them as a vec<uint16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readUint32()¶

Read a uint32 and return it as a number.

Returns:

number

StreamDecoding.readUint32s(size)¶
Read size uint32 and return them as a vec<uint32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readUint64()¶

Read a uint64 and return it as a bigint.

Returns:

bigint

StreamDecoding.readUint64s(size)¶
Read size uint64 and return them as a vec<uint64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readUint8()¶

Read a uint8 and return it as a number.

Returns:

number

StreamDecoding.readUint8s(size)¶
Read size uint8 and return them as a vec<uint8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamDecoding.readUuid()¶

Read and return a uuid.

Returns:

ValueUUId

StreamDecoding.remaining()¶

Return the number of bytes left to read.

Returns:

number

StreamDecoding.rewind()¶

Rewind the stream.

StreamDecoding.streamReading()¶

Return the StreamReading interface.

Returns:

StreamReading

class StreamSizing()¶

Computes how many bytes the fixed-width types occupy under one codec.

Strings and blobs are variable-length and have no sizeOf here, so a total is exact only over fixed-width values. The answers follow the codec: a token codec adds a byte per value. The size a sizeOf*s method takes is a count of elements, not of bytes.

Note: Not directly instantiable.

exported from index.d

StreamSizing.sizeOfBlobId()¶

Return the number of bytes a blobId occupies.

Returns:

number

StreamSizing.sizeOfBool()¶

Return the number of bytes a bool occupies.

Returns:

number

StreamSizing.sizeOfCommitId()¶

Return the number of bytes a commitId occupies.

Returns:

number

StreamSizing.sizeOfDouble()¶

Return the number of bytes a double occupies.

Returns:

number

StreamSizing.sizeOfDoubles(size)¶

Return the number of bytes size double occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfFloat()¶

Return the number of bytes a float occupies.

Returns:

number

StreamSizing.sizeOfFloats(size)¶

Return the number of bytes size float occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfInt16()¶

Return the number of bytes an int16 occupies.

Returns:

number

StreamSizing.sizeOfInt16s(size)¶

Return the number of bytes size int16 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfInt32()¶

Return the number of bytes an int32 occupies.

Returns:

number

StreamSizing.sizeOfInt32s(size)¶

Return the number of bytes size int32 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfInt64()¶

Return the number of bytes an int64 occupies.

Returns:

number

StreamSizing.sizeOfInt64s(size)¶

Return the number of bytes size int64 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfInt8()¶

Return the number of bytes an int8 occupies.

Returns:

number

StreamSizing.sizeOfInt8s(size)¶

Return the number of bytes size int8 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfUint16()¶

Return the number of bytes a uint16 occupies.

Returns:

number

StreamSizing.sizeOfUint16s(size)¶

Return the number of bytes size uint16 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfUint32()¶

Return the number of bytes a uint32 occupies.

Returns:

number

StreamSizing.sizeOfUint32s(size)¶

Return the number of bytes size uint32 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfUint64()¶

Return the number of bytes a uint64 occupies.

Returns:

number

StreamSizing.sizeOfUint64s(size)¶

Return the number of bytes size uint64 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfUint8()¶

Return the number of bytes a uint8 occupies.

Returns:

number

StreamSizing.sizeOfUint8s(size)¶

Return the number of bytes size uint8 occupy.

Arguments:
  • size (number)

Returns:

number

StreamSizing.sizeOfUuid()¶

Return the number of bytes a uuid occupies.

Returns:

number

class StreamRawReader(streamRawReading)¶

Reads values in the machine’s own byte order.

Raw here is the byte order, not the byte-level StreamRawReading its constructor takes - every codec reader takes one of those.

The fastest of the three readers, and the least portable: a stream written on one endianness reads on the other without error, answering numbers built from the wrong bytes. Use it for memory and same-machine transfers.

exported from index.d

Arguments:
  • streamRawReading (StreamRawReading)

StreamRawReader.readBlob()¶

Read and return a blob.

Returns:

ValueBlob

StreamRawReader.readBlobId()¶

Read and return a blobId.

Returns:

ValueBlobId

StreamRawReader.readBool()¶

Read a bool and return it as a boolean.

Returns:

boolean

StreamRawReader.readCommitId()¶

Read and return a commitId.

Returns:

ValueCommitId

StreamRawReader.readDouble()¶

Read a double and return it as a number.

Returns:

number

StreamRawReader.readDoubles(size)¶
Read size double and return them as a vec<double, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readFloat()¶

Read a float and return it as a number.

Returns:

number

StreamRawReader.readFloats(size)¶
Read size float and return them as a vec<float, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readInt16()¶

Read a int16 and return it as a number.

Returns:

number

StreamRawReader.readInt16s(size)¶
Read size int16 and return them as a vec<int16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readInt32()¶

Read a int32 and return it as a number.

Returns:

number

StreamRawReader.readInt32s(size)¶
Read size int32 and return them as a vec<int32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readInt64()¶

Read an int64 and return it as a bigint.

Returns:

bigint

StreamRawReader.readInt64s(size)¶
Read size int64 and return them as a vec<int64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readInt8()¶

Read a int8 and return it as a number.

Returns:

number

StreamRawReader.readInt8s(size)¶
Read size int8 and return them as a vec<int8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readString()¶

Read and return a string.

Returns:

string

StreamRawReader.readUint16()¶

Read a uint16 and return it as a number.

Returns:

number

StreamRawReader.readUint16s(size)¶
Read size uint16 and return them as a vec<uint16, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readUint32()¶

Read a uint32 and return it as a number.

Returns:

number

StreamRawReader.readUint32s(size)¶
Read size uint32 and return them as a vec<uint32, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readUint64()¶

Read a uint64 and return it as a bigint.

Returns:

bigint

StreamRawReader.readUint64s(size)¶
Read size uint64 and return them as a vec<uint64, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readUint8()¶

Read a uint8 and return it as a number.

Returns:

number

StreamRawReader.readUint8s(size)¶
Read size uint8 and return them as a vec<uint8, size>, a ValueVec; toArray() gives

the native array.

Arguments:
  • size (number)

Returns:

ValueVec

StreamRawReader.readUuid()¶

Read and return a uuid.

Returns:

ValueUUId

StreamRawReader.remaining()¶

Return the number of bytes left to read.

Returns:

number

StreamRawReader.streamReading()¶

Return the StreamReading interface.

Returns:

StreamReading

class StreamRawWriter(streamRawWriting)¶

Writes values in the machine’s own byte order.

Raw here is the byte order, not the byte-level StreamRawWriting its constructor takes - every codec writer takes one of those.

The fastest of the three writers, and the least portable: a stream written on one endianness reads on the other without error, answering numbers built from the wrong bytes. Use it for memory and same-machine transfers.

exported from index.d

Arguments:
  • streamRawWriting (StreamRawWriting)

StreamRawWriter.streamWriting()¶

Return the StreamWriting interface.

Returns:

StreamWriting

StreamRawWriter.writeBlob(value)¶

Write value as a blob.

A base64 string is accepted and decoded.

Arguments:
  • value (ValueBlob)

StreamRawWriter.writeBlobId(value)¶

Write value as a blobId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueBlobId)

StreamRawWriter.writeBool(value)¶

Write value as a bool.

Throw if value is not a boolean.

Arguments:
  • value (boolean)

StreamRawWriter.writeCommitId(value)¶

Write value as a commitId.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueCommitId)

StreamRawWriter.writeDouble(value)¶

Write value as a double.

A bigint is accepted and converted.

Arguments:
  • value (number)

StreamRawWriter.writeDoubles(value, size)¶

Write value, a sequence of size double.

A bigint element is accepted and converted.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeFloat(value)¶

Write value as a float.

Throw if the value does not fit in 32 bits.

Arguments:
  • value (number)

StreamRawWriter.writeFloats(value, size)¶

Write value, a sequence of size float.

Throw if a value does not fit in 32 bits.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeInt16(value)¶

Write value as an int16.

value is a number or a bigint; throw if it is fractional, or out of range for an int16.

Arguments:
  • value (number)

StreamRawWriter.writeInt16s(value, size)¶

Write value, a sequence of size int16.

Throw if an element is fractional, or out of range for an int16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeInt32(value)¶

Write value as an int32.

value is a number or a bigint; throw if it is fractional, or out of range for an int32.

Arguments:
  • value (number)

StreamRawWriter.writeInt32s(value, size)¶

Write value, a sequence of size int32.

Throw if an element is fractional, or out of range for an int32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeInt64(value)¶

Write value as an int64.

value is a number or a bigint; throw if it is fractional, or out of range for an int64.

Arguments:
  • value (number | bigint)

StreamRawWriter.writeInt64s(value, size)¶

Write value, a sequence of size int64.

Throw if an element is fractional, or out of range for an int64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeInt8(value)¶

Write value as an int8.

value is a number or a bigint; throw if it is fractional, or out of range for an int8.

Arguments:
  • value (number)

StreamRawWriter.writeInt8s(value, size)¶

Write value, a sequence of size int8.

Throw if an element is fractional, or out of range for an int8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeString(value)¶

Write value as a string.

Throw if value is not a string.

Arguments:
  • value (string)

StreamRawWriter.writeUint16(value)¶

Write value as a uint16.

value is a number or a bigint; throw if it is fractional, or out of range for a uint16.

Arguments:
  • value (number)

StreamRawWriter.writeUint16s(value, size)¶

Write value, a sequence of size uint16.

Throw if an element is fractional, or out of range for a uint16.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeUint32(value)¶

Write value as a uint32.

value is a number or a bigint; throw if it is fractional, or out of range for a uint32.

Arguments:
  • value (number)

StreamRawWriter.writeUint32s(value, size)¶

Write value, a sequence of size uint32.

Throw if an element is fractional, or out of range for a uint32.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeUint64(value)¶

Write value as a uint64.

value is a number or a bigint; throw if it is fractional, or out of range for a uint64.

Arguments:
  • value (number | bigint)

StreamRawWriter.writeUint64s(value, size)¶

Write value, a sequence of size uint64.

Throw if an element is fractional, or out of range for a uint64.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeUint8(value)¶

Write value as a uint8.

value is a number or a bigint; throw if it is fractional, or out of range for a uint8.

Arguments:
  • value (number)

StreamRawWriter.writeUint8s(value, size)¶

Write value, a sequence of size uint8.

Throw if an element is fractional, or out of range for a uint8.

Arguments:
  • value (ValueVec | InputValue[])

  • size (number)

StreamRawWriter.writeUuid(value)¶

Write value as a uuid.

A string is accepted and parsed; throw if it is neither.

Arguments:
  • value (ValueUUId)

class StreamRawReading()¶

An opaque handle on a byte source, whose one operation is size().

StreamReaderBlob.streamRawReading() and its siblings answer one, and a codec reader is built over it. The typed reads live on StreamReading.

Note: Not directly instantiable.

exported from index.d

StreamRawReading.size()¶

Return the total number of bytes in the stream.

Returns:

number

class StreamRawWriting()¶

An opaque handle on a byte sink, with no operation of its own.

StreamWriterFile.streamRawWriting() and its siblings answer one, and a codec writer is built over it. The typed writes live on StreamWriting.

Note: Not directly instantiable.

exported from index.d