@justinmusti/storage
v0.0.9
Published
JustinMusti Node and Browser unified storage.
Downloads
57
Maintainers
Readme
@justinmusti/storage
This is a platform-agnostic storage utility class.
Supported environments: * Node * Browser
How to Use
import
import {Storage} from "@justinmusti/storage"
Init
// Browser
const storage = new Storage()
// Node
const storage = new Storage({path: "path-to-file-to-write-to"})
Create entry in storage
storage.set("test", "hello")
// Browser: localStorage now has `test` entry with value 'hello'
// Node: file at provided path now has `test` entry with value 'hello'
Check if storage has key
storage.has('uploadURL') // returns true or false
Delete key from storage.
storage.removeitem('test')
storage.has('test') // Now this returns false.
Remove all/Clear
storage.clear()
// All entries are removed.