This package has been deprecated

Author message:

Suggest using p-queue instead

@delucis/stau

0.1.0 • Public • Published

@delucis/stau

npm version Build Status Coverage Status Known Vulnerabilities Greenkeeper badge

🚦 Run promises with limited concurrency

Installation

npm install --save @delucis/stau

Usage

stau(functions[, limit = 15])

Resolves when all of the functions have resolved.

  • functions

    Type: Array of async/Promise-returning functions

    The functions to execute with limited concurrency

  • limit

    Type: Number
    Default: 15

    The maximum number of functions to execute at the same time

Example

const stau = require('@delucis/stau')
const delay = require('delay')

const task = t => async () => {
  console.log(`Waiting for: ${t}ms`)
  return delay(t)
}

const tasks = [
  task(3000),
  task(5000),
  task(12000)
]

(async function () {
  await stau(tasks, 2)
    .then(() => console.log('Done waiting!'))
})()

// immediately:
// => Waiting for: 3000ms
// => Waiting for: 5000ms
//
// after 5 seconds:
// => Waiting for: 12000ms
//
// after 17 seconds:
// => Done waiting!

Readme

Keywords

none

Package Sidebar

Install

npm i @delucis/stau

Weekly Downloads

1

Version

0.1.0

License

GPL-3.0

Unpacked Size

42.9 kB

Total Files

8

Last publish

Collaborators

  • delucis