Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { print } = require("@webassemblyjs/wast-printer");
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 = parse(content);
denormalizeTypeReferences.transform(ast);
wastIdentifierToIndex.transform(ast);
console.log(print(ast));
export function codeFrameFromAst(ast, loc) {
return codeFrameFromSource(print(ast), loc);
}
export function codeFrameFromSource(source, loc) {
export function codeFrameFromAst(ast: Program, loc: SourceLocation): string {
return codeFrameFromSource(print(ast), loc);
}
#!/usr/bin/env node
const { readFileSync } = require("fs");
const { decode } = require("@webassemblyjs/wasm-parser");
const { print } = require("@webassemblyjs/wast-printer");
function toArrayBuffer(buf) {
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}
const filename = process.argv[2];
const buff = toArrayBuffer(readFileSync(filename, null));
const ast = decode(buff);
const wast = print(ast);
process.stdout.write(wast);