Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runTest(file, type, binary, wat) {
const context = new TestContext({
fileName: file,
reporter,
stderr: process.stderr,
stdout: process.stdout,
});
const imports = context.createImports({
wasi_unstable: wasi.exports,
});
const wasm = instantiateBuffer(binary, imports);
wasi.setMemory(wasm.memory);
wasi.view = new DataView(wasm.memory.buffer);
context.run(wasm);
}
const { readFileSync } = require('fs');
const { instantiateBuffer } = require('assemblyscript/lib/loader');
const wasmModule = instantiateBuffer(readFileSync(`${__dirname}/build/optimized.wasm`));
module.exports = function levenshtein(a, b) {
if (a === b) return 0;
if (a.length > b.length) [a, b] = [b, a];
return wasmModule.levenshtein(wasmModule.newString(a), wasmModule.newString(b));
};