as-run-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

AS-Run-JS

Run JavaScript code from AssemblyScript

Installation

~ npm install as-run-js

Usage

JS

...
const loader = require('@assemblyscript/loader')
+ const RunJS = require('as-run-js/imports')
+ const runJS = new RunJS()
const imports = {
+     ...runJS.wasmImports
}
const wasmModule = loader.instantiateSync(..., imports);
+ runJS.wasmExports = wasmModule.exports
...

AssemblyScript

import { runJS } from 'as-run-js;

runJS(`console.log('Hello from AssemblyScript with RunJS!')`)
// Runs in the main file. Can access anything.

Safety

This module use eval(). I am not responible for any damage caused because of this module. When running on the backend, you need to be wary of backdoors and unwanted access. If your going to be using fetch() for your wasm binary, be very cautious when using this module. :)

Package Sidebar

Install

npm i as-run-js

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

8.78 kB

Total Files

15

Last publish

Collaborators

  • slicewire-dev