diff --git a/leveldown.d.ts b/leveldown.d.ts index 41107cf1..4123737a 100644 --- a/leveldown.d.ts +++ b/leveldown.d.ts @@ -1,79 +1,74 @@ -import * as Abstract from 'abstract-leveldown'; +import { AbstractLevelDOWN, AbstractIteratorOptions, AbstractIterator } from 'abstract-leveldown'; -declare namespace leveldown { - export interface LevelDown - extends Abstract.LevelDOWN< - TKey, - TValue, - LevelDownOptions, - LevelDownPutOptions, - LevelDownGetOptions, - LevelDownDeleteOptions, - LevelDownIteratorOptions, - LevelDownBatchOptions> { - approximateSize(start: TKey, end: TKey, cb: (err?: any) => void): void; - compactRange(start: TKey, end: TKey, cb: (err?: any) => void): void; - getProperty(property: string): string; - iterator(options?: LevelDownIteratorOptions): LevelDownIterator - destroy(location: string, cb: (err?: any) => void): void; - repair(location: string, cb: (err?: any) => void): void; - } +type BaseType = string | Buffer - export interface LevelDownOptions { - createIfMissing?: boolean; - errorIfExists?: boolean; - compression?: boolean; - cacheSize?: number; - writeBufferSize?: number; - blockSize?: number; - maxOpenFiles?: number; - blockRestartInterval?: number; - maxFileSize?: number; - } +export interface LevelDown + extends LevelDownConstructor, AbstractLevelDOWN< + BaseType, BaseType, + LevelDownOptions, + LevelDownPutOptions, + LevelDownGetOptions, + LevelDownDeleteOptions, + LevelDownIteratorOptions, + LevelDownBatchOptions> { - export interface LevelDownPutOptions { - sync?: boolean - } + approximateSize(start: BaseType, end: BaseType, cb: (err: any, size: number) => void): void; + compactRange(start: BaseType, end: BaseType, cb: (err?: any) => void): void; + getProperty(property: string): string; + destroy(location: string, cb: (err?: any) => void): void; + repair(location: string, cb: (err?: any) => void): void; - export interface LevelDownGetOptions { - fillCache?: boolean; - asBuffer?: boolean; - } + iterator(options?: LevelDownIteratorOptions & AbstractIteratorOptions): LevelDownIterator +} + +interface LevelDownConstructor { + new (location: string): LevelDown + (location: string): LevelDown +} - export interface LevelDownDeleteOptions { - sync?: boolean; - } +export interface LevelDownOptions { + createIfMissing?: boolean; + errorIfExists?: boolean; + compression?: boolean; + cacheSize?: number; + writeBufferSize?: number; + blockSize?: number; + maxOpenFiles?: number; + blockRestartInterval?: number; + maxFileSize?: number; +} - export interface LevelDownIteratorOptions { - gt?: K; - gte?: K; - lt?: K; - lte?: K; - reverse?: boolean; - keys?: boolean; - values?: boolean; - limit?: number; - fillCache?: boolean; - keyAsBuffer?: boolean; - valueAsBuffer?: boolean; - } +export interface LevelDownPutOptions { + sync?: boolean +} + +export interface LevelDownGetOptions { + fillCache?: boolean; + asBuffer?: boolean; +} - export interface LevelDownBatchOptions { - sync?: boolean; - } +export interface LevelDownDeleteOptions { + sync?: boolean; +} + +export interface LevelDownIteratorOptions { + fillCache?: boolean; + + keyAsBuffer?: boolean; + valueAsBuffer?: boolean; +} + +export interface LevelDownBatchOptions { + sync?: boolean; +} - export interface LevelDownIterator extends Abstract.Iterator { - seek(key: TKey); - binding: any; - cache: any; - finished: any; - fastFuture: any; - } +export interface LevelDownIterator extends AbstractIterator { + seek(key: BaseType); + binding: any; + cache: any; + finished: any; + fastFuture: any; } -declare function leveldown< - TKey=any, - TValue=any - >(location: string) - : leveldown.LevelDown; -export = leveldown; \ No newline at end of file +declare const LevelDown: LevelDownConstructor +export default LevelDown; \ No newline at end of file diff --git a/package.json b/package.json index 9ac532d8..ed26b4b0 100644 --- a/package.json +++ b/package.json @@ -32,13 +32,14 @@ "main": "leveldown.js", "typings": "leveldown.d.ts", "dependencies": { - "abstract-leveldown": "~2.7.0", + "abstract-leveldown": "~2.7.1", "bindings": "~1.3.0", "fast-future": "~1.0.2", "nan": "~2.7.0", "prebuild-install": "^2.1.0" }, "devDependencies": { + "@types/node": "^8.0.31", "async": "^2.0.1", "delayed": "~1.0.1", "du": "~0.1.0",