# All files / src/utils has-node.js

100% Statements 7/7
100% Branches 6/6
100% Functions 3/3
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    2672x

    81x
    2773x
    101x

    2672x

    81x

     // @flow
    import type { NodeType } from "../flow/types";

    export default function hasNode(Type: string, ast: NodeType) {
      const test = node => node && node.Type === Type;

      const walker = node => {
        if (node == null) {
          return false;
        }

        return test(node) || node.params.some(walker);
      };

      return walker(ast);
    }