# @types/promise-queue

> TypeScript definitions for promise-queue

Latest version **2.2.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/promise-queue
pnpm add @types/promise-queue
yarn add @types/promise-queue
bun add @types/promise-queue
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2023-11-07 |
| First published | 2018-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/promise-queue
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/promise-queue
- npm.io page: https://npm.io/package/@types/promise-queue

## Recent versions

- 2.2.3 (latest) — 2023-11-07
- 2.2.0 (ts2.0) — 2018-01-30
- 2.2.2 — 2023-10-18
- 2.2.1 — 2023-09-24

## README

# Installation
> `npm install --save @types/promise-queue`

# Summary
This package contains type definitions for promise-queue (https://github.com/azproduction/promise-queue).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/promise-queue.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/promise-queue/index.d.ts)
````ts
export = PromiseQueue;

declare class PromiseQueue {
    /**
     * @param maxPendingPromises [Infinity] Number of promises that can run at once.
     * @param maxQueuedPromises [Infinity] Number of promises generators that can be in the queue at once.
     *                                     `add()` will return a rejected promise if this limit would be exceeded.
     * @param options [{}] See QueueOptions
     */
    constructor(maxPendingPromises?: number, maxQueuedPromises?: number, options?: PromiseQueue.QueueOptions);

    /**
     * Enqueue a promise generator. When the number of running promises is less than `maxPendingPromises`,
     * this function will be called and the returned promise will be held as a running promise until it
     * rejects or resolves.
     *
     * @throws If the global `Promise` is undefined and `Queue.configure` hasn't been called.
     * @param promiseGenerator A function that returns a promise when called.
     * @returns A promise that forwards the resolution/rejection of the promise returned by `promiseGenerator`,
     *          or immediately rejects if `maxQueuedPromise` is exceeded.
     */
    add<T>(promiseGenerator: () => Promise<T>): Promise<T>;

    /**
     * Returns the number of promiseGenerators waiting in queue.
     */
    getPendingLength(): number;

    /**
     * Returns the number of in-flight promises
     */
    getQueueLength(): number;

    /**
     * Set which promise constructor to use for the value returned by PromiseQueue#add.
     * If this isn't called, the global `Promise` constructor is used.
     * @param GlobalPromise A constructor for Promises
     */
    static configure(GlobalPromise: PromiseConstructor): void;
}

declare namespace PromiseQueue {
    interface QueueOptions {
        /**
         * Callback that is called when the queue is empty and all pending promises have resolved
         */
        onEmpty(): void;
    }
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
 * Dependencies: none

# Credits
These definitions were written by [Lachlan Stuart](https://github.com/LachlanStuart).

---
_Source: https://npm.io/package/@types/promise-queue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
