Skip to content

Commit

Permalink
docs: updates docs of findParent and find (#10479) [skip ci]
Browse files Browse the repository at this point in the history
Makes the documentation of `findParent` and `find` consistent and documents their `null` cases.
  • Loading branch information
TomerAberbach authored and nicolo-ribaudo committed Sep 22, 2019
1 parent b7333ea commit 962015f
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 962015f

Please sign in to comment.