global: private xpub support part 1

This commit is contained in:
nym21
2026-06-16 23:37:03 +02:00
parent 6f430bdb8c
commit 0c7861071d
70 changed files with 5874 additions and 12510 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* @template Item, Result
* @param {readonly Item[]} items
* @param {number} limit
* @param {(item: Item) => Promise<Result>} fn
* @returns {Promise<Result[]>}
*/
export async function mapConcurrent(items, limit, fn) {
const results = /** @type {Result[]} */ ([]);
let next = 0;
const workerCount = Math.min(limit, items.length);
const workers = Array.from({ length: workerCount }, async () => {
while (next < items.length) {
const index = next;
next += 1;
results[index] = await fn(items[index]);
}
});
await Promise.all(workers);
return results;
}