Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function createWebWorker (func) {
  2. // Build a worker from an anonymous function body
  3. const blobURL = URL.createObjectURL(new Blob(['(',
  4.  
  5. func.toString(),
  6.  
  7. ')()'], { type: 'application/javascript' }))
  8.  
  9. const worker = new Worker(blobURL)
  10.  
  11. // Won't be needing this anymore
  12. URL.revokeObjectURL(blobURL)
  13. return worker
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement