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

Updates documentation of the findParent and find methods #10479

Merged
merged 1 commit into from Sep 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/babel-traverse/src/path/ancestry.js
Expand Up @@ -4,8 +4,10 @@ import * as t from "@babel/types";
import NodePath from "./index";

/**
* Call the provided `callback` with the `NodePath`s of all the parents.
* When the `callback` returns a truthy value, we return that node path.
* Starting at the parent path of the current `NodePath` and going up the
* tree, return the first `NodePath` that causes the provided `callback`
* to return a truthy value, or `null` if the `callback` never returns a
* truthy value.
*/

export function findParent(callback): ?NodePath {
Expand All @@ -18,7 +20,8 @@ export function findParent(callback): ?NodePath {

/**
* Starting at current `NodePath` and going up the tree, return the first
* `NodePath` that causes the provided `callback` to return a truthy value.
* `NodePath` that causes the provided `callback` to return a truthy value,
* or `null` if the `callback` never returns a truthy value.
*/

export function find(callback): ?NodePath {
Expand Down