mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
24 lines
547 B
JavaScript
24 lines
547 B
JavaScript
#!/usr/bin/env node
|
|
|
|
var nodeFS = require('fs');
|
|
|
|
var filename = '{test.wasm}';
|
|
var ret = nodeFS['readFileSync'](filename);
|
|
|
|
function instantiate(bytes, imports) {
|
|
return WebAssembly.compile(bytes).then(
|
|
m => new WebAssembly.Instance(m, imports), reason => console.log(reason) );
|
|
}
|
|
|
|
var dependencies = {
|
|
"global": {},
|
|
"env": {}
|
|
};
|
|
dependencies["global.Math"] = Math;
|
|
|
|
|
|
instantiate( ret, dependencies ).then(
|
|
instance => console.log( instance.exports[process.argv[2]]( process.argv.slice(3) ) ),
|
|
reason => console.log(reason)
|
|
);
|