UNPKG

821 BJavaScriptView Raw
1// deno-lint-ignore-file no-explicit-any
2import { jsonStringifyGenerator } from './json-stringify.js';
3export class JSONStringifyStream extends TransformStream {
4 constructor() {
5 let first;
6 super({
7 start(controller) {
8 first = true;
9 controller.enqueue('[');
10 },
11 async transform(obj, controller) {
12 if (!first)
13 controller.enqueue(',');
14 else
15 first = false;
16 for await (const chunk of jsonStringifyGenerator(obj)) {
17 controller.enqueue(chunk);
18 }
19 },
20 flush(controller) {
21 controller.enqueue(']');
22 },
23 });
24 }
25}
26//# sourceMappingURL=json-stringify-stream.js.map
\No newline at end of file