@barchart/common-js
Version:
Library of common JavaScript utilities
67 lines (66 loc) • 1.44 kB
TypeScript
/**
* A map that which only holds objects for a specified duration.
*
* @public
*/
export default class TimeMap {
/**
* @param {number} duration - The time to live, in milliseconds.
*/
constructor(duration: number);
/**
* Returns true, if the map contains the item; otherwise false.
*
* @public
* @param {string} key
* @returns {boolean}
*/
public has(key: string): boolean;
/**
* Puts an item into the map.
*
* @public
* @param {string} key
* @param {*} value
*/
public put(key: string, value: any): void;
/**
* Puts an item into the map.
*
* @public
* @param {string} key
* @param {*} value
*/
public set(key: string, value: any): void;
/**
* Gets an item from the map, returning a null value if the no item
* for the given key exists.
*
* @public
* @param {string} key
* @returns {*|null}
*/
public get(key: string): any | null;
/**
* Removes an item from the map.
*
* @public
* @param {string} key
*/
public remove(key: string): void;
/**
* Removes an item from the map.
*
* @public
* @param {string} key
*/
public delete(key: string): void;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}