MCPcopy
hub / github.com/jestjs/jest / execFunction

Function execFunction

packages/jest-worker/src/workers/threadChild.ts:206–228  ·  view source on GitHub ↗
(
  fn: UnknownFunction,
  ctx: unknown,
  args: Array<unknown>,
  onResult: (result: unknown) => void,
  onError: (error: Error) => void,
)

Source from the content-addressed store, hash-verified

204}
205
206function execFunction(
207 fn: UnknownFunction,
208 ctx: unknown,
209 args: Array<unknown>,
210 onResult: (result: unknown) => void,
211 onError: (error: Error) => void,
212): void {
213 let result: unknown;
214
215 try {
216 result = fn.apply(ctx, args);
217 } catch (error: any) {
218 onError(error);
219
220 return;
221 }
222
223 if (isPromise(result)) {
224 result.then(onResult, onError);
225 } else {
226 onResult(result);
227 }
228}

Callers 4

messageListenerFunction · 0.70
endFunction · 0.70
execHelperFunction · 0.70
execMethodFunction · 0.70

Calls 4

isPromiseFunction · 0.90
onErrorFunction · 0.85
thenMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected