Options
All
  • Public
  • Public/Protected
  • All
Menu

Module LocalStorage

JMap.Util.LocalStorage

Some browser doesn't support local storage, you can use this service in order to avoid error

Index

Functions

get

  • get(key: string): string | null
  • JMap.Util.LocalStorage.get

    Returns the value, or null if not exists, for the given key.

    Returns null if localStorage is not available.

    example
    
    // returns the value if exists for the given key
    JMap.Util.LocalStorage.get("my-key")

    Parameters

    • key: string

      the item key

    Returns string | null

isAvailable

  • isAvailable(): boolean
  • JMap.Util.LocalStorage.isAvailable

    Returns true if browser support local storage.

    example
    
    // returns true if browser support local storage
    JMap.Util.LocalStorage.isAvailable()

    Returns boolean

remove

  • remove(key: string): void
  • JMap.Util.LocalStorage.remove

    Removes the key/value item for the given key.

    Do nothing if local storage is not available.

    example
    
    // removes the key/value item "my-key" if exist
    JMap.Util.LocalStorage.remove("my-key")

    Parameters

    • key: string

      the item key

    Returns void

set

  • set(key: string, value: string): void
  • JMap.Util.LocalStorage.set

    Set the key in local storage.

    Set nothing and do nothing if local storage is not available.

    example
    
    // set the value "my value" for the key "my-key"
    JMap.Util.LocalStorage.set("my-key", "my value")

    Parameters

    • key: string

      the item key

    • value: string

      the new item value

    Returns void