@@ -62,14 +62,16 @@ export default (
62
62
/* Functions */
63
63
/* -------------------------------------------------------------------------- */
64
64
65
- const getLeaves = (
65
+ function getLeaves (
66
66
siblings : { configurable ?: boolean ; value : Record < string , unknown > [ ] } ,
67
67
parent : {
68
68
configurable ?: boolean ;
69
69
value ?: Record < string , unknown > | undefined ;
70
70
} = { } ,
71
- ) : Record < string , unknown > [ ] =>
72
- siblings . value . flatMap ( ( value ) => {
71
+ ) : Record < string , unknown > [ ] {
72
+ function defineProperties (
73
+ value : Record < string , unknown > ,
74
+ ) : Record < string , unknown > [ ] {
73
75
Object . defineProperties ( value , {
74
76
...properties ,
75
77
[ keyParent ] : parent ,
@@ -85,7 +87,9 @@ export default (
85
87
{ configurable, value } ,
86
88
) ,
87
89
] ;
88
- } ) ;
90
+ }
91
+ return siblings . value . flatMap ( defineProperties ) ;
92
+ }
89
93
90
94
/* -------------------------------------------------------------------------- */
91
95
/* Reactives */
@@ -95,23 +99,19 @@ export default (
95
99
? tree
96
100
: reactive ( tree ) ;
97
101
98
- /* -------------------------------------------------------------------------- */
99
- /* Functions */
100
- /* -------------------------------------------------------------------------- */
101
-
102
- const startLeaves = ( ) : Record < string , unknown > [ ] => getLeaves ( { value } ) ;
103
-
104
102
/* -------------------------------------------------------------------------- */
105
103
/* Computations */
106
104
/* -------------------------------------------------------------------------- */
107
105
108
- const leaves : ComputedRef < Record < string , unknown > [ ] > = computed ( startLeaves ) ;
106
+ const leaves : ComputedRef < Record < string , unknown > [ ] > = computed ( ( ) =>
107
+ getLeaves ( { value } ) ,
108
+ ) ;
109
109
110
110
/* -------------------------------------------------------------------------- */
111
111
/* Functions */
112
112
/* -------------------------------------------------------------------------- */
113
113
114
- const add = ( pId : string ) : string | undefined => {
114
+ function add ( pId : string ) : string | undefined {
115
115
const the : Record < string , unknown > | undefined = leaves . value . find (
116
116
( leaf ) => leaf [ keyId ] === pId ,
117
117
) ;
@@ -136,11 +136,11 @@ export default (
136
136
return id ;
137
137
}
138
138
return undefined ;
139
- } ;
139
+ }
140
140
141
141
/* -------------------------------------------------------------------------- */
142
142
143
- const down = ( pId : string ) : void => {
143
+ function down ( pId : string ) : void {
144
144
const the : Record < string , unknown > | undefined = leaves . value . find (
145
145
( leaf ) => leaf [ keyId ] === pId ,
146
146
) ;
@@ -157,11 +157,11 @@ export default (
157
157
siblings [ index ] ,
158
158
] ;
159
159
}
160
- } ;
160
+ }
161
161
162
162
/* -------------------------------------------------------------------------- */
163
163
164
- const left = ( pId : string ) : string | undefined => {
164
+ function left ( pId : string ) : string | undefined {
165
165
const the : Record < string , unknown > | undefined = leaves . value . find (
166
166
( leaf ) => leaf [ keyId ] === pId ,
167
167
) ;
@@ -182,11 +182,11 @@ export default (
182
182
}
183
183
}
184
184
return undefined ;
185
- } ;
185
+ }
186
186
187
187
/* -------------------------------------------------------------------------- */
188
188
189
- const remove = ( pId : string ) : string | undefined => {
189
+ function remove ( pId : string ) : string | undefined {
190
190
const the : Record < string , unknown > | undefined = leaves . value . find (
191
191
( leaf ) => leaf [ keyId ] === pId ,
192
192
) ;
@@ -215,11 +215,11 @@ export default (
215
215
}
216
216
}
217
217
return undefined ;
218
- } ;
218
+ }
219
219
220
220
/* -------------------------------------------------------------------------- */
221
221
222
- const right = ( pId : string ) : string | undefined => {
222
+ function right ( pId : string ) : string | undefined {
223
223
const the : Record < string , unknown > | undefined = leaves . value . find (
224
224
( leaf ) => leaf [ keyId ] === pId ,
225
225
) ;
@@ -239,11 +239,11 @@ export default (
239
239
}
240
240
}
241
241
return undefined ;
242
- } ;
242
+ }
243
243
244
244
/* -------------------------------------------------------------------------- */
245
245
246
- const up = ( pId : string ) : void => {
246
+ function up ( pId : string ) : void {
247
247
const the : Record < string , unknown > | undefined = leaves . value . find (
248
248
( leaf ) => leaf [ keyId ] === pId ,
249
249
) ;
@@ -260,7 +260,7 @@ export default (
260
260
siblings [ prevIndex ] ,
261
261
] ;
262
262
}
263
- } ;
263
+ }
264
264
265
265
/* -------------------------------------------------------------------------- */
266
266
/* Main */
0 commit comments