tangled
alpha
login
or
join now
davidwindham.com
/
npmx.dev
forked from
npmx.dev/npmx.dev
0
fork
atom
[READ-ONLY] a fast, modern browser for the npm registry
0
fork
atom
overview
issues
pulls
pipelines
perf: hoist skill file counting function
Daniel Roe
1 month ago
3f1d2e1f
05ccbe86
+3
-5
1 changed file
expand all
collapse all
unified
split
server
utils
skills.ts
+3
-5
server/utils/skills.ts
···
88
88
.map(child => ({ name: child.name, children: child.children || [] }))
89
89
}
90
90
91
91
+
const countFilesRecursive = (nodes: PackageFileTree[]): number =>
92
92
+
nodes.reduce((acc, n) => acc + (n.type === 'file' ? 1 : countFilesRecursive(n.children || [])), 0)
93
93
+
91
94
/**
92
95
* Count files in skill subdirectories (scripts, references, assets).
93
96
*/
94
97
export function countSkillFiles(children: PackageFileTree[]): SkillFileCounts | undefined {
95
98
const counts: SkillFileCounts = {}
96
96
-
const countFilesRecursive = (nodes: PackageFileTree[]): number =>
97
97
-
nodes.reduce(
98
98
-
(acc, n) => acc + (n.type === 'file' ? 1 : countFilesRecursive(n.children || [])),
99
99
-
0,
100
100
-
)
101
99
102
100
for (const child of children) {
103
101
if (child.type !== 'directory') continue