Rich-Harris/estree-walker

Allow to `return` from `enter` and `leave`

benjaminpreiss opened this issue · 1 comments

Hey y'all

I think it would be great if there was an easy way to break the tree traversal and return something by calling return ....

Then, this code would be possible:

const result = walk(ast, {enter(node) {
    if(node === condition) return something
}})
// Logs the value of something
console.log(result)

What do you think?

I think we need a this.exit() to interrupt the traversal.