storage.ts

Declarations
#

2 declarations

view source

load_from_storage
#

storage.ts view source

<T>(key: string, to_default_value: () => T, validate?: ((value: any) => asserts value is T) | undefined): T

Loads key and falls back to defaultValue. If validate is provided and throws, it removes the key and returns undefined.

key

type string

to_default_value

type () => T

validate?

type ((value: any) => asserts value is T) | undefined
optional

returns

T

set_in_storage
#

storage.ts view source

(key: string, value: any): void

Sets value at key. Importantly, if value is undefined the key is removed, but a value of null is stored.

key

type string

value

type any

returns

void

Imported by
#