all files / javascript/ software.bytepushers.filters.GenericPropertyFilter.js

90.48% Statements 19/21
70% Branches 7/10
100% Functions 5/5
100% Lines 18/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                 
/*global BytePushers, console*/
/*jslint unparam: true*/
(function (BytePushers) {
    'use strict';
    BytePushers = BytePushers || {};
    BytePushers.filters = BytePushers.namespace("software.bytepushers.filters");
    BytePushers.filters.GenericProptertyFilter = BytePushers.namespace("software.bytepushers.filters.GenericProptertyFilter");
 
    BytePushers.filters.GenericProptertyFilter.DatePropteryFilter = function (values, date, propertyName) {
        Iif (!Object.isArray(values)) { return; }
        var filteredDates = [];
 
        values.forEach(function (value, index, values) {
            if (value[propertyName].valueOf() === date.valueOf()) {
                filteredDates.push(value);
            }
        });
 
        return filteredDates;
    };
 
    BytePushers.filters.GenericProptertyFilter.StringPropteryFilter = function (values, searchText, propertyName) {
        Iif (!Object.isArray(values)) { return; }
        var filtered = [];
        searchText = searchText.toLowerCase();
 
        values.forEach(function (value, index, values) {
            if (value[propertyName].toLowerCase().indexOf(searchText) >= 0) { filtered.push(value); }
        });
 
        return filtered;
    };
}(BytePushers));
/*jslint unparam: false*/