mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-11 10:59:55 +08:00
adds typings for the 'encoding-down' package
This commit is contained in:
13
types/encoding-down/encoding-down-tests.ts
Normal file
13
types/encoding-down/encoding-down-tests.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { AbstractLevelDOWN } from 'abstract-leveldown';
|
||||
import EncodingDOWN from 'encoding-down';
|
||||
|
||||
const test = (encoding: EncodingDOWN) => {
|
||||
encoding.put("key", "value", (err?: Error) => { });
|
||||
encoding.put(1, "value", { something: true }, (err?: Error) => { });
|
||||
|
||||
encoding.get("key", (err?: Error) => { });
|
||||
encoding.get(1, { something: true }, (err: Error | undefined, value: any) => { });
|
||||
};
|
||||
|
||||
// $ExpectType void
|
||||
test(new EncodingDOWN(new AbstractLevelDOWN("here")));
|
||||
59
types/encoding-down/index.d.ts
vendored
Normal file
59
types/encoding-down/index.d.ts
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Type definitions for encoding-down 5.0
|
||||
// Project: https://github.com/Level/encoding-down
|
||||
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
|
||||
// Daniel Byrne <https://github.com/danwbyrne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import {
|
||||
AbstractLevelDOWN,
|
||||
AbstractIteratorOptions,
|
||||
AbstractIterator,
|
||||
AbstractOpenOptions,
|
||||
AbstractGetOptions,
|
||||
ErrorCallback,
|
||||
ErrorValueCallback,
|
||||
AbstractChainedBatch,
|
||||
AbstractBatch,
|
||||
AbstractOptions
|
||||
} from 'abstract-leveldown';
|
||||
|
||||
import { CodecOptions, CodecEncoder } from 'level-codec';
|
||||
|
||||
interface EncodingDown<K = any, V = any> extends AbstractLevelDOWN<K, V> {
|
||||
get(key: K, cb: ErrorValueCallback<V>): void;
|
||||
get(key: K, options: EncodingDown.GetOptions, cb: ErrorValueCallback<V>): void;
|
||||
|
||||
put(key: K, value: V, cb: ErrorCallback): void;
|
||||
put(key: K, value: V, options: EncodingDown.PutOptions, cb: ErrorCallback): void;
|
||||
|
||||
del(key: K, cb: ErrorCallback): void;
|
||||
del(key: K, options: EncodingDown.DelOptions, cb: ErrorCallback): void;
|
||||
|
||||
batch(): EncodingDown.ChainedBatch;
|
||||
batch(array: AbstractBatch[], cb: ErrorCallback): EncodingDown.ChainedBatch;
|
||||
batch(array: AbstractBatch[], options: EncodingDown.BatchOptions, cb: ErrorCallback): EncodingDown.ChainedBatch;
|
||||
|
||||
iterator(options?: EncodingDown.IteratorOptions): AbstractIterator<any, any>;
|
||||
}
|
||||
|
||||
declare namespace EncodingDown {
|
||||
interface GetOptions extends AbstractGetOptions, CodecOptions {}
|
||||
interface PutOptions extends AbstractOptions, CodecOptions {}
|
||||
interface DelOptions extends AbstractOptions, CodecOptions {}
|
||||
interface BatchOptions extends AbstractOptions, CodecOptions {}
|
||||
interface IteratorOptions extends AbstractIteratorOptions, CodecOptions {}
|
||||
interface ChainedBatch<K = any, V = any> extends AbstractChainedBatch<K, V> {
|
||||
write(cb: any): any;
|
||||
write(options: CodecOptions & AbstractOptions, cb: any): any;
|
||||
}
|
||||
interface Constructor {
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
<K = any, V = any>(db: AbstractLevelDOWN, options?: CodecOptions): EncodingDown<K, V>;
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
new <K = any, V = any>(db: AbstractLevelDOWN, options?: CodecOptions): EncodingDown<K, V>;
|
||||
}
|
||||
}
|
||||
|
||||
declare const EncodingDown: EncodingDown.Constructor;
|
||||
export default EncodingDown;
|
||||
23
types/encoding-down/tsconfig.json
Normal file
23
types/encoding-down/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"encoding-down-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/encoding-down/tslint.json
Normal file
1
types/encoding-down/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user