import * as uuid from 'uuid'; export class BlackboardRef { private readonly _uuid: string; private readonly _name: string; private readonly _children: BlackboardRef[] = []; // This is unused but prevents assigning, e.g. BlackboardRef to BlackboardRef protected readonly _marker!: T; constructor(name: string, parent?: BlackboardRef) { if (parent) { name = parent.name + '.' + name; } this._uuid = uuid.v4(); this._name = name; } public createChild(name: string): BlackboardRef { const ref = new BlackboardRef(name, this); this._children.push(ref); return ref; } public get children(): ReadonlyArray> { return this._children; } public get descendants(): BlackboardRef[] { return this._children.concat(...this._children.map((c) => c.descendants)); } public get uuid(): string { return this._uuid; } public get name(): string { return this._name; } }