import { JsonStringifyStream } from "https://deno.land/std@0.160.0/encoding/json/_stringify.ts";
Convert each chunk to JSON string.
This can be used to stringify JSON lines, NDJSON, JSON Text Sequences, and Concatenated JSON. You can optionally specify a prefix and suffix for each chunk. The default prefix is "" and the default suffix is "\n".
import { readableStreamFromIterable } from "https://deno.land/std@0.160.0/streams/mod.ts";
import { JsonStringifyStream } from "https://deno.land/std@0.160.0/encoding/json/stream.ts";
const file = await Deno.open("./tmp.jsonl", { create: true, write: true });
readableStreamFromIterable([{ foo: "bar" }, { baz: 100 }])
.pipeThrough(new JsonStringifyStream())
.pipeThrough(new TextEncoderStream())
.pipeTo(file.writable)
.then(() => console.log("write success"));