mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add types for hiredis (#14015)
This commit is contained in:
13
hiredis/hiredis-tests.ts
Normal file
13
hiredis/hiredis-tests.ts
Normal 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
20
hiredis/index.d.ts
vendored
Normal 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
20
hiredis/tsconfig.json
Normal 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
1
hiredis/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user