mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 22:32:28 +00:00
fix: ensure projects that go from having no commits to having commits have sessions migrated (#5105)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -17,3 +17,16 @@ export class AsyncQueue<T> implements AsyncIterable<T> {
|
||||
while (true) yield await this.next()
|
||||
}
|
||||
}
|
||||
|
||||
export async function work<T>(concurrency: number, items: T[], fn: (item: T) => Promise<void>) {
|
||||
const pending = [...items]
|
||||
await Promise.all(
|
||||
Array.from({ length: concurrency }, async () => {
|
||||
while (true) {
|
||||
const item = pending.pop()
|
||||
if (item === undefined) return
|
||||
await fn(item)
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user