Skip to main content

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

Implementation of

Storage.length

Defined in

packages/core/src/storage.ts:56

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:63


getItem

getItem(key): null | string

Returns the current value associated with the given key, or null if the given key does not exist.

Parameters

NameType
keystring

Returns

null | string

Implementation of

Storage.getItem

Defined in

packages/core/src/storage.ts:70


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

NameType
keystring
valuenull | string

Returns

void

Implementation of

Storage.setItem

Defined in

packages/core/src/storage.ts:77


removeItem

removeItem(key): void

Removes the key/value pair with the given key, if a key/value pair with the given key exists.

Parameters

NameType
keystring

Returns

void

Implementation of

Storage.removeItem

Defined in

packages/core/src/storage.ts:88


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

NameType
indexnumber

Returns

null | string

Implementation of

Storage.key

Defined in

packages/core/src/storage.ts:95