Skip to content

Available imports and exports

Xendergo edited this page May 16, 2021 · 1 revision

Exports

autoReload

If you want your code to reload automatically when you change it, export an i32 call it autoReload, and set it to 1.

Example:

export const autoReload: i32 = 1;

This is also checked each time the file changes, so you're welcome to change this dynamically if you want to do that for some reason.

Imports

print(values...)

With this, you can print all numeric types in wasm to chat, and you can import as many arguments as you like, with whatever types you like.

Example:

declare function print(a: i32, b: i64, c: f32): void;

export function thingy(v: i32): void {
  print(v << 1, (<i64>v) << 32, <f32>Math.sqrt(v));
}

printString(value: String)

With this, you can print one string to chat.

Example:

declare function printString(v: String): void;

export function thingy(v: i32): void {
  printString(a.repeat(b * 3));
}