Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalStorage

localStorage class factory Usage : var LocalStorage = fidj.LocalStorageFactory(window.localStorage); // to create a new class Usage : var localStorageService = new LocalStorage(); // to create a new instance

Hierarchy

  • LocalStorage

Index

Constructors

Properties

Methods

Constructors

constructor

  • new LocalStorage(storageService: any, storageKey: any): LocalStorage

Properties

Private storage

storage: any

version

version: string = '0.1'

Methods

Private checkKey

  • checkKey(key: any): boolean

clear

  • clear(): boolean

foreach

  • foreach(f: any, context: any): any
  • Call function f on the specified context for each element of the storage from index 0 to index length-1. WARNING : You should not modify the storage during the loop !!!

    Parameters

    • f: any

      Function to call on every item.

    • context: any

      Context (this for example).

    Returns any

    Number of items in storage

get

  • get(key: string, def?: any): any
  • Looks up a key in cache

    Parameters

    • key: string

      Key to look up.

    • Optional def: any

      Default value to return, if key didn't exist.

    Returns any

    the key value, default value or

remove

  • remove(key: string): boolean
  • Deletes a key from cache.

    Parameters

    • key: string

      Key to delete.

    Returns boolean

    true if key existed or false if it didn't

set

  • set(key: string, value: any): any
  • Sets a key's value.

    Parameters

    • key: string

      Key to set. If this value is not set or not a string an exception is raised.

    • value: any

      Value to set. This can be any value that is JSON compatible (Numbers, Strings, Objects etc.).

    Returns any

    the stored value which is a container of user value.

size

  • size(): any

Generated using TypeDoc