UNPKG

@ng-web-apis/workers

Version:
2 lines (1 loc) 572 B
export declare const WORKER_BLANK_FN = "\nfunction(fn){\n function isFunction(type){\n return type === 'function';\n }\n\n self.addEventListener('message', function(e) {\n var result = fn.call(null, e.data);\n if (result && [typeof result.then, typeof result.catch].every(isFunction)){\n result\n .then(postMessage)\n .catch(function(error) {\n setTimeout(function(){throw error}, 0)\n })\n } else {\n postMessage(result);\n }\n })\n}\n";