How to use the bluebird.resolve function in bluebird

To help you get started, we’ve selected a few bluebird 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 wikimedia / restbase / lib / access_check_filter.js View on Github external
const redirectTitle = mwUtil.extractRedirect(html.body) ||
                    // Redirect detected while saving new HTML.
                    html.headers.location;
                if (redirectTitle) {
                    const newParams = Object.assign({}, rp);
                    newParams[titleParamName] = redirectTitle;
                    const location = mwUtil.createRelativeTitleRedirect(specInfo.path, req, {
                        newReqParams: newParams,
                        titleParamName,
                        dropPathAfterTitle: true
                    });

                    let contentPromise;
                    if (options.attach_body_to_redirect) {
                        if (specInfo.path.indexOf('html') !== -1) {
                            contentPromise = P.resolve(html);
                        } else {
                            contentPromise = next(hyper, req);
                        }
                    } else {
                        contentPromise = P.resolve({
                            headers: {
                                etag: html.headers.etag
                            }
                        });
                    }

                    return contentPromise.then((content) => redirect(content, location, options));
                } else {
                    return next(hyper, req);
                }
            });
github aolarchive / cachelink-service / lib / cache.js View on Github external
// Delete all of the *in* keys for the associations.
      const asyncDeleteInSets = redis.del(keysIn);

      // Remove the keys that were cleared from the *contains* keys.
      const asyncRemoveContains = asyncGetContainsKeys.then(keysAllContains =>
        Promise.all(
          (keysAllContains || []).map(key => redis('srem', prefixContains + key, ...keys))
        ).then(results => ((results && results.length) ? results.reduce((a, b) => a + b) : 0))
      );

      let asyncKeysNextLevel;
      let asyncClearNextLevel;

      if (level > maxLevel) {

        asyncKeysNextLevel  = Promise.resolve([]);
        asyncClearNextLevel = Promise.resolve();

      } else {

        // Get the next level of keys to clear.
        asyncKeysNextLevel = redis.sunion(keysContains);

        // Clear the next level of keys.
        asyncClearNextLevel = asyncKeysNextLevel.then(
          keysNextLevel => (keysNextLevel.length ? cacheClearLevel(keysNextLevel, level + 1) : Promise.resolve())
        );

      }

      return Promise.props({
        success:             true,
github cloudfoundry-incubator / service-fabrik-broker / test / test_broker / jobs.Scheduler.spec.js View on Github external
everyAsync(interval, jobName, data, options) {
    agendaStub.everyAsync(interval, jobName, data, options);
    return Promise.resolve({});
  }
  cancelAsync(criteria) {
github cloudfoundry-incubator / service-fabrik-broker / test / test_broker / fabrik.DBManager.spec.js View on Github external
loggerWarnSpy = sinon.spy(logger, 'warn');
      retryStub = sandbox.stub(utils, 'retry').callsFake((callback, options) => callback());
      dbInitializeSpy = sinon.spy(DBManager.prototype, 'initialize');
      dbInitializeForCreateSpy = sinon.spy(DBManagerCreateWithDelayedReconnectRetry.prototype, 'initialize');
      dbInitializeByUrlSpy = sinon.spy(DBManagerByUrl.prototype, 'initialize');
      dbCreateUpdateSucceededSpy = sandbox.spy(DBManagerForUpdate.prototype, 'dbCreateUpdateSucceeded');
      getDeploymentVMsStub = sandbox.stub(BoshDirectorClient.prototype, 'getDeploymentVms');
      getDeploymentStub = sandbox.stub(BoshDirectorClient.prototype, 'getDeployment');
      pollTaskStatusTillCompleteStub = sandbox.stub(BoshDirectorClient.prototype, 'pollTaskStatusTillComplete').callsFake(
        () => Promise.try(() => {
          if (errorPollTask) {
            throw new errors.ServiceUnavailable('Bosh Down...');
          }
          return {};
        }));
      getDeploymentVMsStub.withArgs().returns(Promise.resolve(deploymentVms));
      getDeploymentStub.withArgs('service-fabrik-mongodb-new').returns(deferred.promise);
      getDeploymentStub.withArgs('service-fabrik-mongodb').returns(Promise.resolve({}));
    });
github kuzzleio / kuzzle / bin / commands / createFirstAdmin.js View on Github external
function getUserName () {
  var username;

  username = readlineSync.question(clcQuestion('\n[❓] First administrator account name\n'));

  if (username.length === 0) {
    return getUserName();
  }

  return Promise.resolve(username);
}
github hazelcast / hazelcast-nodejs-client / src / proxy / PNCounterProxy.ts View on Github external
private getMaxConfiguredReplicaCount(): Promise {
        if (this.maximumReplicaCount > 0) {
            return Promise.resolve(this.maximumReplicaCount);
        } else {
            return this.encodeInvokeOnRandomTarget(PNCounterGetConfiguredReplicaCountCodec).then((count: number) => {
                this.maximumReplicaCount = count;
                return this.maximumReplicaCount;
            });
        }
    }
github cerner / kaiju / node / service / middlewares / RailsRedisSession.js View on Github external
session() {
    if (this.cached_session) {
      return Promise.resolve(this.cached_session);
    }

    return this.client().get(`cache:${this.id}`).then((value) => {
      if (value) {
        this.cached_session = new Marshal(value).parsed;
      }
      return this.cached_session;
    });
  }
}
github cypress-io / cypress / packages / driver / src / cypress / cy.js View on Github external
now (name, ...args) {
      return Promise.resolve(
        commandFns[name].apply(cy, args)
      )
    },
github cloudfoundry-incubator / service-fabrik-broker / lib / fabrik / IpManager.js View on Github external
function getAllUsedIps(ipList, offset, modelName, searchCriteria) {
      if (offset < 0) {
        return Promise.resolve([]);
      }
      const paginateOpts = {
        records: config.mongodb.record_max_fetch_count,
        offset: offset
      };
      return Repository.search(modelName, searchCriteria, paginateOpts)
        .then((result) => {
          ipList.push.apply(ipList, _.map(result.list, (reservedIp) => _.pick(reservedIp, 'ip', 'subnet_range')));
          return getAllUsedIps(ipList, result.nextOffset, modelName, searchCriteria);
        });
    }
    const result = [];
github heroku / cli / packages / ci-v5 / lib / source.js View on Github external
function * prepareSource (ref, context, heroku) {
  const [filePath, source] = yield [
    git.createArchive(ref),
    api.createSource(heroku)
  ]
  yield uploadArchive(source.source_blob.put_url, filePath)
  return Promise.resolve(source)
}