I have a recursive function which does a sort of tree process where each call may call itself multiple times, I don’t have any way of knowing how deep or wide it is. How do I run a callback once the entire process has been completed?
I’m thinking of having some sort of object to pass about to do a count but not quite cracked it yet, i’m wondering if there is a known best/better way of doing this.
what I needed to do is count the number of paths in each tree before calling the callback e.g.:
Perhaps the count should not be inside myFunction but recursion should have its own count, however this works. (i’ve not tested this example)