shitty-queue

    1.1.1 • Public • Published

    Simple queuing system

    Non-blocking recursion-based queue for processing items in series

    npm i shitty-queue
    

    Initialize queue with an item-processor function and optional milliseconds to wait before processing next item - then just start requesting

    Note: Processor must return a Promise

    //Create your item-processor-function
    const item_processor = async ( item ) => {
      //-- Simulate 5-sec process --
      console.log(`Processing ${item}`)
      await new Promise(done => setTimeout(done,5000))
      console.log(`Completed ${item}`)
      return `Result of ${item}`
    }
     
    //Init queue with processor and ms to wait between items
    const queue = require('shitty-queue')(item_processor, 100)
     
    //Add a bunch of requests and 
    queue.request('111111111').then(console.log)
    queue.request('222222222').then(console.log)
    queue.request('333333333').then(console.log)
    queue.request('444444444').then(console.log)
    queue.request('555555555').then(console.log)

    Keywords

    none

    Install

    npm i shitty-queue

    DownloadsWeekly Downloads

    0

    Version

    1.1.1

    License

    ISC

    Unpacked Size

    2.66 kB

    Total Files

    4

    Last publish

    Collaborators

    • r3volved