import { guards, getKindNameFromNode } from './traversals';
export function find(node, predicate) {
    const nodes = [];
    if (!node) {
        return nodes;
    }
    if (predicate(node)) {
        nodes.push(node);
    }
    node.forEachChild(n => {
        nodes.push(...find(n, predicate));
    });
    return nodes;
}
let t;
// @ts-ignore
t = node => {
    return {
        find(kind, predicate = n => true) {
            return find(node, n => guards[`is${kind}`](n) && predicate(n));
        },
    };
};
t.getKindNameFromNode = getKindNameFromNode;
Object.keys(guards).forEach(key => {
    // @ts-ignore
    t[key] = guards[key];
});
export default t;
