Utility for creating functions that run within a web worker and return a promise.