File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -221,8 +221,12 @@ export class Encoder {
221221 }
222222
223223 encodeMap ( object : Record < string , unknown > , depth : number ) {
224- const keys = Object . keys ( object ) ;
225- const size = keys . length ;
224+ let size = 0 ;
225+ for ( const key in object ) {
226+ if ( Object . prototype . hasOwnProperty . call ( object , key ) ) {
227+ size ++ ;
228+ }
229+ }
226230 // map
227231 if ( size < 16 ) {
228232 // fixmap
@@ -238,9 +242,11 @@ export class Encoder {
238242 } else {
239243 throw new Error ( `Too large map object: ${ size } ` ) ;
240244 }
241- for ( const key of keys ) {
242- this . encodeString ( key ) ;
243- this . encode ( object [ key ] , depth + 1 ) ;
245+ for ( const key in object ) {
246+ if ( Object . prototype . hasOwnProperty . call ( object , key ) ) {
247+ this . encodeString ( key ) ;
248+ this . encode ( object [ key ] , depth + 1 ) ;
249+ }
244250 }
245251 }
246252
You can’t perform that action at this time.
0 commit comments