local-preferences
v2.1.2
Published
localStorage with type casting and fallbacks.
Downloads
2
Readme
Methods
localPreferences.set(key, value)
Sets value in localStorage. set key to null
to clear the entry.
import {set} from "local-preferences"
set("isLoggedIn", true)
set("userId", 123)
set("email", "[email protected]")
set("object", {
foo: {
bar: "baz"
}
})
localPreferences.get(key, [fallback])
Retrieves value from localStorage.
import {get} from "local-preferences"
get("isLoggedIn") // => true
get("userId") // => 123
get("email") // => "[email protected]"
get("object") // => {foo: {bar: "baz"}}
get("unset", "foo") // => "foo"
localPreferences.clear()
Passthrough to the native localStorage.clear()