Add types for hiredis (#14015)

This commit is contained in:
Titan
2017-01-18 06:05:16 +08:00
committed by Mohamed Hegazy
parent 57d1aeb1c9
commit e584d29c6c
4 changed files with 54 additions and 0 deletions

13
hiredis/hiredis-tests.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Reader, Config, createConnection } from "hiredis";
const socket = createConnection(6379, "localhost");
socket.write("INFO");
const reader = new Reader({ return_buffers: false });
// Data comes in
reader.feed("$5\r\nhello\r\n");
// Reply comes out
reader.get(); // => "hello"

20
hiredis/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for hiredis 0.5
// Project: http://github.com/redis/hiredis-node
// Definitions by: Titan <https://github.com/titan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as net from "net";
export interface Config {
return_buffers: boolean;
}
export class Reader {
constructor(config?: Config);
feed(reply: string | Buffer): void;
get(): string | Buffer;
}
export function createConnection(port: number, host: string): net.Socket;

20
hiredis/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hiredis-tests.ts"
]
}

1
hiredis/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "../tslint.json" }