h0x91b / redis-fast-driver

78 stars 13 forks source link

Typings #44

Closed Uzlopak closed 2 years ago

Uzlopak commented 3 years ago

Hereby I propose following typings for typescript:

import events = require('events');

interface RedisOptions {
    host: string;
    port: number;
    db: number;
    auth: false | string;
    maxRetries: number;
    tryToReconnect: boolean;
    reconnectTimeout: number;
    autoConnect: boolean;
    doNotSetClientName: boolean;
    doNotRunQuitOnEnd: boolean;
}

type Callback<T = string> = (err: Error | null, result: T) => void;

declare class Redis extends
    events.EventEmitter {
    constructor(opts?: RedisOptions): void;
    init(): void;
    connect(): void;
    processQueue(): void;
    reconnect(): void;
    selectDb(cb: Callback): void;
    sendAuth(cb: Callback): void;
    rawCall<T = string>(args: (string | Buffer)[], cb?: Callback<T>): void;
    rawCallAsync<T = string>(args: (string | Buffer)[]): Promise<T>;
    end(): void;
}
h0x91b commented 2 years ago

Thanks!

Published to npm v2.1.6