Open
Description
Can I access the depth of the currently traversed (e.g. during the depth-first walk) element in constant time? Right now, the only way of getting the depth that I see (besides storing it with the node) is by calling getPath
:
root.walk(el => {console.log(el.model.id, el.getPath().length);})
Activity
[-]Access to current depth during the walk[/-][+]Depth of the currently traversed element[/+][-]Depth of the currently traversed element[/-][+]Depth of the currently traversed element in constant time[/+]joaonuno commentedon Nov 1, 2021
You're right, that's the only way as of now and it's not constant time as you noted. I'll leave this open because it seems a nice improvement for a future version.
coreymunn3 commentedon Mar 16, 2022
Wow, if it weren't for this issue I wouldn't have even know that getting depth was possible using this library, or that you even get something with a "getPath" method on it. The documentation here is painfully inadequate.
joaonuno commentedon Mar 16, 2022
Hi,

getPath
is documented here and there's an example on the lib's page: