MCPcopy Index your code
hub / github.com/midrender/revideo / loopFor

Function loopFor

packages/core/src/flow/loopFor.ts:28–47  ·  view source on GitHub ↗
(
  seconds: number,
  factory: LoopCallback,
)

Source from the content-addressed store, hash-verified

26 * iteration.
27 */
28export function* loopFor(
29 seconds: number,
30 factory: LoopCallback,
31): ThreadGenerator {
32 const thread = useThread();
33 const step = usePlayback().framesToSeconds(1);
34 const targetTime = thread.time() + seconds;
35
36 let iteration = 0;
37 while (targetTime - step > thread.fixed) {
38 const generator = factory(iteration);
39 if (generator) {
40 yield* generator;
41 } else {
42 yield;
43 }
44 iteration += 1;
45 }
46 thread.time(targetTime);
47}

Callers

nothing calls this directly

Calls 4

useThreadFunction · 0.90
usePlaybackFunction · 0.90
framesToSecondsMethod · 0.80
timeMethod · 0.80

Tested by

no test coverage detected