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C,EAAE;gBAC/B,sCAAsC;gBACtC,SAAS;aACV;YAED,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC9B;IACH,CAAC;CACF;AA9CD,oBA8CC","sourcesContent":["export type NodeState = '' | 'dirty' | 'in-progress' | 'pending' | 'done';\n\nexport const STATE_DIRTY: NodeState = 'dirty';\nexport const STATE_IN_PROGRESS: NodeState = 'in-progress';\nexport const STATE_PENDING: NodeState = 'pending';\nexport const STATE_DONE: NodeState = 'done';\n\n/**\n * A Node in the {@link BuildGraph}.\n */\nexport class Node {\n constructor(public readonly url: string) {}\n\n public type: string;\n\n public data: any;\n\n public state: NodeState = '';\n\n public filter(by: (value: Node, index: number) => boolean): Node[] {\n return [...this._dependents].filter(by);\n }\n\n public find(by: (value: Node, index: number) => boolean): Node | undefined {\n return [...this._dependents].find(by);\n }\n\n public some(by: (value: Node, index: number) => boolean): boolean {\n return [...this._dependents].some(by);\n }\n\n public get dependents(): Set<Node> {\n return this._dependents;\n }\n\n public get dependees(): Set<Node> {\n return this._dependees;\n }\n\n private _dependents = new Set<Node>();\n private _dependees = new Set<Node>();\n\n /** @experimental DO NOT USE. For time being, dirty checking is for `type=entryPoint && state !== 'done'` (full rebuild of entry point). */\n public dependsOn(dependent: Node | Node[]) {\n const newDeps = Array.isArray(dependent) ? dependent : [dependent];\n\n for (const newDep of newDeps) {\n if (newDep._dependees.has(this)) {\n // nodes already depends on each other\n continue;\n }\n\n newDep._dependees.add(this);\n this._dependents.add(newDep);\n }\n }\n}\n"]}
\No newline at end of file