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

    Class JsonString<T>

    Represents a JSON string value. Parses and stores string data from the buffer.

    Type Parameters

    • T extends string = string

      The specific string type (defaults to string)

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    buffer: ByteBuffer
    consumed: boolean = false

    Accessors

    • set allowBufferToBeExceeded(value: boolean): void

      Sets whether to allow exceeding the buffer size temporarily. Default is true.

      Parameters

      • value: boolean

        True to allow exceeding the buffer size, false to enforce the limit

      Returns void

    • set maxBufferSize(size: number): void

      Sets the maximum buffer size before compaction occurs. Defaults to 100 KB. NOTE: The buffer size may be exceeded temporarily during reads. For example, if a large string is read that exceeds the max size. If this is not desired, set allowBufferToBeExceeded to false (default is true).

      Parameters

      • size: number

        The maximum buffer size in bytes

      Returns void

    Methods

    • Returns an async iterator for string chunks. Enables use of for await...of loops on JsonString.

      Returns AsyncGenerator<string, any, any>

      Chunks of the string content

    • Returns an iterator for string chunks. Enables use of for...of loops on JsonString.

      Returns Generator<string, any, any>

      Chunks of the string content

    • Generator that yields the string content as chunks of strings.

      Parameters

      • chunkSize: number = 1024

        The maximum size of each yielded string chunk (defaults to 1024)

      Returns Generator<string>

      Chunks of the string content

    • Async generator that yields the string content as chunks of strings.

      Parameters

      • chunkSize: number = 1024

        The maximum size of each yielded string chunk (defaults to 1024)

      Returns AsyncGenerator<string>

      Chunks of the string content

    • Generator that yields the string content as raw byte chunks. Handles escape sequences by converting them to their actual byte values.

      Parameters

      • chunkSize: number = 1024

        The maximum size of each yielded byte array chunk (defaults to 1024)

      Returns Generator<Uint8Array<ArrayBufferLike>>

      Uint8Array chunks containing the unescaped string bytes

    • Async generator that yields the string content as raw byte chunks from a stream. Handles escape sequences by converting them to their actual byte values. Waits for more data from the stream when needed.

      Parameters

      • chunkSize: number = 1024

        The maximum size of each yielded byte array chunk (defaults to 1024)

      Returns AsyncGenerator<Uint8Array<ArrayBufferLike>>

      Uint8Array chunks containing the unescaped string bytes

    • 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

    • Asynchronously serializes a value into a JSON string using json-stream-lite. See jsonStreamStringifyAsync for more details.

      Parameters

      • value: AsyncIterable<unknown, any, any> | Iterable<unknown, any, any>
      • Optionalreplacer: any
      • indent: number = 0
      • Optionaloptions: JsonStreamStringifyOptions

      Returns AsyncGenerator<string>

      An async generator yielding JSON string chunks

    • Asynchronously serializes a value into JSON as Uint8Array byte chunks using json-stream-lite. See jsonStreamStringifyBytesAsync for more details.

      Parameters

      • value: AsyncIterable<unknown, any, any> | Iterable<unknown, any, any>
      • Optionalreplacer: any
      • indent: number = 0
      • Optionaloptions: JsonStreamStringifyOptions

      Returns AsyncGenerator<Uint8Array<ArrayBufferLike>>

      An async generator yielding JSON byte chunks