UNPKG

json-web-streams

Version:

Streaming JSON parser built on top of the Web Streams API, so it works in web browsers, Node.js, and many other environments

33 lines (32 loc) 1 kB
import { JSONParseStreamRaw } from "./JSONParseStreamRaw.js"; import { JSONPath } from "./jsonPathToPathArray.js"; import { StandardSchemaV1 } from "@standard-schema/spec"; //#region src/JSONParseStream.d.ts type JSONParseStreamOutput<T> = T extends { key?: infer K | undefined; path: infer P extends JSONPath; schema?: infer S extends StandardSchemaV1 | undefined; } ? { value: S extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<S> : unknown; wildcardKeys?: string[]; } & (undefined extends K ? { key: P; } : { key: K; }) : T extends JSONPath ? { key: T; value: unknown; wildcardKeys?: string[]; } : never; declare class JSONParseStream<const Key extends unknown, T extends readonly (JSONPath | { key?: Key; path: JSONPath; schema?: StandardSchemaV1; })[]> extends TransformStream<string, JSONParseStreamOutput<T[number]>> { _parser: JSONParseStreamRaw; constructor(jsonPaths: T, options?: { multi?: boolean; }); } //#endregion export { JSONParseStream };