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.jsonEncode / Value.jsonDecode (JSON, for web and REST), 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.jsonEncode(value);
console.log(value.equals(Value.jsonDecode(json, 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 |
|
Default codec; decode needs type + const definitions |
JSON for web / REST |
|
Web integration |
Native format |
|
Round-trips like the others |
Specific wire format |
|
|
Encoder / decoder / sizer |
|
|
Predict encoded size |
|
Byte length without building a blob |
File / blob / shared-memory I/O |
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.
Summary¶
Class |
Description |
|---|---|
A class used to instantiate a codec |
|
A class used to generate a random value |
|
A class used to read data through the StreamRawReading interface (handle endianness) |
|
A class used to write data through the StreamRawWriting interface (handle endianness) |
|
An interface used to create encoder, decoder and sizer |
|
An interface used to read data from a blob |
|
An interface used to write data to a blob |
|
An class used to read data through the StreamRawReading interface |
|
An interface used to read data |
|
A class used to write data through the StreamRawWriting interface |
|
An interface to write data |
|
A class used to read data from a blob |
|
A class used to read data from a file |
|
A class used to read data from a shared memory region |
|
An interface used to read data |
|
An interface used to get the size of data |
|
A class used to read through the StreamRawReading interface (handle endianness) |
|
A class used to write through the StreamRawWriting interface (handle endianness) |
|
A class used to write data to a blob |
|
A class used to write data to a file |
|
A class used to write data to a shared memory region |
|
An interface used to read data |
Reference¶
- class Codec()¶
- A class used to instantiate a codec. Use the static factory method check(…)
and query(…).
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 interface of the codec or throw.
- Arguments:
name (string)
- Returns:
StreamCodecInstancing
- static Codec.query(name)¶
Return the StreamCodecInstancing interface of the codec or null.
- Arguments:
name (string)
- Returns:
StreamCodecInstancing
- class Fuzzer(definitions, seed)¶
A class used to generate a random value.
exported from
index.d- Arguments:
definitions (DefinitionsConst)
seed (number)
- Fuzzer.blobId()¶
Return The special uniq blob_id or null.
- Returns:
ValueBlobId | undefined
- Fuzzer.blobSize()¶
Return the size of the generated blob.
- Returns:
number
- Fuzzer.fuzz(type)¶
Generate and return a random value from the type.
- Arguments:
type (Type)
- Returns:
Value
- Fuzzer.mapSize()¶
Set the size of the generated map.
- Returns:
number
- Fuzzer.seed()¶
Return the seed used by the fuzzer.
- Returns:
number
- Fuzzer.setBlobId(blobId)¶
Set The special uniq blob_id if specified.
- Arguments:
blobId (ValueBlobId)
- Fuzzer.setBlobSize(value)¶
Set the size of the generated blob.
- Arguments:
value (number)
- Fuzzer.setMapSize(value)¶
Set the size of the generated map.
- Arguments:
value (number)
- Fuzzer.setSetSize(value)¶
Set the size of the generated set.
- Arguments:
value (number)
- Fuzzer.setSize()¶
Return the size of the generated set.
- Returns:
number
- Fuzzer.setStringSize(value)¶
Set the size of the generated string.
- Arguments:
value (number)
- Fuzzer.setVectorSize(value)¶
Set the size of the generated vector.
- Arguments:
value (number)
- Fuzzer.setXarraySize(value)¶
Set the size of the generated xarray.
- Arguments:
value (number)
- Fuzzer.stringSize()¶
Return the size of the generated string.
- 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)¶
- A class used to read data through the StreamRawReading interface
(handle endianness).
exported from
index.d- Arguments:
streamRawReading (StreamRawReading)
- StreamBinaryReader.readBlob()¶
Read and return a blob.
- Returns:
ValueBlob
- StreamBinaryReader.readBlobId()¶
Read and return a blob_id.
- Returns:
ValueBlobId
- StreamBinaryReader.readBool()¶
Read and return a bool.
- Returns:
boolean
- StreamBinaryReader.readCommitId()¶
Read and return a commit_id.
- Returns:
ValueCommitId
- StreamBinaryReader.readDouble()¶
Read and return a float.
- Returns:
number
- StreamBinaryReader.readDoubles(size)¶
Read an array of doubles and return a vec<double, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readFloat()¶
Read and return a float.
- Returns:
number
- StreamBinaryReader.readFloats(size)¶
Read an array of float and return a vec<float, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readInt16()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readInt16s(size)¶
Read an array of int16 and return a vec<int16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readInt32()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readInt32s(size)¶
Read an array of int32 and return a vec<int32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readInt64()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readInt64s(size)¶
Read an array of int64 and return a vec<int64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readInt8()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readInt8s(size)¶
Read an array of int8 and return a vec<int8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readString()¶
Read and return a string.
- Returns:
string
- StreamBinaryReader.readUint16()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readUint16s(size)¶
Read an array of uint16 and return a vec<uint16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readUint32()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readUint32s(size)¶
Read an array of uint32 and return a vec<uint32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readUint64()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readUint64s(size)¶
Read an array of uint64 and return a vec<uint64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamBinaryReader.readUint8()¶
Read and return a int.
- Returns:
number
- StreamBinaryReader.readUint8s(size)¶
Read an array of uint8 and return a vec<uint8, size>.
- 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)¶
- A class used to write data through the StreamRawWriting interface
(handle endianness).
exported from
index.d- Arguments:
streamRawWriting (StreamRawWriting)
- StreamBinaryWriter.streamWriting()¶
Return the StreamWriting interface.
- Returns:
StreamWriting
- StreamBinaryWriter.writeBlob(value)¶
Write a blob.
- Arguments:
value (ValueBlob)
- StreamBinaryWriter.writeBlobId(value)¶
Write a blob_id.
- Arguments:
value (ValueBlobId)
- StreamBinaryWriter.writeBool(value)¶
Write a bool.
- Arguments:
value (boolean)
- StreamBinaryWriter.writeCommitId(value)¶
Write a commit_id.
- Arguments:
value (ValueCommitId)
- StreamBinaryWriter.writeDouble(value)¶
Write a double.
- Arguments:
value (number)
- StreamBinaryWriter.writeDoubles(value, size)¶
Write an array of double.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeFloat(value)¶
Write a float.
- Arguments:
value (number)
- StreamBinaryWriter.writeFloats(value, size)¶
Write an array of float.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeInt16(value)¶
Write an int16.
- Arguments:
value (number)
- StreamBinaryWriter.writeInt16s(value, size)¶
Write an array of int16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeInt32(value)¶
Write an int32.
- Arguments:
value (number)
- StreamBinaryWriter.writeInt32s(value, size)¶
Write an array of int32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeInt64(value)¶
Write an int64.
- Arguments:
value (number)
- StreamBinaryWriter.writeInt64s(value, size)¶
Write an array of int64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeInt8(value)¶
Write an int8.
- Arguments:
value (number)
- StreamBinaryWriter.writeInt8s(value, size)¶
Write an array of int8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeString(value)¶
Write a string.
- Arguments:
value (string)
- StreamBinaryWriter.writeUint16(value)¶
Write an uint16.
- Arguments:
value (number)
- StreamBinaryWriter.writeUint16s(value, size)¶
Write an array of uint16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeUint32(value)¶
Write an uint32.
- Arguments:
value (number)
- StreamBinaryWriter.writeUint32s(value, size)¶
Write an array of uint32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeUint64(value)¶
Write an uint64.
- Arguments:
value (number)
- StreamBinaryWriter.writeUint64s(value, size)¶
Write an array of uint64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeUint8(value)¶
Write an uint8.
- Arguments:
value (number)
- StreamBinaryWriter.writeUint8s(value, size)¶
Write an array of uint8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamBinaryWriter.writeUuid(value)¶
Write an uuid.
- Arguments:
value (ValueUUId)
- class StreamCodecInstancing()¶
An interface used to create encoder, decoder and sizer.
Note: Not directly instantiable.
exported from
index.d- StreamCodecInstancing.createDecoder(blob)¶
Create and return a decoder.
- Arguments:
blob (ValueBlob)
- Returns:
StreamDecoding
- StreamCodecInstancing.createEncoder()¶
Create and return an encoder.
- Returns:
StreamEncoding
- StreamCodecInstancing.createSizer()¶
Create and return a sizer.
- Returns:
StreamSizing
- StreamCodecInstancing.name()¶
Return the name.
- Returns:
string
- class StreamDecoding()¶
An interface used to read data from a blob.
Note: Not directly instantiable.
exported from
index.d- StreamDecoding.blob()¶
Return the blob.
- Returns:
ValueBlob
- StreamDecoding.hasMore()¶
Return true if there is something to read.
- Returns:
boolean
- StreamDecoding.offset()¶
Read the offset in the stream.
- Returns:
number
- StreamDecoding.readBlob()¶
Read and return a blob.
- Returns:
ValueBlob
- StreamDecoding.readBlobId()¶
Read and return a blob_id.
- Returns:
ValueBlobId
- StreamDecoding.readBool()¶
Read and return a bool.
- Returns:
boolean
- StreamDecoding.readCommitId()¶
Read and return a commit_id.
- Returns:
ValueCommitId
- StreamDecoding.readDouble()¶
Read and return a float.
- Returns:
number
- StreamDecoding.readDoubles(size)¶
Read an array of doubles and return a vec<double, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readFloat()¶
Read aan return a float.
- Returns:
number
- StreamDecoding.readFloats(size)¶
Read an array of float and return a vec<float, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readInt16()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readInt16s(size)¶
Read an array of int16 and return a vec<int16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readInt32()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readInt32s(size)¶
Read an array of int32 and return a vec<int32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readInt64()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readInt64s(size)¶
Read an array of int64 and return a vec<int64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readInt8()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readInt8s(size)¶
Read an array of int8 and return a vec<int8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readString()¶
Read a return a string.
- Returns:
string
- StreamDecoding.readUint16()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readUint16s(size)¶
Read an array of uint16 and return a vec<uint16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readUint32()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readUint32s(size)¶
Read an array of uint32 and return a vec<uint32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readUint64()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readUint64s(size)¶
Read an array of uint64 and return a vec<uint64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readUint8()¶
Read and return a int.
- Returns:
number
- StreamDecoding.readUint8s(size)¶
Read an array of uint8 and return a vec<uint8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamDecoding.readUuid()¶
Read and return an 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 StreamEncoding()¶
An interface used to write data to a blob.
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 a blob.
- Arguments:
value (ValueBlob)
- StreamEncoding.writeBlobId(value)¶
Write a blob_id.
- Arguments:
value (ValueBlobId)
- StreamEncoding.writeBool(value)¶
Write a bool.
- Arguments:
value (boolean)
- StreamEncoding.writeCommitId(value)¶
Write a commit_id.
- Arguments:
value (ValueCommitId)
- StreamEncoding.writeDouble(value)¶
Write a double.
- Arguments:
value (number)
- StreamEncoding.writeDoubles(value, size)¶
Write an array of double.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeFloat(value)¶
Write a float.
- Arguments:
value (number)
- StreamEncoding.writeFloats(value, size)¶
Write an array of float.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeInt16(value)¶
Write an int16.
- Arguments:
value (number)
- StreamEncoding.writeInt16s(value, size)¶
Write an array of int16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeInt32(value)¶
Write an int32.
- Arguments:
value (number)
- StreamEncoding.writeInt32s(value, size)¶
Write an array of int32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeInt64(value)¶
Write an int64.
- Arguments:
value (number)
- StreamEncoding.writeInt64s(value, size)¶
Write an array of int64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeInt8(value)¶
Write an int8.
- Arguments:
value (number)
- StreamEncoding.writeInt8s(value, size)¶
Write an array of int8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeString(value)¶
Write a string.
- Arguments:
value (string)
- StreamEncoding.writeUint16(value)¶
Write an uint16.
- Arguments:
value (number)
- StreamEncoding.writeUint16s(value, size)¶
Write an array of uint16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeUint32(value)¶
Write an uint32.
- Arguments:
value (number)
- StreamEncoding.writeUint32s(value, size)¶
Write an array of uint32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeUint64(value)¶
Write an uint64.
- Arguments:
value (number)
- StreamEncoding.writeUint64s(value, size)¶
Write an array of uint64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeUint8(value)¶
Write an uint8.
- Arguments:
value (number)
- StreamEncoding.writeUint8s(value, size)¶
Write an array of uint8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamEncoding.writeUuid(value)¶
Write an uuid.
- Arguments:
value (ValueUUId)
- class StreamRawReader(streamRawReading)¶
An class used to read data through the StreamRawReading interface.
exported from
index.d- Arguments:
streamRawReading (StreamRawReading)
- StreamRawReader.readBlob()¶
Read and return a blob.
- Returns:
ValueBlob
- StreamRawReader.readBlobId()¶
Read and return a blob_id.
- Returns:
ValueBlobId
- StreamRawReader.readBool()¶
Read and return a bool.
- Returns:
boolean
- StreamRawReader.readCommitId()¶
Read and return a commit_id.
- Returns:
ValueCommitId
- StreamRawReader.readDouble()¶
Read and return a float.
- Returns:
number
- StreamRawReader.readDoubles(size)¶
Read an array of doubles and return a vec<double, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readFloat()¶
Read aan return a float.
- Returns:
number
- StreamRawReader.readFloats(size)¶
Read an array of float and return a vec<float, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readInt16()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readInt16s(size)¶
Read an array of int16 and return a vec<int16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readInt32()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readInt32s(size)¶
Read an array of int32 and return a vec<int32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readInt64()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readInt64s(size)¶
Read an array of int64 and return a vec<int64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readInt8()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readInt8s(size)¶
Read an array of int8 and return a vec<int8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readString()¶
Read and return a string.
- Returns:
string
- StreamRawReader.readUint16()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readUint16s(size)¶
Read an array of uint16 and return a vec<uint16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readUint32()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readUint32s(size)¶
Read an array of uint32 and return a vec<uint32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readUint64()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readUint64s(size)¶
Read an array of uint64 and return a vec<uint64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readUint8()¶
Read and return a int.
- Returns:
number
- StreamRawReader.readUint8s(size)¶
Read an array of uint8 and return a vec<uint8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamRawReader.readUuid()¶
Read and return an uuid.
- Returns:
ValueUUId
- StreamRawReader.remaining()¶
Return the number of bytes left to read.
- Returns:
number
- StreamRawReader.streamReading()¶
Return the StreamReading interface.
- Returns:
StreamReading
- class StreamRawReading()¶
An interface used to read data.
Note: Not directly instantiable.
exported from
index.d- StreamRawReading.size()¶
Return the total number of bytes in the stream.
- Returns:
number
- class StreamRawWriter(streamRawWriting)¶
A class used to write data through the StreamRawWriting interface.
exported from
index.d- Arguments:
streamRawWriting (StreamRawWriting)
- StreamRawWriter.streamWriting()¶
Return the StreamWriting interface.
- Returns:
StreamWriting
- StreamRawWriter.writeBlob(value)¶
Write a blob.
- Arguments:
value (ValueBlob)
- StreamRawWriter.writeBlobId(value)¶
Write a blob_id.
- Arguments:
value (ValueBlobId)
- StreamRawWriter.writeBool(value)¶
Write a bool.
- Arguments:
value (boolean)
- StreamRawWriter.writeCommitId(value)¶
Write a commit_id.
- Arguments:
value (ValueCommitId)
- StreamRawWriter.writeDouble(value)¶
Write a double.
- Arguments:
value (number)
- StreamRawWriter.writeDoubles(value, size)¶
Write an array of double.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeFloat(value)¶
Write a float.
- Arguments:
value (number)
- StreamRawWriter.writeFloats(value, size)¶
Write an array of float.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeInt16(value)¶
Write an int16.
- Arguments:
value (number)
- StreamRawWriter.writeInt16s(value, size)¶
Write an array of int16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeInt32(value)¶
Write an int32.
- Arguments:
value (number)
- StreamRawWriter.writeInt32s(value, size)¶
Write an array of int32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeInt64(value)¶
Write an int64.
- Arguments:
value (number)
- StreamRawWriter.writeInt64s(value, size)¶
Write an array of int64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeInt8(value)¶
Write an int8.
- Arguments:
value (number)
- StreamRawWriter.writeInt8s(value, size)¶
Write an array of int8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeString(value)¶
Write a string.
- Arguments:
value (string)
- StreamRawWriter.writeUint16(value)¶
Write an uint16.
- Arguments:
value (number)
- StreamRawWriter.writeUint16s(value, size)¶
Write an array of uint16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeUint32(value)¶
Write an uint32.
- Arguments:
value (number)
- StreamRawWriter.writeUint32s(value, size)¶
Write an array of uint32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeUint64(value)¶
Write an uint64.
- Arguments:
value (number)
- StreamRawWriter.writeUint64s(value, size)¶
Write an array of uint64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeUint8(value)¶
Write an uint8.
- Arguments:
value (number)
- StreamRawWriter.writeUint8s(value, size)¶
Write an array of uint8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamRawWriter.writeUuid(value)¶
Write an uuid.
- Arguments:
value (ValueUUId)
- class StreamRawWriting()¶
An interface to write data.
Note: Not directly instantiable.
exported from
index.d
- class StreamReaderBlob(blob)¶
A class used to read data from a blob.
exported from
index.d- Arguments:
blob (ValueBlob)
- StreamReaderBlob.blob()¶
Return the blob.
- Returns:
ValueBlob
- StreamReaderBlob.offset()¶
Return the offset.
- Returns:
number
- StreamReaderBlob.streamRawReading()¶
Return the StreamRawReading interface.
- Returns:
StreamRawReading
- class StreamReaderFile(path)¶
A class used to read data from a file.
exported from
index.d- Arguments:
path (string)
- StreamReaderFile.close()¶
Close the file.
- StreamReaderFile.offset()¶
Return the offset.
- Returns:
number
- StreamReaderFile.streamRawReading()¶
Return the StreamRawReading interface.
- Returns:
StreamRawReading
A class used to read data from a shared memory region.
exported from
index.d- Arguments:
sharedMemory (SharedMemory)
Return the offset.
- Returns:
number
Rewind to the beginning.
Return the size.
- Returns:
number
Return the StreamRawReading interface.
- Returns:
StreamRawReading
- class StreamReading()¶
An interface used to read data.
Note: Not directly instantiable.
exported from
index.d- StreamReading.readBlob()¶
Read and return a blob.
- Returns:
ValueBlob
- StreamReading.readBlobId()¶
Read and return a blob_id.
- Returns:
ValueBlobId
- StreamReading.readBool()¶
Read and return a bool.
- Returns:
boolean
- StreamReading.readCommitId()¶
Read and return a commit_id.
- Returns:
ValueCommitId
- StreamReading.readDouble()¶
Read and return a float.
- Returns:
number
- StreamReading.readDoubles(size)¶
Read an array of doubles and return a vec<double, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readFloat()¶
Read aan return a float.
- Returns:
number
- StreamReading.readFloats(size)¶
Read an array of float and return a vec<float, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readInt16()¶
Read and return a int.
- Returns:
number
- StreamReading.readInt16s(size)¶
Read an array of int16 and return a vec<int16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readInt32()¶
Read and return a int.
- Returns:
number
- StreamReading.readInt32s(size)¶
Read an array of int32 and return a vec<int32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readInt64()¶
Read and return a int.
- Returns:
number
- StreamReading.readInt64s(size)¶
Read an array of int64 and return a vec<int64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readInt8()¶
Read and return a int.
- Returns:
number
- StreamReading.readInt8s(size)¶
Read an array of int8 and return a vec<int8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readString()¶
Read and return a string.
- Returns:
string
- StreamReading.readUint16()¶
Read and return a int.
- Returns:
number
- StreamReading.readUint16s(size)¶
Read an array of uint16 and return a vec<uint16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readUint32()¶
Read and return a int.
- Returns:
number
- StreamReading.readUint32s(size)¶
Read an array of uint32 and return a vec<uint32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readUint64()¶
Read and return a int.
- Returns:
number
- StreamReading.readUint64s(size)¶
Read an array of uint64 and return a vec<uint64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readUint8()¶
Read and return a int.
- Returns:
number
- StreamReading.readUint8s(size)¶
Read an array of uint8 and return a vec<uint8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamReading.readUuid()¶
Read and return an uuid.
- Returns:
ValueUUId
- StreamReading.remaining()¶
Return the number of bytes left to read.
- Returns:
number
- class StreamSizing()¶
An interface used to get the size of data.
Note: Not directly instantiable.
exported from
index.d- StreamSizing.sizeOfBlobId()¶
Return the size of a blob_id.
- Returns:
number
- StreamSizing.sizeOfBool()¶
Return the size of a bool.
- Returns:
number
- StreamSizing.sizeOfCommitId()¶
Return the size of a commit_id.
- Returns:
number
- StreamSizing.sizeOfDouble()¶
Return the size of a double.
- Returns:
number
- StreamSizing.sizeOfDoubles(size)¶
Return the size for an array of double.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfFloat()¶
Return the size of a float.
- Returns:
number
- StreamSizing.sizeOfFloats(size)¶
Return the size for an array of float.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfInt16()¶
Return the size of an int16.
- Returns:
number
- StreamSizing.sizeOfInt16s(size)¶
Return the size for an array of int16.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfInt32()¶
Return the size of an int32.
- Returns:
number
- StreamSizing.sizeOfInt32s(size)¶
Return the size for an array of int32.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfInt64()¶
Return the size of an int64.
- Returns:
number
- StreamSizing.sizeOfInt64s(size)¶
Return the size for an array of uint64.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfInt8()¶
Return the size of an int8.
- Returns:
number
- StreamSizing.sizeOfInt8s(size)¶
Return the size for an array of int8.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfUint16()¶
Return the size of an uint16.
- Returns:
number
- StreamSizing.sizeOfUint16s(size)¶
Return the size for an array of uint16.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfUint32()¶
Return the size of an uint32.
- Returns:
number
- StreamSizing.sizeOfUint32s(size)¶
Return the size for an array of uint32.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfUint64()¶
Return the size of an uint64.
- Returns:
number
- StreamSizing.sizeOfUint64s(size)¶
Return the size for an array of uint64.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfUint8()¶
Return the size of an uint8.
- Returns:
number
- StreamSizing.sizeOfUint8s(size)¶
Return the size for an array of uint8.
- Arguments:
size (number)
- Returns:
number
- StreamSizing.sizeOfUuid()¶
Return the size of an uuid.
- Returns:
number
- class StreamTokenBinaryReader(streamRawReading)¶
- A class used to read through the StreamRawReading interface
(handle endianness).
exported from
index.d- Arguments:
streamRawReading (StreamRawReading)
- StreamTokenBinaryReader.readBlob()¶
Read and return a blob.
- Returns:
ValueBlob
- StreamTokenBinaryReader.readBlobId()¶
Read and return a blob_id.
- Returns:
ValueBlobId
- StreamTokenBinaryReader.readBool()¶
Read and return a bool.
- Returns:
boolean
- StreamTokenBinaryReader.readCommitId()¶
Read and return a commit_id.
- Returns:
ValueCommitId
- StreamTokenBinaryReader.readDouble()¶
Read and return a float.
- Returns:
number
- StreamTokenBinaryReader.readDoubles(size)¶
Read an array of double and return a vec<double, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readFloat()¶
Read aan return a float.
- Returns:
number
- StreamTokenBinaryReader.readFloats(size)¶
Read an array of float and return a vec<float, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readInt16()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readInt16s(size)¶
Read an array of int16 and return a vec<int16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readInt32()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readInt32s(size)¶
Read an array of int32 and return a vec<int32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readInt64()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readInt64s(size)¶
Read an array of int64 and return a vec<int64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readInt8()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readInt8s(size)¶
Read an array of int8 and return a vec<int8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readString()¶
Read and return a string.
- Returns:
string
- StreamTokenBinaryReader.readUint16()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readUint16s(size)¶
Read an array of uint16 and return a vec<uint16, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readUint32()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readUint32s(size)¶
Read an array of uint32 and return a vec<uint32, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readUint64()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readUint64s(size)¶
Read an array of uint64 and return a vec<uint64, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readUint8()¶
Read and return a int.
- Returns:
number
- StreamTokenBinaryReader.readUint8s(size)¶
Read an array of uint8 and return a vec<uint8, size>.
- Arguments:
size (number)
- Returns:
ValueVec
- StreamTokenBinaryReader.readUuid()¶
Read and return an 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)¶
- A class used to write through the StreamRawWriting interface
(handle endianness).
exported from
index.d- Arguments:
streamRawWriting (StreamRawWriting)
- StreamTokenBinaryWriter.streamWriting()¶
Return the StreamWriting interface.
- Returns:
StreamWriting
- StreamTokenBinaryWriter.writeBlob(value)¶
Write a blob.
- Arguments:
value (ValueBlob)
- StreamTokenBinaryWriter.writeBlobId(value)¶
Write a blob_id.
- Arguments:
value (ValueBlobId)
- StreamTokenBinaryWriter.writeBool(value)¶
Write a bool.
- Arguments:
value (boolean)
- StreamTokenBinaryWriter.writeCommitId(value)¶
Write a commit_id.
- Arguments:
value (ValueCommitId)
- StreamTokenBinaryWriter.writeDouble(value)¶
Write a double.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeDoubles(value, size)¶
Write an array of double.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeFloat(value)¶
Write a float.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeFloats(value, size)¶
Write an array of float.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeInt16(value)¶
Write an int16.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeInt16s(value, size)¶
Write an array of int16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeInt32(value)¶
Write an int32.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeInt32s(value, size)¶
Write an array of int32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeInt64(value)¶
Write an int64.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeInt64s(value, size)¶
Write an array of int64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeInt8(value)¶
Write an int8.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeInt8s(value, size)¶
Write an array of int8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeString(value)¶
Write a string.
- Arguments:
value (string)
- StreamTokenBinaryWriter.writeUint16(value)¶
Write an uint16.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeUint16s(value, size)¶
Write an array of uint16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeUint32(value)¶
Write an uint32.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeUint32s(value, size)¶
Write an array of uint32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeUint64(value)¶
Write an uint64.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeUint64s(value, size)¶
Write an array of uint64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeUint8(value)¶
Write an uint8.
- Arguments:
value (number)
- StreamTokenBinaryWriter.writeUint8s(value, size)¶
Write an array of uint8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamTokenBinaryWriter.writeUuid(value)¶
Write an uuid.
- Arguments:
value (ValueUUId)
- class StreamWriterBlob()¶
A class used to write data to a blob.
exported from
index.d- StreamWriterBlob.blob()¶
Return the blob.
- Returns:
ValueBlob
- StreamWriterBlob.streamRawWriting()¶
Return the StreamRawWriting interface.
- Returns:
StreamRawWriting
- class StreamWriterFile(path)¶
A class used to write data to a file.
exported from
index.d- Arguments:
path (string)
- StreamWriterFile.close()¶
Close the file.
- StreamWriterFile.offset()¶
Return the offset.
- Returns:
number
- StreamWriterFile.streamRawWriting()¶
Return the StreamRawWriting interface.
- Returns:
StreamRawWriting
A class used to write data to a shared memory region.
exported from
index.d- Arguments:
sharedMemory (SharedMemory)
Return the offset.
- Returns:
number
Rewind to the beginning.
Return the StreamRawWriting interface.
- Returns:
StreamRawWriting
- class StreamWriting()¶
An interface used to read data.
Note: Not directly instantiable.
exported from
index.d- StreamWriting.writeBlob(value)¶
Write a blob.
- Arguments:
value (ValueBlob)
- StreamWriting.writeBlobId(value)¶
Write a blob_id.
- Arguments:
value (ValueBlobId)
- StreamWriting.writeBool(value)¶
Write a bool.
- Arguments:
value (boolean)
- StreamWriting.writeCommitId(value)¶
Write a commit_id.
- Arguments:
value (ValueCommitId)
- StreamWriting.writeDouble(value)¶
Write a double.
- Arguments:
value (number)
- StreamWriting.writeDoubles(value, size)¶
Write an array of double.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeFloat(value)¶
Write a float.
- Arguments:
value (number)
- StreamWriting.writeFloats(value, size)¶
Write an array of float.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeInt16(value)¶
Write an int16.
- Arguments:
value (number)
- StreamWriting.writeInt16s(value, size)¶
Write an array of int16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeInt32(value)¶
Write an int32.
- Arguments:
value (number)
- StreamWriting.writeInt32s(value, size)¶
Write an array of int32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeInt64(value)¶
Write an int64.
- Arguments:
value (number)
- StreamWriting.writeInt64s(value, size)¶
Write an array of int64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeInt8(value)¶
Write an int8.
- Arguments:
value (number)
- StreamWriting.writeInt8s(value, size)¶
Write an array of int8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeString(value)¶
Write a string.
- Arguments:
value (string)
- StreamWriting.writeUint16(value)¶
Write an uint16.
- Arguments:
value (number)
- StreamWriting.writeUint16s(value, size)¶
Write an array of uint16.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeUint32(value)¶
Write an uint32.
- Arguments:
value (number)
- StreamWriting.writeUint32s(value, size)¶
Write an array of uint32.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeUint64(value)¶
Write an uint64.
- Arguments:
value (number)
- StreamWriting.writeUint64s(value, size)¶
Write an array of uint64.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeUint8(value)¶
Write an uint8.
- Arguments:
value (number)
- StreamWriting.writeUint8s(value, size)¶
Write an array of uint8.
- Arguments:
value (InputValue[] | ValueVec)
size (number)
- StreamWriting.writeUuid(value)¶
Write an uuid.
- Arguments:
value (ValueUUId)