char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somweb: polyfill stream async iteration for Safarica9626a

main
625 B25 linesraw
1Object.defineProperty(ReadableStream.prototype, Symbol.asyncIterator, {
2  configurable: true,
3  writable: true,
4  value: async function* <T>(
5    this: ReadableStream<T>,
6    { preventCancel = false }: { preventCancel?: boolean } = {},
7  ) {
8    const reader = this.getReader();
9    let done = false;
10    try {
11      while (true) {
12        const result = await reader.read();
13        done = result.done;
14        if (done) return;
15        yield result.value;
16      }
17    } finally {
18      try {
19        if (!done && !preventCancel) await reader.cancel();
20      } finally {
21        reader.releaseLock();
22      }
23    }
24  },
25});