# lightning-pool

> Fastest generic Pool written with TypeScript

Latest version **4.14.2** (published 2026-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install lightning-pool
pnpm add lightning-pool
yarn add lightning-pool
bun add lightning-pool
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.14.2 |
| Published | 2026-11-09 |
| First published | 2017-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 3 |
| Unpacked size | 64 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 35 |
| Author | Panates |
| Maintainers | erayhanoglu, ilkergurelli, onurtokel, bircanyuruk |
| Keywords | pool, generic, generic-pool |

## Links

- npm: https://www.npmjs.com/package/lightning-pool
- Repository: https://github.com/panates/lightning-pool
- npm.io page: https://npm.io/package/lightning-pool

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.9.1
- [doublylinked](https://npm.io/package/doublylinked.md) ^2.5.6
- [putil-promisify](https://npm.io/package/putil-promisify.md) ^1.10.1

## Recent versions

- 4.14.2 (latest) — 2026-11-09
- 4.14.0 — 2026-09-08
- 4.13.0 — 2026-08-27
- 4.12.0 — 2025-12-04
- 4.11.1 — 2025-05-02
- 4.11.0 — 2025-05-02
- 4.10.1 — 2025-01-28
- 4.10.0 — 2024-10-15
- 4.9.0 — 2024-10-15
- 4.8.0 — 2024-08-20
- 4.7.3 — 2024-08-12
- 4.7.2 — 2024-08-12
- 4.7.1 — 2024-08-12
- 4.7.0 — 2024-08-12
- 4.6.1 — 2024-08-11
- … 53 more at https://npm.io/package/lightning-pool/versions

## README

# lightning-pool

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![CI Tests][ci-test-image]][ci-test-url]
[![Test Coverage][coveralls-image]][coveralls-url]

## About

High performance resource pool written with TypeScript.

 - A fast Resource Pool implementation for JavaScript - see [docs/BENCHMARKS.md](docs/BENCHMARKS.md) for the numbers against [generic-pool](https://github.com/coopernurse/node-pool), or [benchmark/README.md](benchmark/README.md) to reproduce them yourself
 - Advanced configuration options, suits for enterprise level applications
 - Configuration can be changed while pool running
 - Promise based factory supported
 - Supports validation and resource reset
 - Fully tested. (%100 coverage)

## Installation

  - `npm install lightning-pool --save`

## Example

```ts
import {Pool} from 'lightning-pool';
import dbDriver from 'some-db-driver';

/**
 * Step 1 - Create a factory object
 */
const factory = {
    create: async function(opts) {
        const client = await DbDriver.createClient();
        return client;
    },
    destroy: async function(client) {  
       await client.close();       
    },
    reset: async function(client){   
       await client.rollback();       
    },
    validate: async function(client) {
       await client.query('select 1');       
    }    
};

/**
 * Step 2 - Create a the pool object
 */
const pool = new Pool(factory, {  
    max: 10,    // maximum size of the pool
    min: 2,     // minimum size of the pool
    minIdle: 2  // minimum idle resources
});

pool.start();

/**
 * Step 3 - Use pool in your code to acquire/release resources
 */
// acquire connection - Promise is resolved
const client = await pool.acquire();
// once a resource becomes available
// Use resource
await client.query("select * from foo");
// return object back to pool
await pool.releaseAsync(client);

/**
 * Step 4 - Shutdown pool (optional)
 * Call close(force) when you need to shutdown the pool
 */

// Wait for active resource for 5 sec than force shutdown
await pool.close(5000);
```

## Documentation

See [docs/API.md](docs/API.md) for the full API reference - factory/options shape, every method and property,
emitted events, and the `PoolState`/`ResourceState` enums.

## Node Compatibility

  - node `>= 22.0`;
  
### License
[MIT](LICENSE)

[npm-image]: https://img.shields.io/npm/v/lightning-pool.svg
[npm-url]: https://npmjs.org/package/lightning-pool
[ci-test-image]: https://github.com/panates/lightning-pool/actions/workflows/test.yml/badge.svg
[ci-test-url]: https://github.com/panates/lightning-pool/actions/workflows/test.yml
[coveralls-image]: https://img.shields.io/coveralls/panates/lightning-pool/dev.svg
[coveralls-url]: https://coveralls.io/r/panates/lightning-pool
[downloads-image]: https://img.shields.io/npm/dm/lightning-pool.svg
[downloads-url]: https://npmjs.org/package/lightning-pool
[gitter-image]: https://badges.gitter.im/panates/lightning-pool.svg
[gitter-url]: https://gitter.im/panates/lightning-pool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[dependencies-image]: https://david-dm.org/panates/lightning-pool/status.svg
[dependencies-url]:https://david-dm.org/panates/lightning-pool
[devdependencies-image]: https://david-dm.org/panates/lightning-pool/dev-status.svg
[devdependencies-url]:https://david-dm.org/panates/lightning-pool?type=dev
[quality-image]: http://npm.packagequality.com/shield/lightning-pool.png
[quality-url]: http://packagequality.com/#?package=lightning-pool

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