Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onlymisaky/geedstorage
https://github.com/onlymisaky/geedstorage
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/onlymisaky/geedstorage
- Owner: onlymisaky
- Created: 2020-05-30T11:04:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-23T10:49:13.000Z (almost 4 years ago)
- Last Synced: 2024-11-04T00:32:40.267Z (12 days ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GeedStorage
支持 `json` 的本地存储。
## Features
- 支持存储和读取 `string`、`numer`、`object`、`boolean`、`undefined`
- 支持设置存储key的前辍
- 支持设置过期时间
- 友好的类型提示## API
```typescript
const storage = new GeedStorage({
type: 'local', // local | session
prefix: 'Geed_', // 默人为 Geed_
});/** set */
storage.set('name', 'qq');
storage.set('age', 18);
storage.set('busy', true);
storage.set('user', { name: 'qq', age: 18 }, { expires: 1000 * 60 }); // 1分钟后再次读取将会自动清空并返回 null/** get */
storage.get('age'); // 'qq' string
storage.get('name'); // 18 numer
storage.get('busy'); // true boolean
storage.get<{ name: string; age: number; }>('user'); // { name: 'qq', age: 18 }/** remove */
storage.remove('busy'); // remove busy
storage.clearAll(); // clear all keys
```