Skip to content

techa/undoable

Repository files navigation

Undoable

zero-dependency simple undoable class

npm install git+ssh://[email protected]:/techa/undoable
"dependencies": {
	"undoable": "git://github.com/techa/undoable.git"
}
const actions = ['Initial state']

class ExUndoable<T> extends Undoable {
	onCapacityOver(): void {
		actions.shift()
	}
	set(value: T, action?: string): boolean {
		if (!action) {
			throw new Error(`(${action}): action is invalid`)
		}
		const bool = super.set(value)
		if (bool) {
			actions.push(action)
		}
		return bool
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published