MCPcopy Index your code
hub / github.com/MultithreadedJSBook/code-samples / exec

Method exec

ch2-patterns/rpc-worker.js:17–27  ·  view source on GitHub ↗
(method, ...args)

Source from the content-addressed store, hash-verified

15 }
16// THIS LINE SHOULD NOT APPEAR IN PRINT
17 exec(method, ...args) {
18 const id = ++this.next_command_id;
19 let resolve, reject;
20 const promise = new Promise((res, rej) => {
21 resolve = res;
22 reject = rej;
23 });
24 this.in_flight_commands.set(id, { resolve, reject });
25 this.worker.postMessage({ method, params: args, id });
26 return promise;
27 }
28}

Callers 1

main.jsFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected