import { KVStorage as KVStorageInterface, VALUE } from './interface'; declare type DriverNames = 'sqlite' | 'indexeddb' | 'leveldatastore' | 'websql' | 'localstorage'; declare type PickRequired = { [P in K]-?: T[P]; }; export interface KVStorageConfig { /** * The name of the database. * May appear during storage limit prompts. * Useful to use the name of your app here. * In localStorage, this is used as a key prefix for all keys stored in localStorage and level-datastore. * Must be alphanumeric, with underscores. */ name?: string; version?: number; /** * The size of the database in bytes. * Used only in WebSQL for now. */ size?: number; /** * The name of the datastore. * In IndexedDB this is the dataStore, * in WebSQL this is the name of the key/value table in the database, * Must be alphanumeric, with underscores. Any non-alphanumeric characters will be converted to underscores. */ storeName?: string; description?: string; driverOrder?: DriverNames[]; /** * similar to `name`. * Used only in CordovaSQLiteDriver. */ dbKey?: string; /** * Used only in localforage-driver-datastore-level */ path?: string; } export declare const getDefaultConfig: () => PickRequired; /** * Preference (key-value) Storage, * work in both Browser, Node.js, and Cordova/Ionic * * Modified from https://github.com/ionic-team/ionic-storage/blob/master/src/storage.ts */ export declare class KVStorage implements KVStorageInterface { private _db; private _driver; readonly backend = "localforage"; constructor(config?: KVStorageConfig); ready(): Promise; close(): Promise; /** * Get the name of the driver being used. */ get driver(): string | null; private _getDrivers; has(key: string): Promise; /** * Get the value associated with the given key. * @param key the key to identify this value * @returns Returns a promise with the value of the given key */ get(key: string): Promise; /** * Set the value for the given key. * @param key the key to identify this value * @param value the value for this key * @returns Returns a promise that resolves when the key and value are set */ set(key: string, value: T): Promise; /** * Remove any value associated with this key. * @param key the key to identify this value * @returns Returns a promise that resolves when the value is removed */ remove(key: string): Promise; /** * Clear the entire key value store. WARNING: HOT! * @returns Returns a promise that resolves when the store is cleared */ clear(): Promise; /** * @returns Returns a promise that resolves with the number of keys stored. */ length(): Promise; /** * @returns Returns a promise that resolves with the keys in the store. */ keys(): Promise; /** * Iterate through each key,value pair. * @param iteratorCallback a callback of the form (value, key, iterationNumber) * @returns Returns a promise that resolves when the iteration has finished. */ forEach(iteratorCallback: (value: any, key: string, iterationNumber: Number) => any): Promise; } export default KVStorage;