json-stream-lite - v1.0.17
    Preparing search index...

    Class JsonArray<T>

    Represents a JSON array. Provides streaming access to array items.

    Type Parameters

    • T = any

      The expected type of array elements

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    buffer: ByteBuffer
    consumed: boolean = false

    Accessors

    • get bufferLength(): number

      Gets the current length of the buffer.

      Returns number

      The number of bytes in the buffer

    • get entityType(): string

      Gets the type name of this entity.

      Returns string

      The constructor name of this entity

    • set maxBufferSize(size: number): void

      Sets the maximum buffer size before compaction occurs.

      Parameters

      • size: number

        The maximum buffer size in bytes

      Returns void

    Methods

    • Returns an async iterator for array items. Enables use of for await...of loops on JsonArray.

      Returns AsyncGenerator<JsonValueType<T>, any, any>

    • Asynchronously consumes the entity by reading it if not already consumed.

      Returns Promise<void>

    • Generator that yields array items. Allows for streaming/incremental processing of large arrays.

      Returns Generator<JsonValueType<T>>

      Each item entity in the array

    • Async generator that yields array items from a stream. Allows for asynchronous streaming/incremental processing.

      Returns AsyncGenerator<JsonValueType<T>>

      Each item entity in the array

    • Reads and parses the entity, consuming it in the process.

      Returns T[]

      The parsed value

      Error if the entity has already been consumed

    • Asynchronously reads and parses the entity from a stream.

      Returns Promise<T[]>

      A promise that resolves to the parsed value

      Error if the entity has already been consumed

    • Attempts to parse by executing a callback, reverting buffer state on failure.

      Type Parameters

      Parameters

      • cb: (entity: this) => T

        The callback function to execute

      Returns T | undefined

      The result of the callback, or undefined if parsing needs more data

      Error if the entity has already been consumed