1+ import { hasOwn } from "@smithy/core/client" ;
12import { SerdeContext } from "@smithy/core/protocols" ;
23import { NormalizedSchema } from "@smithy/core/schema" ;
34import { NumericValue , _parseEpochTimestamp , nv } from "@smithy/core/serde" ;
@@ -173,6 +174,7 @@ function readStruct(ns: NormalizedSchema, count: number, startPos: number): any
173174 if ( isUnion ) {
174175 let resultEmpty = true ;
175176 for ( const _ in result ) {
177+ if ( ! hasOwn ( result , _ ) ) continue ;
176178 resultEmpty = false ;
177179 break ;
178180 }
@@ -348,6 +350,7 @@ function readMapIndefinite(ns: NormalizedSchema): any {
348350 if ( isUnion ) {
349351 let resultEmpty = true ;
350352 for ( const _ in result ) {
353+ if ( ! hasOwn ( result , _ ) ) continue ;
351354 resultEmpty = false ;
352355 break ;
353356 }
@@ -694,6 +697,7 @@ function transformObject(ns: NormalizedSchema, value: any): any {
694697 if ( ns . isMapSchema ( ) ) {
695698 const targetSchema = ns . getValueSchema ( ) ;
696699 for ( const key in value ) {
700+ if ( ! hasOwn ( value , key ) ) continue ;
697701 newObject [ key ] = transformObject ( targetSchema , value [ key ] ) ;
698702 }
699703 } else if ( ns . isStructSchema ( ) ) {
@@ -702,6 +706,7 @@ function transformObject(ns: NormalizedSchema, value: any): any {
702706 if ( isUnion ) {
703707 keys = new Set < string > ( ) ;
704708 for ( const k in value ) {
709+ if ( ! hasOwn ( value , k ) ) continue ;
705710 if ( k !== "__type" ) {
706711 keys . add ( k ) ;
707712 }
@@ -718,6 +723,7 @@ function transformObject(ns: NormalizedSchema, value: any): any {
718723 if ( isUnion && keys ?. size === 1 ) {
719724 let newObjectEmpty = true ;
720725 for ( const _ in newObject ) {
726+ if ( ! hasOwn ( newObject , _ ) ) continue ;
721727 newObjectEmpty = false ;
722728 break ;
723729 }
@@ -727,6 +733,7 @@ function transformObject(ns: NormalizedSchema, value: any): any {
727733 }
728734 } else if ( typeof value . __type === "string" ) {
729735 for ( const k in value ) {
736+ if ( ! hasOwn ( value , k ) ) continue ;
730737 if ( ! ( k in newObject ) ) {
731738 newObject [ k ] = value [ k ] ;
732739 }
0 commit comments