Debian Codegraph @

.cargo/vendor/js-sys/tests/wasm/WebAssembly.js

raw
1 const { TextEncoder } = require("util");
2
3 const data =
4 "\u0000asm\u0001\u0000\u0000\u0000\u0001\b\u0002`\u0001\u007f\u0000`\u0000" +
5 "\u0000\u0002\u0019\u0001\u0007imports\rimported_func\u0000\u0000\u0003" +
6 "\u0002\u0001\u0001\u0007\u0011\u0001\rexported_func\u0000\u0001\n\b\u0001" +
7 "\u0006\u0000A*\u0010\u0000\u000b";
8
9 const encoder = new TextEncoder();
10 const wasmArray = encoder.encode(data);
11
12 function getWasmArray() {
13 return wasmArray;
14 }
15
16 function getTableObject() {
17 return { element: "anyfunc", initial: 1 }
18 }
19
20 function getInvalidTableObject() {
21 return { element: "anyfunc", initial: 1, maximum: 0 }
22 }
23
24 function getImports() {
25 return {
26 imports: {
27 imported_func: function () {
28 return 1;
29 }
30 }
31 };
32 }
33
34 // Polyfill `WebAssembly.instantiateStreaming` for node.
35 if (!global.WebAssembly.instantiateStreaming) {
36 global.WebAssembly.instantiateStreaming =
37 (response, imports) => response.then(buf => WebAssembly.instantiate(buf, imports));
38 }
39
40 module.exports = {
41 getInvalidTableObject,
42 getTableObject,
43 getWasmArray,
44 getImports,
45 };