All files / src/analysis/worker likelihood.worker.ts

0% Statements 0/4
100% Branches 1/1
100% Functions 1/1
0% Lines 0/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                                       
/**
 * A helper for pastis-NB's fit (ยง25.6, `analysis/likelihoodThreads.ts`): its
 * MDS start, then its likelihood.
 *
 * Sent its bands' rows once per objective, and then a point per evaluation, it
 * computes its bands' values and gradients and sends them back
 * (`likelihoodHelper`). One fit per worker: the thread that started it terminates it when the fit ends, or
 * stops.
 */
 
import { likelihoodHelper, type LikelihoodMessage, type LikelihoodRequest } from '../likelihoodThreads'
 
const scope = self as unknown as {
  onmessage: ((event: MessageEvent<LikelihoodRequest>) => void) | null
  postMessage(message: LikelihoodMessage, transfer?: Transferable[]): void
}
 
const handle = likelihoodHelper((message, transfer) => scope.postMessage(message, transfer ?? []))
scope.onmessage = (event) => handle(event.data)