📄 createWorkerBlobUrl¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/core/useWebWorkerFn/lib/createWorkerBlobUrl.ts
📦 Imports¶
| Name | Source |
|---|---|
depsParser |
./depsParser |
jobRunner |
./jobRunner |
Functions¶
createWorkerBlobUrl(fn: Function, deps: string[], localDeps: Function[]): string¶
Converts the "fn" function into the syntax needed to be executed within a web worker
Parameters:
fnany: the function to run with web workerdepsany: array of strings, imported into the worker through "importScripts"localDepsany: array of function, local dependencies
Returns: undefined
a blob url, containing the code of "fn" as a string
Examples:
createWorkerBlobUrl((a,b) => a+b, [])
// return "onmessage=return Promise.resolve((a,b) => a + b)
.then(postMessage(['SUCCESS', result]))
.catch(postMessage(['ERROR', error])"
Raw JSDoc
/**
* Converts the "fn" function into the syntax needed to be executed within a web worker
*
* @param fn the function to run with web worker
* @param deps array of strings, imported into the worker through "importScripts"
* @param localDeps array of function, local dependencies
*
* @returns a blob url, containing the code of "fn" as a string
*
* @example
* createWorkerBlobUrl((a,b) => a+b, [])
* // return "onmessage=return Promise.resolve((a,b) => a + b)
* .then(postMessage(['SUCCESS', result]))
* .catch(postMessage(['ERROR', error])"
*/
Calls:
depsParser (from ./depsParser)URL.createObjectURL
Code
Generated by Syntax Scribe