@@ -46,10 +46,10 @@ export default class BER {
4646 this . #a = buffer ;
4747 else
4848 this . #a = new Uint8Array ( new ArrayBuffer ( 0 , { maxByteLength : 0x10000000 } ) ) ;
49- } ;
49+ }
5050 getTag ( ) {
5151 return this . #a[ this . #i++ ] ;
52- } ;
52+ }
5353 getLength ( ) {
5454 let length = this . #a[ this . #i++ ] ;
5555 if ( length < 128 )
@@ -64,19 +64,19 @@ export default class BER {
6464 result = ( result << 8 ) | this . #a[ this . #i++ ] ;
6565
6666 return result ;
67- } ;
67+ }
6868 peek ( ) {
6969 return this . #a[ this . #i] ;
70- } ;
70+ }
7171 skip ( length ) {
7272 this . #i += length ;
73- } ;
73+ }
7474 next ( ) {
7575 const i = this . #i;
7676 this . getTag ( ) ;
7777 this . skip ( this . getLength ( ) ) ;
7878 return this . #a. subarray ( i , this . #i)
79- } ;
79+ }
8080 getInteger ( ) {
8181 if ( this . getTag ( ) !== 2 )
8282 throw new Error ( "BER: not an integer" ) ;
@@ -92,7 +92,7 @@ export default class BER {
9292 this . skip ( length )
9393 return BigInt . fromArrayBuffer ( this . #a. buffer . slice ( offset , offset + length ) ) ;
9494 }
95- } ;
95+ }
9696 getBitString ( ) {
9797 let result ;
9898 if ( this . getTag ( ) != 3 )
@@ -102,19 +102,19 @@ export default class BER {
102102 if ( pad ) {
103103 result = new Uint8Array ( length - 1 ) ;
104104 for ( let i = 0 ; i < length - 1 ; i ++ )
105- bs [ i ] = this . #a[ this . #i++ ] >>> pad ;
105+ result [ i ] = this . #a[ this . #i++ ] >>> pad ;
106106 }
107107 else {
108108 result = this . #a. subarray ( this . #i, this . #i + length - 1 ) ;
109109 this . #i += length ;
110110 }
111111 return result ;
112- } ;
112+ }
113113 getOctetString ( ) {
114114 if ( this . getTag ( ) != 0x04 )
115115 throw new Error ( "BER: not a octet string" ) ;
116116 return this . getChunk ( this . getLength ( ) ) ;
117- } ;
117+ }
118118 getObjectIdentifier ( ) {
119119 if ( this . getTag ( ) !== 0x06 )
120120 throw new Error ( "BER: not an object identifier" ) ;
@@ -131,39 +131,39 @@ export default class BER {
131131 oid . push ( ( v << 7 ) | i ) ;
132132 }
133133 return Uint32Array . from ( oid ) ;
134- } ;
134+ }
135135 getSequence ( ) {
136136 if ( this . getTag ( ) != 0x30 )
137137 throw new Error ( "BER: not a sequence" ) ;
138138 const length = this . getLength ( ) ;
139139 const result = this . #a. subarray ( this . #i, + this . #i + length ) ;
140140 this . #i += length ;
141141 return result ;
142- } ;
142+ }
143143 getChunk ( n ) {
144144 const result = new Uint8Array ( this . #a. buffer , this . #a. byteOffset + this . #i, n ) ;
145145 this . skip ( n ) ;
146146 return result ;
147- } ;
147+ }
148148 getBuffer ( ) {
149149 return this . #a. slice ( 0 , this . #i) . buffer ;
150- } ;
150+ }
151151
152152 morebuf ( n ) {
153153 if ( n < 128 ) n = 128 ;
154154 this . #a. buffer . resize ( this . #a. length + n ) ;
155- } ;
155+ }
156156 getc ( ) {
157157 return this . #a[ this . #i++ ] ;
158- } ;
158+ }
159159 putc ( c ) {
160160 if ( this . #i >= this . #a. length )
161161 this . morebuf ( 1 ) ;
162162 this . #a[ this . #i++ ] = c ;
163- } ;
163+ }
164164 putTag ( tag ) {
165165 this . putc ( tag ) ;
166- } ;
166+ }
167167 putLength ( len ) {
168168 if ( len < 128 )
169169 this . putc ( len ) ;
@@ -176,13 +176,13 @@ export default class BER {
176176 while ( -- lenlen >= 0 )
177177 this . putc ( len >>> ( lenlen << 3 ) ) ;
178178 }
179- } ;
179+ }
180180 putChunk ( c ) {
181181 if ( this . #i + c . byteLength > this . #a. length )
182182 this . morebuf ( c . byteLength ) ;
183183 this . #a. set ( new Uint8Array ( c ) , this . #i) ;
184184 this . #i += c . byteLength ;
185- } ;
185+ }
186186 get i ( ) {
187187 return this . #i;
188188 }
@@ -191,7 +191,7 @@ export default class BER {
191191 if ( n . length < 2 )
192192 return "0" + n ;
193193 return n ;
194- } ;
194+ }
195195 static encode ( arr ) {
196196 const b = new BER ;
197197 const tag = arr [ 0 ] ;
@@ -334,7 +334,7 @@ export default class BER {
334334 }
335335 b . #a. buffer . resize ( b . #i) ;
336336 return b . #a. buffer ;
337- } ;
337+ }
338338 static decode ( a ) {
339339 return this . _decode ( new BER ( a ) ) ;
340340 }
@@ -356,7 +356,7 @@ export default class BER {
356356 res = [ res ] ;
357357 res . unshift ( tag ) ;
358358 return res ;
359- } ;
359+ }
360360 static decodeTag ( tag , b , len ) {
361361 let res ;
362362 if ( ( tag >> 6 ) == 2 ) { // context specific class
@@ -424,7 +424,6 @@ export default class BER {
424424 break ;
425425 case 0x09 : // real -- not supported
426426 throw new Error ( "BER: unsupported" ) ;
427- break ;
428427 case 0x07 : // object descriptor
429428 case 0x0c : // UTF8 string
430429 case 0x12 : // numeric string
@@ -470,7 +469,5 @@ export default class BER {
470469 break ;
471470 }
472471 return res ;
473- } ;
474- } ;
475-
476- Object . freeze ( BER . prototype ) ;
472+ }
473+ }
0 commit comments