Вход Регистрация
Файл: error-kitty/node_modules/cheerio/node_modules/CSSselect/lib/sort.js
Строк: 31
<?php
module
.exports sortByProcedure;

/*
    sort the parts of the passed selector,
    as there is potential for optimization
    (some types of selectors are faster than others)
*/

var ATTRIBUTE 1;

var 
procedure = {
    
__proto__null,
    
universal5//should be last so that it can be ignored
    
tag3//very quick test
    
attributeATTRIBUTE,
    
pseudo0//can be pretty expensive (especially :has)

    //everything else shouldn't be moved
    
descendant: -1,
    
child: -1,
    
parent: -1,
    
sibling: -1,
    
adjacent: -1
};

var 
attributes = {
    
__proto__null,
    
exists8,
    
equals7,
    
not6,
    
start5,
    
end4,
    
any3,
    
hyphen2,
    
element1
};

function 
sortByProcedure(arr){
    for(var 
1arr.lengthi++){
        var 
procNew procedure[arr[i].type];

        if(
procNew 0) continue;

        for(var 
1>= 0j--){
            if(
                
procNew procedure[arr[j].type] || !(
                    
procNew === ATTRIBUTE &&
                    
procedure[arr[j].type] === ATTRIBUTE &&
                    
attributes[arr[i].action] <= attributes[arr[j].action]
                )
            ) break;

            var 
tmp arr[1];
            
arr[1] = arr[j];
            
arr[j] = tmp;
        }
    }
    return 
arr;
}
?>
Онлайн: 1
Реклама