Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinaryDeltaScript

A script for Myers Binary Diff algorithm to process the differences between two pieces of CBOR data

Hierarchy

  • BinaryDeltaScript

Implements

Index

Constructors

constructor

  • new BinaryDeltaScript(cborEncoder: Encoder, buffer: Uint8Array, offset: number, blowsBudget: (length: number) => boolean): BinaryDeltaScript
  • Create a new Script instance

    Parameters

    • cborEncoder: Encoder
    • buffer: Uint8Array

      the buffer containing the data

    • offset: number

      the offset in the buffer to encode from

    • blowsBudget: (length: number) => boolean

      a function that indicates whether or not to send the new value instead of * the difference, depending on the byte cost.

        • (length: number): boolean
        • Parameters

          • length: number

          Returns boolean

    Returns BinaryDeltaScript

Properties

Private Readonly blowsBudget

blowsBudget: (length: number) => boolean

A function that indicates whether or not to send the new value instead of the difference, depending on the byte cost.

param

the byte cost of the difference

returns

true if the cost blows the budget

Type declaration

    • (length: number): boolean
    • Parameters

      • length: number

      Returns boolean

Private Readonly buffer

buffer: Uint8Array

The buffer containing the data

Private Readonly cborEncoder

cborEncoder: Encoder

The CBOR encoder

Private insertLength

insertLength: number

Private insertStart

insertStart: number = -1

If insertStart is not -1, there is an unflushed insert of insertLength bytes.

Private matchLength

matchLength: number

Private matchStart

matchStart: number = -1

If matchStart is not -1, there is an unflushed/uncoalesced match of matchLength bytes. If insertStart is also not -1, the match follows the insert; they could not be coalesced, but that might change if the next insert is small.

Private Readonly offset

offset: number

The offset in the buffer to encode from

Methods

close

  • close(): boolean
  • Close the script and flush all pending operations

    Returns boolean

    a flag indicating success

delete

  • delete(aStart?: undefined | number, length?: undefined | number): boolean
  • Process a delete operation

    Parameters

    • Optional aStart: undefined | number
    • Optional length: undefined | number

      the number of bytes of the delete

    Returns boolean

    a flag indicating success

Private flush

  • flush(): boolean
  • Flush all pending operations

    Returns boolean

    a flag indicating success

insert

  • insert(bStart: number, length: number): boolean
  • Process an insert operation

    Parameters

    • bStart: number

      the starting position of the insert

    • length: number

      the number of bytes of the insert

    Returns boolean

    a flag indicating success

match

  • match(aStart: number, length: number): boolean
  • Process a match operation

    Parameters

    • aStart: number
    • length: number

      the number of bytes of the match

    Returns boolean

    a flag indicating success

Private writeInsert

  • writeInsert(): boolean
  • Write an insert to the encoder

    Returns boolean

    a flag indicating success

Private writeMatch

  • writeMatch(): boolean
  • Write a match to the encoder

    Returns boolean

    a flag indicating success

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.