@jitsi/js-utils
Version:
Utilities for Jitsi JS projects
83 lines (82 loc) • 2.85 kB
TypeScript
import EventEmitter from 'events';
/**
* Wrapper class for browser's local storage object.
*/
export declare class JitsiLocalStorage extends EventEmitter {
/**
* The storage backend (either window.localStorage or DummyLocalStorage).
*/
private _storage;
/**
* Whether window.localStorage is disabled.
*/
private _localStorageDisabled;
/**
* Creates a new JitsiLocalStorage instance.
*/
constructor();
/**
* Returns true if window.localStorage is disabled and false otherwise.
*
* @returns {boolean} True if window.localStorage is disabled and false otherwise.
*/
isLocalStorageDisabled(): boolean;
/**
* Switch between window.localStorage and DummyLocalStorage.
*
* @param {boolean} value - Whether to disable localStorage.
* @returns {void}
*/
setLocalStorageDisabled(value: boolean): void;
/**
* Empties all keys out of the storage.
*
* @returns {void}
*/
clear(): void;
/**
* Returns the number of data items stored in the Storage object.
*
* @returns {number} The number of data items stored in the Storage object.
*/
get length(): number;
/**
* Returns that passed key's value.
*
* @param {string} keyName - The name of the key you want to retrieve the value of.
* @returns {string | null} The value of the key. If the key does not exist, null is returned.
*/
getItem(keyName: string): string | null;
/**
* Adds a key to the storage, or update key's value if it already exists.
*
* @param {string} keyName - The name of the key you want to create/update.
* @param {string} keyValue - The value you want to give the key you are creating/updating.
* @param {boolean} [dontEmitChangedEvent=false] - If true a changed event won't be emitted.
* @returns {void}
*/
setItem(keyName: string, keyValue: string, dontEmitChangedEvent?: boolean): void;
/**
* Remove a key from the storage.
*
* @param {string} keyName - The name of the key you want to remove.
* @returns {void}
*/
removeItem(keyName: string): void;
/**
* Returns the name of the nth key in the list, or null if n is greater
* than or equal to the number of key/value pairs in the object.
*
* @param {number} i - The index of the key in the list.
* @returns {string | null} The name of the nth key, or null if out of bounds.
*/
key(i: number): string | null;
/**
* Serializes the content of the storage.
*
* @param {string[]} [ignore=[]] - Array with keys from the local storage to be ignored.
* @returns {string} The serialized content.
*/
serialize(ignore?: string[]): string;
}
export declare const jitsiLocalStorage: JitsiLocalStorage;