mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-13 04:36:12 +01:00
feat: zip reader
This commit is contained in:
1 parent
2101dba7c6
commit
f33a73e1bb
9 files changed
+59
-5
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { HTTPRangeReader, unzip, ZipEntry } from "unzipit";
|
||||
import { AbstractVFS } from "./abstract";
|
||||
|
||||
export class ZipVFS extends AbstractVFS {
|
||||
entries: Record<string, ZipEntry> = {};
|
||||
|
||||
constructor(private url: string, private root = "app/") {
|
||||
super();
|
||||
}
|
||||
|
||||
async init() {
|
||||
const reader = new HTTPRangeReader(this.url);
|
||||
const { entries } = await unzip(reader);
|
||||
|
||||
for (const entry of Object.values(entries)) {
|
||||
this.entries[entry.name.slice(this.root.length)] = entry;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user