declare module 'levelup' { import { EventEmitter } from 'events'; import * as levelerrors from 'level-errors'; import { AbstractLevelDOWN, AbstractIteratorOptions, AbstractBatch, ErrorCallback, AbstractPutOptions, ErrorValueCallback, AbstractGetOptions, AbstractDelOptions } from 'abstract-leveldown'; type LevelUpPut = ((key: K, value: V, callback: ErrorCallback) => void) & ((key: K, value: V, options: O, callback: ErrorCallback) => void) & ((key: K, value: V, options?: O) => Promise); type LevelUpGet = ((key: K, callback: ErrorValueCallback) => void) & ((key: K, options: O, callback: ErrorValueCallback) => void) & ((key: K, options?: O) => Promise); type LevelUpDel = ((key: K, callback: ErrorCallback) => void) & ((key: K, options: O, callback: ErrorCallback) => void) & ((key: K, options?: O) => Promise); type LevelUpBatch = ((key: K, callback: ErrorCallback) => void) & ((key: K, options: O, callback: ErrorCallback) => void) & ((key: K, options?: O) => Promise); type InferDBPut = DB extends { put: (key: infer K, value: infer V, options: infer O, cb: any) => void } ? LevelUpPut : LevelUpPut; type InferDBGet = DB extends { get: (key: infer K, options: infer O, callback: ErrorValueCallback) => void } ? LevelUpGet : LevelUpGet; type InferDBDel = DB extends { del: (key: infer K, options: infer O, callback: ErrorCallback) => void } ? LevelUpDel : LevelUpDel; export interface LevelUp extends EventEmitter { open(): Promise; open(callback?: ErrorCallback): void; close(): Promise; close(callback?: ErrorCallback): void; put: InferDBPut; get: InferDBGet; del: InferDBDel; batch(array: AbstractBatch[], options?: any): Promise; batch(array: AbstractBatch[], options: any, callback: (err?: any) => any): void; batch(array: AbstractBatch[], callback: (err?: any) => any): void; batch(): LevelUpChain; isOpen(): boolean; isClosed(): boolean; createReadStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream; createKeyStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream; createValueStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream; /**emitted when a new value is 'put' */ on(event: 'put', cb: (key: any, value: any) => void): this /**emitted when a value is deleted*/ on(event: 'del', cb: (key: any) => void): this /**emitted when a batch operation has executed */ on(event: 'batch', cb: (ary: any[]) => void): this /**emitted when the database has opened ('open' is synonym) */ on(event: 'ready', cb: () => void): this /**emitted when the database has opened */ on(event: 'open', cb: () => void): this /** emitted when the database has closed*/ on(event: 'closed', cb: () => void): this /** emitted when the database is opening */ on(event: 'opening', cb: () => void): this /** emitted when the database is closing */ on(event: 'closing', cb: () => void): this } interface LevelUpConstructor { ( db: DB, options: any, cb?: ErrorCallback): LevelUp; ( db: DB, cb?: ErrorCallback): LevelUp; new ( db: DB, options: any, cb?: ErrorCallback): LevelUp; new ( db: DB, cb?: ErrorCallback): LevelUp; errors: typeof levelerrors; } export interface LevelUpChain { readonly length: number; put(key: K, value: V): this; del(key: K): this; clear(): this; write(callback: ErrorCallback): this; write(): Promise; } export var errors: typeof levelerrors; const LevelUp: LevelUpConstructor; export default LevelUp; }