0.0.1 • Published 2 years ago
@browserfs/fs-zip v0.0.1
BrowserFS Zip Backend
BrowserFS backend for Zip files.
Please read the BrowserFS documentation!
Backend
This package adds ZipFS, which allows you to create a readonly file system from a zip file.
For more information, see the API documentation.
Installing
npm install @browserfs/fs-zipUsage
🛈 The examples are written in ESM. If you are using CJS, you can
requirethe package. If running in a browser you can add a script tag to your HTML pointing to thebrowser.min.jsand use BrowserFS Zip via the globalBrowserFS_Zipobject.
You can't use ZipFS on its own. You must import the core in order to use the backend, and must register it if you plan on using configure:
import { configure, fs, registerBackend } from '@browserfs/core';
import { ZipFS } from '@browserfs/fs-zip';
registerBackend(ZipFS);
const res = await fetch('http://example.com/archive.zip');
const zipData = await res.arrayBuffer();
await configure({ '/mnt/zip': { fs: 'ZipFS', options: { zipData } } });
const contents = fs.readFileSync('/mnt/zip/in-archive.txt', 'utf-8');
console.log(contents);0.0.1
2 years ago