( seconds: number, factory: LoopCallback, )
| 26 | * iteration. |
| 27 | */ |
| 28 | export 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 | } |
nothing calls this directly
no test coverage detected