Skip to main content

Class: Storage<V>

@ima/core.Storage

The Storage is an unordered collection of named values of any type. Values in the storage are named using string keys. The storage can be therefore thought of as a Map<string, *>.....

Type parameters

Name
V

Hierarchy

Constructors

constructor

new Storage<V>()

Type parameters

Name
V

Methods

clear

clear(): Storage<V>

Clears the storage of all entries.

Returns

Storage<V>

This storage.

Defined in

packages/core/src/storage/Storage.ts:73


delete

delete(key): Storage<V>

Deletes the entry identified by the specified key from this storage.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

Storage<V>

This storage.

Defined in

packages/core/src/storage/Storage.ts:64


get

get(key): undefined | V

Retrieves the value of the entry identified by the specified . The method returns undefined if the entry does not exists.

Entries set to the undefined value can be tested for existence using the link has method.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

undefined | V

The value of the storage entry.

Defined in

packages/core/src/storage/Storage.ts:42


has

has(key): boolean

Returns true if the entry identified by the specified key exists in this storage.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.

Returns

boolean

true if the storage entry exists.

Defined in

packages/core/src/storage/Storage.ts:28


init

init(): Storage<V>

This method is used to finalize the initialization of the storage after the dependencies provided through the constructor have been prepared for use.

This method must be invoked only once and it must be the first method invoked on this instance.

Returns

Storage<V>

This storage.

Defined in

packages/core/src/storage/Storage.ts:17


keys

keys(): Iterable<string>

Returns an iterator for traversing the keys in this storage. The order in which the keys are traversed is undefined.

Returns

Iterable<string>

An iterator for traversing the keys in this storage. The iterator also implements the iterable protocol, returning itself as its own iterator, allowing it to be used in a for..of loop.

Defined in

packages/core/src/storage/Storage.ts:86


set

set(key, value): Storage<V>

Sets the storage entry identified by the specified key to the provided value. The method creates the entry if it does not exist already.

Parameters

NameTypeDescription
keystringThe key identifying the storage entry.
valueVThe storage entry value.

Returns

Storage<V>

This storage.

Defined in

packages/core/src/storage/Storage.ts:54


size

size(): number

Returns the number of entries in this storage.

Returns

number

The number of entries in this storage.

Defined in

packages/core/src/storage/Storage.ts:95