@@ -83,7 +83,7 @@ export interface PostgresEmitterOptions {
83
83
84
84
export class Emitter <
85
85
EmitEvents extends EventsMap = DefaultEventsMap ,
86
- ServerSideEvents extends EventsMap = DefaultEventsMap
86
+ ServerSideEvents extends EventsMap = DefaultEventsMap ,
87
87
> {
88
88
public readonly channel : string ;
89
89
public readonly tableName : string ;
@@ -92,7 +92,7 @@ export class Emitter<
92
92
constructor (
93
93
readonly pool : any ,
94
94
readonly nsp : string = "/" ,
95
- opts : Partial < PostgresEmitterOptions > = { }
95
+ opts : Partial < PostgresEmitterOptions > = { } ,
96
96
) {
97
97
const channelPrefix = opts . channelPrefix || "socket.io" ;
98
98
this . channel = `${ channelPrefix } #${ nsp } ` ;
@@ -122,7 +122,7 @@ export class Emitter<
122
122
) : true {
123
123
return new BroadcastOperator < EmitEvents , ServerSideEvents > ( this ) . emit (
124
124
ev ,
125
- ...args
125
+ ...args ,
126
126
) ;
127
127
}
128
128
@@ -134,7 +134,7 @@ export class Emitter<
134
134
* @public
135
135
*/
136
136
public to (
137
- room : string | string [ ]
137
+ room : string | string [ ] ,
138
138
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
139
139
return new BroadcastOperator ( this ) . to ( room ) ;
140
140
}
@@ -147,7 +147,7 @@ export class Emitter<
147
147
* @public
148
148
*/
149
149
public in (
150
- room : string | string [ ]
150
+ room : string | string [ ] ,
151
151
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
152
152
return new BroadcastOperator ( this ) . in ( room ) ;
153
153
}
@@ -160,7 +160,7 @@ export class Emitter<
160
160
* @public
161
161
*/
162
162
public except (
163
- room : string | string [ ]
163
+ room : string | string [ ] ,
164
164
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
165
165
return new BroadcastOperator ( this ) . except ( room ) ;
166
166
}
@@ -185,7 +185,7 @@ export class Emitter<
185
185
* @public
186
186
*/
187
187
public compress (
188
- compress : boolean
188
+ compress : boolean ,
189
189
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
190
190
return new BroadcastOperator ( this ) . compress ( compress ) ;
191
191
}
@@ -231,7 +231,7 @@ export class Emitter<
231
231
...args : EventParams < ServerSideEvents , Ev >
232
232
) : void {
233
233
return new BroadcastOperator < EmitEvents , ServerSideEvents > (
234
- this
234
+ this ,
235
235
) . serverSideEmit ( ev , ...args ) ;
236
236
}
237
237
}
@@ -247,13 +247,14 @@ export const RESERVED_EVENTS: ReadonlySet<string | Symbol> = new Set(<const>[
247
247
248
248
export class BroadcastOperator <
249
249
EmitEvents extends EventsMap ,
250
- ServerSideEvents extends EventsMap
251
- > implements TypedEventBroadcaster < EmitEvents > {
250
+ ServerSideEvents extends EventsMap ,
251
+ > implements TypedEventBroadcaster < EmitEvents >
252
+ {
252
253
constructor (
253
254
private readonly emitter : Emitter ,
254
255
private readonly rooms : Set < string > = new Set < string > ( ) ,
255
256
private readonly exceptRooms : Set < string > = new Set < string > ( ) ,
256
- private readonly flags : BroadcastFlags = { }
257
+ private readonly flags : BroadcastFlags = { } ,
257
258
) { }
258
259
259
260
/**
@@ -264,7 +265,7 @@ export class BroadcastOperator<
264
265
* @public
265
266
*/
266
267
public to (
267
- room : string | string [ ]
268
+ room : string | string [ ] ,
268
269
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
269
270
const rooms = new Set ( this . rooms ) ;
270
271
if ( Array . isArray ( room ) ) {
@@ -276,7 +277,7 @@ export class BroadcastOperator<
276
277
this . emitter ,
277
278
rooms ,
278
279
this . exceptRooms ,
279
- this . flags
280
+ this . flags ,
280
281
) ;
281
282
}
282
283
@@ -288,7 +289,7 @@ export class BroadcastOperator<
288
289
* @public
289
290
*/
290
291
public in (
291
- room : string | string [ ]
292
+ room : string | string [ ] ,
292
293
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
293
294
return this . to ( room ) ;
294
295
}
@@ -301,7 +302,7 @@ export class BroadcastOperator<
301
302
* @public
302
303
*/
303
304
public except (
304
- room : string | string [ ]
305
+ room : string | string [ ] ,
305
306
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
306
307
const exceptRooms = new Set ( this . exceptRooms ) ;
307
308
if ( Array . isArray ( room ) ) {
@@ -313,7 +314,7 @@ export class BroadcastOperator<
313
314
this . emitter ,
314
315
this . rooms ,
315
316
exceptRooms ,
316
- this . flags
317
+ this . flags ,
317
318
) ;
318
319
}
319
320
@@ -325,14 +326,14 @@ export class BroadcastOperator<
325
326
* @public
326
327
*/
327
328
public compress (
328
- compress : boolean
329
+ compress : boolean ,
329
330
) : BroadcastOperator < EmitEvents , ServerSideEvents > {
330
331
const flags = Object . assign ( { } , this . flags , { compress } ) ;
331
332
return new BroadcastOperator (
332
333
this . emitter ,
333
334
this . rooms ,
334
335
this . exceptRooms ,
335
- flags
336
+ flags ,
336
337
) ;
337
338
}
338
339
@@ -350,7 +351,7 @@ export class BroadcastOperator<
350
351
this . emitter ,
351
352
this . rooms ,
352
353
this . exceptRooms ,
353
- flags
354
+ flags ,
354
355
) ;
355
356
}
356
357
@@ -377,10 +378,10 @@ export class BroadcastOperator<
377
378
debug (
378
379
"sending event of type %s to channel %s" ,
379
380
document . type ,
380
- this . emitter . channel
381
+ this . emitter . channel ,
381
382
) ;
382
383
await this . emitter . pool . query (
383
- `NOTIFY "${ this . emitter . channel } ", '${ payload } '`
384
+ `NOTIFY "${ this . emitter . channel } ", '${ payload } '` ,
384
385
) ;
385
386
} catch ( err ) {
386
387
// @ts -ignore
@@ -394,11 +395,11 @@ export class BroadcastOperator<
394
395
debug (
395
396
"sending event of type %s with attachment to channel %s" ,
396
397
document . type ,
397
- this . emitter . channel
398
+ this . emitter . channel ,
398
399
) ;
399
400
const result = await this . emitter . pool . query (
400
401
`INSERT INTO ${ this . emitter . tableName } (payload) VALUES ($1) RETURNING id;` ,
401
- [ payload ]
402
+ [ payload ] ,
402
403
) ;
403
404
const attachmentId = result . rows [ 0 ] . id ;
404
405
const headerPayload = JSON . stringify ( {
@@ -407,7 +408,7 @@ export class BroadcastOperator<
407
408
attachmentId,
408
409
} ) ;
409
410
this . emitter . pool . query (
410
- `NOTIFY "${ this . emitter . channel } ", '${ headerPayload } '`
411
+ `NOTIFY "${ this . emitter . channel } ", '${ headerPayload } '` ,
411
412
) ;
412
413
}
413
414
@@ -422,7 +423,7 @@ export class BroadcastOperator<
422
423
...args : EventParams < EmitEvents , Ev >
423
424
) : true {
424
425
if ( RESERVED_EVENTS . has ( ev ) ) {
425
- throw new Error ( `"${ ev } " is a reserved event name` ) ;
426
+ throw new Error ( `"${ String ( ev ) } " is a reserved event name` ) ;
426
427
}
427
428
428
429
// set up packet object
0 commit comments