@ivanbeldad/timed-queue
v1.0.1
Published
Create a queue to limit async execution in time
Downloads
1
Maintainers
Readme
Timed Queue
Create a queue to limit async execution in time
Examples
// 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
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
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.