(response: Response | Request)
| 201 | } |
| 202 | |
| 203 | export async function deserializeJSONStream(response: Response | Request) { |
| 204 | if (!response.body) { |
| 205 | throw new Error("missing body"); |
| 206 | } |
| 207 | const reader = new SerovalChunkReader(response.body); |
| 208 | const result = await reader.next(); |
| 209 | if (!result.done) { |
| 210 | const refs = new Map(); |
| 211 | |
| 212 | function interpretChunk(chunk: string): unknown { |
| 213 | const value = fromCrossJSON(JSON.parse(chunk) as SerovalNode, { |
| 214 | refs, |
| 215 | disabledFeatures: DISABLED_FEATURES, |
| 216 | depthLimit: MAX_SERIALIZATION_DEPTH_LIMIT, |
| 217 | plugins: DEFAULT_PLUGINS, |
| 218 | }); |
| 219 | return value; |
| 220 | } |
| 221 | |
| 222 | void reader.drain(interpretChunk); |
| 223 | |
| 224 | return interpretChunk(result.value); |
| 225 | } |
| 226 | return undefined; |
| 227 | } |
| 228 | |
| 229 | export async function deserializeJSStream(id: string, response: Request | Response) { |
| 230 | if (!response.body) { |
no test coverage detected
searching dependent graphs…