lru-collection
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

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';

Package Sidebar

Install

npm i lru-collection

Weekly Downloads

1

Version

0.1.3

License

none

Unpacked Size

13 kB

Total Files

8

Last publish

Collaborators

  • mastondzn