public branchesOf()

in packages/redux-dag-history/src/DagGraph.ts [518:537]


	public branchesOf(commit: StateId): BranchId[] {
		if (!commit) {
			throw new Error('commit must be defined')
		}
		const children = this.childrenOf(commit)
		if (children.length === 0) {
			const branches: BranchId[] = []
			for (const branch of this.branches) {
				if (this.latestOn(branch) === commit) {
					branches.push(branch)
				}
			}
			return branches
		} else {
			let result: BranchId[] = []
			const childrenBranches = children.map(child => this.branchesOf(child))
			childrenBranches.forEach(cb => (result = result.concat(...cb)))
			return result
		}
	}