https://github.com/talljack/storage
Typescript support a storage lib which sessionStorage and localStorage with the same api and extend api
https://github.com/talljack/storage
storage typescript
Last synced: about 1 month ago
JSON representation
Typescript support a storage lib which sessionStorage and localStorage with the same api and extend api
- Host: GitHub
- URL: https://github.com/talljack/storage
- Owner: Talljack
- License: mit
- Created: 2021-06-08T23:20:00.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-11T15:20:18.000Z (almost 5 years ago)
- Last Synced: 2024-05-01T19:59:45.850Z (about 2 years ago)
- Topics: storage, typescript
- Language: JavaScript
- Homepage:
- Size: 104 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# storage
Typescript support a storage lib which sessionStorage and localStorage with the same api and extend api
## 🦄 Usage
```javascript
import storage from '@caoyugang/better-storage'
storage.setItem('sessionStorage', key, value)
storage.getItem('localStorage', key)
in vue3
setup () {
const key = 'store'
const onStore = () => {
storage.setItem('sessionStorage', key, '123')
}
const onRemove = () => {
storage.removeItem('localStorage', key)
}
return {
onStore,
onRemove
}
}
```
## 📦 Install
```bash
npm i @caoyugang/better-storage
or
yarn add @caoyugang/better-storage
```
## 🎁 api
```typescript
type = 'sessionStorage' | 'localStorage'
getItem(type, key)
get storage with key, return value or undefined
setItem(type, key, value)
set storage with key and val
hasItem(type, key)
determine storage has the key
removeItem(type, key)
remove storage with key
clear(type)
clear all storages
getStorageLength(type)
get storage length
getStorageKey(type, index)
get storage key by index
getStorageKeyValue(type)
get all the storages about key and value
```
## 📄 License
[MIT License](https://github.com/Talljack/storage/blob/main/LICENSE) © 2021-PRESENT [caoyugang_1](https://github.com/Talljack)