Skip to content

Latest commit

 

History

History
28 lines (25 loc) · 1.14 KB

File metadata and controls

28 lines (25 loc) · 1.14 KB

ANGULARJS

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 ?? [];
    }
});