Skip to content

Commit

Permalink
Merge pull request #1456 from ebkr/chunky-pt3
Browse files Browse the repository at this point in the history
Use fflate to decompress package list chunks
  • Loading branch information
anttimaki authored Oct 7, 2024
2 parents 4d6914c + 8aeaaad commit b7ba72f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build-osx": "quasar build --mode electron -T mac",
"publish": "quasar build --mode electron --publish always",
"publish-win": "quasar build --mode electron -T win32 --publish always",
"publish-linux": "quasar build --mode electron -T linux --publish always",
"publish-linux": "quasar build --mode electron -T linux --publish always",
"test:unit": "jest --updateSnapshot",
"test:unit:ci": "jest --ci",
"test:unit:coverage": "jest --coverage",
Expand All @@ -42,6 +42,7 @@
"dot-prop": "^5.2.0",
"electron-updater": "4.2.5",
"elliptic": "^6.5.4",
"fflate": "^0.8.2",
"floating-vue": "^1.0.0-beta.19",
"fs-extra": "^8.1.0",
"glob-parent": "^6.0.2",
Expand Down
11 changes: 8 additions & 3 deletions src/utils/GzipUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import * as zlib from 'zlib';
// Use third party library as Node's zlib is not available on TSMM.
import { AsyncGunzip } from "fflate";

export function decompressArrayBuffer(compressed: ArrayBuffer, encoding = 'utf-8'): Promise<string> {
return new Promise((resolve, reject) => {
zlib.gunzip(compressed, (err, result) => {
const gunzip = new AsyncGunzip((err, result) => {
if (err) {
return reject(err);
}

return resolve(result.toString(encoding));
const decoder = new TextDecoder(encoding);
const decodedString = decoder.decode(result);
return resolve(decodedString);
});

gunzip.push(new Uint8Array(compressed), true);
});
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6216,6 +6216,11 @@ fd-slicer@~1.1.0:
dependencies:
pend "~1.2.0"

fflate@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.2.tgz#fc8631f5347812ad6028bbe4a2308b2792aa1dea"
integrity sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==

figgy-pudding@^3.5.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
Expand Down

0 comments on commit b7ba72f

Please sign in to comment.