import { guards, getKindNameFromNode } from './traversals';
export function find(node, predicate) {
    var nodes = [];
    if (!node) {
        return nodes;
    }
    if (predicate(node)) {
        nodes.push(node);
    }
    node.forEachChild(function (n) {
        nodes.push.apply(nodes, find(n, predicate));
    });
    return nodes;
}
var t;
// @ts-ignore
t = function (node) {
    return {
        find: function (kind, predicate) {
            if (predicate === void 0) { predicate = function (n) { return true; }; }
            return find(node, function (n) { return guards["is" + kind](n) && predicate(n); });
        },
    };
};
t.getKindNameFromNode = getKindNameFromNode;
Object.keys(guards).forEach(function (key) {
    // @ts-ignore
    t[key] = guards[key];
});
export default t;
