How to use the q.fcall function in q

To help you get started, we’ve selected a few q examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github axemclion / grunt-saucelabs / src / TestRunner.js View on Github external
browser: browser
            });

            return job
              .stop()
            // Try to delete the timed out job in order to prevent the SauceLabs badge to
            // indicate failure. The del() function can also fail, in that case swallow the
            // exception.
              .then(function () { return job.del().fail(_.noop); })
              .then(getResult);
          }
          return result;
        });
    }

    return Q
      .fcall(function () {
        me.startedJobs += 1;
        me.reportProgress({
          type: 'jobStarted',
          numberOfJobs: me.numberOfJobs,
          startedJobs: me.startedJobs
        });
      })
      .then(getResult)
      .then(function (result) {
        if (me.onTestComplete) {
          var clone = _.clone(result, true);
          return Q
            .nfcall(me.onTestComplete, clone)
            .then(
              function (passed) {
github LinDA-tools / Visualization / backend / preconfiguration_engine.js View on Github external
PREFIX rdfs: \n\
                SELECT DISTINCT ?property WHERE {\n\
                    GRAPH <' + dsUri + '> {\n\
                        ' + union + '\n\
                    }\n\
                } LIMIT 50';

        return client.query(q).then(function(results) {
            console.log('properties by class result:');
            console.dir(results);
            return results.map(function(result) {
                return result.property.value;
            });
        });
    } else {
        return Q.fcall(function() {
            return [];
        });
    }
}
github christian-raedel / nightlife-rabbit / lib / nightlife / session.js View on Github external
}
                        },
                        details: {},
                        call: {
                            args: message.args,
                            kwargs: message.kwargs
                        }
                    });
                })
                .catch(function (err) {
                    logger.error('cannot call remote procedure', message.registered.registration.id, err.stack);
                    self.error('CALL', message.request.id, err);
                });
                break;
            case 'YIELD':
                q.fcall(function () {
                    var defer = q.defer();
                    self.emit('yield', message.invocation.request.id, defer);
                    return defer.promise;
                })
                .then(function (invocation) {
                    invocation.session.send('RESULT', {
                        call: {
                            request: {
                                id: invocation.requestId
                            }
                        },
                        options: {},
                        yield: {
                            args: message.args,
                            kwargs: message.kwargs
                        }
github noobaa / noobaa-core / attic / simple_ws.js View on Github external
SimpleWS.prototype._acceptKeepalive = function(msg) {
    var self = this;
    if (self._state !== STATE_READY && self._state !== STATE_HANDSHAKE) {
        dbg.error('WS KEEPALIVE ON BAD STATE', self._name, self._state);
        self._onWsError(msg._ws, new Error('WS MESSAGE ON BAD STATE'));
        return;
    }
    dbg.log0('WS KEEPALIVE ACCEPT', self._name);
    var acceptFunc = self._options.keepalive && self._options.keepalive.accept || noop;
    Q.fcall(acceptFunc, self, msg.data)
        .then(null, function(err) {
            dbg.error('WS HANDSHAKE ACCEPT ERROR', self._name);
            self._onWsError(msg._ws, err);
        });

};
github KIDx / ACdream / routers / admin.js View on Github external
router.post('/batchcreateprob', function(req, res){
  var cnt = parseInt(req.body.cnt, 10);
  var manager = Comm.clearSpace(req.body.manager);
  var source = Comm.clearSpace(req.body.source);
  var resp = {ret: ERR.OK};
  var ret = ERR.SYS;
  Q.fcall(function(){
    var name = req.session.user ? req.session.user.name : '';
    if (name !== 'admin') {
      ret = ERR.ACCESS_DENIED;
      throw new Error('access denied.');
    }
    if (!manager || !source || !cnt || cnt > 50) {
      ret = ERR.ARGS;
      throw new Error('invalid args.');
    }
    return User.watch(manager);
  })
  .then(function(user){
    if (!user) {
      ret = ERR.NOT_EXIST;
      throw new Error('user('+manager+') NOT exist.');
    }
github montagejs / mr / boot / preload-boilerplate.js View on Github external
return function (key, arg) {
        if (!has(cache, key)) {
            cache[key] = Q.fcall(callback, key, arg);
        }
        return cache[key];
    };
}
github automategreen / home-controller / lib / Insteon / Thermostat.js View on Github external
Thermostat.prototype.mode = function (mode, next) {
  if(typeof mode === 'function') {
    next = mode;
    mode = null;
  }

  if(mode) {
    var modeCmd = MODE_CMDS[mode.toLowerCase()];
    if(!modeCmd) {
      return Q.fcall(function() { 
        throw new Error('Invalid mode. Must be one of the following: ' + MODES.join(', '));
      }).nodeify(next);
    }
    var cmd = {
      cmd1: '6B',
      cmd2: modeCmd,
      extended: true,
      exitOnAck: true
    };

    return this.insteon.directCommand(this.id, cmd)
      .then(function(status) {
        if(!!status && status.success) {
          return mode;
        } else {
          return null;
github projectkudu / KuduSync / bin / kudusync.js View on Github external
return action().then(Q.resolve, function (err) {
                if(retries >= currentTry++) {
                    return Q.delay(Q.fcall(retryAction), delayBeforeRetry);
                } else {
                    return Q.reject(err);
                }
            });
        };
github kra / futel-installation / bunkerbox / src / metrics_util.js View on Github external
var get_promise = function(value) {
    return Q.fcall(function() { return value; }) };
github KIDx / ACdream / routers / topic.js View on Github external
router.get('/list', function(req, res){
  var page = parseInt(req.query.page, 10);
  if (!page) {
    page = 1;
  }
  var search = req.query.search;
  var resp = {
    title: 'TopicList',
    key: KEY.TOPIC_LIST,
    page: page,
    search: search,
    getDate: getTime
  };
  var ret = ERR.SYS;
  Q.fcall(function(){
    if (page < 0) {
      ret = ERR.REDIRECT;
      throw new Error('redirect.');
    }
    var cond1 = {cid: -1}, cond2 = {cid: -1};
    if (search) {
      cond1.title = cond2.user = new RegExp("^.*"+Comm.toEscape(search)+".*$", 'i');
    }
    return Topic.get({$or: [cond1, cond2]}, page);
  })
  .then(function(o){
    resp.topics = o.topics;
    resp.totalPage = o.totalPage;
    var names = new Array(), has = {};
    o.topics.forEach(function(p){
      if (!has[p.user]) {

q

A library for promises (CommonJS/Promises/A,B,D)

MIT
Latest version published 7 years ago

Package Health Score

63 / 100
Full package analysis