MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / workerFunc

Function workerFunc

www/js/ext/worker.js:69–106  ·  view source on GitHub ↗
(self2)

Source from the content-addressed store, hash-verified

67 // src/ext/worker.js
68 var invocationIdCounter = 0;
69 var workerFunc = function(self2) {
70 self2.onmessage = function(e) {
71 switch (e.data.type) {
72 case "init":
73 self2.importScripts(e.data._hyperscript);
74 self2.importScripts.apply(self2, e.data.extraScripts);
75 const _hyperscript = self2["_hyperscript"];
76 var hyperscript = _hyperscript.parse(e.data.src);
77 hyperscript.apply(self2, self2);
78 postMessage({ type: "didInit" });
79 break;
80 case "call":
81 try {
82 var result = self2["_hyperscript"].internals.runtime.getHyperscriptFeatures(self2)[e.data.function].apply(self2, e.data.args);
83 Promise.resolve(result).then(function(value) {
84 postMessage({
85 type: "resolve",
86 id: e.data.id,
87 value
88 });
89 }).catch(function(error) {
90 postMessage({
91 type: "reject",
92 id: e.data.id,
93 error: error.toString()
94 });
95 });
96 } catch (error) {
97 postMessage({
98 type: "reject",
99 id: e.data.id,
100 error: error.toString()
101 });
102 }
103 break;
104 }
105 };
106 };
107 var workerCode = "(" + workerFunc.toString() + ")(self)";
108 var blob = new Blob([workerCode], { type: "text/javascript" });
109 var workerUri = URL.createObjectURL(blob);

Callers

nothing calls this directly

Calls 5

applyMethod · 0.45
parseMethod · 0.45
resolveMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected