libems-mini
v0.2.0
Published
Runtime function-bits from emscripten for direct usage in javascript
Readme
🔋 libems-mini
Runtime function-bits from emscripten for direct usage in javascript
About
This is a tiny module which brings a selection of javascript functions from the emscripten SDK to other WASM compilers – such as mainline clang.
Usage
// main.ts
import initEMS from 'libems-mini'
let module = initEMS({ instantiateWasm: async (imports, init) => {
let wasm = await WebAssembly.instantiate('file.wasm', imports);
return init(wasm.instance)
});
...
// example: ccall
let ptrAnswer = module.ccall('malloc', 'number', 'number', [42]);
// example: addFunction
let ptrJsFunc = module.addFunction(() => alert('hello from javascript!'), 'v');Provided functions
ccalladdFunctionremoveFunctiongetValuesetValuelengthBytesUTF8stringToUTF8stringToNewUTF8HEAP8HEAPU8HEAPU32
License info
libems-mini is licensed under the MIT License.
The module is entirely based on a selection of runtime functions that are part of the emscripten SDK (using emcc which is dual-licensed under MIT and the University of Illinois/NCSA Open Source License).
Created by Lesosoftware in 2025
