lib/util/node-event-generator.js
function countIdentifiers(parsedSelector) {
    switch (parsedSelector.type) {
        case "child":
        case "descendant":
        case "sibling":
        case "adjacent":
            return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);

        case "compound":
        case "not":
        case "matches":
            return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);

        case "identifier":
            return 1;

        default:
            return 0;
    }
}
function countIdentifiers(parsedSelector) {
    switch (parsedSelector.type) {
        case "child":
        case "descendant":
        case "sibling":
        case "adjacent":
            return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);

        case "compound":
        case "not":
        case "matches":
            return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);

        case "identifier":
            return 1;

        default:
            return 0;
    }
}
function countIdentifiers ( parsedSelector ) { switch ( parsedSelector . type ) { case "child" : case "descendant" : case "sibling" : case "adjacent" : return countIdentifiers ( parsedSelector . left ) + countIdentifiers ( parsedSelector . right ) ; case "compound" : case "not" : case "matches" : return parsedSelector . selectors . reduce ( ( sum , childSelector ) => sum + countIdentifiers ( childSelector ) , 0 ) ; case "identifier" : return 1 ; default : return 0 ; } }
Counts the number of identifier queries in this selector
@param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
@returns {number} The number of identifier queries
Counts the number of identifier queries in this selector