Create a gist now

Instantly share code, notes, and snippets.

@rhysd /index.html Secret
Created Mar 24, 2016

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
</head>
<body>
<div id="test"></div>
</body>
<script>
const buf = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x0a, 0x00, 0x00, 0x00, 0x14, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x02, 0x01, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04, 0x04, 0x18, 0x13, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x03, 0x00, 0x01, 0x00, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x01, 0x01, 0x01, 0x20, 0x0c, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x03, 0x00, 0x03, 0x61, 0x62, 0x73, 0x01, 0x05, 0x73, 0x71, 0x72, 0x74, 0x32, 0x02, 0x04, 0x73, 0x71, 0x72, 0x74, 0x7e, 0x0f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x6f, 0x64, 0x69, 0x65, 0x73, 0x03, 0x20, 0x00, 0x01, 0x02, 0x07, 0x00, 0x00, 0x48, 0x9b, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x0e, 0x00, 0x0e, 0x00, 0x0f, 0x00, 0x90, 0x0e, 0x00, 0x14, 0x0e, 0x00, 0x39, 0x00, 0x01, 0x02, 0x07, 0x00, 0x00, 0x9c, 0x12, 0x00, 0x8a, 0x0e, 0x00, 0x0e, 0x01, 0x0c, 0xf1, 0x68, 0xe3, 0x88, 0xb5, 0xf8, 0xe4, 0x3e, 0x14, 0x0e, 0x01, 0x14, 0x12, 0x01, 0x0e, 0x01, 0x89, 0x0e, 0x01, 0x8c, 0x8a, 0x8b, 0x0e, 0x01, 0x0e, 0x01, 0x0e, 0x02, 0x8b, 0x0e, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0e, 0x02, 0x11, 0x00, 0x14, 0x12, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00])
const module = window.Wasm.instantiateModule(buf);
console.log(module);
document.getElementById('test').innerText = `Result: ${module.exports.sqrt(314)}`;
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment