Last active
January 19, 2018 13:15
-
-
Save deebloo/2361d7f9565844f666719a3bc9020561 to your computer and use it in GitHub Desktop.
Small function for inline workers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createWorker(fn) { | |
var blob = new Blob(['self.onmessage = ', fn.toString()], { type: 'text/javascript' }); | |
var url = URL.createObjectURL(blob); | |
return new Worker(url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment