@awesomeorganization/promise-queue
v1.2.1
Published
[ESM] The promise-based queue with concurrency control. Works with Browser and Node.js
Downloads
5
Maintainers
Readme
promise-queue
:boom: [ESM] The promise-based queue with concurrency control. Works with Browser and Node.js
Install
npm install @awesomeorganization/promise-queue
Example
Full example in /example
folder.
const { push } = promiseQueue({
concurrency: 2,
})
const [
{
headers: { date: dateA },
},
{
headers: { date: dateB },
},
{
headers: { date: dateC },
},
] = await Promise.all([
push(() => {
return request('https://httpbin.org/delay/1')
}),
push(() => {
return request('https://httpbin.org/delay/1')
}),
push(() => {
return request('https://httpbin.org/delay/1')
}),
])
console.dir({
dateA,
dateB,
dateC,
})
// {
// dateA: 'Wed, 26 Jan 2022 20:00:01 GMT',
// dateB: 'Wed, 26 Jan 2022 20:00:02 GMT',
// dateC: 'Wed, 26 Jan 2022 20:00:02 GMT',
// }