UNPKG

@worker-tools/json-stream

Version:

Utilities for working with streaming JSON in Worker Runtimes such as Cloudflare Workers, Deno Deploy and Service Workers.

20 lines (19 loc) 1 kB
declare type SeenWeakSet = WeakSet<any>; declare type Primitive = undefined | boolean | number | string | bigint | symbol; export declare type ToJSON = { toJSON: (key?: any) => string; }; export declare const isIterable: <T>(x: unknown) => x is Iterable<T>; export declare const isAsyncIterable: <T>(x: unknown) => x is AsyncIterable<T>; /** * @deprecated Change name to something more descriptive!? */ export declare function jsonStringifyGenerator(value: null | Primitive | ToJSON | any[] | Record<string, any> | PromiseLike<any> | AsyncIterable<any> | ReadableStream, seen?: SeenWeakSet): AsyncIterableIterator<string>; /** * @deprecated Change name to something more descriptive!? */ export declare function jsonStringifyStream(value: null | Primitive | ToJSON | any[] | Record<string, any> | PromiseLike<any> | AsyncIterable<any> | ReadableStream): ReadableStream<string>; export declare class JSONStringifyReadable extends ReadableStream<string> { constructor(value: any); } export {};