How to use the @webassemblyjs/wast-parser.parseSource function in @webassemblyjs/wast-parser

To help you get started, we’ve selected a few @webassemblyjs/wast-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 / wastast.js View on Github external
#!/usr/bin/env node
// @flow

const { parseSource } = require("@webassemblyjs/wast-parser");
const { readFileSync } = require("fs");

const filename = process.argv[2];

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

const content = readFileSync(filename, "utf8");
const ast = parseSource(content);

console.log(JSON.stringify(ast, null, 2));