@@ -67,41 +67,46 @@ const nonSerializable = function nonSerializableClosure() {
6767} ;
6868
6969class Dict {
70+ __nonSerializable__ = nonSerializable ; // Disable cloning of the Dict.
71+
72+ #map = new Map ( ) ;
73+
74+ objId = null ;
75+
76+ suppressEncryption = false ;
77+
78+ xref ;
79+
7080 constructor ( xref = null ) {
71- // Map should only be used internally, use functions below to access.
72- this . _map = new Map ( ) ;
7381 this . xref = xref ;
74- this . objId = null ;
75- this . suppressEncryption = false ;
76- this . __nonSerializable__ = nonSerializable ; // Disable cloning of the Dict.
7782 }
7883
7984 assignXref ( newXref ) {
8085 this . xref = newXref ;
8186 }
8287
8388 get size ( ) {
84- return this . _map . size ;
89+ return this . #map . size ;
8590 }
8691
8792 #getValue( isAsync , key1 , key2 , key3 ) {
88- let value = this . _map . get ( key1 ) ;
93+ let value = this . #map . get ( key1 ) ;
8994 if ( value === undefined && key2 !== undefined ) {
9095 if (
9196 ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "TESTING" ) ) &&
9297 key2 . length < key1 . length
9398 ) {
9499 unreachable ( "Dict.#getValue: Expected keys to be ordered by length." ) ;
95100 }
96- value = this . _map . get ( key2 ) ;
101+ value = this . #map . get ( key2 ) ;
97102 if ( value === undefined && key3 !== undefined ) {
98103 if (
99104 ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "TESTING" ) ) &&
100105 key3 . length < key2 . length
101106 ) {
102107 unreachable ( "Dict.#getValue: Expected keys to be ordered by length." ) ;
103108 }
104- value = this . _map . get ( key3 ) ;
109+ value = this . #map . get ( key3 ) ;
105110 }
106111 }
107112 if ( value instanceof Ref && this . xref ) {
@@ -139,20 +144,20 @@ class Dict {
139144
140145 // No dereferencing.
141146 getRaw ( key ) {
142- return this . _map . get ( key ) ;
147+ return this . #map . get ( key ) ;
143148 }
144149
145150 getKeys ( ) {
146- return this . _map . keys ( ) ;
151+ return this . #map . keys ( ) ;
147152 }
148153
149154 // No dereferencing.
150155 getRawValues ( ) {
151- return this . _map . values ( ) ;
156+ return this . #map . values ( ) ;
152157 }
153158
154159 getRawEntries ( ) {
155- return this . _map . entries ( ) ;
160+ return this . #map . entries ( ) ;
156161 }
157162
158163 set ( key , value ) {
@@ -163,7 +168,7 @@ class Dict {
163168 unreachable ( 'Dict.set: The "value" cannot be undefined.' ) ;
164169 }
165170 }
166- this . _map . set ( key , value ) ;
171+ this . #map . set ( key , value ) ;
167172 }
168173
169174 setIfNotExists ( key , value ) {
@@ -205,11 +210,11 @@ class Dict {
205210 }
206211
207212 has ( key ) {
208- return this . _map . has ( key ) ;
213+ return this . #map . has ( key ) ;
209214 }
210215
211216 * [ Symbol . iterator ] ( ) {
212- for ( const [ key , value ] of this . _map ) {
217+ for ( const [ key , value ] of this . #map ) {
213218 yield [
214219 key ,
215220 value instanceof Ref && this . xref
@@ -273,14 +278,14 @@ class Dict {
273278
274279 clone ( ) {
275280 const dict = new Dict ( this . xref ) ;
276- for ( const [ key , rawVal ] of this . getRawEntries ( ) ) {
277- dict . set ( key , rawVal ) ;
281+ for ( const [ key , value ] of this . #map ) {
282+ dict . set ( key , value ) ;
278283 }
279284 return dict ;
280285 }
281286
282287 delete ( key ) {
283- this . _map . delete ( key ) ;
288+ this . #map . delete ( key ) ;
284289 }
285290}
286291
0 commit comments