Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiwi/queuefy
Wrapper to make any async handler act like a single thread with a queue
https://github.com/qiwi/queuefy
utils
Last synced: 4 days ago
JSON representation
Wrapper to make any async handler act like a single thread with a queue
- Host: GitHub
- URL: https://github.com/qiwi/queuefy
- Owner: qiwi
- License: mit
- Created: 2020-05-17T09:52:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T00:45:25.000Z (18 days ago)
- Last Synced: 2024-11-09T20:44:02.307Z (6 days ago)
- Topics: utils
- Language: TypeScript
- Homepage:
- Size: 1.05 MB
- Stars: 1
- Watchers: 10
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# queuefy
[![CI](https://github.com/qiwi/queuefy/actions/workflows/ci.yaml/badge.svg)](https://github.com/qiwi/queuefy/actions/workflows/ci.yaml)
[![Maintainability](https://api.codeclimate.com/v1/badges/2392bab0fb3bfa330f74/maintainability)](https://codeclimate.com/github/qiwi/queuefy/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/2392bab0fb3bfa330f74/test_coverage)](https://codeclimate.com/github/qiwi/queuefy/test_coverage)
[![npm (tag)](https://img.shields.io/npm/v/queuefy)](https://www.npmjs.com/package/queuefy)Wrapper to make any async handler act like a single thread with a queue.
## Install
```shell script
yarn add queuefy
npm i queuefy
```## Usage
```typescript
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
* [sindresorhus/p-queue](https://github.com/sindresorhus/p-queue)## License
[MIT](./LICENSE)