Yomguithereal / baobab

JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
MIT License
3.15k stars 117 forks source link

Fix history .undo() - unnecessary condition #470

Open whitcik opened 7 years ago

whitcik commented 7 years ago

Hi, I think that throw Error is unnecessary, becouse if in the tree is stored value that returns false in the if condition you can't use methods .undo (), because it always returns throw error. This blocking me, because I have a lot of value in the tree like null, false and i get error when i try undo to this value.

Yomguithereal commented 7 years ago

Hello @whitcik. You are right, there is a bug here. However, instead of just dropping this condition, it would be better to change the way the method and the Archive class works so that we may throw the error when needed.

whitcik commented 7 years ago

@Yomguithereal hmm, what do you want to change in class Archive and method? I think that works well, and there is no need throw the error.

Yomguithereal commented 7 years ago

There is a need to throw an error if you attempt to go back further than it is possible.

whitcik commented 7 years ago

@Yomguithereal I added throw an error in Archive.back(), please check this