https://github.com/ivanbeldad/timed-queue
Create a queue to limit async execution in time. The main motivation is to prevent API's quota limits
https://github.com/ivanbeldad/timed-queue
async nodejs queue
Last synced: 6 months ago
JSON representation
Create a queue to limit async execution in time. The main motivation is to prevent API's quota limits
- Host: GitHub
- URL: https://github.com/ivanbeldad/timed-queue
- Owner: ivanbeldad
- License: mit
- Created: 2018-06-05T15:31:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T03:09:09.000Z (about 8 years ago)
- Last Synced: 2025-12-23T06:44:13.867Z (7 months ago)
- Topics: async, nodejs, queue
- Language: JavaScript
- Homepage:
- Size: 116 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Timed Queue
[](https://www.npmjs.com/package/@ivanbeldad/timed-queue)
[](https://github.com/ivanbeldad/timed-queue/blob/master/LICENSE)
Create a queue to limit async execution in time
## Examples
```javascript
// Execute 5 functions at the same time, but never more than 5 per second.
const queue = require('@ivanbeldad/timed-queue').create({ items: 5, time: 1000 })
```
### Promises approach example
```javascript
queue.add(myPromise)
.then(result => console.log(`My result after completed! => ${result}`))
.catch(error => console.error(`Oh no! After all the work it failed! => ${error}`))
```
### Async/Await approach example
```javascript
try {
const result = await queue.add(myAsyncFunction)
console.log(`My result after completed! => ${result}`))
} catch (error) {
console.error(`Oh no! After all the work it failed! => ${error}`))
}
```
## License
Timed Queue is open-sourced software licensed under
the [MIT license](https://github.com/ivanbeldad/timed-queue/blob/master/LICENSE).