0.1.2 • Published 12 months ago

wasm-fs v0.1.2

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

wasm-fs

Extract & Instantiate embedded file structure from WebAssembly.

Support

  • Emscripten SDK
  • Go

Installation

$ npm i wasm-fs

or

$ yarn add wasm-fs

Example

Emscripten SDK

Generate WASM with embedded file

$ emcc hello.c -s STANDALONE_WASM -o hello.html --embed-file embedded_file

Generate WASM with embedded directory

$ emcc hello.c -s STANDALONE_WASM -o hello.html --embed-file embedded_dir

Extract embedded file structure from WASM

import fs from "fs";
import { resolve } from "path";

import WASMFileSystem from "wasm-fs";

(async () => {
  const wasmFileSystem = await WASMFileSystem.from(
    fs.readFileSync(resolve(__dirname, "hello.wasm"))
  );
  console.log("root:", wasmFileSystem.root);
  const testDirectory = wasmFileSystem.root.getChild("testDirectory");
  console.log("testDirectory:", testDirectory);
  fs.writeFileSync(
    "./image.png",
    testDirectory.getFile("testImage.png").content
  );
})();

Go

Not Implemented Yet.

License

MIT License

Copyright (c) 2023 이승훈

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago