Like Promise.all, but limit number of concurrent promises
npm install restricted-concurrent-actionsLike Promise.all, but limit number of concurrent promises
* Node.js ≥ 8.9.0
``typescript
declare function restrictedConcurrentActions
actions: Iterable<() => Promise
partLength: number,
handleRemain?: (tray: Y[]) => Y[]
): AsyncIterableIterator
declare namespace restrictedConcurrentActions {
declare function asArray
actions: Iterable<() => Promise
partLength: number,
handleRemain?: (tray: Y[]) => Y[]
): Promise
}
`
#### Fetch 4 URLs at a time
`javascript
import rca from 'restricted-concurrent-actions'
import fetch from 'node-fetch'
const resources = [ / An array of URLs / ]
const actions = resources.map(url => () => fetch(url))
const partLength = 4
const result = await rca.asArray(actions, partLength)
console.log(result)
``