forked from socketio/socket.io-redis-emitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
54 lines (40 loc) · 1.43 KB
/
index.d.ts
File metadata and controls
54 lines (40 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Type definitions for socket.io-emitter 3.1
// Project: https://github.com/socketio/socket.io-emitter#readme
// Definitions by: Ben Salili-James <https://github.com/benhjames>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace init {
/**
* The Redis client passed to `socket.io-emitter` only requires the `publish`
* method, so accept any client that implements this.
*/
interface RedisClient {
publish: (channel: string, message: string) => Promise<any>;
}
class SocketIOEmitter {
redis: RedisClient;
prefix: string;
nsp: string;
channel: string;
private _rooms: string[];
private _flags: Record<'broadcast' | 'json' | 'volatile', boolean | undefined>;
// TypeScript Version: 3.6
get broadcast(): this;
// TypeScript Version: 3.6
get json(): this;
// TypeScript Version: 3.6
get volatile(): this;
in(room: string): this;
to(room: string): this;
of(nsp: string): SocketIOEmitter;
emit(...data: any[]): this;
}
type SocketIORedisOptions = { host: string; port: number } | { socket: string };
interface SocketIOEmitterOptions {
key?: string;
}
}
declare function init(
redisOptions: init.RedisClient | init.SocketIORedisOptions | string,
options?: init.SocketIOEmitterOptions,
): init.SocketIOEmitter;
export = init;