Neocon Propaganda Machine

    timeout-promise-queue

    0.9.3 • Public • Published

    timeout-promise-queue

    NPM Version Build Status Coverage Status

    Promise queue with timeouts and promise cleanup after expiration.

    Motivation

    Reduce threads associated with forked processes by throttling the creating of processes.

    Installation

    timeout-promise-queue can be installed using npm:

    npm install timeout-promise-queue
    

    Interface

    • PromiseQueue(Number maxConcurrent): Queue
    • Queue#add(Function promseGenerator, [Number timeout, [rejection]]): Promise - calls function to generate a promise to add to the queue
      • `promiseGenerator([EventEmitter cancel]): Promise - generate a promise to add to the queue
      • if timeout is defined, promseGenerator is called with an EventEmitter which will get a 'timeout' event if timeout is exceeded. If rejection is not defined, timeouts call reject(Error('timeout of ' + timeout + ' exceeded')) If rejection is defined, it generates the timeout error. rejection must be one of:
        • if rejection is function, timouts call reject(rejection()).
        • otherwise timouts call reject(rejection).
    • Queue#size(): Number - returns number of pending promises

    Use

    const Queue = require('timeout-promise-queue').PromiseQueue(25) // allow 25 concurrent promises
    Promise.all([
      Queue.add(cancel => cancellable(cancel)),
      Queue.add(cancel => cancellable(cancel)),
      Queue.add(cancel => cancellable(cancel))...,
    ]).then(l => {console.log('done') })

    Install

    npm i timeout-promise-queue

    DownloadsWeekly Downloads

    4

    Version

    0.9.3

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    8

    Last publish

    Collaborators

    • ericprud