A list class where items are removed after their given expiration time.
const list = new PerishableList<string>();list.add("Hello, World!", 1000);console.log(list.items); // ["Hello, World!"];await sleep(1000);console.log(list.items); // []; Copy
const list = new PerishableList<string>();list.add("Hello, World!", 1000);console.log(list.items); // ["Hello, World!"];await sleep(1000);console.log(list.items); // [];
Retrieved the un-expired items in the list
Adds an item to the list with an expiresIn time. The item will be removed from the list if the expiresIn time has passed.
expiresIn
list.add("Hello, World!", 1000); Copy
list.add("Hello, World!", 1000);
id of the item
Removes all items from the list.
list.clear(); Copy
list.clear();
Removes an item from the list with the key returned from the add method.
add
const key = list.add("Hello, World!", 1000);list.remove(key); Copy
const key = list.add("Hello, World!", 1000);list.remove(key);
A list class where items are removed after their given expiration time.
Usage