Adds a callback that gets passed any extra varargs as a arguments
@chainable
431933
public function callback($callback)
    {
        $t = $this;
        $args = array_slice(func_get_args(),1);

        // use an event handler to dispatch to the callback
        $this->_events->register('startTransaction', function($event, $connection) use ($t, $callback, $args) {
            $t->results []= call_user_func_array($callback, $args);
        });

        return $this;
    }
1250315
def add_func(self, callback, names, *args):
        

        if isinstance(names, list):
            for name in names:
                self.add_func(callback, name, *args)
                self.aliases[name] = names
        elif isinstance(names, str):
            if names in self.cmds or names in self.clis:
                raise ValueError('Attempting to overwrite cmd or extern CLI: %s' % names)
            parser = argparse.ArgumentParser(prog=names)
            for cmd, spec in args:
                parser.add_argument(cmd, **spec)
            self.cmds[names] = (callback, parser)
        else:
            raise TypeError("Command must be specified by str name or list of names")
878248
def call_with_asked_args(callback, args):
    
    # FIXME: support default args
    # FIXME: support kwargs
    # co_varnames contains both args and local variables, in order. 
    # We only pick the local variables
    asked_arg_names = callback.__code__.co_varnames[:callback.__code__.co_argcount]
    asked_arg_values = []
    missing_args = []
    for asked_arg_name in asked_arg_names:
        if asked_arg_name in args:
            asked_arg_values.append(args[asked_arg_name])
        else:
            missing_args.append(asked_arg_name)
    if missing_args:
        raise TypeError(
            '{}() missing required positional argument: {}'.format(
                callback.__code__.co_name,
                ', '.join(missing_args)
            )
        )
    return callback(*asked_arg_values)
1346030
public function addArguments($mixed, $_ = null)
  {
    if (!is_array($mixed)) {
      $mixed = func_get_args();
    }

    foreach ($mixed as $arg) {
      $this->addArgument($arg);
    }

    return $this;
  }
320282
function extend() { var args
        args = [{}]
        args.push.apply(args, arguments)
        return nextend.apply(null, args)
    }
564885
def v_args(inline=False, meta=False, tree=False):
    ""
    if [tree, meta, inline].count(True) > 1:
        raise ValueError("Visitor functions can either accept tree, or meta, or be inlined. These cannot be combined.")
    def _visitor_args_dec(obj):
        return _apply_decorator(obj, _visitor_args_func_dec, inline=inline, meta=meta, whole_tree=tree)
    return _visitor_args_dec
65136
def add_callback(obj, callback, args=()):
    """"""
    callbacks = obj._callbacks
    node = Node(callback, args)
    # Store a single callback directly in _callbacks
    if callbacks is None:
        obj._callbacks = node
        return node
    # Otherwise use a dllist.
    if not isinstance(callbacks, dllist):
        obj._callbacks = dllist()
        obj._callbacks.insert(callbacks)
        callbacks = obj._callbacks
    callbacks.insert(node)
    return node
126743
public function addCallback($concrete, callable $callback)
    {
        //Strip all leading backslashes
        if ($concrete[0] === '\\') {
            $concrete = substr($concrete, 1);
        }

        if (!isset($this->callbacks[$concrete])) {
            $this->callbacks[$concrete] = [];
        }
        $this->callbacks[$concrete][] = $callback;
    }
440739
def _iterable_to_varargs_method(func):
    """"""
    def wrapped(self, *args, **kwargs):
        return func(self, args, **kwargs)
    return wrapped
341787
function dispatchCallback(name, args) {
                    if(_initialized) {
                        var callback = _currentPreparedOptions.callbacks[name];
                        var extensionOnName = name;
                        var ext;

                        if(extensionOnName.substr(0, 2) === "on")
                            extensionOnName = extensionOnName.substr(2, 1).toLowerCase() + extensionOnName.substr(3);

                        if(type(callback) == TYPES.f)
                            callback.call(_base, args);

                        FRAMEWORK.each(_extensions, function() {
                            ext = this;
                            if(type(ext.on) == TYPES.f)
                                ext.on(extensionOnName, args);
                        });
                    }
                    else if(!_destroyed)
                        _callbacksInitQeueue.push({ n : name, a : args });
                }
758357
private function _wrapArgs($caller_args, $num_args=null) {
    $num_args = (is_null($num_args)) ? count($caller_args) - 1 : $num_args;
    
    $filled_args = array();
    if(isset($this) && isset($this->_wrapped)) {
      $filled_args[] =& $this->_wrapped;
    }
    if(count($caller_args) > 0) {
      foreach($caller_args as $k=>$v) {
        $filled_args[] = $v;
      }
    }
    
    return array_pad($filled_args, $num_args, null);
  }
354562
function callbackify(func) {
  return function(...args) {
    if (args.length === 0
        || typeof args[args.length - 1] !== 'function') {
      throw new Error(`${func.name || 'Function'} requires a callback.`);
    }

    const callback = args.pop();

    func.call(this, ...args).then((value) => {
      setImmediate(() => callback(null, value));
    }, (err) => {
      setImmediate(() => callback(err));
    });
  };
}
261103
function(callback, thisArg) {
      this.values.forEach(function(v, i) {
        callback.call(thisArg, v, this.keys[i], this);
      }, this);
    }
259894
public static <T> Callback<T> chain(Iterable<Callback<T>> callbacks)
    {
        return new ChainCallback<T>(callbacks);
    }
599990
def inject_extra_args(callback, request, kwargs):
    ''''''
    # TODO: this is a temporary pach, should be managed via honouring the
    # mimetype in the request header....
    annots = dict(callback.__annotations__)
    del annots['return']
    for param_name, (param_type, _) in annots.items():
        if param_type == Ptypes.path:
            continue  # Already parsed by werkzeug
        elif param_type == Ptypes.body:
            value = getattr(request, PTYPE_TO_REQUEST_PROPERTY[param_type])
            # TODO: The JSON conversion should be dependant from request
            # header type, really...
            value = json.loads(value.decode('utf-8'))
        else:
            get = lambda attr: getattr(request, attr).get(param_name, None)
            value = get(PTYPE_TO_REQUEST_PROPERTY[param_type])
        if value is not None:
            kwargs[param_name] = value
649881
function() {
      var args = u.toArray(arguments);
      args.unshift(u.fn);
      return u.extend.apply(this, args);
    }
528002
def add_args(self, args):
        
        for key, value in vars(args).items():
            if value is not None:
                setattr(self, key.upper(), value)