@awesomeorganization/promise-queue

1.2.1 • Public • Published

promise-queue

💥 [ESM] The promise-based queue with concurrency control. Works with Browser and Node.js


GitHub Workflow Codacy CodeFactor Snyk Depfu npms.io


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',
// }

Package Sidebar

Install

npm i @awesomeorganization/promise-queue

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

4.97 kB

Total Files

6

Last publish

Collaborators

  • sergey.sedoy.97