package
AssemblyScript's loader component as a stand-alone module.
npm install assemblyscript-loaderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
AssemblyScript's loader component to run and work with compiled WebAssembly modules, as a stand-alone module.
$> npm install assemblyscript-loaderimport load from "assemblyscript-loader"; // JS: var load = require("assemblyscript-loader").load;
load("path/to/myModule.wasm", {
imports: {
...
}
}).then(module => {
...
// i.e. call module.exports.main()
});Alternatively, when LoadOptions#exports is specified, the respective object is pre-initialized
with the (always present) ready promise that is resolved when loading is complete:
// myModule.js (CommonJS)
require("assemblyscript-loader").load("path/to/myModule.wasm", { exports: module.exports });// otherModule.js (CommonJS)
var myModule = require("./myModule.js");
myModule.ready.then(() => {
...
});load(file: string | Uint8Array | ArrayBuffer, options: LoadOptions): Promise<Module>
Loads a WebAssembly module either from a file or a buffer and returns a promise for the loaded Module.
LoadOptions
Options to set up the environment created by load.
WebAssembly.Memory{ [key: string]: any }{ [key: string]: any }Module
Common module interface as returned by load.
ImportsExportsMemoryLogType, message: string): voidImports
An object of imported functions.
Exports
An object of exported functions (plus the ready promise).
LogType
An enum of log types:
Note that the create methods of array and string accessors require an exported or imported
implementation of malloc, memset, free etc. to be present. Also remember that memory is
unmanaged here and that free must be called manually to clean up memory, just like in C. Once
WebAssembly exposes the garbage collector natively, there will be other options as well.
The long.js dependency can be safely excluded if working with
long/ulong values isn't needed. In this case, the implementation will still accept and produce
Long-like objects having a low and a high property representing the respective low and high
32-bits.
Clone the GitHub repository and install the development dependencies:
$> git clone https://github.com/AssemblyScript/loader.git
$> cd loader
$> npm installAfterwards, to build the distribution files to dist/, run:
$> npm run builddcode
dcode+npm@dcode.io
| Key | Value |
|---|
| LOG | 0 |
| INFO | 1 |
| WARN | 2 |
| ERROR | 3 |
Memory extends WebAssembly.Memory
The WebAssembly Memory
instance populated with additional accessors for more convenient memory access.
NumberAccessorNumberAccessorNumberAccessorNumberAccessorNumberAccessorNumberAccessorLongAccessorLongAccessorNumberAccessorNumberAccessorArrayAccessorStringAccessorNumberAccessor
Number memory accessor.
number): numbernumber, value: number): voidLongAccessor
Long memory accessor. See also: long.js
number): Longnumber, value: Long): voidArrayAccessor
Array memory accessor.
number): { length: number, base: number }number, elementByteSize: number): { ptr: number, base: number }StringAccessor
String memory accessor.
number): stringstring): numberinitializeMemory(memoryInstance: WebAssembly.Memory, malloc: Function, memset: Function): Memory
Just populates a WebAssembly Memory instance with the AssemblyScript-typical accessors.
xfetch(file: string): Promise<Response>
Underlying fetch
implementation that also works under node.js.
Estimated unpacked size across 4 packages.
139.6 kB
Includes dependencies.
3 direct · 3 outdated