Skip to content

Commit

Permalink
Merge pull request #18 from MeirionHughes/master
Browse files Browse the repository at this point in the history
add basic typings
  • Loading branch information
ralphtheninja authored Sep 12, 2017
2 parents aceb6ff + d221bd8 commit 4ab6188
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

declare namespace codec {
interface CodecEncoder {
encode: (val: any) => any;
decode: (val: any) => any;
buffer: boolean
type: string
}

interface CodecOptions {
keyEncoding?: string | CodecEncoder
valueEncoding?: string | CodecEncoder
}

interface Codec {
encodeKey(key: any, opts?: codec.CodecOptions, batchOpts?: codec.CodecOptions): any;
encodeValue(value: any, opts?: codec.CodecOptions, batchOpts?: codec.CodecOptions): any;
decodeKey(key: any, opts?: codec.CodecOptions): any;
decodeValue(value: any, opts?: codec.CodecOptions): any;
encodeBatch(ops: any, opts?: codec.CodecOptions): any;
encodeLtgt(ltgt: any): any;
createStreamDecoder(opts: codec.CodecOptions): any;
keyAsBuffer(opts?: codec.CodecOptions): any;
valueAsBuffer(opts?: codec.CodecOptions): any;
}

interface CodecConstructor {
new(options?: CodecOptions): Codec;
(options?: CodecOptions): Codec;
}
}

declare const codec: codec.CodecConstructor;

export = codec;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"devDependencies": {
"tape": "^4.3.0"
},
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"test": "make test"
},
Expand Down

0 comments on commit 4ab6188

Please sign in to comment.