new BinaryDataType()
Binary data type.
Accessed via:
diffusion.datatypes.binary();
The implementation provides support for binary deltas.
diffusion.datatypes.Binary values can be used to store and transmit arbitrary information. The responsibility for formatting and interpreting the information belongs solely to the application. Before using Binary for a topic, consider other data types such as JSON or single value topic types; these may provide a simpler interface for your application.
- Since:
-
- 5.7
Extends
Methods
-
deltaType(name, delta) → {diffusion.datatypes.DeltaType}
-
Obtain a diffusion.datatypes.DeltaType by name or delta type.
Parameters:
Name Type Argument Description name
String <optional>
The name, as returned by diffusion.datatypes.DeltaType#name delta
Object <optional>
The delta, from which a type-appropriate dela support will be derived - Inherited From:
Returns:
the delta supportExamples
// Get by name var deltas = datatype.deltaType("binary");
// Get by type var deltas = datatype.deltaType(delta);
-
from(buffer) → {diffusion.datatypes.Binary}
-
Returns a new diffusion.datatypes.Binary instance from a buffer.
Parameters:
Name Type Description buffer
Buffer The binary data Returns:
a Binary data-type instance -
name() → {String}
-
The external type identifier.
- Inherited From:
Returns:
The name of this datatype.- Type
- String
-
readValue(input, offset, length) → {Object}
-
Parse a value from binary.
Parameters:
Name Type Argument Description input
Buffer The binary data offset
Number <optional>
The offset to start reading from the provided buffer length
Number <optional>
The length of the data to read - Inherited From:
Throws:
Error if the data is invalid for this typeReturns:
An instance of this data type value- Type
- Object
-
writeValue(value) → {Buffer}
-
Serialise a value to binary
Parameters:
Name Type Description value
Object The value to serialise - Inherited From:
Throws:
Error if the value can not be serialisedReturns:
The serialised value as a buffer- Type
- Buffer