createLimit
createLimit(
concurrency):Limit
Defined in: packages/synapse-core/src/utils/concurrency.ts:22
Create a limit that runs at most concurrency tasks at a time, in call order.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
concurrency | number | The maximum number of tasks running at the same time. Infinity means no limit. |
Returns
Section titled “Returns”A function that runs a task when a slot is free and resolves with its result.
Example
Section titled “Example”import { createLimit } from '@filoz/synapse-core/utils'
const limit = createLimit(2)const results = await Promise.all(urls.map((url) => limit(() => fetch(url))))