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

0.0.2 • Public • Published

@nixjs23n6/web-storage

A minimalistic Typescript plugin for web storage

Install

yarn add @nixjs23n6/web-storage

Usage

New instance

import { LocalStorage, SessionStorage, WebStorage } from '@nixjs23n6/web-storage'

const localStorage = new LocalStorage();
// const sessionStorage = new SessionStorage();

localStorage.setItem("ACCESS_TOKEN_KEY", "ACCESS_TOKEN")
localStorage.getItem<string>("ACCESS_TOKEN_KEY")

Extend

import { LocalStorage } from '@nixjs23n6/web-storage'

class LocalStore extends LocalStorage {

  authorize (token: string): this {
    return this.setItem('ACCESS_TOKEN', token);
  }

  deAuthorize (): this {
    return this.removeItem('ACCESS_TOKEN');
  }

}

const store =  new LocalStore();

Static class

import { LocalStorageStatic } from '@nixjs23n6/web-storage'

LocalStorageStatic.setItem("ACCESS_TOKEN_KEY", "ACCESS_TOKEN")
LocalStorageStatic.getItem<string>("ACCESS_TOKEN_KEY")

Package Sidebar

Install

npm i @nixjs23n6/web-storage

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

12.5 kB

Total Files

9

Last publish

Collaborators

  • nixjs23n6