Skip to content

Latest commit

History

History
36 lines (29 loc) 路 1.26 KB

File metadata and controls

36 lines (29 loc) 路 1.26 KB

ANGULARJS

LEARN

LIBS

FILTER

// usage ex: | numLower:'pScore':'0.1'
app.filter('numLower', function () {
    return function (items, key, num) {
        return items.filter(item => item[key] <= num);
    }
});
// usage ex: | pValueFilter:true:'0.1'
app.filter('pValueFilter', function () {
    return function (items, isTested, thresholdLevel) {
        const res = isTested === true && thresholdLevel ?
            items?.filter(item => item.pCount > 0 && item.pScore <= thresholdLevel) :
            // isTested && !thresholdLevel ? items?.filter(item => item.pCount > 0) :
            isTested === false ? items?.filter(item => item.pCount === 0) : items;
        // console.log('馃殌 ~ pValueFilter:', { isTested, thresholdLevel, arrIn: items?.length, arrOut: res?.length});
        return res ?? [];
    }
});