How to use the babel-runtime/core-js/promise.resolve function in babel-runtime

To help you get started, we’ve selected a few babel-runtime 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 less / less-preview / jspm_packages / npm / babel-runtime@5.8.38 / regenerator / runtime.js View on Github external
function invoke(method, arg, resolve, reject) {
      var record = tryCatch(generator[method], generator, arg);
      if (record.type === "throw") {
        reject(record.arg);
      } else {
        var result = record.arg;
        var value = result.value;
        if (value instanceof AwaitArgument) {
          return _Promise.resolve(value.arg).then(function (value) {
            invoke("next", value, resolve, reject);
          }, function (err) {
            invoke("throw", err, resolve, reject);
          });
        }

        return _Promise.resolve(value).then(function (unwrapped) {
          // When a yielded Promise is resolved, its final value becomes
          // the .value of the Promise<{value,done}> result for the
          // current iteration. If the Promise is rejected, however, the
          // result for this iteration will be rejected with the same
          // reason. Note that rejections of yielded Promises are not
          // thrown back into the generator function, as is the case
          // when an awaited Promise is rejected. This difference in
          // behavior between yield and await is important, because it
          // allows the consumer to decide what to do with the yielded
github Automattic / wpcom.js / dist / lib / site.post.js View on Github external
return this.wpcom.req.post(this.path + '/new', query, body).then(function (data) {
				// update POST object
				_this._id = data.ID;
				debug('Set post _id: %s', _this._id);

				_this._slug = data.slug;
				debug('Set post _slug: %s', _this._slug);

				if ('function' === typeof fn) {
					fn(null, data);
				} else {
					return _Promise.resolve(data);
				}
			})['catch'](function (err) {
				if ('function' === typeof fn) {
github TeamScheire / bicycleLight / SmartLight / app / platforms / android / app / src / main / assets / www / lib / OnsenUI / esm / elements / ons-tabbar / index.js View on Github external
var prevIndex = this.getActiveTabIndex();
      var prevTab = this.tabs[prevIndex],
          nextTab = this.tabs[nextIndex];

      if (!nextTab) {
        return _Promise.reject('Specified index does not match any tab.');
      }

      if (nextIndex === prevIndex) {
        util.triggerElementEvent(this, 'reactive', { index: nextIndex, activeIndex: nextIndex, tabItem: nextTab });
        return _Promise.resolve(nextTab.pageElement);
      }

      // FIXME: nextTab.loaded is broken in Zone.js promises (Angular2)
      var nextPage = nextTab.pageElement;
      return (nextPage ? _Promise.resolve(nextPage) : nextTab.loaded).then(function (nextPage) {
        return _this4._swiper.setActiveIndex(nextIndex, _extends({
          reject: true
        }, options, {
          animation: prevTab && nextPage ? options.animation || _this4.getAttribute('animation') : 'none',
          animationOptions: util.extend({ duration: .3, timing: 'cubic-bezier(.4, .7, .5, 1)' }, _this4.hasAttribute('animation-options') ? util.animationOptionsParse(_this4.getAttribute('animation-options')) : {}, options.animationOptions || {})
        })).then(function () {
          options.callback instanceof Function && options.callback(nextPage);
          return nextPage;
        });
      });
    }
github pavelvlasov / koa-generic-session-mongo / dist / store.js View on Github external
value: function _initWithDb(_ref) {
      var db = _ref.db;
      var _ref$collection = _ref.collection;
      var collection = _ref$collection === undefined ? DEFAULT_COLLECTION : _ref$collection;

      return _Promise.resolve(db.collection(collection));
    }
github ratson / factory-bot / dist / index.es6.js View on Github external
var promises = _Object$keys(source).map(function (attr) {
    var promise = void 0;
    if (Array.isArray(source[attr])) {
      target[attr] = [];
      promise = asyncPopulate(target[attr], source[attr]);
    } else if (source[attr] === null) {
      target[attr] = null;
    } else if (isPlainObject(source[attr])) {
      target[attr] = target[attr] || {};
      promise = asyncPopulate(target[attr], source[attr]);
    } else if (typeof source[attr] === 'function') {
      promise = _Promise.resolve(source[attr]()).then(function (v) {
        target[attr] = v;
      });
    } else {
      promise = _Promise.resolve(source[attr]).then(function (v) {
        target[attr] = v;
      });
    }
    return promise;
  });
  return _Promise.all(promises);
github zerkalica / immutable-di / dist / flux / action-to-promise.js View on Github external
action: action + 'Progress',
            payload: {}
        }));
        actionPromises.push(payload.then(function (payload) {
            return {
                action: action + 'Success',
                payload: payload
            };
        })['catch'](function (err) {
            return {
                action: action + 'Fail',
                payload: err
            };
        }));
    } else {
        actionPromises.push(_Promise.resolve({
            action: action,
            payload: payload
        }));
    }

    return actionPromises;
}
github cowboyd / recomplete.js / lib / recomplete.js View on Github external
value: function setQuery(query) {
      var _this = this;

      var value = this.source.call(this, query);
      var promise = value.then ? value : _Promise.resolve(value);
      update(this, {
        query: query,
        isPending: true,
        isRejected: false,
        isFulfilled: false,
        isSettled: false
      });
      var originalData = this.data;
      var updateIfFresh = function updateIfFresh(attrs) {
        if (originalData === _this.data) {
          update(_this, attrs);
        }
      };

      return promise.then(function (result) {
        updateIfFresh({
github TeamScheire / bicycleLight / SmartLight / app / platforms / android / app / src / main / assets / www / lib / OnsenUI / esm / elements / ons-navigator / index.js View on Github external
util.throw('First argument must be a page name or the index of an existing page. You supplied ' + item);
      }
      var index = typeof item === 'number' ? this._normalizeIndex(item) : this._lastIndexOfPage(item);
      var page = this.pages[index];

      if (index < 0) {
        return this.pushPage(item, options);
      }

      var _preparePageAndOption5 = this._preparePageAndOptions(page, options);

      options = _preparePageAndOption5.options;


      if (index === this.pages.length - 1) {
        return _Promise.resolve(page);
      }
      if (!page) {
        util.throw('Failed to find item ' + item);
      }
      if (this._isRunning) {
        return _Promise.reject('pushPage is already running.');
      }
      if (this._emitPrePushEvent()) {
        return _Promise.reject('Canceled in prepush event.');
      }

      page.style.display = '';
      page.style.visibility = 'hidden';
      page.parentNode.appendChild(page);
      return this._pushPage(options);
    }
github lukeed / taskr / dist / fly.js View on Github external
f = filters[0];

                              if (!(filters.length === 0)) {
                                context$5$0.next = 5;
                                break;
                              }

                              context$5$0.t0 = { data: data, ext: ext };
                              context$5$0.next = 16;
                              break;

                            case 5:
                              context$5$0.t1 = reduce;
                              context$5$0.t2 = this;
                              context$5$0.next = 9;
                              return _Promise.resolve(f.transform.call(this, data, f.options));

                            case 9:
                              context$5$0.t3 = context$5$0.sent;
                              context$5$0.t4 = f.ext || ext;
                              context$5$0.t5 = filters.slice(1);
                              context$5$0.t6 = _("filter %s", f.transform);
                              context$5$0.next = 15;
                              return context$5$0.t1.call.call(context$5$0.t1, context$5$0.t2, context$5$0.t3, context$5$0.t4, context$5$0.t5, context$5$0.t6);

                            case 15:
                              context$5$0.t0 = context$5$0.sent;

                            case 16:
                              return context$5$0.abrupt("return", context$5$0.t0);

                            case 17: