@justinmusti/storage
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

@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.

Package Sidebar

Install

npm i @justinmusti/storage

Weekly Downloads

7

Version

0.0.9

License

MIT

Unpacked Size

14.5 kB

Total Files

18

Last publish

Collaborators

  • justinmusti