mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 05:27:30 +00:00
adds typings for the 'level-codec' package
This commit is contained in:
parent
cd1db00d94
commit
c8a0139cb1
32
types/level-codec/index.d.ts
vendored
Normal file
32
types/level-codec/index.d.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// Type definitions for level-codec 9.0
|
||||
// Project: https://github.com/Level/codec
|
||||
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface CodecEncoder {
|
||||
encode: (val: any) => any;
|
||||
decode: (val: any) => any;
|
||||
buffer: boolean;
|
||||
type: string;
|
||||
}
|
||||
export interface CodecOptions {
|
||||
keyEncoding?: string | CodecEncoder;
|
||||
valueEncoding?: string | CodecEncoder;
|
||||
}
|
||||
export interface Codec {
|
||||
encodeKey(key: any, opts?: CodecOptions, batchOpts?: CodecOptions): any;
|
||||
encodeValue(value: any, opts?: CodecOptions, batchOpts?: CodecOptions): any;
|
||||
decodeKey(key: any, opts?: CodecOptions): any;
|
||||
decodeValue(value: any, opts?: CodecOptions): any;
|
||||
encodeBatch(ops: any, opts?: CodecOptions): any;
|
||||
encodeLtgt(ltgt: any): any;
|
||||
createStreamDecoder(opts: CodecOptions): any;
|
||||
keyAsBuffer(opts?: CodecOptions): any;
|
||||
valueAsBuffer(opts?: CodecOptions): any;
|
||||
}
|
||||
export interface CodecConstructor {
|
||||
new (options?: CodecOptions): Codec;
|
||||
(options?: CodecOptions): Codec;
|
||||
}
|
||||
|
||||
export const Codec: CodecConstructor;
|
||||
12
types/level-codec/level-codec-tests.ts
Normal file
12
types/level-codec/level-codec-tests.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Codec } from "level-codec";
|
||||
|
||||
const test = (codec: Codec) => {
|
||||
return codec.keyAsBuffer();
|
||||
};
|
||||
|
||||
test(new Codec({ keyEncoding: "hex" }));
|
||||
test(new Codec());
|
||||
|
||||
// new not needed
|
||||
test(Codec({ keyEncoding: "hex" }));
|
||||
test(Codec());
|
||||
23
types/level-codec/tsconfig.json
Normal file
23
types/level-codec/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",
|
||||
"level-codec-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/level-codec/tslint.json
Normal file
1
types/level-codec/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user