A library's size counts what is under its top-level nodes, the same in /api/libraries and the root's byline (a root alone is 0 nodes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-17 02:53:58 -05:00
1 parent a6dbfbc19f
commit f888525808
5 files changed
+13 -8

No files matched your search

+3
View File
@@ -897,6 +897,9 @@ export function tops(snap: Snap): NodeId[] {
export const isLibraryRoot = (snap: Snap, id: NodeId) => snap.library && id === snap.root;
/** How many nodes a library holds: everything under its top-level nodes, the root and the Wikipedia container left out (0 for a root alone). */
export const libraryNodeCount = (snap: Snap) => tops(snap).reduce((n, d) => n + 1 + descendants(snap, d).length, 0);
/**
* The top of a node's branch: its ancestor (or itself) among the root's children. A relation, not
* a kind of node. None for the library root itself; in a single tree, the root.