MCPcopy
hub / github.com/opentrace/opentrace / runFunction

Function runFunction

ui/public/lbug_wasm_worker.js:404–437  ·  view source on GitHub ↗
(jobUID, fn, args)

Source from the content-addressed store, hash-verified

402 }
403 }
404 function runFunction(jobUID, fn, args) {
405 return __awaiter(this, void 0, void 0, function* () {
406 let syncResult;
407 try {
408 syncResult = fn(...args);
409 } catch (error) {
410 return postJobErrorMessage(jobUID, error);
411 }
412 const resultType = isObservable(syncResult) ? 'observable' : 'promise';
413 postJobStartMessage(jobUID, resultType);
414 if (isObservable(syncResult)) {
415 const subscription = syncResult.subscribe(
416 (value) =>
417 postJobResultMessage(jobUID, false, common_1.serialize(value)),
418 (error) => {
419 postJobErrorMessage(jobUID, common_1.serialize(error));
420 activeSubscriptions.delete(jobUID);
421 },
422 () => {
423 postJobResultMessage(jobUID, true);
424 activeSubscriptions.delete(jobUID);
425 },
426 );
427 activeSubscriptions.set(jobUID, subscription);
428 } else {
429 try {
430 const result = yield syncResult;
431 postJobResultMessage(jobUID, true, common_1.serialize(result));
432 } catch (error) {
433 postJobErrorMessage(jobUID, common_1.serialize(error));
434 }
435 }
436 });
437 }
438 function expose2(exposed) {
439 if (!implementation_1.default.isWorkerRuntime()) {
440 throw Error('expose() called in the master thread.');

Callers 1

expose2Function · 0.85

Calls 6

postJobErrorMessageFunction · 0.85
isObservableFunction · 0.85
postJobStartMessageFunction · 0.85
postJobResultMessageFunction · 0.85
serializeMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected