1 import { BroadcastChannel
} from
'worker_threads';
3 import { BroadcastChannelRequest
, BroadcastChannelResponse
} from
'../types/WorkerBroadcastChannel';
5 export default abstract class WorkerBroadcastChannel
extends BroadcastChannel
{
6 protected constructor() {
10 public sendRequest(request
: BroadcastChannelRequest
): void {
11 this.postMessage(request
);
14 protected sendResponse(response
: BroadcastChannelResponse
): void {
15 this.postMessage(response
);
18 protected isRequest(message
: any): boolean {
19 return Array.isArray(message
) && message
.length
=== 3;
22 protected isResponse(message
: any): boolean {
23 return Array.isArray(message
) && message
.length
=== 2;