/** * an expirable local storage (Singleton) */ export declare class ExpirableLocalStorage { private static readonly PREFIX; private static readonly TRUE; private static readonly FALSE; private static readonly DEFAULT_DATA_VALUE; private static instance; private storage; /** * get the ExpirableStorage instance */ static getInstance(): ExpirableLocalStorage; /** * clear keys * @param keys keys to clear */ clear(keys: string | string[]): void; /** * clear all keys */ clearAll(): void; /** * set boolean value * @param key storage key * @param value boolean value * @param expiryTimestamp expiry timestamp */ setBool(key: string, value: boolean, expiryTimestamp: number): void; /** * set string * @param key storage key * @param value string value * @param expiryTimestamp expiry timestamp */ setString(key: string, value: string, expiryTimestamp: number): void; /** * set number * @param key storage key * @param value number value * @param expiryTimestamp expiry timestamp */ setNumber(key: string, value: number, expiryTimestamp: number): void; /** * set object * @param key storage key * @param item object * @param expiryTimestamp expiry timestamp */ setObject(key: string, item: T, expiryTimestamp: number): void; /** * get boolean value * @param key storage key * @param defaultValue default value * @returns boolean value */ getBool(key: string, defaultValue: boolean): boolean; /** * get string value * @param key storage key * @param defaultValue default value * @param validValues valid values * @returns string value */ getString(key: string, defaultValue: T, validValues?: readonly T[]): T; /** * get number value * @param key storage key * @param defaultValue default value * @param validator validator * @returns number value */ getNumber(key: string, defaultValue: number, validator?: number[] | ((value: number) => boolean)): number; /** * get object value * @param key storage key * @param defaultValue default value * @param validator validator * @returns object value */ getObject(key: string, defaultValue: T, validator: (item: object) => boolean): T; /** * get the raw localstorage data * @param key storage key * @returns raw data */ getRaw(key: string): string | null; /** * The ExpirableStorage's constructor should always be private to prevent direct * construction calls with the `new` operator. */ private constructor(); /** * get current timestamp * @returns current timestamp */ private now; /** * get value * @param key storage key * @param defaultValue * @param transformer * @returns */ private get; /** * set value * @param key storage key * @param value storage value * @param expiryTimestamp The "expiryTimestamp" (expiration time) claim identifies the expiration time on or after which the value MUST NOT be accepted for processing. The processing of the "expiryTimestamp" claim requires that the current date/time MUST be before the expiration date/time listed in the "expiryTimestamp" claim. */ private set; /** * * @param key storage key * @returns the original localstorage canonical key with prefix like "@@EXPIRABLE/key" */ private canonicalKey; private getData; /** * set Data * @param key storage key * @param data storage value */ private setData; /** * internal clear (keys should be canonical keys) * @param keys keys to clear */ private internalClear; /** * delete the expired keys */ private prune; }