Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createWebWorker (func) {
- // Build a worker from an anonymous function body
- const blobURL = URL.createObjectURL(new Blob(['(',
- func.toString(),
- ')()'], { type: 'application/javascript' }))
- const worker = new Worker(blobURL)
- // Won't be needing this anymore
- URL.revokeObjectURL(blobURL)
- return worker
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement