@awesomeorganization/promise-queue

    1.1.0 • Public • Published

    promise-queue

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


    npm npm npm npm npm npm


    Example

    Full example in /example folder.

    import { promiseQueue } from '@awesomeorganization/promise-queue'
    import undici from 'undici'
    
    const example = async () => {
      const { push } = promiseQueue({
        concurrency: 2,
      })
      const [
        {
          headers: { date: dateA },
        },
        {
          headers: { date: dateB },
        },
        {
          headers: { date: dateC },
        },
      ] = await Promise.all([
        push(() => {
          return undici.request('https://httpbin.org/delay/1')
        }),
        push(() => {
          return undici.request('https://httpbin.org/delay/1')
        }),
        push(() => {
          return undici.request('https://httpbin.org/delay/1')
        }),
      ])
      console.dir({
        dateA,
        dateB,
        dateC,
      })
    }
    
    example()
    

    Install

    npm i @awesomeorganization/promise-queue

    DownloadsWeekly Downloads

    21

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    4.44 kB

    Total Files

    6

    Last publish

    Collaborators

    • sergey.sedoy.97