await-parallel-limit

Await an array of async functions with parallel limit.

Usage no npm install needed!

<script type="module">
  import awaitParallelLimit from 'https://cdn.skypack.dev/await-parallel-limit';
</script>

README

await-parallel-limit

npm install await-parallel-limit --save

Processes an array of async functions with concurrency limit (default limit is 5).

API

parallel(
    Array jobs,
    Integer concurrency,
)

Typescript

import parallel from 'await-parallel-limit'

const jobs = [
    async () { return await true },
    async () { return await 2 },
] as const

// results array is typed based on return types of async functions
// it is an ordered tuple of types

// const results: [ boolean, number ]
const results = await parallel(jobs, 2)

Javascript

const parallel = require('await-parallel-limit').default

var jobs = [
    async () { ... },
    async () { ... },
    async () { ... },
    async () { ... }
]

var results = await parallel(jobs, 2)