Expiration
For having an array of items that expire after a dynamic amount of time
Install:
npm install expiration
Quick Example:
const ExpireList = const expireList = // Expire in 10sexpireList // Expire in 60sexpireList console // 2 console // [ 'hey!', 'bye!'] ... // 30s later console // 1 console // [ 'bye!' ] ... // 60s later console // 0 console // []
Methods
constructor()
Creates a new expiring list
add(storeItem, timeToCache = 60000)
Adds the given item to the list and removes from the list in the given amount of milliseconds
Parameters:
storeItem
- Object to store (can be a string, number, item, whatever)timeToCache
- Amount of milliseconds to store
length
How long is the list
list
What is the list at the given time
Notes:
Full example can be found under test/
.