Hyperlinkv0.8.0-beta.28

Group

Group.isGroupconstsrc/Group.ts:71
(x: unknown): x is {
  readonly key: string
  readonly members: Record<string, unknown>
}

Whether x is a group tag (vs a leaf resource tag) — the discriminator for walking a tree. Tags are classes (so typeof is "function", not "object"); a group is one carrying a members record. Use it to recurse on branches and treat everything else as a leaf:

for (const [name, member] of Object.entries(Group.members(node)))
  Group.isGroup(member) ? walk(member) : renderLeaf(name, member);
guards
Source src/Group.ts:714 lines
export const isGroup = (
  x: unknown,
): x is { readonly key: string; readonly members: Record<string, unknown> } =>
  (typeof x === "object" || typeof x === "function") && x !== null && "members" in x;