UNPKG

keyv-file

Version:

File storage adapter for Keyv, using msgpack to serialize data fast and small.

22 lines (21 loc) 895 B
import type Keyv from 'keyv'; import type KeyvFile from './index'; export declare class Field<T, D extends T | void = T | void> { protected kv: KeyvFile | Keyv | Map<string, any>; protected key: string; protected defaults: D; constructor(kv: KeyvFile | Keyv | Map<string, any>, key: string, defaults: D); get(): Promise<D>; get(def: D): Promise<D>; getSync(): D; getSync(def: D): D; /** * Note: `await kv.someFiled.set()` will wait <options.writeDelay> millseconds to save to disk, it would be slow. Please remove `await` if you find performance issues. * @param value * @param ttl * @returns */ set(val: T, ttl?: number): Promise<any> | Map<string, any>; delete(): boolean | Promise<boolean>; } export declare function makeField<T = any, D = T>(kv: KeyvFile | Keyv | Map<string, any>, key: string, defaults: T): Field<T, T>;