Skip to content

Commit 15477fb

Browse files
committed
fix: move await to function initiate in node.js
1 parent 9f71345 commit 15477fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const wasi = new WASI({
1818
});
1919

2020
const buf = readFileSync(WASM_PATH);
21-
const wasiModule = await WebAssembly.compile(new Uint8Array(buf));
21+
const wasiModule = undefined;
2222

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

0 commit comments

Comments
 (0)