Skip to content

Commit 88d976d

Browse files
committed
Extend Node.js compatibility.
1 parent 703bbb8 commit 88d976d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/api.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ async function fetchObject(obj, fetchFn) {
2323
}
2424

2525
function fetchWebAssembly(url) {
26-
return fetch(url).then(WebAssembly.compileStreaming);
26+
if (WebAssembly.compileStreaming !== undefined) {
27+
return fetch(url).then(WebAssembly.compileStreaming);
28+
} else {
29+
// Node doesn't have `{compile,instantiate}Streaming`.
30+
return fetch(url).then((resp) => resp.arrayBuffer()).then(WebAssembly.compile);
31+
}
2732
}
2833

2934
function fetchUint8Array(url) {

0 commit comments

Comments
 (0)