Skip to content

Commit

Permalink
fix: move await to function initiate in node.js (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey600 committed Feb 29, 2024
1 parent 9f71345 commit 99ffd9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion node.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const wasi = new WASI({
});

const buf = readFileSync(WASM_PATH);
const wasiModule = await WebAssembly.compile(new Uint8Array(buf));
let wasiModule = undefined;

// Encode string into memory starting at address base.
const encode = (memory, buffer) => {
Expand Down Expand Up @@ -64,6 +64,7 @@ export class FontKitIndex {
* **NOTE**: You **MUST** CALL `.free()` when discarding FontKit.
*/
async initiate() {
if (!wasiModule) wasiModule = await WebAssembly.compile(new Uint8Array(buf));
this.instance = await WebAssembly.instantiate(wasiModule, { wasi_snapshot_preview1: wasi.wasiImport });
wasi.initialize(this.instance);
this.fontkit_ptr = this.instance.exports.build_font_kit();
Expand Down

0 comments on commit 99ffd9e

Please sign in to comment.