MCPcopy Index your code
hub / github.com/andywer/threads.js / setPrivateThreadProps

Function setPrivateThreadProps

src/master/spawn.ts:120–132  ·  view source on GitHub ↗
(raw: T, worker: WorkerType, workerEvents: Observable<WorkerEvent>, terminate: () => Promise<void>)

Source from the content-addressed store, hash-verified

118}
119
120function setPrivateThreadProps<T>(raw: T, worker: WorkerType, workerEvents: Observable<WorkerEvent>, terminate: () => Promise<void>): T & PrivateThreadProps {
121 const workerErrors = workerEvents
122 .filter(event => event.type === WorkerEventType.internalError)
123 .map(errorEvent => (errorEvent as WorkerInternalErrorEvent).error)
124
125 // tslint:disable-next-line prefer-object-spread
126 return Object.assign(raw, {
127 [$errors]: workerErrors,
128 [$events]: workerEvents,
129 [$terminate]: terminate,
130 [$worker]: worker
131 })
132}
133
134/**
135 * Spawn a new thread. Takes a fresh worker instance, wraps it in a thin

Callers 1

spawnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected