Skip to content

Instantly share code, notes, and snippets.

@mikehibm
Last active November 14, 2018 22:24
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