wasm-import
v0.3.0
Published
WASM Loader for Node.js and Web
Downloads
276
Maintainers
Readme
WASM Import
npm i wasm-import
See MDN docs how to pass callbacks to wasm via importObject
:
https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Instance
load(
fileName: string, // File name or URL
importObject?: object // See MDN docs
): Promise<object>;
Example
import { load } from 'wasm-import';
// Alternative: const { load } = require('wasm-import');
const example = await load('example.wasm');
example.instance.exports.add(3, 7, (result) => {
console.log({ result, expected: 10 });
});
License & Contributors
Copyright (c) 2023 WASM Import contributors. WASM Import is MIT licensed.