diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..fec2801 --- /dev/null +++ b/index.d.ts @@ -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; \ No newline at end of file diff --git a/package.json b/package.json index 9ca4c66..7b70c59 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "devDependencies": { "tape": "^4.3.0" }, + "main": "index.js", + "typings": "index.d.ts", "scripts": { "test": "make test" },