Class: MapStorage<V>
@ima/core.MapStorage
Implementation of the link Storage
interface that relies on the
native Map
for storage.
Type parameters
Name |
---|
V |
Hierarchy
Storage
<V
>↳
MapStorage
Constructors
constructor
• new MapStorage<V
>()
Type parameters
Name |
---|
V |
Inherited from
Properties
_storage
• Private
_storage: Map
<string
, V
>
The internal storage of entries.
Defined in
packages/core/src/storage/MapStorage.ts:12
Accessors
$dependencies
• Static
get
$dependencies(): Dependencies
Returns
Defined in
packages/core/src/storage/MapStorage.ts:14
Methods
clear
▸ clear(): MapStorage
<V
>
Clears the storage of all entries.
Returns
MapStorage
<V
>
This storage.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:60
delete
▸ delete(key
): MapStorage
<V
>
Deletes the entry identified by the specified key from this storage.
Parameters
Name | Type | Description |
---|---|---|
key | string | The key identifying the storage entry. |
Returns
MapStorage
<V
>
This storage.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:51
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
Name | Type | Description |
---|---|---|
key | string | The key identifying the storage entry. |
Returns
undefined
| V
The value of the storage entry.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:35
has
▸ has(key
): boolean
Returns true
if the entry identified by the specified key exists
in this storage.
Parameters
Name | Type | Description |
---|---|---|
key | string | The key identifying the storage entry. |
Returns
boolean
true
if the storage entry exists.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:28
init
▸ init(): MapStorage
<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
MapStorage
<V
>
This storage.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:21
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.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:69
set
▸ set(key
, value
): MapStorage
<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
Name | Type | Description |
---|---|---|
key | string | The key identifying the storage entry. |
value | V | The storage entry value. |
Returns
MapStorage
<V
>
This storage.
Overrides
Defined in
packages/core/src/storage/MapStorage.ts:42
size
▸ size(): number
Returns the number of entries in this storage.
Returns
number
The number of entries in this storage.