ngx-webstorage-service
Version:
Angular service wrappers for the webstorage API
47 lines (46 loc) • 2.14 kB
TypeScript
import { BaseStorageService } from './base-storage.service';
/**
* A volatile `StorageService` implementation. This service guarantees that data stored will remain available as long as the application
* instance is active. After the application is terminated all data will be lost.
*/
export declare class InMemoryStorageService extends BaseStorageService<any> {
/** A map that serves as the underlying backing storage for this service. */
private readonly storage;
/**
* Creates a new `InMemoryStorageService` instance.
*/
constructor();
/**
* Checks whether an entry with the specified key exists in the storage.
*
* @param key Identifier of the entry for which its presence in the storage is to be checked.
* @returns `true` if an entry with the specified key exists in the storage, `false` if not.
*/
has(key: string): boolean;
/**
* Removes the entry that is identified by the specified key. Attempting to remove an entry for an unknown key will have no effect.
* Attempting to retrieve an entry via the `get` method after it has been removed will result in `undefined`.
*
* @param key Identifier of the entry which is to be removed.
*/
remove(key: string): void;
/**
* Clears the storage by removing all entries. Subsequent `get(x)` calls for a key *x* will return `undefined`, until a new value is set
* for key *x*.
*/
clear(): void;
/**
* Performs the actual retrieval of a value from storage.
*
* @param key Identifier of the entry whose value is to be retrieved.
* @returns The value that is stored for the specified entry or `undefined` if no entry exists for the specified key.
*/
protected getItem(key: string): string | undefined;
/**
* Stores the provided value using specified key in the storage.
*
* @param key Identifier of the entry for which the value is to be stored.
* @param value The value that is to be stored.
*/
protected setItem(key: string, value: string): void;
}