functionToWorker (fn: (): any): string

Converts a function into a WebWorker URL object that can be passed into thread(). Note that fn has to be a single function with no external references or bindings, so that it can be stringified using .toString().

Name Type Default Description
fn (): any    

thread (url: string|URL, data: any, timeout: number): Promise<T>

Creates a new web worker, posts it a serializable data object, and returns when the worker responds (or after a fixed timeout).

Name Type Default Description  
url string URL    
data any      
timeout number 5000    

Copyright © 2024