Installation
npm install --save @types/generic-pool
Summary
This package contains type definitions for generic-pool (https://github.com/coopernurse/node-pool#readme).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/generic-pool.
import { EventEmitter } from "events";
export class Pool<T> extends EventEmitter {
spareResourceCapacity: number;
size: number;
available: number;
borrowed: number;
pending: number;
max: number;
min: number;
start(): void;
acquire(priority?: number): PromiseLike<T>;
release(resource: T): PromiseLike<void>;
destroy(resource: T): PromiseLike<void>;
drain(): PromiseLike<void>;
clear(): PromiseLike<void>;
use<U>(cb: (resource: T) => U | PromiseLike<U>): PromiseLike<U>;
isBorrowedResource(resource: T): boolean;
}
export interface Factory<T> {
create(): PromiseLike<T>;
destroy(client: T): PromiseLike<void>;
validate?(client: T): PromiseLike<boolean>;
}
export interface Options {
max?: number | undefined;
min?: number | undefined;
maxWaitingClients?: number | undefined;
testOnBorrow?: boolean | undefined;
testOnReturn?: boolean | undefined;
acquireTimeoutMillis?: number | undefined;
fifo?: boolean | undefined;
priorityRange?: number | undefined;
autostart?: boolean | undefined;
evictionRunIntervalMillis?: number | undefined;
numTestsPerEvictionRun?: number | undefined;
softIdleTimeoutMillis?: number | undefined;
idleTimeoutMillis?: number | undefined;
}
export function createPool<T>(factory: Factory<T>, opts?: Options): Pool<T>;
Additional Details
- Last updated: Tue, 06 Jul 2021 20:33:03 GMT
- Dependencies: @types/node
- Global values: none
Credits
These definitions were written by Jerray Fu, and Will Boyce.