Class: WASMJSAPI

WASMJSAPI(wasmInstance, helperFunctions)

WASMJSAPI class. Creates a JS API from a WASM instance by demangling C++ function names.

Constructor

new WASMJSAPI(wasmInstance, helperFunctions)

WASMJSAPI constructor.
Parameters:
Name Type Description
wasmInstance Object An instantiated WASM.
helperFunctions Object An object that provides these helper functions: malloc, free, memset, demangle.
Source:

Methods

allocBytes(data) → {Number}

Writes bytes directly into the WASM memory and returns a pointer to its location.
Parameters:
Name Type Description
data Uint8Array The data to be written.
Source:
Returns:
A pointer to the data.
Type
Number

allocString(str) → {Number}

Converts a JS string to a WASM string.
Parameters:
Name Type Description
str String The JS string.
Source:
Returns:
A pointer to the WASM string.
Type
Number

freeMemory(ptr)

Frees the memory at a given pointer.
Parameters:
Name Type Description
ptr Number The pointer to the WASM memory.
Source: