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

Function workerFunc

src/ext/worker.js:11–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9var invocationIdCounter = 0;
10
11var workerFunc = function (self) {
12 self.onmessage = function (e) {
13 switch (e.data.type) {
14 case "init":
15 self.importScripts(e.data._hyperscript);
16 self.importScripts.apply(self, e.data.extraScripts);
17 const _hyperscript = self['_hyperscript']
18 var hyperscript = _hyperscript.parse(e.data.src);
19 hyperscript.apply(self, self);
20 postMessage({ type: "didInit" });
21 break;
22 case "call":
23 try {
24 var result = self['_hyperscript'].internals.runtime
25 .getHyperscriptFeatures(self)[e.data.function]
26 .apply(self, e.data.args);
27 Promise.resolve(result)
28 .then(function (value) {
29 postMessage({
30 type: "resolve",
31 id: e.data.id,
32 value: value,
33 });
34 })
35 .catch(function (error) {
36 postMessage({
37 type: "reject",
38 id: e.data.id,
39 error: error.toString(),
40 });
41 });
42 } catch (error) {
43 postMessage({
44 type: "reject",
45 id: e.data.id,
46 error: error.toString(),
47 });
48 }
49 break;
50 }
51 };
52};
53
54var workerCode = "(" + workerFunc.toString() + ")(self)";
55var blob = new Blob([workerCode], { type: "text/javascript" });

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