std
    Preparing search index...

    Class PerishableList<T>

    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); // [];

    Type Parameters

    • T
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Adds an item to the list with an expiresIn time. The item will be removed from the list if the expiresIn time has passed.

      Parameters

      • item: T
      • expiresIn: number

      Returns number

      id of the item

      list.add("Hello, World!", 1000);
      
    • Removes all items from the list.

      list.clear();
      

      Returns void

    • Removes an item from the list with the key returned from the add method.

      Parameters

      • index: number
        const key = list.add("Hello, World!", 1000);

        list.remove(key);

      Returns void