Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/level-ttl/level-ttl-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LevelUp as levelup } from 'levelup';
import levelup = require('levelup');
import { AbstractLevelDOWN } from 'abstract-leveldown';
import ttl, { LevelTTL, LevelTTLOptions } from 'level-ttl';

Expand Down
6 changes: 3 additions & 3 deletions types/level/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { AbstractOptions, ErrorCallback } from "abstract-leveldown";

import EncodingDown from "encoding-down";

import { LevelUp, errors } from "levelup";
import levelup = require("levelup");

declare namespace Level {
interface LevelDB<K = any, V = any> extends LevelUp<EncodingDown<K, V>> {
errors: typeof errors;
interface LevelDB<K = any, V = any> extends levelup.LevelUp<EncodingDown<K, V>> {
errors: typeof levelup.errors;
}
interface Constructor {
(location: string, options?: AbstractOptions, callback?: ErrorCallback): LevelDB;
Expand Down
183 changes: 91 additions & 92 deletions types/levelup/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,98 +77,97 @@ interface AbstractClearOptions<K = any> extends AbstractOptions {
limit?: number | undefined;
}

export interface LevelUp<DB = AbstractLevelDOWN, Iterator = AbstractIterator<any, any>> extends EventEmitter {
open(): Promise<void>;
open(callback?: ErrorCallback): void;
close(): Promise<void>;
close(callback?: ErrorCallback): void;

put: InferDBPut<DB>;
get: InferDBGet<DB>;
del: InferDBDel<DB>;
clear: InferDBClear<DB>;
getMany: InferDBGetMany<DB>;

batch(array: AbstractBatch[], options?: any): Promise<void>;
batch(array: AbstractBatch[], options: any, callback: (err?: any) => any): void;
batch(array: AbstractBatch[], callback: (err?: any) => any): void;

batch(): LevelUpChain;
iterator(options?: AbstractIteratorOptions): Iterator;

isOpen(): boolean;
isClosed(): boolean;

readonly status: "new" | "opening" | "open" | "closing" | "closed";
isOperational(): 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 clear is called
*/
on(event: 'clear', cb: (opts: any) => void): this;
/*
emitted on given event
*/
on(event: 'open' | 'ready' | 'closed' | 'opening' | 'closing', cb: () => void): this;
declare namespace levelup {
interface LevelUpChain<K = any, V = any> {
readonly length: number;
put(key: K, value: V): this;
del(key: K): this;
clear(): this;
write(callback: ErrorCallback): this;
write(): Promise<this>;
}
interface LevelUp<DB = AbstractLevelDOWN, Iterator = AbstractIterator<any, any>> extends EventEmitter {
open(): Promise<void>;
open(callback?: ErrorCallback): void;
close(): Promise<void>;
close(callback?: ErrorCallback): void;

put: InferDBPut<DB>;
get: InferDBGet<DB>;
del: InferDBDel<DB>;
clear: InferDBClear<DB>;
getMany: InferDBGetMany<DB>;

batch(array: AbstractBatch[], options?: any): Promise<void>;
batch(array: AbstractBatch[], options: any, callback: (err?: any) => any): void;
batch(array: AbstractBatch[], callback: (err?: any) => any): void;

batch(): LevelUpChain;
iterator(options?: AbstractIteratorOptions): Iterator;

isOpen(): boolean;
isClosed(): boolean;

readonly status: "new" | "opening" | "open" | "closing" | "closed";
isOperational(): 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 clear is called
*/
on(event: 'clear', cb: (opts: any) => void): this;
/*
emitted on given event
*/
on(event: 'open' | 'ready' | 'closed' | 'opening' | 'closing', cb: () => void): this;
}

interface LevelUpConstructor {
<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;

<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;

new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;

new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;

errors: {
LevelUPError: typeof LevelUPError;
InitializationError: typeof InitializationError;
OpenError: typeof OpenError;
ReadError: typeof ReadError;
WriteError: typeof WriteError;
NotFoundError: typeof NotFoundError;
EncodingError: typeof EncodingError;
};
}
}

interface LevelUpConstructor {
<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;

<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;

new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;

new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;

errors: {
LevelUPError: typeof LevelUPError;
InitializationError: typeof InitializationError;
OpenError: typeof OpenError;
ReadError: typeof ReadError;
WriteError: typeof WriteError;
NotFoundError: typeof NotFoundError;
EncodingError: typeof EncodingError;
};
}

export interface LevelUpChain<K = any, V = any> {
readonly length: number;
put(key: K, value: V): this;
del(key: K): this;
clear(): this;
write(callback: ErrorCallback): this;
write(): Promise<this>;
}

export const errors: LevelUpConstructor["errors"];

export const LevelUp: LevelUpConstructor;
declare const levelup: levelup.LevelUpConstructor;

export {};
export = levelup;
2 changes: 1 addition & 1 deletion types/levelup/levelup-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LevelUp as levelup } from 'levelup';
import levelup = require('levelup');
import { AbstractLevelDOWN } from 'abstract-leveldown';

interface StringEncoding {
Expand Down
16 changes: 1 addition & 15 deletions types/levelup/tslint.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
{
"extends": "@definitelytyped/dtslint/dt.json",
"rules": {
"npm-naming": [
true,
{
"errors": [
[
"NeedsExportEquals",
false
]
],
"mode": "code"
}
]
}
"extends": "@definitelytyped/dtslint/dt.json"
}
2 changes: 1 addition & 1 deletion types/subleveldown/subleveldown-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LevelUp as levelup } from 'levelup';
import levelup = require('levelup');
import sub from 'subleveldown';
import { AbstractLevelDOWN } from 'abstract-leveldown';

Expand Down