|
12 | 12 | </head>
|
13 | 13 |
|
14 | 14 | <body>
|
15 |
| - <script src="wasm_exec.js"></script> |
16 | 15 | <script>
|
17 |
| - if (!WebAssembly.instantiateStreaming) { // polyfill |
18 |
| - WebAssembly.instantiateStreaming = async (resp, importObject) => { |
19 |
| - const source = await (await resp).arrayBuffer(); |
20 |
| - return await WebAssembly.instantiate(source, importObject); |
21 |
| - }; |
22 |
| - } |
23 |
| - |
24 | 16 | // Add polyfill for TextEncoder and TextDecoder for Microsoft Edge 17/18 support
|
25 | 17 | // https://caniuse.com/#feat=textencoder
|
26 | 18 | if (!window.TextEncoder) {
|
27 |
| - TextEncoder = function(){} |
| 19 | + window.TextEncoder = function(){} |
28 | 20 | TextEncoder.prototype.encode = function (string) {
|
29 |
| - var octets = []; |
30 |
| - var length = string.length; |
31 |
| - var i = 0; |
| 21 | + const octets = []; |
| 22 | + const length = string.length; |
| 23 | + let i = 0; |
32 | 24 | while (i < length) {
|
33 |
| - var codePoint = string.codePointAt(i); |
34 |
| - var c = 0; |
35 |
| - var bits = 0; |
| 25 | + let codePoint = string.codePointAt(i); |
| 26 | + let c = 0; |
| 27 | + let bits = 0; |
36 | 28 | if (codePoint <= 0x0000007F) {
|
37 | 29 | c = 0;
|
38 | 30 | bits = 0x00;
|
|
58 | 50 | };
|
59 | 51 | }
|
60 | 52 | if (!window.TextDecoder) {
|
61 |
| - TextDecoder = function(){} |
| 53 | + window.TextDecoder = function(){} |
62 | 54 | TextDecoder.prototype.decode = function (octets) {
|
63 |
| - var string = ""; |
64 |
| - var i = 0; |
| 55 | + let string = ""; |
| 56 | + let i = 0; |
65 | 57 | while (i < octets.length) {
|
66 |
| - var octet = octets[i]; |
67 |
| - var bytesNeeded = 0; |
68 |
| - var codePoint = 0; |
| 58 | + const octet = octets[i]; |
| 59 | + let bytesNeeded = 0; |
| 60 | + let codePoint = 0; |
69 | 61 | if (octet <= 0x7F) {
|
70 | 62 | bytesNeeded = 0;
|
71 | 63 | codePoint = octet & 0xFF;
|
|
80 | 72 | codePoint = octet & 0x07;
|
81 | 73 | }
|
82 | 74 | if (octets.length - i - bytesNeeded > 0) {
|
83 |
| - var k = 0; |
| 75 | + let k = 0; |
84 | 76 | while (k < bytesNeeded) {
|
85 | 77 | octet = octets[i + k + 1];
|
86 | 78 | codePoint = (codePoint << 6) | (octet & 0x3F);
|
|
93 | 85 | string += String.fromCodePoint(codePoint);
|
94 | 86 | i += bytesNeeded + 1;
|
95 | 87 | }
|
96 |
| - return string |
| 88 | + return string; |
| 89 | + }; |
| 90 | + } |
| 91 | + </script> |
| 92 | + <script src="wasm_exec.js"></script> |
| 93 | + <script> |
| 94 | + if (!WebAssembly.instantiateStreaming) { // polyfill |
| 95 | + WebAssembly.instantiateStreaming = async (resp, importObject) => { |
| 96 | + const source = await (await resp).arrayBuffer(); |
| 97 | + return await WebAssembly.instantiate(source, importObject); |
97 | 98 | };
|
98 | 99 | }
|
99 | 100 |
|
|
0 commit comments