/** * @public */ export type JSONParser = (line: string) => Type /** * @public */ export interface JSONOptions { parse?: JSONParser } /** * @public */ export async function* parseJSON( it: AsyncIterableIterator, {parse = JSON.parse}: JSONOptions = {}, ): AsyncIterableIterator { for await (const chunk of it) { yield parse(chunk) } } /** * @public */ export async function* stringifyJSON(it: AsyncIterableIterator) { for await (const chunk of it) { yield JSON.stringify(chunk) } }