# refpool

> Pool of references that gc the least recently unref'ed ones when it reaches a max size

Latest version **1.2.2** (published 2020-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install refpool
pnpm add refpool
yarn add refpool
bun add refpool
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2020-09-15 |
| First published | 2020-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/refpool
- Repository: https://github.com/mafintosh/refpool
- Issues: https://github.com/mafintosh/refpool/issues
- npm.io page: https://npm.io/package/refpool

## Dependencies (1)

- [time-ordered-set](https://npm.io/package/time-ordered-set.md) ^1.0.2

## Recent versions

- 1.2.2 (latest) — 2020-09-15
- 1.2.1 — 2020-07-24
- 1.2.0 — 2020-07-24
- 1.1.0 — 2020-07-24
- 1.0.0 — 2020-07-23

## README

# refpool

Pool of references that gc the least recently unref'ed ones when it reaches a max size

```
npm install refpool
```

## Usage

``` js
const Pool = require('refpool')

const p = new Pool({
  maxSize: 42,
  close (data) {
    console.log('should close', data)
  }
})

const someResource = ...

p.set(key, val) // add a key to the pool
p.get(key) // get a val (bumps it) get(key, false) does not bump
p.add(data) // sugar for p.set(data, data)
const e = p.entry(key) // get the cache entry object out.
                       // you can call e.increment, decrement and bump on this direcly

p.increment(key) // add it and increment the reference count
p.decrement(key) // decrement the ref count
p.bump(key) // indicate that you used a thing in the pool
```

When more than `maxSize` items are inserted the least recently used
resource with no references will be passed to close.

## License

MIT

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