UNPKG

@pokt-network/pocket-js

Version:

Pocket-js core package with the main functionalities to interact with the Pocket Network.

49 lines (48 loc) 1.9 kB
import { IKVStore } from "./kv-store"; /** * * * @class InMemoryKVStore * @description Save data using a Key/Value relationship. This object save information in memory, that means if the application is closed, * the saved information will be deleted */ export declare class InMemoryKVStore implements IKVStore { private readonly localStorage; /** * @description Associates the specified value with the specified key and save this association in memory. * @param {string} key - key with which the specified value is to be associated * @param {any} value - value to be associated with the specified key * @memberof InMemoryKVStore */ add(key: string, value: any): void; /** * @description Returns the value to which the specified key is mapped. * @param {string} key - the key whose associated value is to be returned * @returns {any | undefined} - Key or undefined. * @memberof InMemoryKVStore */ get(key: string): any | undefined; /** * @description Returns a list with all the saved value * @returns {any[]} - An array of items. */ getItems(): any[]; /** * @description Verifies if the object has an association identified with a key. * @param {string} key - key whose mapping is to be checked from the memory * @returns {boolean} - True or false if the key exists in the local storage. * @memberof InMemoryKVStore */ has(key: string): boolean; /** * @description Removes the mapping for a key from this object if it is present. * @param {string} key - key whose mapping is to be removed from the memory * @returns {boolean} - True or false if the item was removed or not. * @memberof InMemoryKVStore */ remove(key: string): boolean; /** * @description Removes all of the mappings from this object. */ clear(): void; }