closest: function()

in src/collections/Node.js [76:90]


  closest: function(type, filter) {
    return this.map(function(path) {
      let parent = path.parent;
      while (
        parent &&
        !(
          type.check(parent.value) &&
          (!filter || matchNode(parent.value, filter))
        )
      ) {
        parent = parent.parent;
      }
      return parent || null;
    });
  },