import { AsyncMapLike } from 'async-map-like'; export interface IteratorOptions { gt?: any; gte?: any; lt?: any; lte?: any; reverse?: boolean; limit?: number; prefix?: any; } export declare class FlashStore implements AsyncMapLike { workdir: string; static VERSION: string; private levelDb; /** * FlashStore is a Key-Value database tool and makes using leveldb more easy for Node.js * * Creates an instance of FlashStore. * @param {string} [workdir=path.join(appRoot, 'flash-store.workdir')] * @example * import { FlashStore } from 'flash-store' * const flashStore = new FlashStore('flashstore.workdir') */ constructor(workdir?: string); version(): string; /** * Put data in database * * @param {K} key * @param {V} value * @returns {Promise} * @example * await flashStore.put(1, 1) */ put(key: K, value: V): Promise; set(key: K, value: V): Promise>; /** * Get value from database by key * * @param {K} key * @returns {(Promise)} * @example * console.log(await flashStore.get(1)) */ get(key: K): Promise; /** * Del data by key * * @param {K} key * @returns {Promise} * @example * await flashStore.del(1) */ del(key: K): Promise; delete(key: K): Promise; /** * @typedef IteratorOptions * * @property { any } gt - Matches values that are greater than a specified value * @property { any } gte - Matches values that are greater than or equal to a specified value. * @property { any } lt - Matches values that are less than a specified value. * @property { any } lte - Matches values that are less than or equal to a specified value. * @property { boolean } reverse - Reverse the result set * @property { number } limit - Limits the number in the result set. * @property { any } prefix - Make the same prefix key get together. */ /** * Find keys by IteratorOptions * * @param {IteratorOptions} [options={}] * @returns {AsyncIterableIterator} * @example * const flashStore = new FlashStore('flashstore.workdir') * for await(const key of flashStore.keys({gte: 1})) { * console.log(key) * } */ keys(options?: IteratorOptions): AsyncIterableIterator; /** * Find all values * * @returns {AsyncIterableIterator} * @example * const flashStore = new FlashStore('flashstore.workdir') * for await(const value of flashStore.values()) { * console.log(value) * } */ values(options?: IteratorOptions): AsyncIterableIterator; /** * Get the counts of the database * @deprecated use property `size` instead * @returns {Promise} * @example * const count = await flashStore.count() * console.log(`database count: ${count}`) */ count(): Promise; get size(): Promise; /** * FIXME: use better way to do this */ has(key: K): Promise; /** * TODO: use better way to do this with leveldb */ clear(): Promise; get [Symbol.toStringTag](): Promise; [Symbol.iterator](): AsyncIterableIterator<[K, V]>; /** * @private */ entries(options?: IteratorOptions): AsyncIterableIterator<[K, V]>; [Symbol.asyncIterator](): AsyncIterableIterator<[K, V]>; /** * @private */ streamAsyncIterator(): AsyncIterator<[K, V]>; forEach(callbackfn: (value: V, key: K, map: any) => void, thisArg?: any): Promise; close(): Promise; /** * Destroy the database * * @returns {Promise} */ destroy(): Promise; } export default FlashStore;