MCPcopy Create free account
hub / github.com/blacksmithgu/datacore / asyncEvalInContext

Function asyncEvalInContext

src/utils/javascript.ts:39–45  ·  view source on GitHub ↗
(script: string, variables: Record<string, unknown>)

Source from the content-addressed store, hash-verified

37 * Evaluate a script possibly asynchronously, if the script contains `async/await` blocks.
38 */
39export async function asyncEvalInContext(script: string, variables: Record<string, unknown>): Promise<unknown> {
40 if (script.includes("await")) {
41 return evalInContext("return (async () => { " + script + " })()", variables) as Promise<unknown>;
42 } else {
43 return Promise.resolve(evalInContext(script, variables));
44 }
45}

Callers 2

loadUncachedMethod · 0.90
rendererMethod · 0.90

Calls 3

evalInContextFunction · 0.85
includesMethod · 0.65
resolveMethod · 0.65

Tested by

no test coverage detected