refactor: cleanup, change wording

This commit is contained in:
Azgaar 2023-08-15 13:15:24 +04:00
parent ef24e3ea1a
commit 2424c66475
8 changed files with 83 additions and 68 deletions

View file

@ -15,19 +15,18 @@ if (Array.prototype.flat === undefined) {
};
}
// polyfill readable stream iterator: https://bugs.chromium.org/p/chromium/issues/detail?id=929585#c10
if(ReadableStream.prototype[Symbol.asyncIterator] === undefined){
// readable stream iterator: https://bugs.chromium.org/p/chromium/issues/detail?id=929585#c10
if (ReadableStream.prototype[Symbol.asyncIterator] === undefined) {
ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
const reader = this.getReader()
const reader = this.getReader();
try {
while (true) {
const {done, value} = await reader.read()
if (done) return
yield value
const {done, value} = await reader.read();
if (done) return;
yield value;
}
} finally {
reader.releaseLock();
}
finally {
reader.releaseLock()
}
}
}
};
}