root 3bf41bf355 update | 1 jaar geleden | |
---|---|---|
.. | ||
index.d.ts | 1 jaar geleden | |
index.js | 1 jaar geleden | |
license | 1 jaar geleden | |
package.json | 1 jaar geleden | |
readme.md | 1 jaar geleden |
Useful when you need to cache something and limit memory usage.
Inspired by the hashlru
algorithm, but instead uses Map
to support keys of any type, not just strings, and values can be undefined
.
$ npm install quick-lru
const QuickLRU = require('quick-lru');
const lru = new QuickLRU({maxSize: 1000});
lru.set('🦄', '🌈');
lru.has('🦄');
//=> true
lru.get('🦄');
//=> '🌈'
Returns a new instance.
Type: object
Required
Type: number
The maximum number of items before evicting the least recently used items.
The instance is iterable
so you can use it directly in a for…of
loop.
Both key
and value
can be of any type.
Set an item. Returns the instance.
Get an item.
Check if an item exists.
Get an item without marking it as recently used.
Delete an item.
Returns true
if the item is removed or false
if the item doesn't exist.
Delete all items.
Iterable for all the keys.
Iterable for all the values.
The stored item count.