@@ -5,10 +5,7 @@ const nestedHandler = {
5
5
levels . push ( key ) ;
6
6
const topLevel = levels [ 0 ] ;
7
7
levels . shift ( ) ;
8
- const copiedParent = Array . isArray ( this . _parent [ topLevel ] )
9
- ? [ ...this . _parent [ topLevel ] ]
10
- : { ...this . _parent [ topLevel ] } ;
11
- const scope = deepcopy ( copiedParent ) ;
8
+ const scope = deepcopy ( this . _parent [ topLevel ] ) ;
12
9
let target = scope ;
13
10
const max_level = levels . length - 1 ;
14
11
levels . some ( ( level , i ) => {
@@ -36,13 +33,12 @@ const nestedHandler = {
36
33
( Object . prototype . toString . call ( prop ) === '[object Object]' &&
37
34
prop ?. constructor ?. name === 'Object' )
38
35
) {
39
- const thisHandler = { ... nestedHandler } ;
36
+ const thisHandler = deepcopy ( nestedHandler ) ;
40
37
thisHandler . _path = `${ this . _path } .${ key } ` ;
41
38
thisHandler . _parent = this . _parent ;
42
39
const isArray = Array . isArray ( prop ) ;
43
40
thisHandler . _array = isArray ;
44
- const copied = isArray ? [ ...prop ] : { ...prop } ;
45
- return new Proxy ( copied , thisHandler ) ;
41
+ return new Proxy ( deepcopy ( prop ) , thisHandler ) ;
46
42
}
47
43
return reflector ;
48
44
} ,
@@ -64,10 +60,10 @@ const proxyHandler = {
64
60
Object . prototype . toString . call ( getValue ) === '[object Object]' &&
65
61
getValue ?. constructor ?. name === 'Object'
66
62
) {
67
- const thisHandler = { ... nestedHandler } ;
63
+ const thisHandler = deepcopy ( nestedHandler ) ;
68
64
thisHandler . _path = key ;
69
65
thisHandler . _parent = receiver ;
70
- return new Proxy ( { ... getValue } , thisHandler ) ;
66
+ return new Proxy ( deepcopy ( getValue ) , thisHandler ) ;
71
67
}
72
68
return getValue ;
73
69
} ,
0 commit comments