Hyperlinkv0.9.0-beta.0

Group

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

Whether x is a group tag (vs a leaf HyperService 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:794 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;
Referenced by 1 symbols