primea-wasm-container
Advanced tools
Comparing version 0.3.3 to 0.3.4
19
index.js
@@ -58,4 +58,4 @@ const ReferanceMap = require('reference-map') | ||
*/ | ||
onMessage (message) { | ||
return this._run(message, 'onMessage') | ||
onMessage (message, method = 'onMessage') { | ||
return this._run(message, method) | ||
} | ||
@@ -67,9 +67,11 @@ | ||
this.instance = result.instance | ||
if (this.instance.exports[method]) { | ||
// add the message and ports to the refereance map | ||
const messageRef = this.referanceMap.add(message) | ||
// add the message and ports to the refereance map | ||
const messageRef = this.referanceMap.add(message) | ||
// runs the wasm code | ||
this.instance.exports[method](messageRef) | ||
return this.onDone() | ||
// runs the wasm code | ||
this.instance.exports[method](messageRef) | ||
await this.onDone() | ||
this.referanceMap.clear() | ||
} | ||
} | ||
@@ -87,3 +89,2 @@ | ||
} | ||
this.referanceMap.clear() | ||
} | ||
@@ -90,0 +91,0 @@ |
{ | ||
"name": "primea-wasm-container", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -172,1 +172,18 @@ const tape = require('tape') | ||
}) | ||
tape('shouldnt run non exstant methods', async t => { | ||
const hypervisor = new Hypervisor(tree) | ||
const main = fs.readFileSync(`${__dirname}/wasm/referances.wasm`) | ||
hypervisor.registerContainer(WasmContainer, { | ||
env: ContainerTestInterface, | ||
test: testInterface(t) | ||
}) | ||
const cap = await hypervisor.createActor(WasmContainer.typeId, new Message({ | ||
data: main | ||
})) | ||
const actor = await hypervisor.getActor(cap.destId) | ||
await actor.container.onMessage(new Message(), 'test') | ||
t.end() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
181981
703