@vyrekxd/localstorage-plus
v1.0.3
Published
A helpfull module to improve localStorage methods, originally maked for MyPresences.
Downloads
6
Maintainers
Readme
LocalStorage+
A module that upgrades the base localStorage of webs, originally maked for MyPresences.
class LocalStoragePlus
- new LocalStoragePlus()
- LocalStoragePlus#get()
- LocalStoragePlus#set()
- LocalStoragePlus#delete()
- LocalStoragePlus#key()
- LocalStoragePlus#deleteAll()
- Properties
new LocalStoragePlus(storage: Storage)
To instance the class you need to put your localStorage.
window.localStorage.plus = new LocalStoragePlus(window.localStorage)
get(key: string) -> object
Gets an object in localStorage with the key.
window.localStorage.plus.set('my-key', 'my-object')
const res = window.localStorage.plus.get('my-key')
/*
my-object
*/
set(key: string, value: T) -> T
Set an object in the localStorage.
window.localStorage.plus.set('my-key', 'my-object')
delete(key: string) -> void
Deletes a key on localStorage.
window.localStorage.plus.delete('my-key', 'my-object')
key(index: number) -> string
Get a key in localStorage using his index.
const res = window.localStorage.plus.key(0)
/*
my-key
*/
deleteAll() -> void
Delete all keys in localStorage.
window.localStorage.plus.deleteAll()
Properties
- length -> Shows the quantity of elements in localStorage.