-- Listener type -- func - a function accepting a callback of error and element max_exec - A maximum number of elements executing
519542
function Listener(func, max_out) {
  this._func = func;
  this._max = max_out || 0;
  this._out = 0;
  this._end = false;
  this._ended = false;
  this._listening = false;

  var self = this;

  this.on('done', function () {
    self._out = Math.max(self._out - 1, 0);

    if (self._end && self._out === 0 && !self._listenning) {
      self.emit('end'); // We are ready to end
    }

    self.start();
  });

  this.on('end', function () {
    this._ended = true;
  });
}
1313709
function setListener(callback) {
    if (onFinish) {
      throw new Error('thenDo/finally called more than once');
    }
    if (finished) {
      onFinish = function() {};
      callback(finished.err, finished.result);
    } else {
      onFinish = function() {
        callback(finished.err, finished.result);
      };
    }
  }
1230451
function CallbackHandler(callable) {
    CallbackHandler.super_.call(this);

    if (!_.isFunction(callable)) {
        throw new TypeError(
            'Argument  must be valid callable'
        );
    }

    this.__callable = callable;
}
563815
function (keyOrList, func) { // alias: `bind`
				listeners.unshift({ keys: toArray(keyOrList), cb: func,
					calls: Infinity });
				return me;
			}
800202
function( type ) {

      var emitter = this
      var listeners = this._events[ type ]

      if( type === 'error' && !listeners ) {
        if( !this._events.error ) {
          throw !( arguments[1] instanceof Error ) ?
            new Error( 'Unhandled "error" event.' ) :
            arguments[1]
        }
      } else if( !listeners ) {
        return false
      }

      var argv = [].slice.call( arguments, 1 )
      var i, len = listeners.length

      function fire( handler, argv ) {
        typeof handler !== 'function' ?
          handler.handleEvent.apply( handler, argv ) :
          handler.apply( this, argv )
      }

      for( i = 0; i < len; i++ ) {
        Emitter.nextTick(
          fire.bind( this, listeners[i], argv )
        )
      }

      return true

    }
1287620
function Callback (retType, argTypes, abi, func) {
  debug('creating new Callback');

  if (typeof abi === 'function') {
    func = abi;
    abi = undefined;
  }

  // check args
  assert(!!retType, 'expected a return "type" object as the first argument');
  assert(Array.isArray(argTypes), 'expected Array of arg "type" objects as the second argument');
  assert.equal(typeof func, 'function', 'expected a function as the third argument');

  // normalize the "types" (they could be strings, so turn into real type
  // instances)
  retType = ref.coerceType(retType);
  argTypes = argTypes.map(ref.coerceType);

  // create the `ffi_cif *` instance
  const cif = CIF(retType, argTypes, abi);
  const argc = argTypes.length;

  const callback = _Callback(cif, retType.size, argc, errorReportCallback, (retval, params) => {
    debug('Callback function being invoked')
    try {
      const args = [];
      for (var i = 0; i < argc; i++) {
        const type = argTypes[i];
        const argPtr = params.readPointer(i * ref.sizeof.pointer, type.size);
        argPtr.type = type;
        args.push(argPtr.deref());
      }

      // Invoke the user-given function
      const result = func.apply(null, args);
      try {
        ref.set(retval, 0, result, retType);
      } catch (e) {
        e.message = 'error setting return value - ' + e.message;
        throw e;
      }
    } catch (e) {
      return e;
    }
  });

  return callback;
}
650204
function listeners(type) {
      var object = this,
          events = object.events || (object.events = {});

      return _.has(events, type) ? events[type] : (events[type] = []);
    }
347654
function listeners(type) {
    var me = this,
        events = me.events || (me.events = {});

    return hasKey(events, type) ? events[type] : (events[type] = []);
  }
918863
function createEventEmitterCallback(event, emitter) {
    return function (ex) {
        if (ex) {
            emitter.emit('error', ex);
        } else {
            var args = Array.prototype.slice.call(arguments);
            args[0] = event;
            emitter.emit.apply(emitter, args);
            if (event == 'end') {
                emitter.removeAllListeners();
            }
        }
    };
}
73782
function (events, func) {
    for (var i = 0; i < events.length; i++) {
      obj.once(events[i], func)
      listeners[events[i]] = func
    }
  }
1003104
function(a,b,c,d,e,f,g,h) {
            //console.log("running callback function", a, that, moduleId);
            // store the value
            that.execValues[moduleId] = {
               output: [a,b,c,d,e,f,g,h]
            };
            
            that.executeModules(moduleId, "output");
         }
1185769
def add_handler(self, func, type='all'):
        
        if not callable(func):
            raise ValueError("{} is not callable".format(func))

        self._handlers[type].append(
            (func, len(signature(func).parameters.keys()))
        )
517313
function(el, type, func) {
      if(el.addEventListener) {
        el.addEventListener(type, func, false);
      } else if(el.attachEvent){ 
        el.attachEvent('on' + type, func);
      } else{ 
        el['on' + type] = func; 
      }  
    }
1189167
function execCallbacks(object) {
        if (object.hasClass('active')) {
          if (typeof(options.onOpen) === "function") {
            options.onOpen.call(this, object.parent());
          }
        } else {
          if (typeof(options.onClose) === "function") {
            options.onClose.call(this, object.parent());
          }
        }
      }
1164520
function exec (func, context, args) {
	switch (args.length) {
		case 0: func.call(context); break;
		case 1: func.call(context, args[0]); break;
		case 2: func.call(context, args[0], args[1]); break;
		case 3: func.call(context, args[0], args[1], args[2]); break;
		case 4: func.call(context, args[0], args[1], args[2], args[3]); break;
		default: func.apply(context, args); break;
	}
}
433073
function onListen(type, err, server) {
    servers[type] = server || true;
    if (err) {
      errors[type] = err;
    }

    if (servers.http && servers.https) {
      Object.keys(servers)
        .forEach(function (key) {
          if (typeof servers[key] === 'boolean') {
            delete servers[key];
          }
        });

      if (errors.http || errors.https) {
        return listening(errs.create({
          message: (errors.https || errors.http).message,
          https: errors.https,
          http:  errors.http
        }), servers);
      }

      listening(undefined, servers);
    }
  }
884820
public void putListener(CallbackType callbackType, Method method) {
    if (callbacks == null) {
      callbacks = new EnumMap<>(CallbackType.class);
    }
    Method oldMethod = callbacks.put(callbackType, method);
    if (oldMethod != null) {
      String format = "Class %s has at least two methods, %s and %s, with annotation of %s. "
          + "At most one method is allowed for a given callback type. ";
      String message = String.format(format, listenerClass.getName(), oldMethod.getName(),
          method.getName(), callbackType.getAnnotationClass().getName());
      throw new EntityManagerException(message);
    }
  }