MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / toReadableStream

Method toReadableStream

out/cli.cjs:69199–69222  ·  view source on GitHub ↗

* Converts this stream to a newline-separated ReadableStream of * JSON stringified values in the stream * which can be turned back into a Stream with `Stream.fromReadableStream()`.

()

Source from the content-addressed store, hash-verified

69197 new _Stream(() => teeIterator(right), this.controller)
69198 ];
69199 }
69200 /**
69201 * Converts this stream to a newline-separated ReadableStream of
69202 * JSON stringified values in the stream
69203 * which can be turned back into a Stream with `Stream.fromReadableStream()`.
69204 */
69205 toReadableStream() {
69206 const self2 = this;
69207 let iter;
69208 const encoder = new TextEncoder();
69209 return new ReadableStream2({
69210 async start() {
69211 iter = self2[Symbol.asyncIterator]();
69212 },
69213 async pull(ctrl) {
69214 try {
69215 const { value, done } = await iter.next();
69216 if (done)
69217 return ctrl.close();
69218 const bytes = encoder.encode(JSON.stringify(value) + "\n");
69219 ctrl.enqueue(bytes);
69220 } catch (err) {
69221 ctrl.error(err);
69222 }
69223 },
69224 async cancel() {
69225 await iter.return?.();

Callers 3

toReadableStreamMethod · 0.45
toReadableStreamMethod · 0.45
toReadableStreamMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected