Sha256: 5fda0cc795c51dc64d34ea3c677ebaf5bf5cdc2b764b8f64505b9d9a2ca684d4

Contents?: true

Size: 304 Bytes

Versions: 13

Compression:

Stored size: 304 Bytes

Contents

function hasAncestor(path, types) {
  let parent = 0;
  let parentNode = path.getParentNode();

  while (parentNode) {
    if (types.includes(parentNode.type)) {
      return true;
    }

    parent += 1;
    parentNode = path.getParentNode(parent);
  }

  return false;
}

module.exports = hasAncestor;

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prettier-1.6.1 src/utils/hasAncestor.js
prettier-1.6.0 src/utils/hasAncestor.js
prettier-1.5.5 src/utils/hasAncestor.js
prettier-1.5.4 src/utils/hasAncestor.js
prettier-1.5.3 src/utils/hasAncestor.js
prettier-1.5.2 src/utils/hasAncestor.js
prettier-1.5.1 src/utils/hasAncestor.js
prettier-1.5.0 src/utils/hasAncestor.js
prettier-1.4.0 src/utils/hasAncestor.js
prettier-1.3.0 src/utils/hasAncestor.js
prettier-1.2.5 src/utils/hasAncestor.js
prettier-1.2.4 src/utils/hasAncestor.js
prettier-1.2.3 src/utils/hasAncestor.js