SHARE
TWEET

Untitled

a guest Aug 25th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top