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: 2 months 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 (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-05T01:55:53.000Z (3 months ago)
- Last Synced: 2025-04-21T07:42:36.743Z (2 months ago)
- Topics: utils
- Language: TypeScript
- Homepage:
- Size: 966 KB
- Stars: 1
- Watchers: 9
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# queuefy
[](https://github.com/qiwi/queuefy/actions/workflows/ci.yaml)
[](https://codeclimate.com/github/qiwi/queuefy/maintainability)
[](https://codeclimate.com/github/qiwi/queuefy/test_coverage)
[](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)