Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
typings: es2015 module export
Browse files Browse the repository at this point in the history
typings: use updated Abstract typings
typings: fix approximate size
chore: add node typings for dev
  • Loading branch information
MeirionHughes committed Sep 30, 2017
1 parent 8ed6aed commit 138c16b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 70 deletions.
133 changes: 64 additions & 69 deletions leveldown.d.ts
Original file line number Diff line number Diff line change
@@ -1,79 +1,74 @@
import * as Abstract from 'abstract-leveldown';
import { AbstractLevelDOWN, AbstractIteratorOptions, AbstractIterator } from 'abstract-leveldown';

declare namespace leveldown {
export interface LevelDown<TKey, TValue>
extends Abstract.LevelDOWN<
TKey,
TValue,
LevelDownOptions,
LevelDownPutOptions,
LevelDownGetOptions,
LevelDownDeleteOptions,
LevelDownIteratorOptions<TKey, TValue>,
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<TKey, TValue>): LevelDownIterator<TKey>
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<BaseType>): 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<K, V> {
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<TKey> extends Abstract.Iterator {
seek(key: TKey);
binding: any;
cache: any;
finished: any;
fastFuture: any;
}
export interface LevelDownIterator extends AbstractIterator<BaseType, BaseType> {
seek(key: BaseType);
binding: any;
cache: any;
finished: any;
fastFuture: any;
}
declare function leveldown<
TKey=any,
TValue=any
>(location: string)
: leveldown.LevelDown<TKey, TValue>;

export = leveldown;
declare const LevelDown: LevelDownConstructor
export default LevelDown;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 138c16b

Please sign in to comment.