vlocode-project - v1.40.0-beta-4
    Preparing search index...

    Class TimedMap<K, T>

    Represents a map with timed entries. Entries in the map have an optional expiration time and can be automatically cleaned up.

    Type Parameters

    • K

      The type of the keys in the map.

    • T

      The type of the values in the map.

    Index

    Constructors

    Properties

    lastCleanup: number = 0
    map: Map<K, { created: number; lastAccess?: number; value: T }> = ...

    Accessors

    • get size(): number

      Gets the number of key-value pairs in the TimedMap.

      Returns number

      The number of key-value pairs in the TimedMap.

    Methods

    • Deletes the entry with the specified key from the map.

      Parameters

      • key: K

        The key of the entry to delete.

      Returns boolean

      true if the entry was successfully deleted, false otherwise.

    • Returns an iterable iterator that contains the entries of the timed map. Each entry is a key-value pair, represented as an array [key, value]. If the entries have expired based on the time-to-live (ttl) option, they are skipped.

      Returns IterableIterator<[K, T]>

      An iterable iterator of key-value pairs.

    • Retrieves the value associated with the specified key from the timed map.

      Parameters

      • key: K

        The key to retrieve the value for.

      Returns undefined | T

      The value associated with the key, or undefined if the key does not exist.

    • Returns an iterable iterator of the keys in the TimedMap.

      Returns IterableIterator<K>

      An iterable iterator of the keys.

    • Sets a key-value pair in the map. If the key already exists, updates the value and updates the last access timestamp. If the key does not exist, adds a new entry with the specified key, value, and creation timestamp. Performs cleanup if necessary.

      Parameters

      • key: K

        The key to set.

      • value: T

        The value to set.

      Returns this

      The updated TimedMap instance.

    • Checks if the expiration time for the map entries has been reached.

      Returns undefined | boolean | 0

      True if the expiration time has been reached, false otherwise.

    • Returns an iterable iterator of the values in the TimedMap.

      Returns IterableIterator<T>

      An iterable iterator of the values.