util.js
function(settings, filters, allowed) {
  if (filters.length > 0) {
    _.each(filters, function(obj) {
      if (!_.has(obj, 'word')) {
        return;
      }
      if (!_.has(obj, 'pattern')) {
        // configure existing filter options
        var filter = _.findWhere(settings.filters, { word: obj.word });
        if (!_.isUndefined(filter)) {
          filter.configure(obj);
        }
      } else if (!_.contains(allowed, obj.word)) {
        // if filter word isn't whitelisted, add as new GrawlixFilter
        settings.filters.push( toGrawlixFilter(obj) );
      }
    });
  }
  return settings;
}
function(settings, filters, allowed) {
  if (filters.length > 0) {
    _.each(filters, function(obj) {
      if (!_.has(obj, 'word')) {
        return;
      }
      if (!_.has(obj, 'pattern')) {
        // configure existing filter options
        var filter = _.findWhere(settings.filters, { word: obj.word });
        if (!_.isUndefined(filter)) {
          filter.configure(obj);
        }
      } else if (!_.contains(allowed, obj.word)) {
        // if filter word isn't whitelisted, add as new GrawlixFilter
        settings.filters.push( toGrawlixFilter(obj) );
      }
    });
  }
  return settings;
}
function ( settings , filters , allowed ) { if ( filters . length > 0 ) { _ . each ( filters , function ( obj ) { if ( ! _ . has ( obj , 'word' ) ) { return ; } if ( ! _ . has ( obj , 'pattern' ) ) { // configure existing filter options var filter = _ . findWhere ( settings . filters , { word : obj . word } ) ; if ( ! _ . isUndefined ( filter ) ) { filter . configure ( obj ) ; } } else if ( ! _ . contains ( allowed , obj . word ) ) { // if filter word isn't whitelisted, add as new GrawlixFilter settings . filters . push ( toGrawlixFilter ( obj ) ) ; } } ) ; } return settings ; }
Loads an array of filter objects into the GrawlixSettings object
@param  {GrawlixSettings} settings GrawlixSettings object
@param  {Array}           filters  Array of filter objects
@param  {Array}           allowed  Whitelist of words to ignore
@return {GrawlixSettings}          Settings objects with filters added
Loads an array of filter objects into the GrawlixSettings object