package
Core to create fast image math in WebAssembly and JS.
npm install multimathGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Core to create fast image math in WebAssembly and JS.
multimath simplifies creation of small CPU-intensive webassembly modules
with fallback to JavaScript implementations.
Built-in functions (currently - unsharp mask) are available as examples for your extensions.
npm install multimathimport { MultiMath, unsharp_mask_plugin } from 'multimath'
const mm = new MultiMath()
.use(unsharp_mask_plugin)
.use(your_custom_plugin)
// Simple sync call. Will use sync wasm compile. Ok for webworkers.
// Can freeze interface at first call if wasm source is too big.
mm.unsharp_mask(rgba_buffer, width, height)
// Async init, compile all modules at once in async way.
await mm.init()
mm.unsharp_mask(rgba_buffer, width, height)Create library instance.
const mm = new MultiMath({
// Options are not mandatory, but you can disable js or wasm
// implementations for testing
js: true,
wasm: true
})Register new plugin, format is:
{
name: String, // method name to expose on instance
fn: Function, // JS implementation
wasm_fn: Function, // WebAssembly glue
wasm_src: String // Base64 encoded WebAssembly module
}See lib/unsharp_mask_plugin/ as an example implementation.
Optional. Compile all wasm modules asynchronously. Useful when:
Note: a 3K wasm file initializes in ~3ms.
All plugins loaded via .use() pin their methods to the MultiMath instance.
The best implementation is selected automatically based on browser features
and constructor options.
Ways to go with your own plugins:
lib/unsharp_mask_plugin/ as an example.Estimated unpacked size across 2 packages.
45.4 kB
Includes dependencies.