refpool
Pool of references that gc the least recently unref'ed ones when it reaches a max size
npm install refpool
Usage
const Pool =const p =maxSize: 42{console}const someResource = ...p // add a key to the poolp // get a val (bumps it) get(key, false) does not bumpp // sugar for p.set(data, data)const e = p // get the cache entry object out.// you can call e.increment, decrement and bump on this direclyp // add it and increment the reference countp // decrement the ref countp // 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