Wraps synchronous function with common interface

@param   {object} context - context to invoke within
@param   {function} func - function to execute
@param   {Function} callback - invoke after function is finished executing
@returns {void}
763254
function runSync(context, func, callback)
{
  var result
    , requiresContext = isArrowFunction(func)
    ;

  try
  {
    if (requiresContext)
    {
      result = func.call(null, context);
    }
    else
    {
      result = func.call(context);
    }
  }
  catch (ex)
  {
    // pass error as error-first callback
    callback(ex);
    return;
  }

  // everything went well
  callback(null, result);
}
926826
def call_with_context(func, context, *args):
    
    return make_context_aware(func, len(args))(*args + (context,))
531742
function(evname, callback, context) {
    var self = this, args = arguments;
    this.on(evname, function() {
      callback.apply(context, arguments);
      self.off.apply(self, args);
    });
    return this;
  }
247585
function _wrapReadyCallback(onready, target) {
            return function(err) {
                if (target && "function" === typeof target.callback) {
                    target.callback.call(target.context, err, this.target);
                }
                if (onready) {
                    if ("function" === typeof onready) {
                        onready(err, this.target);
                    }
                    else if ("function" === typeof onready.callback) {
                        onready.callback.call(onready.context, err, this.target);
                    }
                }
            };
        }
450858
function(func) {
		var timeout, timestamp;
		var wait = 99;
		var run = function(){
			timeout = null;
			func();
		};
		var later = function() {
			var last = Date.now() - timestamp;

			if (last < wait) {
				setTimeout(later, wait - last);
			} else {
				(requestIdleCallback || run)(run);
			}
		};

		return function() {
			timestamp = Date.now();

			if (!timeout) {
				timeout = setTimeout(later, wait);
			}
		};
	}
880004
function(callback, context)
  {
    var db = this;
    var promise = new Promise();
    var success = this.handleRefreshSuccess( promise );
    var failure = this.handleRefreshFailure( promise );

    promise.complete( callback, context || db );

    batchExecute(function()
    {
      db.executeRefresh( success, failure );
    });

    return promise;
  }
302836
function(ev, callback, context) {
      var calls = this._callbacks || (this._callbacks = {});
      var list  = calls[ev] || (calls[ev] = []);
      list.push([callback, context]);
      return this;
    }
303283
function callback(fn, context, event) {
        //window.setTimeout(function(){
        event.target = context;
        (typeof context[fn] === "function") && context[fn].apply(context, [event]);
        //}, 1);
    }
597983
def coerce_to_synchronous(func):
    '''
    
    '''
    if inspect.iscoroutinefunction(func):
        @functools.wraps(func)
        def sync_wrapper(*args, **kwargs):
            loop = asyncio.get_event_loop()
            try:
                loop.run_until_complete(func(*args, **kwargs))
            finally:
                loop.close()
        return sync_wrapper
    return func
425032
def ensure_contexted(func):
        
        @wraps(func)
        def wrapped(self, *args, **kwargs):
            if self._buf is None:
                raise TypeError("An Evtx object must be used with"
                                " a context (see the `with` statement).")
            else:
                return func(self, *args, **kwargs)
        return wrapped
24033
def call_async(func):
    """"""

    @wraps(func)
    def wrapper(self, *args, **kw):
        """Wraps instance method to be called on loop thread"""

        def call():
            """Calls function on loop thread"""
            try:
                func(self, *args, **kw)
            except Exception:
                logger.exception(
                    "failed to call async [%r] with [%r] [%r]", func, args, kw
                )

        self.loop.call_soon_threadsafe(call)

    return wrapper
1201718
function callHandler(fn, req, res, next) {
    let context = new Context(req, res);
    if (utils.isGeneratorFunction(fn)) {
        co(fn).call(context, function (err) {
            if (err || !res.terminated) {
                next(err);
            }
        });
    } else {
        fn.call(context);
        if (!res.terminated) {
            next();
        }
    }
}
46380
function asyncNeeded(funcDecl) {
  // the function body starts after the arguments
  var bodyPos;
  if(sl.typeOf(funcDecl[1]) === 'symbol') {
    bodyPos = 3;  // named function
  }
  else {
    bodyPos = 2;  // anonymous function
  }
  for(var i=bodyPos;i<funcDecl.length;i++) {
    if(sl.isList(funcDecl[i]) && sl.typeOf(funcDecl[i][0]) === 'symbol') {
      if(sl.valueOf(funcDecl[i][0]) === 'await') {
        return true;
      }
    }
  }
  return false;
}
480007
function then (callback) {
        if (typeof callback !== 'function') {
          throw new Error('Callback must be a function, instead got: ' + (typeof callback));
        }

        function thenCallback (result) {
          callback(result);
          unbind('end', thenCallback);
        }

        bind('end', thenCallback);
        bind('stop', unbind.bind(null, 'end', thenCallback));

        return self;
      }
202631
function(callback, context) {
      var objects = this.getObjects(),
          i = objects.length;
      while (i--) {
        callback.call(context, objects[i], i, objects);
      }
      return this;
    }
811185
def synced(func):
    '''
    
    '''

    def wrapper(self, *args, **kwargs):
        '''
        Actual wrapper for the synchronous function
        '''
        task = DataManagerTask(func, *args, **kwargs)
        self.submit_task(task)
        return task.get_results()
    return wrapper
537211
public static AsyncCallback<String> wrapCallback(final JavaScriptObject func) {

        return new AsyncCallback<String>() {

            public void onFailure(Throwable caught) {

                // TODO Auto-generated method stub

            }

            public void onSuccess(String result) {

                callWithString(func, result);
            }

        };
    }