ls-map-wrap
A wrapper around localstorage, so it can be used as a Map
Getting Started
Install it via npm:
npm install ls-map-wrap
And include in your project:
// Using ESM;// Or using CJSconst lsMapWrap = ;
Usage
; lsMapWrap;lsMapWrap; // {ultimateAnswer: 42}lsMapWrap; // true // works with values not typically handled by JSON.stringify/parselsMapWrap;Number; // true // works with functions toolsMapWrap;const fn = lsMapWrap;; // hello is logged to the console lsMapWrap;lsMapWrap; // false lsMapWrapclear;lsMapWrap; // false
API
Implements all of the functions nessecary to drop it in place for an in-memory map
get(key)
Returns the value for the given key
key
Type: string
set(key, value)
Saves the value in localstorage for the given key
key
Type: string
value
Type: any
has(key)
Returns true if the map (localStorage) contains this value, false otherwise
key
Type: string
delete(key)
Removes the value from the map with the given key
key
Type: string
clear()
Removes all values from the map (localStorage)