new Binary()
A read-only binary value with support for binary deltas.
Values are effectively immutable. Instances can be backed by user-supplied buffers. Once a Binary has been constructed around a buffer, care must be taken not to modify the data in the buffer because doing so would violate immutability.
- Since:
-
- 5.7
Methods
-
apply(delta)
-
Apply a delta to this Binary value to create a new value.
Convenient equivalent to:
diffusion.datatypes.binary().deltaSupport(delta).apply(this, delta);
Parameters:
Name Type Description delta
Object The binary delta to apply to this value
Throws:
Error if the delta is invalid
Returns:
A new instance derived from applying the delta to this value
-
diff(original [, type])
-
Compare this Binary value with an earlier version to create a delta.
Convenient equivalent to:
diffusion.datatypes.binary().deltaSupport(type).diff(original, this);
Buffers may also be provided as the value to diff instead of a diffusion.datatypes.Binary instance.
Parameters:
Name Type Argument Default Description original
diffusion.datatypes.Binary | Buffer The value to diff against this
type
String <optional>
"binary" The type of delta to generate
Returns:
A delta representing the difference between this and the provided value
Example
var delta = binaryValue.diff(new Buffer('Hello world'));
-
get()
-
Get the value as a Buffer.
Returns:
The buffer value
- Type
- Buffer