Basic gzip an gunzip on load and save.

This commit is contained in:
Efruz Yıldırır 2023-08-14 12:06:55 +03:00
parent c3a385b2c9
commit 3f205cd499
5 changed files with 73 additions and 30 deletions

View file

@ -14,3 +14,20 @@ if (Array.prototype.flat === undefined) {
return this.reduce((acc, val) => (Array.isArray(val) ? acc.concat(val.flat()) : acc.concat(val)), []);
};
}
// polyfill 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()
try {
while (true) {
const {done, value} = await reader.read()
if (done) return
yield value
}
}
finally {
reader.releaseLock()
}
}
}