dcousens / qup.js

A compact async stack-based concurrent queue with batch support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qup

NPM

A compact async/await stack-based concurrent queue for Javascript. No dependencies.

Examples

const q = qup(async (x) => {
  return x * x
}, 2) // at most 2 concurrent

await q.push(2)
// => 4

await q.push(4)
// => 16

q.push(3)
// => Promise { <pending> }

await Promise.all([
  q.push(2),
  q.push(4),
  q.push(8)
])
// => [4, 16, 64]

// or
await q.drain()

LICENSE MIT

About

A compact async stack-based concurrent queue with batch support

License:MIT License


Languages

Language:TypeScript 100.0%