queuefy
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

queuefy

CI Maintainability Test Coverage npm (tag)

Wrapper to make any async handler act like a single thread with a queue.

Install

yarn add queuefy
npm i queuefy

Usage

import {queuefy} from 'queuefy'

let count = 0
const target = (param: number) => new Promise(resolve =>
  setTimeout(() => {
    count++
    resolve(count + param)
  }, Math.random() * 100),
)
const fn = queuefy(target)
const [r0, r1, r2, r3, r4] = await Promise.all([fn(4), fn(3), fn(2), fn(1), fn(0)])

// r0 is 5
// r1 is 5
// r2 is 5
// ... 

Alternatives

License

MIT

/queuefy/

    Package Sidebar

    Install

    npm i queuefy

    Weekly Downloads

    2,005

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    31.7 kB

    Total Files

    19

    Last publish

    Collaborators

    • antongolub
    • qiwibot