@@ -131,16 +131,14 @@ export function objectMerge(target, source) {
131
131
if ( Array . isArray ( source ) ) {
132
132
return source . slice ( )
133
133
}
134
- for ( const property in source ) {
135
- if ( source . hasOwnProperty ( property ) ) {
136
- const sourceProperty = source [ property ]
137
- if ( typeof sourceProperty === 'object' ) {
138
- target [ property ] = objectMerge ( target [ property ] , sourceProperty )
139
- continue
140
- }
134
+ Object . keys ( source ) . forEach ( ( property ) => {
135
+ const sourceProperty = source [ property ]
136
+ if ( typeof sourceProperty === 'object' ) {
137
+ target [ property ] = objectMerge ( target [ property ] , sourceProperty )
138
+ } else {
141
139
target [ property ] = sourceProperty
142
140
}
143
- }
141
+ } )
144
142
return target
145
143
}
146
144
@@ -253,15 +251,13 @@ export function deepClone(source) {
253
251
throw new Error ( 'error arguments' , 'shallowClone' )
254
252
}
255
253
const targetObj = source . constructor === Array ? [ ] : { }
256
- for ( const keys in source ) {
257
- if ( source . hasOwnProperty ( keys ) ) {
258
- if ( source [ keys ] && typeof source [ keys ] === 'object' ) {
259
- targetObj [ keys ] = source [ keys ] . constructor === Array ? [ ] : { }
260
- targetObj [ keys ] = deepClone ( source [ keys ] )
261
- } else {
262
- targetObj [ keys ] = source [ keys ]
263
- }
254
+ Object . keys ( source ) . forEach ( ( keys ) => {
255
+ if ( source [ keys ] && typeof source [ keys ] === 'object' ) {
256
+ targetObj [ keys ] = source [ keys ] . constructor === Array ? [ ] : { }
257
+ targetObj [ keys ] = deepClone ( source [ keys ] )
258
+ } else {
259
+ targetObj [ keys ] = source [ keys ]
264
260
}
265
- }
261
+ } )
266
262
return targetObj
267
263
}
0 commit comments