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

Function execFunction

packages/jest-worker/src/workers/processChild.ts:200–222  ·  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

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

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