INNER CODE UNIT · JavaScript
runPool
ImranR98/apps.obtainium.imranr.dev · scripts/validate_icons.js:117
async function runPool(items, worker, limit) {
const queue = items.slice()
const workers = Array.from({ length: Math.min(limit, queue.length) }, async () => {
while (queue.length) {
const item = queue.shift()
await worker(item)
}
})
await Promise.all(workers)
}
async function main() {
const files = targetPaths.length
? targetPaths.flatMap(target => {
const stat = fs.statSync(target)
return stat.isDirectory() ? getAllJsonFiles(target) : [target]
})
: getAllJsonFiles(APPS_DIR)