![]() |
Infohub JS API
|
Streaming JSON for payloads that exceed V8's max string length (0x1fffffe8 ≈ 512 MiB).
A single JS string can never hold such a payload, so JSON.parse(wholeString) / JSON.stringify(wholeObject) throw "Invalid string length". These helpers parse from / serialize to chunks and never materialize the payload as one giant string — the resulting object lives in memory (objects are not size-capped, only strings).
Environment-agnostic: works in the browser (Blob/File, ReadableStream, fetch Response) and in Node (fs read streams are async-iterable). No fs import, so it bundles safely for the browser.
Static Public Member Functions | |
| static async | parse (source) |
| static * | stringifyChunks (value, chunkSize=1<< 20) |
|
static |
Parse a JSON payload of any size into a JS value without ever holding it as a single string.
Accepts:
Chunks may be Uint8Array (incl. Node Buffer) or string.
| {Blob|File|ReadableStream|Response|AsyncIterable|Iterable|Uint8Array|string} | source |
|
static |
Serialize a JS value to a sequence of string chunks (each well under the string-length cap) without ever building one giant string.
Walks the value and only ever calls JSON.stringify() on individual leaves / keys.
Consume it however the environment needs:
Matches JSON.stringify semantics: undefined/function values are dropped from objects and rendered as null in arrays.
| {any} | value |
| {number} | [chunkSize=1048576] flush threshold in chars (~1 MiB) |