Skip to main content

WebStorage <T>

Hierarchy

Index

Constructors

Accessors

Methods

Constructors

constructor

  • Type parameters

    • T

    Parameters

    • key: string
    • initialValue: T
    • storage: Storage
    • optionaloptions: StorageOptions<T>

    Returns WebStorage<T>

Accessors

initialValue

  • get initialValue(): T
  • Get initial value of storage


    Returns T

value

  • get value(): T
  • Read value from storage or return initial value if value does not exist in storage


    Returns T

Methods

has

  • has(): boolean
  • Check if the value exists in storage


    Returns boolean

    true if the value exists in storage

reset

  • reset(): void
  • Reset storage to initial value


    Returns void

write

  • write(value: T): T
  • write(value: (prevValue: T) => T): T
  • Write value to storage and return the value written


    Parameters

    • value: T

      Value to write to storage

    Returns T