Skip to content

Commit

Permalink
Renamed backend
Browse files Browse the repository at this point in the history
Added example to readme
  • Loading branch information
james-pre committed Oct 10, 2024
1 parent 47dcd61 commit 1c60a53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ npm install @zenfs/emscripten
> 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_Emscripten` object.
No examples yet. Please feel free to open a PR.
```ts
import { configure, fs } from '@zenfs/core';
import { Emscripten } from '@zenfs/emscripten';

// Note: this assumes you have included Emscripten correctly and have the global `FS` variable available.
await configureSingle({ backend: Emscripten, FS: FS });

if (!fs.existsSync('/test.txt')) {
fs.writeFileSync('/test.txt', 'This is in the Emscripten file system!');
}

const contents = fs.readFileSync('/test.txt', 'utf-8');
console.log(contents);
```
2 changes: 1 addition & 1 deletion src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export interface EmscriptenOptions {
}

const _Emscripten = {
name: 'EmscriptenFileSystem',
name: 'Emscripten',

options: {
FS: {
Expand Down

0 comments on commit 1c60a53

Please sign in to comment.