samples/custom.js
function(regex) {
  var self = this; var re = new RegExp(regex);
  var keys = {};
  self.init = function() { keys = {}; };
  self.accumulate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v+1; else keys[k] = 1; // count by key
  };
  self.compensate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v-1; else keys[k] = 1;
  };
  self.emit = function() {
    return keys;
  };
  self.make = function() { return new WideFinderFunction(regex); };
}
function(regex) {
  var self = this; var re = new RegExp(regex);
  var keys = {};
  self.init = function() { keys = {}; };
  self.accumulate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v+1; else keys[k] = 1; // count by key
  };
  self.compensate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v-1; else keys[k] = 1;
  };
  self.emit = function() {
    return keys;
  };
  self.make = function() { return new WideFinderFunction(regex); };
}
function ( regex ) { var self = this ; var re = new RegExp ( regex ) ; var keys = { } ; self . init = function ( ) { keys = { } ; } ; self . accumulate = function ( line ) { var m = re . exec ( line ) ; if ( m == null ) return ; var k = m [ 1 ] ; // use 1st group as key var v = keys [ k ] ; if ( v ) keys [ k ] = v + 1 ; else keys [ k ] = 1 ; // count by key } ; self . compensate = function ( line ) { var m = re . exec ( line ) ; if ( m == null ) return ; var k = m [ 1 ] ; // use 1st group as key var v = keys [ k ] ; if ( v ) keys [ k ] = v - 1 ; else keys [ k ] = 1 ; } ; self . emit = function ( ) { return keys ; } ; self . make = function ( ) { return new WideFinderFunction ( regex ) ; } ; }
Widefinder aggregate function
Widefinder aggregate function