Return a deferred.
365
def delete(self, **params):
        """"""
        d = self.request('delete', self.instance_url(), params)
        return d.addCallback(self.refresh_from).addCallback(lambda _: self)
10521
function () {
                var deferred = $q.defer();
                if (!window.cordova) {
                    deferred.reject('Not supported in browser');
                } else {
                    if (!window.ThreeDeeTouch) {
                        deferred.reject('Could not find 3D touch plugin');
                    } else {
                        window.ThreeDeeTouch.isAvailable(function (value) {
                            deferred.resolve(value);
                        }, function (err) {
                            deferred.reject(err);
                        });
                    }
                }

                return deferred.promise;
            }
1094799
function (milliseconds) {
            var deferred,
                timer = setTimeout(function () {
                    deferred.emitSuccess();
                }, milliseconds),
                canceller = function () {
                    clearTimeout(timer);
                };
            deferred = new Deferred(canceller);
            return deferred.getPromise();
        }
380291
def _defer_to_worker(deliver, worker, work, *args, **kwargs):
    
    deferred = Deferred()

    def wrapped_work():
        try:
            result = work(*args, **kwargs)
        except BaseException:
            f = Failure()
            deliver(lambda: deferred.errback(f))
        else:
            deliver(lambda: deferred.callback(result))
    worker.do(wrapped_work)
    return deferred
435876
function() {
                var deferred = $q.defer();

                this.isAvailable().then(function() {
                    window.ThreeDeeTouch.enableLinkPreview();
                        deferred.resolve(true);
                },
                function(err) {
                    deferred.reject(err);
                });

                return deferred.promise;
            }
1136054
function(url, method = 'get', body = undefined) {
		var deferred = Q.defer();

		this.extendedRequest(url, method, body)
			.then((res) => { deferred.resolve(res.body); })
			.catch((err) => { deferred.reject(err); });

		return deferred.promise;
	}
722977
function(){
        var deferred = Q.defer();

        fs.readFile( this.path, "utf-8", function( err, data ){
            if( err ){
                deferred.resolve( err );
                return;
            }

            this.parentTemplateId = utils.detectTemplateId( data );
            this.defaultValues = this.pickOutDefaultValues( data );
            this.processor = _.template( this.convertToTemplateFormat( data ) );

            deferred.resolve( this );
        }.bind( this ) );

        return deferred.promise;
    }
550425
function( templateId ){
        var deferred = Q.defer();

        if( this.templates[ templateId ] ){
            deferred.resolve( this.templates[ templateId ] );
        }
        else {
            this.registerTemplate( templateId ).done( function( template ){
                deferred.resolve( template );
            } );
        }

        return deferred.promise;
    }
1063537
function getFromNpm(url) {
    var deferred = Q.defer();
    request({url: url, json: true}, function(err, res, data){
        if (err) {
            return deferred.reject(err);
        }

        if (!data) {
            return deferred.reject('No data?');
        }

        deferred.resolve(data);
    });
    return deferred.promise;
}
454730
def _raise_deferred_exc(self):
    """"""
    if self._deferred_exception:
      try:
        exc_type, exc_value, exc_traceback = self._deferred_exception
        raise_with_traceback(exc_value, exc_traceback)
      except TypeError:
        # If `_deferred_exception` isn't a 3-item tuple (raising a TypeError on the above
        # destructuring), treat it like a bare exception.
        raise self._deferred_exception
965782
def _connect_deferred(self, deferred):
        
        self._deferred = deferred

        # Because we use __del__, we need to make sure there are no cycles
        # involving this object, which is why we use a weakref:
        def put(result, eventual=weakref.ref(self)):
            eventual = eventual()
            if eventual:
                eventual._set_result(result)
            else:
                err(result, "Unhandled error in EventualResult")

        deferred.addBoth(put)
433565
def _request(self, method, identifier, key=None, value=None):
        """"""
        params = {'id': identifier}
        if key is not None and value is not None:
            params[key] = value
        result = yield from self._transact(method, params)
        return result.get(key)
954376
function defer(timeout) {
    var resolve, reject;
    var promise = new Promise(function() {
        resolve = arguments[0];
        reject = arguments[1];
        setTimeout(reject, timeout, "Timeout");
    });
    return {
        resolve: resolve,
        reject: reject,
        promise: promise,
        timestamp:new Date().getTime()
    };
}
1215089
function(callback) {
            var d = Q.defer();
            if (_.isFunction(callback)) d.promise.done(callback);

            this.on("ready", function() {
                d.resolve(this);
            }, this);
            if (this.is_ready) d.resolve(this);

            return d.promise;
        }
442025
def after(self):
        

        d = Deferred()
        self._after_deferreds.append(d)
        return d.chain
358864
function(arg, typeSpec) {
				var result = new Deferred();
				var predictions = this._getPredictions(arg.text, typeSpec);
				result.resolve(this._createCompletion(arg.text, predictions));
				return result;
			}
402931
function () {
  var deferred = Q.defer();
  fs.exists(settings.SPLASH_FILE, function (exists) {
    if (exists) {
      display.success(settings.SPLASH_FILE + ' exists');
      deferred.resolve();
    } else {
      display.error(settings.SPLASH_FILE + ' does not exist');
      deferred.reject();
    }
  });
  return deferred.promise;
}