MCPcopy
hub / github.com/triggerdotdev/trigger.dev / dateForUpdates

Function dateForUpdates

apps/webapp/app/routes/tests.sse.stream.ts:42–61  ·  view source on GitHub ↗
(opts: {
  minDelay: number;
  maxDelay: number;
  undefinedProbability: number;
})

Source from the content-addressed store, hash-verified

40}
41
42async function dateForUpdates(opts: {
43 minDelay: number;
44 maxDelay: number;
45 undefinedProbability: number;
46}): Promise<number | undefined> {
47 // Randomly await between minDelay and maxDelay
48 await new Promise((resolve) => {
49 setTimeout(resolve, Math.random() * (opts.maxDelay - opts.minDelay) + opts.minDelay);
50 });
51
52 // There should be about a x% chance that this returns undefined
53 if (Math.random() < opts.undefinedProbability) {
54 logger.debug("Test SSE dataForUpdates returning undefined");
55
56 return undefined;
57 }
58
59 // Randomly return true or false
60 return Date.now();
61}
62
63function calculateChangeSignals(ts: number) {
64 return {

Callers 1

loaderFunction · 0.85

Calls 2

randomMethod · 0.80
debugMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…