public squashCurrentBranch()

in packages/redux-dag-history/src/DagGraph.ts [542:570]


	public squashCurrentBranch() {
		const toSquash: StateId[] = []
		const branch = this.branchOf(this.currentStateId)
		let current = this.parentOf(this.currentStateId)
		let keepSquashing = true

		do {
			if (current && this.branchOf(current) === branch) {
				toSquash.push(current)
				current = this.parentOf(current)
			} else {
				keepSquashing = false
			}
		} while (keepSquashing)

		log(
			'squashing %s states on branch %s => ',
			toSquash.length,
			branch,
			current,
			toSquash,
		)
		if (toSquash.length > 0) {
			toSquash.forEach(c => this.remove(c))
			this.setParent(this.currentStateId, current)
		}

		return this
	}