MCPcopy
hub / github.com/midrender/revideo / loop

Function loop

packages/core/src/flow/loop.ts:92–118  ·  view source on GitHub ↗
(
  iterations: LoopCallback | number,
  factory?: LoopCallback,
)

Source from the content-addressed store, hash-verified

90 factory: LoopCallback,
91): ThreadGenerator;
92export function* loop(
93 iterations: LoopCallback | number,
94 factory?: LoopCallback,
95): ThreadGenerator {
96 if (typeof iterations !== 'number') {
97 factory = iterations;
98 iterations = Infinity;
99 }
100
101 if (iterations === Infinity && useThread().parent === null) {
102 useLogger().error({
103 message: 'Tried to execute an infinite loop in the main thread.',
104 remarks: infiniteLoop,
105 stack: new Error().stack,
106 });
107 return;
108 }
109
110 for (let i = 0; i < iterations; i++) {
111 const generator = factory!(i);
112 if (generator) {
113 yield* generator;
114 } else {
115 yield;
116 }
117 }
118}

Callers 1

presentation.tsxFile · 0.90

Calls 3

useThreadFunction · 0.90
useLoggerFunction · 0.90
errorMethod · 0.45

Tested by

no test coverage detected