/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const util = require('util');

function Filter(filter) {
  // valid filters: regexp, string, function
  var type = typeof filter;
  if (type === 'function') {
    this._filter = filter;
  } else if (type === 'string') {
    this._filter = function(record) {
      if (filter === record.name) {
        return true;
      } else if (record.name.indexOf(filter) === -1) {
        return false;
      } else {
        return record.name[filter.length] === '.';
      }
    };
  } else if (util.isRegExp(filter)) {
    this._filter = function(record) {
      return filter.test(record.message);
    };
  }
}

Filter.prototype = {

  filter: function(record) {
    return this._filter(record);
  }

};

module.exports = Filter;

@@ -359,33 +359,32 @@
 on') %7B%0A    this.
-_
 filter = filter;
@@ -384,16 +384,16 @@
 filter;%0A
+
   %7D else
@@ -419,33 +419,32 @@
 ng') %7B%0A    this.
-_
 filter = functio
@@ -436,32 +436,43 @@
 ilter = function
+ nameFilter
 (record) %7B%0A     
@@ -724,25 +724,24 @@
  %7B%0A    this.
-_
 filter = fun
@@ -737,32 +737,45 @@
 ilter = function
+ regexpFilter
 (record) %7B%0A     
@@ -866,30 +866,24 @@
 unction(
-record
 ) %7B%0A    
 return t
@@ -878,34 +878,54 @@
     
-return this._filter(record
+throw new Error('Filter type was not defined.'
 );%0A 

remove a function call from Filter#filter