storage.ts

Declarations
#

2 declarations

view source

load_from_storage
#

storage.ts view source

<T>(key: string, is_json?: boolean, parse_fn?: ((value: unknown) => T | null) | undefined): T | null

Utility function to load a value from localStorage with optional parsing

key

The localStorage key

type string

is_json

Whether to parse the value as JSON

type boolean
default false

parse_fn?

Optional custom parsing function to transform the value

type ((value: unknown) => T | null) | undefined
optional

returns

T | null

The parsed value or null if not found or parsing fails

save_to_storage
#

storage.ts view source

(key: string, value: any, is_json?: boolean): void

Utility function to save a value to localStorage.

key

type string

value

type any

is_json

type boolean
default false

returns

void

Imported by
#