UNPKG

eslint-plugin-unicorn

Version:
16 lines (14 loc) 331 B
// TODO: Support more types function getPredicate(options) { if (typeof options === 'string') { return node => node.type === options; } } export default function getAncestor(node, options) { const predicate = getPredicate(options); for (; node.parent; node = node.parent) { if (predicate(node)) { return node; } } }