From 15477fb5c9815323fc3197c5e9ff3d2a5631e66e Mon Sep 17 00:00:00 2001 From: "corey.fcx" Date: Thu, 29 Feb 2024 11:26:58 +0800 Subject: [PATCH] fix: move await to function initiate in node.js --- node.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node.js b/node.js index 81a3820..742454a 100644 --- a/node.js +++ b/node.js @@ -18,7 +18,7 @@ const wasi = new WASI({ }); const buf = readFileSync(WASM_PATH); -const wasiModule = await WebAssembly.compile(new Uint8Array(buf)); +const wasiModule = undefined; // Encode string into memory starting at address base. const encode = (memory, buffer) => { @@ -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();