shadow-function
Version:
ioing lib - shadow Function, worker Function
14 lines (11 loc) • 404 B
text/typescript
class WorkerFunction {
constructor (code: string | Function) {
code = typeof(code) === 'string' ? code : typeof(code) === 'function' ? Object.toString.call(code) : ''
// code = `self.addEventListener('message', function (event) { ` + code + ` }, false)`
return new Worker(URL.createObjectURL(new Blob([code], { type : 'text/javascript' })))
}
}
export {
WorkerFunction
}