23 lines
643 B
JavaScript
23 lines
643 B
JavaScript
var wasm_solver = null
|
|
|
|
function init_wasm_solver(words_str) {
|
|
const fill_string = (offset) => {
|
|
console.log("fill strings called " + offset)
|
|
const str_buf = new Uint8Array(wasm_solver.exports.memory.buffer, offset)
|
|
const buf = new TextEncoder().encode(words_str, "utf8")
|
|
str_buf.set(buf, 0)
|
|
}
|
|
const log_num_idxs = i => {
|
|
console.log("wasm: found " + i + " words")
|
|
}
|
|
WebAssembly.instantiateStreaming(fetch("wordle_opt.wasm"), {
|
|
env: {
|
|
fill_string: fill_string,
|
|
log_num_idxs: log_num_idxs,
|
|
}
|
|
}).then(wm => {
|
|
wasm_solver = wm.instance
|
|
wasm_solver.exports.init(words_str.length)
|
|
})
|
|
}
|