Decorator to rename cls.Event 'Event' as 'cls.Event
516444
def name_inner_event(cls):
    """'"""
    if hasattr(cls, 'Event'):
        cls.Event._event_name = '{}.Event'.format(cls.__name__)
    else:
        warnings.warn('Class {} does not have a inner Event'.format(cls))
    return cls
431664
def event(self, **kwargs):
        
        if self.callback.noargs and self.streams == []:
            self.param.warning(
                'No streams declared. To update a DynamicMaps using '
                'generators (or callables without arguments) use streams=[Next()]')
            return
        if self.streams == []:
            self.param.warning('No streams on DynamicMap, calling event '
                               'will have no effect')
            return

        stream_params = set(util.stream_parameters(self.streams))
        invalid = [k for k in kwargs.keys() if k not in stream_params]
        if invalid:
            msg = 'Key(s) {invalid} do not correspond to stream parameters'
            raise KeyError(msg.format(invalid = ', '.join('%r' % i for i in invalid)))

        streams = []
        for stream in self.streams:
            contents = stream.contents
            applicable_kws = {k:v for k,v in kwargs.items()
                              if k in set(contents.keys())}
            if not applicable_kws and contents:
                continue
            streams.append(stream)
            rkwargs = util.rename_stream_kwargs(stream, applicable_kws, reverse=True)
            stream.update(**rkwargs)

        Stream.trigger(streams)
1168279
def RenameFunction(function, name):
    
    return FunctionType(function.__code__,
                        function.__globals__,
                        name,
                        function.__defaults__)
428504
function (name) {
        name = name.toLowerCase()
        if (!this._events || !this._events[name]) return this;
        var args = Array.prototype.slice.call(arguments, 1);
        var events = this._events[name];
        for (var i = 0, count = events.length; i < count; i++) {
            events[i].callback.apply(this, args);
        }
        return this;

    }
1071799
def eventFilter(self, obj, event):
        
        if event.type() == event.Resize:
            self.resize(event.size())
        
        return False
1211379
function (eventName) {
        var event = { type: eventName, target: this },
            handlerList = this._eventHandlers && this._eventHandlers[eventName],
            i;

        if (!handlerList) {
            return;
        }

        // Use a clone of the list in case handlers call on()/off() while we're still in the loop
        handlerList = handlerList.slice();

        // Pass 'event' object followed by any additional args trigger() was given
        var applyArgs = Array.prototype.slice.call(arguments, 1);
        applyArgs.unshift(event);

        for (i = 0; i < handlerList.length; i++) {
            try {
                // Call one handler
                handlerList[i].handler.apply(null, applyArgs);
            } catch (err) {
                console.error("Exception in '" + eventName + "' listener on", this, String(err), err.stack);
                console.assert();  // causes dev tools to pause, just like an uncaught exception
            }
        }
    }
404800
function(obj, eventName, alias) {
    ['addEventListener', 'removeEventListener'].forEach(function(method) {
      var nativeMethod = obj[method];
      obj[method] = function(nativeEventName, cb) {
        if (nativeEventName !== alias) {
          return nativeMethod.apply(this, arguments);
        }
        return nativeMethod.apply(this, [eventName, cb]);
      };
    });

    Object.defineProperty(obj, 'on' + alias, {
      get: function() {
        return this['_on' + alias];
      },
      set: function(cb) {
        if (this['_on' + alias]) {
          this.removeEventListener(alias, this['_on' + alias]);
          delete this['_on' + alias];
        }
        if (cb) {
          this.addEventListener(alias, this['_on' + alias] = cb);
        }
      }
    });
  }
979305
function(eventName, selector, callback) {
        if (!isString(selector)) {
            callback = selector;
            selector = '';
        }

        if (callback) {
            var events = this.events[eventName];
            if (events) {
                events = events[selector];
                if (events) {
                    for (var i = 0; i < events.length; i++) {
                        if (events[i] === callback) {
                            events.splice(i, 1);
                            i--;
                        }
                    }
                }
            }
        } else {
            this.events[eventName][selector] = [];
        }
    }
463803
function(eventName, fn) {
    apos.handlers[eventName] = (apos.handlers[eventName] || []).concat([ fn ]);
  }
657227
function (event, fn) {
		this._events = this._events || {};
		var e = this._events[event];
		if (e) {
			for (var i = 0, l = e.length; i < l; i++) {
				if (e[i][0] === fn) {
					e.splice(i, 1);
					i--;
					l--;
				}
			}
		}
	}
156961
def event_emitter(cls_=None, *, events=('*', )):
    

    # create a dictionary from items in the 'events' parameter and with empty
    # lists as values
    event_dict = dict.fromkeys(events, [])

    # if '*' was in the events tuple - then pop it out of the event_dict
    # and store the fact that we may allow any event name to be added to the
    # event emitter.
    allow_any_eventname = event_dict.pop('*', False) == []

    def _event_emitter(cls):

        def on(self, name, callback):
            """
            Add a callback to the event named 'name'. Returns the object for
            chained 'on' calls.
            """
            if not (callable(callback) or isawaitable(callback)):
                raise ValueError("Callback not callable: %r" % callback)

            try:
                event_dict[name].append(callback)
            except KeyError:
                if allow_any_eventname:
                    event_dict[name] = [callback]
                else:
                    msg = "Event Emitter has no event {!r}".format(name)
                    raise KeyError(msg)

            return self

        async def emit(self, name):
            """
            Coroutine which executes each of the callbacks added to the event
            identified by 'name'
            """
            for cb in event_dict[name]:
                if isawaitable(cb):
                    await cb
                else:
                    cb()

        cls.on = on
        cls.emit = emit

        return cls

    if cls_ is None:
        return _event_emitter
    else:
        return _event_emitter(cls_)
774077
function(events, name, callback, context) {
  // Remove all callbacks for all events.
  if (!events || !name && !context && !callback) return;

  var names = name ? [name] : _.keys(events);
  for (var i = 0, length = names.length; i < length; i++) {
    name = names[i];
    var handlers = events[name];

    // Bail out if there are no events stored.
    if (!handlers) break;

    // Find any remaining events.
    var remaining = [];
    if (callback || context) {
      for (var j = 0, k = handlers.length; j < k; j++) {
        var handler = handlers[j];
        if (
          callback && callback !== handler.callback &&
            callback !== handler.callback._callback ||
              context && context !== handler.context
        ) {
          remaining.push(handler);
        }
      }
    }

    // Replace events if there are any remaining.  Otherwise, clean up.
    if (remaining.length) {
      events[name] = remaining;
    } else {
      delete events[name];
    }
  }
  if (!_.isEmpty(events)) return events;
}
280129
def replace_event_annotations(event, newanns):
    """"""
    _humilis = event.get("_humilis", {})
    if not _humilis:
        event["_humilis"] = {"annotation": newanns}
    else:
        event["_humilis"]["annotation"] = newanns
338081
function(scope, attrs) {
      var events = {};
      var toLowercaseFunc = function($1){
        return "_"+$1.toLowerCase();
      };
      var EventFunc = function(attrValue) {
        // funcName(argsStr)
        var matches = attrValue.match(/([^\(]+)\(([^\)]*)\)/);
        var funcName = matches[1];
        var argsStr = matches[2].replace(/event[ ,]*/,'');  //remove string 'event'
        var argsExpr = $parse("["+argsStr+"]"); //for perf when triggering event
        return function(event) {
          var args = argsExpr(scope); //get args here to pass updated model values
          function index(obj,i) {return obj[i];}
          var f = funcName.split('.').reduce(index, scope);
          f && f.apply(this, [event].concat(args));
          $timeout( function() {
            scope.$apply();
          });
        };
      };

      for(var key in attrs) {
        if (attrs[key]) {
          if (!key.match(/^on[A-Z]/)) { //skip if not events
            continue;
          }

          //get event name as underscored. i.e. zoom_changed
          var eventName = key.replace(/^on/,'');
          eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1);
          eventName = eventName.replace(/([A-Z])/g, toLowercaseFunc);

          var attrValue = attrs[key];
          events[eventName] = new EventFunc(attrValue);
        }
      }
      return events;
    }
734674
def add_event(self, func: Callable, event: str) -> None:
        
        self._events[event].add(func)
625874
function processEventName(eventName) {
  // bindtap => onTap
  // tap => onTap
  if (eventName.startsWith('bind') || !eventName.startsWith('on')) {
    return eventName.replace(/^(bind){0,1}(.*)/, (g, $1, $2) => {
      return `on${$2[0].toUpperCase()}${$2.slice(1)}`
    })
  }
  return eventName
}
511964
def for_events(*events):
    
    events = set(events)

    def wrap(func):
        func.event_types = events
        return func

    return wrap