MCPcopy Index your code
hub / github.com/pyscript/pyscript / createFunction

Function createFunction

core/src/hooks.js:28–44  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

26};
27
28export const createFunction = (self, name) => {
29 const cbs = [...worker(name)];
30 if (cbs.length) {
31 const cb = toJSONCallback(
32 self[`_${name}`] ||
33 (name.endsWith("Async")
34 ? async (wrap, xworker, ...cbs) => {
35 for (const cb of cbs) await cb(wrap, xworker);
36 }
37 : (wrap, xworker, ...cbs) => {
38 for (const cb of cbs) cb(wrap, xworker);
39 }),
40 );
41 const a = cbs.map(toJSONCallback).join(", ");
42 return Function(`return(w,x)=>(${cb})(w,x,...[${a}])`)();
43 }
44};
45
46const SetFunction = typedSet({ typeof: "function" });
47const SetString = typedSet({ typeof: "string" });

Callers 5

onReadyFunction · 0.90
onBeforeRunFunction · 0.90
onBeforeRunAsyncFunction · 0.90
onAfterRunFunction · 0.90
onAfterRunAsyncFunction · 0.90

Calls 2

workerFunction · 0.85
cbFunction · 0.85

Tested by

no test coverage detected