Skip to main content

LocalStorage <T>

Hierarchy

Index

Constructors

Accessors

Methods

Constructors

constructor

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