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

feat: Improve argument types of initialize functions #25

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import type { Yoga } from "./wrapAsm.js";
export * from "./generated/YGEnums.js";
export * from "./wrapAsm.js";

export default function (wasm: ArrayBuffer): Promise<Yoga>;
export function initStreaming(response: Response): Promise<Yoga>;
export default function (wasm: BufferSource | WebAssembly.Module): Promise<Yoga>;
export function initStreaming(response: Response | PromiseLike<Response>): Promise<Yoga>;
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ export * from "./yoga/javascript/src_js/generated/YGEnums.js";
export default async function (wasm) {
const mod = await yoga({
instantiateWasm(info, receive) {
WebAssembly.instantiate(wasm, info).then(({ instance }) => {
receive(instance);
WebAssembly.instantiate(wasm, info).then((instance) => {
if (instance instanceof WebAssembly.Instance) {
receive(instance);
} else {
receive(instance.instance);
}
});
},
});
Expand Down