Skip to content

Instantly share code, notes, and snippets.

@mikehibm
Last active November 14, 2018 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehibm/10ae9293468f70b365ef7d5589b67494 to your computer and use it in GitHub Desktop.
Save mikehibm/10ae9293468f70b365ef7d5589b67494 to your computer and use it in GitHub Desktop.
export default (workerFunc: () => void) => {
let code = workerFunc.toString();
code = code.substring(code.indexOf('{') + 1, code.lastIndexOf('}'));
const blob = new Blob([code], { type: 'application/javascript' });
return new Worker(URL.createObjectURL(blob));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment