/** * Defines a StorageCallback for certain storage events */ export type StorageCallback = (oldValue: TYPE | undefined, newValue: TYPE | undefined, url: string) => void; export default abstract class LocalStorage { /** * Returns if the module is using a browser's [localStorage](https://www.w3schools.com/html/html5_webstorage.asp) */ static get isBrowserLocalStorage(): boolean; /** * Returns the current local storage path if not browser */ static get path(): string | undefined; /** * Sets the local storage path if not browser * * @param value */ static set path(value: string | undefined); /** * Retrieves the underlying key ID for the specified key * * @param key */ static id(key: KeyType): string; /** * Clears the local storage */ static clear(): void; /** * Returns if the local storage has the key available * * @deprecated * @param key */ static has(key: KeyType): boolean; /** * Returns if the local storage has the key available * * @param key */ static includes(key: KeyType): boolean; /** * Retrieves the value for the specified key if it exists in the local storage * @param key */ static get(key: KeyType): ValueType | undefined; /** * Removes a listener previously attached with LocalStorage.on(key, fn). * * value: the current value for key in local storage, parsed from the persisted JSON * old: the old value for key in local storage, parsed from the persisted JSON * url: the url for the tab where the modification came from * * @param key * @param StorageCallback */ static off(key: KeyType, StorageCallback: StorageCallback): void; /** * Listen for changes persisted against key on other tabs. * Triggers StorageCallback when a change occurs, passing the following arguments. * * value: the current value for key in local storage, parsed from the persisted JSON * old: the old value for key in local storage, parsed from the persisted JSON * url: the url for the tab where the modification came from * * @param key * @param StorageCallback */ static on(key: KeyType, StorageCallback: StorageCallback): void; /** * Listen ONCE for changes persisted against key on other tabs * Triggers StorageCallback when a change occurs, passing the following arguments. * * value: the current value for key in local storage, parsed from the persisted JSON * old: the old value for key in local storage, parsed from the persisted JSON * url: the url for the tab where the modification came from * * @param key * @param StorageCallback */ static once(key: KeyType, StorageCallback: StorageCallback): void; /** * Removes the key from local storage * * @param key */ static remove(key: KeyType): void; /** * Sets the value for the key in local storage * * @param key * @param value */ static set(key: KeyType, value: ValueType): void; /** * Sets the domain scope of the local storage on disk * * This prevents other applications using this library from stomping on the storage of others * * Note: For scope to apply, must be called before all other calls * * @param scope */ static domain(scope: string): void; } export { LocalStorage };