Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MyersBinaryDiff

Implementation of Myer's diff with the linear space refinement.

Diff the subset of two buffers, as specified by offset/length parameters, with differences written to the provided script.

See E. Myers (1986). "An O(ND) Difference Algorithm and Its Variations". Algorithmica 1 (2): 251–266. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927

For more documentation, refer to the Java implementation.

The bail out factor determines when to give up in middlesnake and produce a more approximate result. Larger values increase the precision at the cost of increased CPU.

The number of diagonals to search in each middleSnake call is bounded by max(256, bailOutFactor/100 * totalLength)

For inputs with a lot of small differences, a smaller bailOutFactor often has a beneficial effect of moderately reducing the size of the result. But it can also increase the size, occasionally dramatically. Additionally, the reduced precision affects the quality of JSON structural deltas. YMMV, as they say.

Hierarchy

  • MyersBinaryDiff

Index

Constructors

Properties

Methods

Constructors

constructor

  • new MyersBinaryDiff(maximumStorage?: number, bailOutFactor?: number): MyersBinaryDiff
  • Create a MyersBinaryDiff object

    Parameters

    • Default value maximumStorage: number = MAXIMUM_STORAGE

      maximum storage limit

    • Default value bailOutFactor: number = BAIL_OUT_FACTOR

      bail-out limit factor

    Returns MyersBinaryDiff

Properties

Private bailOutFactor

bailOutFactor: number

Private storage

storage: Storage

Methods

diff

  • diff(a: Uint8Array, aOffset: number, aLength: number, b: Uint8Array, bOffset: number, bLength: number, editScript: EditScript): number
  • Parameters

    • a: Uint8Array

      source data

    • aOffset: number

      start of source data

    • aLength: number

      length of source data

    • b: Uint8Array

      target data

    • bOffset: number

      start of target data

    • bLength: number

      length of target data

    • editScript: EditScript

      the edit script

    Returns number

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.