Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinaryImpl

Implementation of Binary

Hierarchy

Implements

Index

Constructors

constructor

  • new BinaryImpl(buffer: Uint8Array, offset?: number, length?: number): BinaryImpl
  • Create a new BinaryImpl instance

    Parameters

    • buffer: Uint8Array

      the internal buffer

    • Default value offset: number = 0

      the offset of the slice

    • Default value length: number = buffer.length

      the number of bytes in the slice

    Returns BinaryImpl

Properties

$buffer

$buffer: Uint8Array

The internal buffer

$length

$length: number

The number of bytes in the slice

$offset

$offset: number

The offset of the slice

Methods

apply

  • Apply a delta to this Binary value to create a new value.

    Convenient equivalent to: diffusion.datatypes.binary().deltaSupport(delta).apply(this, delta);

    throws

    an InvalidDataError if the delta is invalid

    Parameters

    • delta: BinaryDelta

      the binary delta to apply to this value

    Returns Binary

    a new instance derived from applying the delta to this value

asArray

  • asArray(): Uint8Array
  • Get a copy of the array containing this value.

    Returns Uint8Array

    This value in binary form

asBuffer

  • asBuffer(): Buffer
  • Get a copy of the buffer containing this value.

    deprecated

    since version 6.11. Buffer has been replaced by Uint8Array. This will be removed in a future release.

    Returns Buffer

    This value in binary form

copyTo

  • copyTo(target: Uint8Array, offset?: number): void
  • inheritdoc

    Parameters

    • target: Uint8Array
    • Default value offset: number = 0

    Returns void

diff

  • Compare this Binary value with an earlier version to create a delta.

    Convenient equivalent to: diffusion.datatypes.binary().deltaSupport(type).diff(original, this);

    Buffers stored in a Uint8Array may also be provided as the value to diff instead of a Binary instance.

    Example:

    Node.js:

    const delta = binaryValue.diff(Buffer.from('Hello world'));
    

    Browser:

    const delta = binaryValue.diff(new TextEncoder().encode('Hello World'));
    

    Parameters

    • original: Binary | Uint8Array

      the value to diff against this

    • Optional type: undefined | string

      the type of delta to generate (default: binary);

    Returns BinaryDeltaImpl

    a delta representing the difference between this and the provided value

equalBytes

  • equalBytes(buffer: Uint8Array, offset?: number, length?: number): boolean
  • Check if the Bytes are equal to a buffer slices

    Parameters

    • buffer: Uint8Array

      the buffer

    • Default value offset: number = 0

      the offset of the slice

    • Default value length: number = buffer.length

      the number of bytes in the slice

    Returns boolean

    true if the two bytes are equal

equals

  • Check if the Bytes are equal to a buffer slices

    Parameters

    Returns boolean

    true if the two bytes are equal

get

  • get(): Buffer
  • Get the value as a Buffer.

    deprecated

    since version 6.11. Buffer has been replaced by Uint8Array. Use getArray instead. This will be removed in a future release.

    Returns Buffer

    the buffer value

getArray

  • getArray(): Uint8Array
  • Get the value as a Uint8Array.

    Returns Uint8Array

    the array value

length

  • length(): number
  • Get the number of bytes

    Returns number

    The length of the data in bytes

toString

  • toString(): string
  • Convert the objet to a string

    Returns string

    a string representation of the BinaryImpl

Static from

  • Create a new BinaryImpl object from a buffer or BinaryImpl. If a BinaryImpl is passed as argument it is simply returned.

    throws

    an IllegalArgumentError if an incompatible datatype was supplied

    Parameters

    • value: Binary | Uint8Array

      the object to create a record from

    Returns BinaryImpl

    the record created

Static toString

  • toString(): string
  • Return the name of the data type

    Returns string

    BinaryImpl

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.