EventCollector class.

@class EventCollector
@constructor
@param {Number} total  Number of events that must fire.
971248
function(total, timeout) {
  events.EventEmitter.call(this);

  if (! isPositiveInteger(total)) {
    throw new Error('`total` must be a positive integer');
  }

  if (timeout && ! isPositiveInteger(timeout)) {
    throw new Error('`timeout` must be a positive integer');
  }

  this.destroyed = false;
  this.total = total;
	this.fired = 0;
  if (timeout) {
    this.timer = setTimeout(function() {
      this.onTimeout();
    }.bind(this), timeout);
  }
}
920865
function AggregateFunction() {
  var self = this;
  // function type can be one of
  // - simple (default)
  // - ordered - will require window to store elements in arrival and sorted order
  //
  self.type = "simple";
  // invoked when a window opens - should 'reset' or 'zero' a windows internal state
  self.init = function() { throw "Must subclass"; };
  // invoked when an event is enqueued into a window
  self.accumulate = function(value) { throw "Must subclass"; };
  // invoked to compensate sliding window overwrite
  self.compensate = function(value) { throw "Must subclass"; };
  // invoked when a window closes
  self.emit = function() { throw "Must subclass"; };
  // used by window implementations variously to preallocate function instances - makes things 'fast', basically
  self.make = function(win) { throw "Must subclass"; };
}
143866
function(callback) {
  console.log('Removing Checks');
  async.series([
    function(cb) { CheckEvent.collection.remove(cb); },
    function(cb) { Check.collection.remove(cb); }
  ], callback);
}
839149
function(handlers) {
				var h;
						
				if (Basic.typeOf(handlers) !== 'array') {
					handlers = [handlers];
				}

				for (var i = 0; i < handlers.length; i++) {
					h = 'on' + handlers[i];
					
					if (Basic.typeOf(this[h]) === 'function') {
						this.addEventListener(handlers[i], this[h]);
					} else if (Basic.typeOf(this[h]) === 'undefined') {
						this[h] = null; // object must have defined event properties, even if it doesn't make use of them
					}
				}
			}
1030531
function fireEvent (element, type, data) {
  const evt = document.createEvent('Event')
  evt.data = data
  for (const k in data) {
    if (data.hasOwnProperty(k)) {
      evt[k] = data[k]
    }
  }
  // need bubble.
  evt.initEvent(type, true, true)

  element.dispatchEvent(evt)
}
403038
function ObjectCollection(parent) {
    tr.model.EventContainer.call(this);
    this.parent = parent;
    this.instanceMapsById_ = {}; // id -> TimeToObjectInstanceMap
    this.instancesByTypeName_ = {};
    this.createObjectInstance_ = this.createObjectInstance_.bind(this);
  }
808970
function () {
      var eventDict = element.$blaze_events;
      if (! eventDict)
        return;
      // newHandlerRecs has only one item unless you specify multiple
      // event types.  If this code is slow, it's because we have to
      // iterate over handlerList here.  Clearing a whole handlerList
      // via stop() methods is O(N^2) in the number of handlers on
      // an element.
      for (var i = 0; i < newHandlerRecs.length; i++) {
        var handlerToRemove = newHandlerRecs[i];
        var info = eventDict[handlerToRemove.type];
        if (! info)
          continue;
        var handlerList = info.handlers;
        for (var j = handlerList.length - 1; j >= 0; j--) {
          if (handlerList[j] === handlerToRemove) {
            handlerToRemove.unbind();
            handlerList.splice(j, 1); // remove handlerList[j]
          }
        }
      }
      newHandlerRecs.length = 0;
    }
15877
function each(collection, iterator) {
  for (var i = 0; i < collection.length; i++) {
    iterator(collection[i], i);
  }
}
227653
function(events, handler) {
        if (events === undefined) {
            return;
        }
        if (handler === undefined) {
            return;
        }

        var handlers = this.handlers;
        each(splitStr(events), function(event) {
            handlers[event] = handlers[event] || [];
            handlers[event].push(handler);
        });
        return this;
    }
132395
function () {
            this._handler = $B.bind( function (e) {
                var evt = {target: this, img: this.img, data: this._data};
    
                switch (e.type) {
                    case 'load':
                        evt.type = 'complete';
                        this._isComplete = true;
                        this.dispatch( 'complete', evt );
                        break;
                    case 'error':
                        this.dispatch( 'error', evt );
                        break;
                }
    
                this._removeEvents();
            }, this);
        }
312993
function(events){
    events = events || this.events;
    if (_.isFunction(events)){ events = events.call(this); }

    var combinedEvents = {};
    var triggers = this.configureTriggers();
    _.extend(combinedEvents, events, triggers);

    Backbone.View.prototype.delegateEvents.call(this, combinedEvents);
  }
52406
function ( eventName, handler ) {
        var events = this.events[ eventName ],
            handlers = [],
            i;
        if ( !events ) {
            return;
        }
        if ( $.isArray( events ) ) {
            for ( i = 0; i < events.length; i++ ) {
                if ( events[i].handler !== handler ) {
                    handlers.push( events[ i ] );
                }
            }
            this.events[ eventName ] = handlers;
        }
    }
657543
function globalEventHandler(event) {
    if (listeners[event.type]) {
      listeners[event.type].forEach(function(currentHandler) {
        currentHandler.call(this, event);
      }, this);
    }
  }
73247
function createEventTracker (emitter) {
  const events = []
  return {
    on (event, fn) {
      events.push([ event, fn ])
      return emitter.on(event, fn)
    },
    remove () {
      events.forEach(([ event, fn ]) => {
        emitter.off(event, fn)
      })
    }
  }
}
866995
function(target, events) {
      for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
        this.addEvent(target, e);
      }
    }
1155386
function (model, options, eventName) {
        var newModels = slice.call(this.models);
        var comparator = this.comparator || this.collection.comparator;
        //Whether or not we are to expect a sort event from our collection later
        var sortable = eventName === 'add' && this.collection.comparator && (options.at == null) && options.sort !== false;
        if (!sortable) {
            var index = sortedIndexBy(newModels, model, comparator);
            newModels.splice(index, 0, model);
        } else {
            newModels.push(model);
            if (options.at) newModels = this._sortModels(newModels);
        }

        this.models = newModels;
        this._addIndex(this._indexes, model);
        if (this.comparator && !sortable) {
            this.trigger('sort', this);
        }
    }
422414
function addEvent(eventName, {
    onElement,
    withCallback,
    avoidDuplicate = true,
    once = false,
    useCapture = false} = { }, thisArg) {
    let element = onElement || []
    if (utils.isString(element)) {
        element =  document.querySelectorAll(element)
    }
    function handler(event) {
        if (utils.isFunction(withCallback)) {
            withCallback.call(thisArg, event, this)
        }
        if (once) {
            handler.destroy();
        }
    }
    handler.destroy = function() {
        each(element, (el) => {
            const events = getNodeEvents(el, eventName, handler);
            if (events.found) { events.all.splice(events.evt, 1); }
            if (el.removeEventListener) el.removeEventListener(eventName, handler, useCapture)
        })
    }
    each(element, (el) => {
        const events = getNodeEvents(el, eventName, handler);
        if (el.addEventListener && (avoidDuplicate && !events.found) || !avoidDuplicate) {
            el.addEventListener(eventName, handler, useCapture)
            events.all.push({ eventName: eventName, fn: handler});
        }
    })
    return handler
}