Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedrouid/keyvaluestorage-interface
Isomorphic Key-Value Storage Interface
https://github.com/pedrouid/keyvaluestorage-interface
Last synced: 7 days ago
JSON representation
Isomorphic Key-Value Storage Interface
- Host: GitHub
- URL: https://github.com/pedrouid/keyvaluestorage-interface
- Owner: pedrouid
- License: mit
- Created: 2021-02-02T19:06:45.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-02T19:07:03.000Z (almost 4 years ago)
- Last Synced: 2024-11-29T13:19:11.189Z (30 days ago)
- Language: TypeScript
- Size: 126 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# keyvaluestorage-interface [![npm version](https://badge.fury.io/js/keyvaluestorage-interface.svg)](https://badge.fury.io/js/keyvaluestorage-interface)
Isomorphic Key-Value Storage Interface
## Example
```typescript
import KeyValueStorage from "keyvaluestorage-interface";const options = {
// required for React-Native platform
// package from @react-native-async-storage/async-storage
asyncStorage: AsyncStorage
// required for NodeJS platform
// sqlite database connection (in-memory supported)
database: 'foobar.db'
// optional for NodeJS platform
// sqlite table name (default: 'keyvaluestorage-interface')
tableName: 'keyvaluestorage-interface'
}const storage = new KeyValueStorage(options)
// setItem
await storage.setItem('user1', { name: 'John Doe', age: 21 })// getItem
const item = await storage.getItem('user1')// removeItem
await storage.removeItem('user1')
```## API
```typescript
export class IKeyValueStorage {
public getKeys(): Promise;
public getEntries(): Promise<[string, T][]>;
public getItem(key: string): Promise;
public setItem(key: string, value: T): Promise;
public removeItem(key: string): Promise;
}
```