Skip to content

Commit

Permalink
Updated example and example notice
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed May 22, 2024
1 parent 97be665 commit ce97032
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ For more information, see the [API documentation](https://zen-fs.github.io/zip).
## Usage

> [!NOTE]
> The examples are written in ESM. If you are using CJS, you can `require` the package. If running in a browser you can add a script tag to your HTML pointing to the `browser.min.js` and use ZenFS Zip via the global `ZenFS_Zip` object.
> The examples are written in ESM.
> For CJS, you can `require` the package.
> For a browser environment without support for `type=module` in `script` tags, you can add a `script` tag to your HTML pointing to the `browser.min.js` and use the global `ZenFS_ZIP` object.
You can't use `Zip` on its own. You must import the core in order to use the backend.

Expand All @@ -24,7 +26,9 @@ import { Zip } from '@zenfs/zip';
const res = await fetch('http://example.com/archive.zip');

await configure({
'/mnt/zip': { backend: Zip, zipData: await res.arrayBuffer() },
mounts: {
'/mnt/zip': { backend: Zip, data: await res.arrayBuffer() },
}
});

const contents = fs.readFileSync('/mnt/zip/in-archive.txt', 'utf-8');
Expand Down

0 comments on commit ce97032

Please sign in to comment.