Shumoku Docs

Search documentation

Shared docs and current release

Loading search…

日本語

@shumoku/core · 0.4.0 · function

mapWithConcurrency

Source

Run `fn` over `items` with at most `limit` calls in flight at once, preserving input order in the result array. Replaces the two failure modes the audit found: unbounded `Promise.all` fan-out (network-scan would open hundreds of SNMP sockets at once) and fully sequential `await`-in-a-loop polling (zabbix walked hosts one by one). A rejected `fn` rejects the whole call (like `Promise.all`); a caller wanting partial results should catch inside `fn`.

mapWithConcurrency(items: readonly T[], limit: number, fn: object): Promise<R[]>

Parameters

Parameter Type Description Default
items readonly T[] No additional description.
limit number No additional description.
fn object No additional description.

Returns

Promise<R[]>

libs/@shumoku/core/src/plugin-kit/concurrency.ts:15