ilyabogdanov/zen-ui-angularjs · components.js
javascript logo
function () {
        return function(input, filterString, textParam) {
            if (!filterString) {
                return input;
            }
            filterString = ".*" + filterString.toLowerCase().split(" ").join(".*");
            var regex = new RegExp(filterString, 'i'), output = [];
            angular.forEach(input, function(item) {
                if (regex.test(item[textParam])) {
                    output.push(item);
                }
            });
            return output;
        };
    }
Similar code snippets
1.
kchapelier/ngram-word-generator · ngram-process.js
Match rating: 55.45% · See similar code snippets
javascript logo
function preProcessString (string, config) {
    string = string.toLowerCase();

    if (config.filter) {
        var filterRegex = null;

        if (config.filter instanceof RegExp) {
            filterRegex = config.filter
        } else if (filters.hasOwnProperty(config.filter)) {
            filterRegex = filters[config.filter];
        } else {
            filterRegex = stringToRegExp(config.filter);
        }

        if (filterRegex) {
            string = string.replace(filterRegex, ' ');
        }
    }

    var strings = string.split(/\s+/).filter(function (v) {
        return v.length > 0;
    });

    if (config.minLength) {
        strings = strings.filter(function (v) {
            return v.length > config.minLength;
        });
    }

    if (config.unique) {
        uniq(strings);
    }

    return strings;
}
2.
MorganConrad/metalsmith-inspect · inspect.js
Match rating: 55.22% · See similar code snippets
javascript logo
function fileFilter(filter) {
  if (filter) {
     if (typeof filter === 'string') {
        var regex = new RegExp(filter);
        return function(filePath) { return regex.test(filePath); }
     }
     else if (filter instanceof RegExp)
        return function(filePath) { return filter.test(filePath); }
     else {   // must be a function itself
        return filter;
     }
   }
   else  // none, return "pass all"
      return function() { return true; };
}
3.
MorganConrad/metalsmith-keymaster · keymaster.js
Match rating: 54.46% · See similar code snippets
javascript logo
function computeFilterFn(filter) {
     if (filter) {
        if (typeof filter === 'string') {
           var regex = new RegExp(filter);
           return function(filePath) { return regex.test(filePath); }
        }
        else if (filter instanceof RegExp)
           return function(filePath) { return filter.test(filePath); }
        else   // must be a function itself
           return filter;
      }
      else  // none, return "pass all"
         return function() { return true; };
   }
4.
apigee-internal/rbac-abacus · fsWalker.js
Match rating: 54.17% · See similar code snippets
javascript logo
function matcher (filter) {
    if (!filter) {
        return cTrue;
    }
    if (typeof filter === 'string') {
        return matchRegex(new RegExp(filter));
    }
    if (typeof filter === 'function') {
        return filter;
    }
    if (typeof filter.test === 'function') {
        return matchRegex(filter);
    }
    return cTrue;
}
5.
deftly/node-deftly · log.js
Match rating: 52.87% · See similar code snippets
javascript logo
function addFilter (config, filter) {
  if (filter) {
    if (filter[ 0 ] === '-') {
      config.filters.ignore[ filter ] = new RegExp('^' + filter.slice(1).replace(/[*]/g, '.*?') + '$')
    } else {
      config.filters.should[ filter ] = new RegExp('^' + filter.replace(/[*]/g, '.*?') + '$')
    }
  }
}
6.
marcelpuyat/html-stemmer · index.js
Match rating: 52.68% · See similar code snippets
javascript logo
function filterDataString(dataString) {
		var regexFilter;

		for (var i = 0; i < regexFilters.length; i++) {
			regexFilter = regexFilters[i];
			dataString = dataString.replace(regexFilter.regex, regexFilter.replacement);
		}

		return dataString;
	}
7.
TonyGermaneri/canvas-datagrid · intf.js
Match rating: 52.43% · See similar code snippets
javascript logo
function (value, filterFor) {
                value = String(value);
                var filterRegExp,
                    regEnd = /\/(i|g|m)*$/,
                    pattern = regEnd.exec(filterFor),
                    flags = pattern ? pattern[0].substring(1) : '',
                    flagLength = flags.length;
                self.invalidFilterRegEx = undefined;
                if (filterFor.substring(0, 1) === '/' && pattern) {
                    try {
                        filterRegExp = new RegExp(filterFor.substring(1, filterFor.length - (flagLength + 1)), flags);
                    } catch (e) {
                        self.invalidFilterRegEx = e;
                        return;
                    }
                    return filterRegExp.test(value);
                }
                return value.toString ? value.toString().toLocaleUpperCase()
                    .indexOf(filterFor.toLocaleUpperCase()) !== -1 : false;
            }
8.
easylogic/codemirror-colorpicker · codemirror-colorpicker.js
Match rating: 51.42% · See similar code snippets
javascript logo
function flatFilter(filterString) {

    var filter_list = [];

    if (typeof filterString == 'string') {
        filter_list = matches$1(filterString);
    } else if (Array.isArray(filterString)) {
        filter_list = filterString;
    }

    var allFilter = [];

    filter_list.forEach(function (filterObj) {
        var filterName = filterObj.arr[0];

        if (GLFilter[filterName]) {
            var f = makeFilterFunction(filterObj);

            if (f.type == 'convolution' || f.type == 'shader') {
                allFilter.push(f);
            } else {
                f.forEach(function (subFilter) {
                    allFilter = allFilter.concat(flatFilter(subFilter));
                });
            }
        }
    });

    // console.log(filter_list, allFilter)

    return allFilter;
}
9.
TeselaGen/teselagen-react-components · queryParams.js
Match rating: 50.73% · See similar code snippets
javascript logo
function getAndAndOrFilters(allFilters) {
  const orFilters = [];
  const andFilters = [];
  const otherOrFilters = [];
  allFilters.forEach(filter => {
    if (
      filter.isOrFilter &&
      typeof filter.filterValue === "string" &&
      filter.filterValue.includes(",")
    ) {
      // handle comma separated filters by adding more orWheres
      const allFilterValues = filter.filterValue.split(",");
      allFilterValues.forEach((filterValue, i) => {
        filterValue = filterValue.trim();
        if (!filterValue) return;
        const newFilter = {
          ...filter,
          filterValue
        };
        if (i === 0) {
          orFilters.push(newFilter);
        } else {
          const iMinus = i - 1;
          if (!otherOrFilters[iMinus]) otherOrFilters[iMinus] = [];
          otherOrFilters[iMinus].push(newFilter);
        }
      });
    } else if (filter.isOrFilter) {
      orFilters.push(filter);
    } else {
      andFilters.push(filter);
    }
  });
  return {
    orFilters,
    andFilters,
    otherOrFilters
  };
}
10.
onechiporenko/ember-models-table · models-table.js
Match rating: 50.55% · See similar code snippets
javascript logo
function (row) {
      return filtersFor.any(filterFor => {
        let cellValue = '' + get(row, filterFor);
        if (filteringIgnoreCase) {
          cellValue = cellValue.toLowerCase();
        }
        return -1 !== cellValue.indexOf(filterString);
      });
    }