Class: MemoryStorage
The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
Implements
Storage
Constructors
constructor
• new MemoryStorage()
Defined in
packages/core/src/storage.ts:49
Accessors
length
• get
length(): number
Returns the number of key/value pairs.
Returns
number
The number of key/value pairs.
Implementation of
Storage.length
Defined in
packages/core/src/storage.ts:57
Methods
clear
▸ clear(): void
Removes all key/value pairs, if there are any.
Returns
void
Implementation of
Storage.clear
Defined in
packages/core/src/storage.ts:64
getItem
▸ getItem(key
): null
| string
Returns the current value associated with the given key, or null if the given key does not exist.
Parameters
Name | Type | Description |
---|---|---|
key | string | The specified storage key. |
Returns
null
| string
The current value associated with the given key, or null if the given key does not exist.
Implementation of
Storage.getItem
Defined in
packages/core/src/storage.ts:73
setItem
▸ setItem(key
, value
): void
Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
Parameters
Name | Type | Description |
---|---|---|
key | string | The storage key. |
value | null | string | The new value. |
Returns
void
Implementation of
Storage.setItem
Defined in
packages/core/src/storage.ts:82
removeItem
▸ removeItem(key
): void
Removes the key/value pair with the given key, if a key/value pair with the given key exists.
Parameters
Name | Type | Description |
---|---|---|
key | string | The storage key. |
Returns
void
Implementation of
Storage.removeItem
Defined in
packages/core/src/storage.ts:94
key
▸ key(index
): null
| string
Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
Parameters
Name | Type | Description |
---|---|---|
index | number | The numeric index. |
Returns
null
| string
The nth key.
Implementation of
Storage.key
Defined in
packages/core/src/storage.ts:103