How to use wabt - 5 common examples

To help you get started, we’ve selected a few wabt 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 wasm-tool / emscripten / loader.js View on Github external
function wast2wasm(str) {
  const module = wabt.parseWat("hack.wat", str);
  const { buffer } = module.toBinary({});

  return buffer.buffer;
}
github xtuc / webassemblyjs / packages / webassemblyjs / benchmark / index.js View on Github external
function wastToWasm(content) {
  const module = wabt.parseWat("module.wast", content);
  module.resolveNames();
  module.validate();

  const { buffer } = module.toBinary({ write_debug_names: true });

  return buffer.buffer;
}
github ewasm / evm2wasm / index.js View on Github external
exports.evm2wasm = function (evmCode, opts = {
  'stackTrace': false,
  'useAsyncAPI': false,
  'inlineOps': true,
  'testName': 'temp',
  'chargePerOp': false
}) {
  const wast = exports.evm2wast(evmCode, opts)
  const mod = wabt.parseWat('arbitraryModuleName', wast)
  mod.resolveNames()
  mod.validate()
  const bin = mod.toBinary({log: false, write_debug_names: false}).buffer
  mod.destroy()
  return Promise.resolve(bin)
}

wabt

JavaScript version of WABT, The WebAssembly Binary Toolkit.

Apache-2.0
Latest version published 4 months ago

Package Health Score

73 / 100
Full package analysis