0.0.4 • Published 5 years ago
throttled-concurrent-actions v0.0.4
throttled-concurrent-actions
Like Promise.all
, but throttled
Requirements
- Node.js ≥ 8.9.0
Function Signature
declare function throttledConcurrentActions<X> (count: number, list: Action<X>[]): Promise<X[]>
type Action<X> = (x?: X) => X | Promise<X>
Usage Example
import throttledConcurrentActions from 'throttled-concurrent-actions'
const result = await throttledConcurrentActions(
3,
[
() => 'Sync Example',
async () => 'Async Example',
() => 'Another Sync Example',
async past => ({past}),
past => ({past})
]
)
Result:
[
'Sync Example',
'Async Example',
'Another Sync Example',
{past: 'Sync Example'},
{past: 'Async Example'}
]