File

src/CookieStorage.ts

Implements

ICustomStorage

Index

Methods
Accessors

Methods

Public clear
clear()
Returns : void
Public getItem
getItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : any
Public hasItem
hasItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : boolean
Public key
key(index: number)
Parameters :
Name Type Optional Description
index number
Returns : any
Public removeItem
removeItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : void
Public setItem
setItem(key: string, value: any, config: IStorageSetConfig)
Parameters :
Name Type Optional Description
key string
value any
config IStorageSetConfig
Returns : void

Accessors

length
getlength()
import {ICustomStorage, IStorageSetConfig} from './metadata'
import {Cookie} from './Cookie'

export class CookieStorage implements ICustomStorage {
  public hasItem(key: string) {
    return <boolean>!!Cookie.get(key)
  }

  public getItem(key: string) {
    return Cookie.get(key)
  }

  public setItem(key: string, value: any, config: IStorageSetConfig) {
    Cookie.set(key, value, config)
  }

  public removeItem(key: string) {
    Cookie.remove(key)
  }

  public clear() {
    Object.keys(Cookie.getAll())
      .forEach((key) => Cookie.remove(key))
  }

  public key(index: number) {
    const cookies = Object.keys(Cookie.getAll())

    return cookies[index]
  }

  public get length() {
    return Object.keys(Cookie.getAll()).length
  }
}

results matching ""

    No results matching ""