browser-session-tabs-tracker
Version:
A light-weight library for tracking multiple browser tabs in a web session.
25 lines (24 loc) • 1.02 kB
TypeScript
export declare class StorageService {
/**
* Sets a given value identified by a given key, in session storage.
* The value will be stored as a JSON string.
*/
sessionStorageSet(key: string, value: any): void;
/**
* Get a value from session storage, by a given key.
* @returns The unserialised object if found, otherwise the provided default value.
* If no default value is provided, it returns `null`.
*/
sessionStorageGet<T>(key: string, defaultValue?: T): T | null;
/**
* Sets a given value identified by a given key, as a session cookie.
* The value will be stored as a JSON string.
*/
sessionCookieSet(key: string, value: any): void;
/**
* Get a value from session cookies, by a given key.
* @returns The unserialised object if found, otherwise the provided default value.
* If no default value is provided, it returns `null`.
*/
sessionCookieGet<T>(key: string, defaultValue?: T): T | null;
}