Skip to content

Commit 91ea2f0

Browse files
committed
Extract calculateTotalUncompressedByteSize function
1 parent 2267e9d commit 91ea2f0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

extensions/ql-vscode/src/common/unzip.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export function excludeDirectories(entries: ZipEntry[]): ZipEntry[] {
2525
return entries.filter((entry) => !/\/$/.test(entry.fileName));
2626
}
2727

28+
function calculateTotalUncompressedByteSize(entries: ZipEntry[]): number {
29+
return entries.reduce((total, entry) => total + entry.uncompressedSize, 0);
30+
}
31+
2832
export function readZipEntries(zipFile: ZipFile): Promise<ZipEntry[]> {
2933
return new Promise((resolve, reject) => {
3034
const files: ZipEntry[] = [];
@@ -191,10 +195,7 @@ export async function unzipToDirectory(
191195
let filesExtracted = 0;
192196
const totalFiles = entries.length;
193197
let bytesExtracted = 0;
194-
const totalBytes = entries.reduce(
195-
(total, entry) => total + entry.uncompressedSize,
196-
0,
197-
);
198+
const totalBytes = calculateTotalUncompressedByteSize(entries);
198199

199200
const reportProgress = () => {
200201
progress?.({

0 commit comments

Comments
 (0)