emitter.js
function( type, handler ) {

      if( handler === void 0 || handler === null )
        throw new Error( 'Missing argument "handler"' )

      if( typeof handler !== 'function' && typeof handler.handleEvent !== 'function' )
        throw new TypeError( 'Handler must be a function.' )

      this._events[ type ] ?
        this._events[ type ].push( handler ) :
        this._events[ type ] = [ handler ]

      if( Emitter.warn && this._events[ type ].length > this._maxListeners ) {
        if( this._maxListeners > 0 && !this._memLeakDetected ) {
          this._memLeakDetected = true
          console.warn(
            'WARNING: Possible event emitter memory leak detected.',
            this._events[ type ].length, 'event handlers added.',
            'Use emitter.setMaxListeners() to increase the threshold.'
          )
          console.trace()
        }
      }

      return this

    }
function( type, handler ) {

      if( handler === void 0 || handler === null )
        throw new Error( 'Missing argument "handler"' )

      if( typeof handler !== 'function' && typeof handler.handleEvent !== 'function' )
        throw new TypeError( 'Handler must be a function.' )

      this._events[ type ] ?
        this._events[ type ].push( handler ) :
        this._events[ type ] = [ handler ]

      if( Emitter.warn && this._events[ type ].length > this._maxListeners ) {
        if( this._maxListeners > 0 && !this._memLeakDetected ) {
          this._memLeakDetected = true
          console.warn(
            'WARNING: Possible event emitter memory leak detected.',
            this._events[ type ].length, 'event handlers added.',
            'Use emitter.setMaxListeners() to increase the threshold.'
          )
          console.trace()
        }
      }

      return this

    }
function ( type , handler ) { if ( handler === void 0 || handler === null ) throw new Error ( 'Missing argument "handler"' ) if ( typeof handler !== 'function' && typeof handler . handleEvent !== 'function' ) throw new TypeError ( 'Handler must be a function.' ) this . _events [ type ] ? this . _events [ type ] . push ( handler ) : this . _events [ type ] = [ handler ] if ( Emitter . warn && this . _events [ type ] . length > this . _maxListeners ) { if ( this . _maxListeners > 0 && ! this . _memLeakDetected ) { this . _memLeakDetected = true console . warn ( 'WARNING: Possible event emitter memory leak detected.' , this . _events [ type ] . length , 'event handlers added.' , 'Use emitter.setMaxListeners() to increase the threshold.' ) console . trace ( ) } } return this }
Adds a listener for the specified event
@param  {String}   type
@param  {Function} handler
@return {Emitter}
Adds a listener for the specified event