git ssb

0+

wanderer🌟 / wasm-persist



Tree: 7d51e5a74d530f6929e58ff52e28b160b4f1d4a4

Files: 7d51e5a74d530f6929e58ff52e28b160b4f1d4a4 / README.md

1868 bytesRaw

SYNOPSIS

NPM Package
Build Status
Coverage Status

js-standard-style

This allows you to hibernate a WebAssembly instance and later start it up again at the exact place you left off

INSTALL

npm install wasm-persist

USAGE

const persist = require('wasm-persist')
...
wasm = persit.prepare(wasm)
const {instance} = await WebAssembly.instantiate(wasm)
// call some exported functions on your instance 
// then when you are done
const state = persit.hibernate(instance)

...

// later you can revive the wasm instance
const {instance} = await WebAssembly.instantiate(wasm)
// just call persist.resume with the old state
persit.resume(instance, state)

DESCIPTION

The Idea for wasm-perist came from orthongal persistance#Orthogonal_or_transparent_persistence) wasm-persist injects getter and setter function for each global and exports the memory and table if they exist. Hibernate calls the getters and creates an Object that contains the memory (as a typedArray) the globals and the function table. Resume does the opposite and calls the setters for the globals and updates the memory and the table. Forgein function on the table are not handled currently.

API

./docs/

LICENSE

MPL-2.0

Built with git-ssb-web