Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SpanParser

A SpanParser calculates JSON pointers for processing {@JSONDelta}. See DeltaVisitor for a more detailed discussion.

Hierarchy

  • SpanParser

Index

Constructors

constructor

  • Create a span parser using the JSON data

    Parameters

    Returns SpanParser

Properties

Private Readonly json

The buffer containing the JSON data

Private Readonly parentStack

parentStack: AbstractAccumulator[] = []

The current stack of accumulators for JSONPointers

Private Readonly startOffset

startOffset: number

Starting offset in the tokeniser

Private structure

The current accumulator for JSONPointers

Private Readonly tokeniser

tokeniser: Tokeniser

The tokeniser

Methods

nextByte

  • nextByte(): number
  • Get the position of the next byte

    Returns number

    the position of the next byte

Private nextTokenIsStructEnd

  • nextTokenIsStructEnd(t: Token, next: number): boolean
  • Determine if the next token ends an array, map, or string

    Parameters

    • t: Token

      the current token

    • next: number

      the current reading position

    Returns boolean

    true if the next token ends a structure

spanTo

  • Parse the JSON data up to a given offset position.

    throws

    an InvalidDataError if there was an error parsing the next token

    Parameters

    • offset: number

      the position up to which to read

    • result: SpanParserConsumer

      the consumer that records the JSON pointers

    • Default value atLeastOne: boolean = false

      if true and if the current reading position is less than the offset, this is guaranteed to read at least one value

    Returns number

    the change in the height of the parent stack

spanToNext

  • Parse the JSON data up to a given offset position. If the current reading position is less than the offset, this is guaranteed to read at least one value.

    throws

    an InvalidDataError if there was an error parsing the tokens

    Parameters

    • offset: number

      the position up to which to read

    • result: SpanParserConsumer

      the consumer that records the JSON pointers

    Returns number

    the change in the height of the parent stack

toString

  • toString(): string
  • Convert the span parser to a string

    Returns string

    a string representation of the span parser

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.