throttled-concurrent-actions
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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'}
]

License

MIT © Hoàng Văn Khải

Readme

Keywords

Package Sidebar

Install

npm i throttled-concurrent-actions

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

2.43 kB

Total Files

4

Last publish

Collaborators

  • khai96_