Skip to main content
Home

makes a worker from a given script string

This package works with Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.1.1)
Package root>src>stringWorker.ts
/** * Takes a script represented as a string, and returns a worker running that script. */ export function stringWorker(script: string): Worker { const blob = new Blob([script], { type: 'text/javascript' }) const url = URL.createObjectURL(blob) const worker = new Worker(url, { type: 'module' }) URL.revokeObjectURL(url) return worker }