fetch("simple.wasm")
.then((response) => response.arrayBuffer())
.then((bytes) => {
const valid = WebAssembly.validate(bytes);
console.log(
`The given bytes are ${valid ? "" : "not "}a valid Wasm module`,
);
});WebAssembly.validate() / notebook
WebAssembly.validate()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const compileOptions = {
builtins: ["js-string"], // Enable JavaScript string builtins
importedStringConstants: "string_constants", // Enable imported global string constants
};
fetch("log-concat.wasm")
.then((response) => response.arrayBuffer())
.then((bytes) => WebAssembly.validate(bytes, compileOptions))
.then((result) => console.log(`Wasm module valid: ${result}`));