Compare commits

...

6 Commits

3 changed files with 23 additions and 3 deletions

View File

@ -82,6 +82,7 @@ export default class Go {
private exited = false;
private _resolveCallbackPromise?: () => void;
importObject: ImportObject;
private _pendingEvent?: any;
constructor() {
this._callbackTimeouts = new Map();
@ -437,6 +438,16 @@ export default class Go {
}
this._inst.exports.resume();
}
_makeFuncWrapper(id) {
const go = this;
return function () {
const event = { id: id, this: this, args: arguments };
go._pendingEvent = event;
go._resume();
// @ts-ignore
return event.result;
};
}
}
if (

View File

@ -89,7 +89,7 @@ func start() int {
return callbackId
}
// exit write
//export exit
func exit() {
exitChan <- true
}

View File

@ -12,6 +12,13 @@ export async function getVerifiableStream(
const reader = new VariableChunkStream(data);
let bytesToRead;
if (root instanceof ArrayBuffer) {
root = new Uint8Array(root);
}
if (proof instanceof ArrayBuffer) {
proof = new Uint8Array(proof);
}
const getNextBytes = async () => {
bytesToRead = getWasmProperty(wasmId, "write_promise");
bytesToRead = await bytesToRead;
@ -67,9 +74,9 @@ export async function getVerifiableStream(
const result = getWasmProperty(wasmId, "result");
const wasmDone = result === undefined;
const wasmDone = result !== undefined;
if (result === undefined) {
if (!wasmDone) {
await getNextBytes();
}
@ -84,6 +91,8 @@ export async function getVerifiableStream(
done(controller);
}
}
controller.enqueue(chunk.value);
},
async cancel(reason: any) {
await reader.cancel(reason);