◐ Shell
clean mode source ↗

Need to call `walker.start()` for `tree.walk()` not documented except in example

System information

  • node version: v10.13.0
  • npm or yarn version: 6.4.1
  • OS/version/architecture: gLinux 64-bit (Google-internal, like Debian Testing)
  • Applicable nodegit version: v0.23.0 built from source

https://www.nodegit.org/api/tree/ has an example of how to use tree.walk(), but it doesn't mention a critical detail, which is mentioned in an example:

// Don't forget to call `start()`!
walker.start();

It looks like the start() method is added to the instance here:

event.start = function() {
bfs(null, self);

It took me quite a while to work out what the problem was, looking at the EventEmitter documentation would not have helped. I'm not sure if subclassing from EventEmitter is a good idea, but having a TreeWalker class where the this is documented would have made it easier to discover.