MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / processInBatches

Function processInBatches

scripts/fetchLicenses.mjs:115–128  ·  view source on GitHub ↗
(items, batchSize, fn)

Source from the content-addressed store, hash-verified

113}
114
115async function processInBatches(items, batchSize, fn) {
116 const results = [];
117 for (let i = 0; i < items.length; i += batchSize) {
118 const batch = items.slice(i, i + batchSize);
119 const batchResults = await Promise.all(batch.map(fn));
120 results.push(...batchResults);
121
122 if (i + batchSize < items.length) {
123 process.stdout.write(`\r Fetched ${results.length}/${items.length} packages...`);
124 }
125 }
126 process.stdout.write(`\r Fetched ${results.length}/${items.length} packages...\n`);
127 return results;
128}
129
130async function main() {
131 const args = process.argv.slice(2);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected