UNPKG

@e280/quay

Version:

File-browser and outliner UI for the web

24 lines (23 loc) 943 B
import { Id } from "./types.js"; /** * Tree of nestable things. * - Things can have multiple children. * - Things can only have one parent. * - Things can be orphans (bring your own concept of a "root"). */ export declare class Hierarchy { #private; has(id: Id): boolean; getChildren(id: Id): Set<string>; getParent(id: Id): string | undefined; /** establish an id as a root with no parents, but ready to accept children */ establishRoot(root: Id): void; /** give a parent some children */ attach(parent: Id, ...children: Id[]): void; /** detach this id from its parent in the hierarchy */ detach(id: Id): undefined; /** destroy all relations associated with this id, and all its descendants */ destroy(id: Id): void; /** iterate over this id and all its descendants */ crawl(id: Id, predicate?: (id: Id, path: Id[]) => boolean): Generator<[string, string[]], void, unknown>; }