Skip to content

Commit

Permalink
feat: Improve argument types of initialize functions (#25)
Browse files Browse the repository at this point in the history
* feat: Improve argument types of initialize functions

* feat: Add `BufferSource`
  • Loading branch information
shun-shobon committed Mar 12, 2023
1 parent 3d8489a commit 58938fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/index.d.ts
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
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

0 comments on commit 58938fb

Please sign in to comment.