Cargo for your various luggage
Fetching, setting and deleting data in localStorage with an expressive syntax.
Local storage
By default, localStorage
will be used when creating a new instance:
Session storage
To use sessionStorage
, which exists only within the pages session, just pass sessionStorage
as a second argument when creating a new instance:
set()
The set
method takes two parameters. The first parameter can be a string representing a specific key or a dot seperated list of keys. The second parameter is the value that is stored:
get()
The get
method takes a single parameter. The value can be a string representing a specific key or a dot seperated list of keys. If no match is found, undefined
is returned.
delete()
The delete
method takes a single parameter. The value can be a string representing a specific key or a dot seperated list of keys:
destroy()
The destroy
method destroys all data stored at the specified key, essentially erasing everything under the instance: