lib/index.js
function on(evt, handler) {
            var _this = this;

            var thisArg = arguments[2] === undefined ? null : arguments[2];

            // if multiple events are passed, call our utility method `eachEvt` to deal with this.
            // if it returns `true`, we should exit, because we're actually being called recursively.
            // If it returns `false`, we're not being called with multiple parameters (this time, anyway),
            // and so can continue processing.
            if (eachEvt(evt, handler, thisArg, function () {
                for (var _len2 = arguments.length, _ = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
                    _[_key2] = arguments[_key2];
                }

                return _this.on.apply(_this, _);
            })) {
                return this;
            } // simplify typing; eH = eventHandlers
            var eH = this[_eventHandlers];

            if (!eH.has(evt)) {
                // if we don't have an event category already in the map, create it as a new map
                // this map will be of the form bindingObject:methods.
                eH.set(evt, new core.Map());
            }

            // simplify typing; objMap == objectMap (bindingObject:methods)
            var objMap = eH.get(evt);

            if (!objMap.has(thisArg)) {
                // if we don't have `thisArg` in the map, make a set for it. The set is the set of functions
                // and we use a set so as to prevent duplicates automatically.
                objMap.set(thisArg, new core.Set());
            }
            var handlerSet = objMap.get(thisArg);

            if (typeof handler === "function") {
                // add the handler
                handlerSet.add(handler);
            } else {
                // a little error checking!
                throw new TypeError("Event handler must be a function.");
            }

            return this;
        }
function on(evt, handler) {
            var _this = this;

            var thisArg = arguments[2] === undefined ? null : arguments[2];

            // if multiple events are passed, call our utility method `eachEvt` to deal with this.
            // if it returns `true`, we should exit, because we're actually being called recursively.
            // If it returns `false`, we're not being called with multiple parameters (this time, anyway),
            // and so can continue processing.
            if (eachEvt(evt, handler, thisArg, function () {
                for (var _len2 = arguments.length, _ = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
                    _[_key2] = arguments[_key2];
                }

                return _this.on.apply(_this, _);
            })) {
                return this;
            } // simplify typing; eH = eventHandlers
            var eH = this[_eventHandlers];

            if (!eH.has(evt)) {
                // if we don't have an event category already in the map, create it as a new map
                // this map will be of the form bindingObject:methods.
                eH.set(evt, new core.Map());
            }

            // simplify typing; objMap == objectMap (bindingObject:methods)
            var objMap = eH.get(evt);

            if (!objMap.has(thisArg)) {
                // if we don't have `thisArg` in the map, make a set for it. The set is the set of functions
                // and we use a set so as to prevent duplicates automatically.
                objMap.set(thisArg, new core.Set());
            }
            var handlerSet = objMap.get(thisArg);

            if (typeof handler === "function") {
                // add the handler
                handlerSet.add(handler);
            } else {
                // a little error checking!
                throw new TypeError("Event handler must be a function.");
            }

            return this;
        }
function on ( evt , handler ) { var _this = this ; var thisArg = arguments [ 2 ] === undefined ? null : arguments [ 2 ] ; // if multiple events are passed, call our utility method `eachEvt` to deal with this. // if it returns `true`, we should exit, because we're actually being called recursively. // If it returns `false`, we're not being called with multiple parameters (this time, anyway), // and so can continue processing. if ( eachEvt ( evt , handler , thisArg , function ( ) { for ( var _len2 = arguments . length , _ = Array ( _len2 ) , _key2 = 0 ; _key2 < _len2 ; _key2 ++ ) { _ [ _key2 ] = arguments [ _key2 ] ; } return _this . on . apply ( _this , _ ) ; } ) ) { return this ; } // simplify typing; eH = eventHandlers var eH = this [ _eventHandlers ] ; if ( ! eH . has ( evt ) ) { // if we don't have an event category already in the map, create it as a new map // this map will be of the form bindingObject:methods. eH . set ( evt , new core . Map ( ) ) ; } // simplify typing; objMap == objectMap (bindingObject:methods) var objMap = eH . get ( evt ) ; if ( ! objMap . has ( thisArg ) ) { // if we don't have `thisArg` in the map, make a set for it. The set is the set of functions // and we use a set so as to prevent duplicates automatically. objMap . set ( thisArg , new core . Set ( ) ) ; } var handlerSet = objMap . get ( thisArg ) ; if ( typeof handler === "function" ) { // add the handler handlerSet . add ( handler ) ; } else { // a little error checking! throw new TypeError ( "Event handler must be a function." ) ; } return this ; }
Registers a handler for one or more events bound to `thisArg`.
@param {string|Array<string>|Object} evt
@param {function} [handler]
@param {Object} [thisArg]
@throws {TypeError}
@returns {Emitter}
Registers a handler for one or more events bound to thisArg .