mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 22:00:02 -04:00
fix no async iteration over readablestream in chrome
This commit is contained in:
parent
ccf556118b
commit
f6a06b5fb3
1 changed files with 13 additions and 0 deletions
|
@ -19,6 +19,19 @@ type OpenWSMeta = {
|
||||||
onerror: (message: string) => void;
|
onerror: (message: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(ReadableStream as any).prototype[Symbol.asyncIterator] = async function* () {
|
||||||
|
const reader = this.getReader();
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) return;
|
||||||
|
yield value;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export class Connection {
|
export class Connection {
|
||||||
requestCallbacks: Record<number, Function> = {};
|
requestCallbacks: Record<number, Function> = {};
|
||||||
openRequestStreams: Record<number, ReadableStreamDefaultController<any>> = {};
|
openRequestStreams: Record<number, ReadableStreamDefaultController<any>> = {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue