StateContainer

@perion/core. StateContainer

A key:value state asynchronous, serializable state container. Can store primitives and objects including BigInt.

Constructor

new StateContainer(initialState)

Source:

Initializes the initial state by copying the provided object

Parameters:
Name Type Description
initialState Object

Methods

(static) from(serializedState) → {StateContainer}

Source:

Static constructor from serialized state

Parameters:
Name Type Description
serializedState Buffer
Returns:
Type
StateContainer

delete(key) → {*}

Source:

Deletes a key, value pair

Parameters:
Name Type Description
key *
Returns:

Returns the value

Type
*

get(key) → {*}

Source:

Fetches a value from a key

Parameters:
Name Type Description
key *
Returns:

Returns the removed object

Type
*

pack() → {Buffer}

Source:

Serializes a StateContainer into a Buffer

Returns:
Type
Buffer

set(key, value) → {*}

Source:

Sets a key, value pair

Parameters:
Name Type Description
key *
value *
Returns:

Returns the value

Type
*