How to use the @webassemblyjs/wasm-parser.parseBinary function in @webassemblyjs/wasm-parser

To help you get started, we’ve selected a few @webassemblyjs/wasm-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtuc / webassemblyjs / packages / cli / src / wasmast.js View on Github external
const fastast = require("./printer/fast-ast");
const { readFileSync } = require("fs");

function toArrayBuffer(buf) {
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}

const filename = process.argv[2];

if (typeof filename === "undefined") {
  throw new Error("Missing file");
}

// $FlowIgnore: this is correct but not correctly documented
const buff = toArrayBuffer(readFileSync(filename, null));
const ast = parseBinary(buff);

fastast.print(ast);

@webassemblyjs/wasm-parser

WebAssembly binary format parser

MIT
Latest version published 15 days ago

Package Health Score

88 / 100
Full package analysis