Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move await to function initiate in node.js #20

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading