angular2-locker
Wrapper around sessionStorage and localStorage for angular2. If both are unavailable will use an in memory storage.
Getting Started
$ npm i --save angular2-locker
With Custom Config
Methods
get
locker.get('myKey')
set
locker.set'myKey', 'value'locker.set'myKey',
key
locker.set'key', 'value' locker.key0 // 'key'
has
locker.has('key')
setNamespace
locker.setNamespace('myName')
locker.setNamespace()
- Resets to lockerConfig default
setSeparator
locker.setSeparator('-')
locker.setSeparator()
- Resets to lockerConfig default
useDriver
// for more info on drivers look for static methods driver.set'keey', 'value'
remove
locker.remove('key')
clear
locker.clear()
Static Methods
DRIVERS
These are the types of drivers available. If you try to set it to a driver that is unsupported it will fallback to the memory driver
Types are available under Locker.DRIVERS
or import {DRIVERS} from 'angular2-locker'
DRIVERS.SESSION
- Session CacheDRIVERS.LOCAL
- Local StorageDRIVERS.MEMORY
- Memory StorageDRIVERS.COOKIE
- Cookies