Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nixjs/web-storage
A minimalistic Typescript plugin for web storage
https://github.com/nixjs/web-storage
javascript localstorage nixjs react-local-storage react-session session sessionstorage storage typescript web-storage
Last synced: 22 days ago
JSON representation
A minimalistic Typescript plugin for web storage
- Host: GitHub
- URL: https://github.com/nixjs/web-storage
- Owner: nixjs
- Created: 2022-10-17T04:10:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-12T08:48:57.000Z (about 1 month ago)
- Last Synced: 2025-01-12T08:50:13.507Z (about 1 month ago)
- Topics: javascript, localstorage, nixjs, react-local-storage, react-session, session, sessionstorage, storage, typescript, web-storage
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @nixjs23n6/web-storage
A minimalistic Typescript plugin for web storage
## Install
`yarn add @nixjs23n6/web-storage`
## Usage
### New instance
```typescript
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("ACCESS_TOKEN_KEY")
```### Extend
```typescript
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
```typescript
import { LocalStorageStatic } from '@nixjs23n6/web-storage'LocalStorageStatic.setItem("ACCESS_TOKEN_KEY", "ACCESS_TOKEN")
LocalStorageStatic.getItem("ACCESS_TOKEN_KEY")
```