How to use the es6-promise.Promise.resolve function in es6-promise

To help you get started, we’ve selected a few es6-promise 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 intermine / im-tables / src / views / item-preview.js View on Github external
getRelationCount(settings, type) {
      let counter, details;
      const id = this.model.get('id');

      if (_.isObject(settings)) {
        const {query, label} = settings;
        counter = query(id); // query is a function from id -> query
        details = c => new CoreModel({parts: [label], id: label, displayName: label, count: c});
      } else {
        const path = this.schema.makePath(`${ type }.${ settings }`);
        if (!__guard__(path.getType(), x => x.attributes.id)) { return Promise.resolve(true); } // Skip if no id.
        counter = {select: [settings + '.id'], from: type, where: {id}};
        details = c => new DetailsModel({path, count: c});
      }

      return this.service.count(counter)
              .then(details)
              .then(d => { if (d.get('count')) { return this.referenceFields.add(d); } });
    }
  };
github zendesk / chariot-tooltips / lib / tutorial.js View on Github external
end(forced = false) {
    // Note: Order matters.
    this.tearDown();

    return Promise.resolve().then(() => {
      if (this.delegate.didFinishTutorial) {
        return this.delegate.didFinishTutorial(this, forced);
      }
    }).then(() => {
      this._isActive = false;
    });
  }
github mozilla-b2g / gaia / bin / gaia_marionette_retry.js View on Github external
function runTests(filenames, args, retry) {
  if (filenames.length === 0) {
    // All done!
    return Promise.resolve({ pass: 0, fail: 0, pending: 0 });
  }

  var next = filenames.pop();
  var tally = {};
  return runTests(filenames, args, retry)
  .then(function(results) {
    [
      'pass',
      'fail',
      'pending'
    ].forEach(function(key) {
      tally[key] = results[key] || 0;
    });

    return runTest(next, args, retry);
  })
github enmasseio / babble / lib / block / Decision.js View on Github external
Decision.prototype.execute = function (conversation, message) {
  var me = this;
  var id = this.decision(message, conversation.context);

  var resolve = isPromise(id) ? id : Promise.resolve(id);
  return resolve.then(function (id) {
    var next = me.choices[id];

    if (!next) {
      // there is no match, fall back on the default choice
      next = me.choices['default'];
    }

    if (!next) {
      throw new Error('Block with id "' + id + '" not found');
    }

    return {
      result: message,
      block: next
    };
github intermine / im-tables / src / utils / table-results.js View on Github external
const {Promise} = require('es6-promise');

const Options = require('../options');
const Page = require('../models/page');

const CACHES = {};
const ALREADY_DONE = Promise.resolve(true);

exports.getCache = function(query) {
  let name;
  const xml = query.toXML();
  const { root } = query.service;
  return CACHES[name = root + ':' + xml] != null ? CACHES[name] : (CACHES[name] = new ResultCache(query));
};

// TODO - make sure that the caches are informed of list change events.
exports.onListChange = function(listName) {
  for (let name in CACHES) {
    var needle;
    const cache = CACHES[name];
    if ((needle = listName, Array.from(listNamesFor(cache.query)).includes(needle))) {
      cache.dropRows(); // we cannot rely on this cache if one of its queries has changed.
    }
github anticoders / gagarin / tests / specs / browser.js View on Github external
it('should be ok', function () {
    return Promise.resolve('should be ok');
  });
github opensheetmusicdisplay / opensheetmusicdisplay / src / Common / FileIO / Mxl.ts View on Github external
(content: string) => {
                const parser: DOMParser = new DOMParser();
                const xml: Document = parser.parseFromString(content, "text/xml");
                const doc: IXmlElement = new IXmlElement(xml.documentElement);
                return Promise.resolve(doc);
            },
            (err: any) => {
github fauna / faunadb-js / src / PageHelper.js View on Github external
}
      data.push(item);
    });
    lambda(data);

    var nextCursor;
    if (reverse) {
      nextCursor = page.before;
    } else {
      nextCursor = page.after;
    }

    if (nextCursor !== undefined) {
      return self._retrieveNextPage(nextCursor, reverse).then(self._consumePages(lambda, reverse));
    } else {
      return Promise.resolve();
    }
  };
};
github anticoders / gagarin / lib / cleanup.js View on Github external
runner.cancel = function () {
    if (!task.promise) {
      task.promise = Promise.resolve();
    }
  }
github peter-mouland / web-caddy / tasks / wrappers / sass.js View on Github external
}).then(function(fileObjs){
        if (!self.options.minify || self.options.dev) return Promise.resolve();
        return self.minify(fileObjs);
    });
};