0.1.3 • Published 12 months ago

lru-collection v0.1.3

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

LRU Collection

A tiny and simple LRU (least recently used) implementation with more utility methods! It extends a Collection, the data structure that is used throughout Discord.js

Documentation

Some generated documentation can be found here (tick the external checkbox in the settings on the right for all the methods), most of which is the same as the documentation for the Collection class from discord.js documentation for the Collection class from discord.js.

Installation

npm install lru-collection
or 
yarn add lru-collection
or
pnpm add lru-collection

Usage

import { LRUCollection } from 'lru-collection';

const lru = new LRUCollection<string, string>();

// set the maximum amount of entries we want
lru.max = 2;

lru.set('foo', 'bar');
lru.set('bar', 'baz');
lru.set('baz', 'qux');
console.log(lru.size):
// => 2
lru.has('foo');
// => false

The library also re-exports the Collection class from discord.js, so you can use it without installing it, if you want to.

import { DCollection as Collection } from 'lru-collection';
0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago