Created
May 11, 2015 09:14
-
-
Save MattiasFestin/9aa83ea041dc86265408 to your computer and use it in GitHub Desktop.
Spawn webworker with function or js code in string
This file contains hidden or 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
let spawn = (...args) => { | |
var src = args.map(function (x) { | |
return typeof x === 'function' ? '((' + x.toString() + ').call(this));' : x; | |
}).join(';'); | |
return new Worker( | |
window.URL.createObjectURL( | |
new Blob([src]) | |
) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment