@@ -4,18 +4,16 @@ import type {
44 WorkerMessengerReplyBufferRecord ,
55} from './types' ;
66
7- declare let self : ServiceWorkerGlobalScope ;
8-
97export class WorkerMessengerReplyBuffer {
10- private replies : {
8+ private _replies : {
119 [ index : string ] : WorkerMessengerReplyBufferRecord [ ] | null ;
1210 } ;
1311
1412 constructor ( ) {
15- this . replies = { } ;
13+ this . _replies = { } ;
1614 }
1715
18- public addListener (
16+ public _addListener (
1917 command : WorkerMessengerCommandValue ,
2018 callback : ( param : unknown ) => void ,
2119 onceListenerOnly : boolean ,
@@ -25,30 +23,30 @@ export class WorkerMessengerReplyBuffer {
2523 onceListenerOnly,
2624 } ;
2725
28- const replies = this . replies [ command . toString ( ) ] ;
26+ const replies = this . _replies [ command . toString ( ) ] ;
2927 if ( replies ) replies . push ( record ) ;
30- else this . replies [ command . toString ( ) ] = [ record ] ;
28+ else this . _replies [ command . toString ( ) ] = [ record ] ;
3129 }
3230
33- public findListenersForMessage (
31+ public _findListenersForMessage (
3432 command : WorkerMessengerCommandValue ,
3533 ) : WorkerMessengerReplyBufferRecord [ ] {
36- return this . replies [ command . toString ( ) ] || [ ] ;
34+ return this . _replies [ command . toString ( ) ] || [ ] ;
3735 }
3836
39- public deleteListenerRecords ( command : WorkerMessengerCommandValue ) {
40- this . replies [ command . toString ( ) ] = null ;
37+ public _deleteListenerRecords ( command : WorkerMessengerCommandValue ) {
38+ this . _replies [ command . toString ( ) ] = null ;
4139 }
4240
43- public deleteAllListenerRecords ( ) {
44- this . replies = { } ;
41+ public _deleteAllListenerRecords ( ) {
42+ this . _replies = { } ;
4543 }
4644
47- public deleteListenerRecord (
45+ public _deleteListenerRecord (
4846 command : WorkerMessengerCommandValue ,
4947 targetRecord : object ,
5048 ) {
51- const listenersForCommand = this . replies [ command . toString ( ) ] ;
49+ const listenersForCommand = this . _replies [ command . toString ( ) ] ;
5250 if ( listenersForCommand == null ) return ;
5351
5452 for (
@@ -92,7 +90,7 @@ export class WorkerMessengerBase<
9290 command : WorkerMessengerCommandValue ,
9391 callback : ( WorkerMessengerPayload : any ) => void ,
9492 ) : void {
95- this . _replies . addListener ( command , callback , false ) ;
93+ this . _replies . _addListener ( command , callback , false ) ;
9694 }
9795
9896 /*
@@ -105,7 +103,7 @@ export class WorkerMessengerBase<
105103 command : WorkerMessengerCommandValue ,
106104 callback : ( WorkerMessengerPayload : any ) => void ,
107105 ) : void {
108- this . _replies . addListener ( command , callback , true ) ;
106+ this . _replies . _addListener ( command , callback , true ) ;
109107 }
110108
111109 /**
@@ -114,9 +112,9 @@ export class WorkerMessengerBase<
114112 */
115113 _off ( command ?: WorkerMessengerCommandValue ) : void {
116114 if ( command ) {
117- this . _replies . deleteListenerRecords ( command ) ;
115+ this . _replies . _deleteListenerRecords ( command ) ;
118116 } else {
119- this . _replies . deleteAllListenerRecords ( ) ;
117+ this . _replies . _deleteAllListenerRecords ( ) ;
120118 }
121119 }
122120}
0 commit comments