MCPcopy Create free account
hub / github.com/MultithreadedJSBook/code-samples / asyncOnMessageWrap

Function asyncOnMessageWrap

ch6-thread-pool/worker.js:3–7  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

1const { parentPort } = require('worker_threads');
2
3function asyncOnMessageWrap(fn) {
4 return async function(msg) {
5 parentPort.postMessage(await fn(msg));
6 }
7}
8
9const commands = {
10 async square_sum(max) {

Callers 1

worker.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected