Skip to content

Commit c652078

Browse files
author
Jerry Bruwes
committed
modified: index.ts
1 parent b963ef0 commit c652078

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ export default (
6262
/* Functions */
6363
/* -------------------------------------------------------------------------- */
6464

65-
const getLeaves = (
65+
function getLeaves(
6666
siblings: { configurable?: boolean; value: Record<string, unknown>[] },
6767
parent: {
6868
configurable?: boolean;
6969
value?: Record<string, unknown> | undefined;
7070
} = {},
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>[] {
7375
Object.defineProperties(value, {
7476
...properties,
7577
[keyParent]: parent,
@@ -85,7 +87,9 @@ export default (
8587
{ configurable, value },
8688
),
8789
];
88-
});
90+
}
91+
return siblings.value.flatMap(defineProperties);
92+
}
8993

9094
/* -------------------------------------------------------------------------- */
9195
/* Reactives */
@@ -95,23 +99,19 @@ export default (
9599
? tree
96100
: reactive(tree);
97101

98-
/* -------------------------------------------------------------------------- */
99-
/* Functions */
100-
/* -------------------------------------------------------------------------- */
101-
102-
const startLeaves = (): Record<string, unknown>[] => getLeaves({ value });
103-
104102
/* -------------------------------------------------------------------------- */
105103
/* Computations */
106104
/* -------------------------------------------------------------------------- */
107105

108-
const leaves: ComputedRef<Record<string, unknown>[]> = computed(startLeaves);
106+
const leaves: ComputedRef<Record<string, unknown>[]> = computed(() =>
107+
getLeaves({ value }),
108+
);
109109

110110
/* -------------------------------------------------------------------------- */
111111
/* Functions */
112112
/* -------------------------------------------------------------------------- */
113113

114-
const add = (pId: string): string | undefined => {
114+
function add(pId: string): string | undefined {
115115
const the: Record<string, unknown> | undefined = leaves.value.find(
116116
(leaf) => leaf[keyId] === pId,
117117
);
@@ -136,11 +136,11 @@ export default (
136136
return id;
137137
}
138138
return undefined;
139-
};
139+
}
140140

141141
/* -------------------------------------------------------------------------- */
142142

143-
const down = (pId: string): void => {
143+
function down(pId: string): void {
144144
const the: Record<string, unknown> | undefined = leaves.value.find(
145145
(leaf) => leaf[keyId] === pId,
146146
);
@@ -157,11 +157,11 @@ export default (
157157
siblings[index],
158158
];
159159
}
160-
};
160+
}
161161

162162
/* -------------------------------------------------------------------------- */
163163

164-
const left = (pId: string): string | undefined => {
164+
function left(pId: string): string | undefined {
165165
const the: Record<string, unknown> | undefined = leaves.value.find(
166166
(leaf) => leaf[keyId] === pId,
167167
);
@@ -182,11 +182,11 @@ export default (
182182
}
183183
}
184184
return undefined;
185-
};
185+
}
186186

187187
/* -------------------------------------------------------------------------- */
188188

189-
const remove = (pId: string): string | undefined => {
189+
function remove(pId: string): string | undefined {
190190
const the: Record<string, unknown> | undefined = leaves.value.find(
191191
(leaf) => leaf[keyId] === pId,
192192
);
@@ -215,11 +215,11 @@ export default (
215215
}
216216
}
217217
return undefined;
218-
};
218+
}
219219

220220
/* -------------------------------------------------------------------------- */
221221

222-
const right = (pId: string): string | undefined => {
222+
function right(pId: string): string | undefined {
223223
const the: Record<string, unknown> | undefined = leaves.value.find(
224224
(leaf) => leaf[keyId] === pId,
225225
);
@@ -239,11 +239,11 @@ export default (
239239
}
240240
}
241241
return undefined;
242-
};
242+
}
243243

244244
/* -------------------------------------------------------------------------- */
245245

246-
const up = (pId: string): void => {
246+
function up(pId: string): void {
247247
const the: Record<string, unknown> | undefined = leaves.value.find(
248248
(leaf) => leaf[keyId] === pId,
249249
);
@@ -260,7 +260,7 @@ export default (
260260
siblings[prevIndex],
261261
];
262262
}
263-
};
263+
}
264264

265265
/* -------------------------------------------------------------------------- */
266266
/* Main */

0 commit comments

Comments
 (0)