Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return result from context.next() #17

Merged
merged 3 commits into from
Oct 28, 2023
Merged

Conversation

Rich-Harris
Copy link
Owner

Returns the result of any transformations in child visitors when calling next():

const node = {
  type: 'Foo',
  bar: {
    type: 'Bar',
    transformed: false
  }
};

walk(root, null, {
  Foo(node, context) {
    const result = context.next();
    console.log(result.bar.transformed); // true
  },
  Bar(node) {
    return { ...node, transformed: true };
  }
});

If no transformations occurred, returns undefined.

@Rich-Harris Rich-Harris merged commit aaf2ce2 into main Oct 28, 2023
4 checks passed
@Rich-Harris Rich-Harris deleted the return-node-from-next branch October 28, 2023 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant