JSPM

  • Created
  • Published
  • Downloads 880596
  • Score
    100M100P100Q192513F
  • License MIT

Isomorphic Key-Value Storage

Package Exports

  • @walletconnect/keyvaluestorage
  • @walletconnect/keyvaluestorage/dist/index.cjs.js
  • @walletconnect/keyvaluestorage/dist/index.es.js
  • @walletconnect/keyvaluestorage/dist/react-native/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@walletconnect/keyvaluestorage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

keyvaluestorage npm version

Isomorphic Key-Value Storage

Example

import KeyValueStorage from "keyvaluestorage";

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')
  tableName: 'keyvaluestorage'
}

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

export class IKeyValueStorage {
  public getKeys(): Promise<string[]>;
  public getEntries<T = any>(): Promise<[string, T][]>;
  public getItem<T = any>(key: string): Promise<T | undefined>;
  public setItem<T = any>(key: string, value: T): Promise<void>;
  public removeItem(key: string): Promise<void>;
}