Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
1
const
{ parentPort } = require(
'worker_threads'
);
2
3
function
asyncOnMessageWrap(fn) {
4
return
async
function
(msg) {
5
parentPort.postMessage(
await
fn(msg));
6
}
7
}
8
9
const
commands = {
10
async
square_sum(max) {
Callers
1
worker.js
File · 0.70
Calls
no outgoing calls
Tested by
no test coverage detected