builds a WebWorker from a function