How to use the promise-polyfill.resolve function in promise-polyfill

To help you get started, we’ve selected a few promise-polyfill 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 gragland / react-component-data / src / resolveRecursive.js View on Github external
function getDataFromTree(rootElement, rootContext, fetchRoot, mergeProps, isTopLevel){

  //console.log(`Now searching element (${rootElement.type.name || rootElement.type.displayName}):`, rootElement);

  // Get array of queries (fetchData promises) from tree
  // This will traverse down recursively looking for fetchData() methods
  let queries = getQueriesFromTree(rootElement, rootContext, fetchRoot, mergeProps);

  // No queries found. We're done!
  if (!queries.length) {
    return Promise.resolve();
  }

  // We've traversed down as far as possible in thecurrent tree branch ...
  // Wait on each query that we found, re-rendering the subtree when it's done.
  const mappedQueries = queries.map(({ query, element, context }) =>  {
    return query.then((newProps) => {
      const displayName = element.type.displayName;

      if (!displayName){
        // TODO: Use Promise.reject and catch()
        throw new Error('[React Component Data] When resolving component data recursively each component must have a displayName set.');
      }

      // Add to finalData array that will be returned
      finalData[displayName] = newProps;
      // Traverse children
github appnexus / cmp / src / docs / assets / portal.js View on Github external
function readCookie(name) {
	const value = '; ' + document.cookie;
	const parts = value.split('; ' + name + '=');
	if (parts.length === 2) {
		return Promise.resolve(parts.pop().split(';').shift());
	}
	return Promise.resolve();
}
github InteractiveAdvertisingBureau / GDPR-Transparency-and-Consent-Framework / reference / src / docs / assets / portal.js View on Github external
function writeCookie({ name, value, path = '/'}) {
	document.cookie = `${name}=${value}${COOKIE_DOMAIN};path=${path};max-age=${COOKIE_MAX_AGE}`;
	return Promise.resolve();
}
github menpo / landmarker.io / src / js / app / backend / dropbox.js View on Github external
Dropbox.prototype.setAssets = function (path, mode) {

    if (!path) {
        return Promise.resolve(null);
    }

    this._assetsPath = path;
    this.setMode(mode);

    const exts = this.mode === 'mesh' ? MESH_EXTENSIONS : IMAGE_EXTENSIONS;

    return this.list(path, {
        filesOnly: true,
        extensions: exts,
        noCache: true
    }).then((items) => {
        this._assets = [];
        this._meshTextures = {};
        this._meshMtls = {};
        if (this.mode === 'image') {
github InteractiveAdvertisingBureau / GDPR-Transparency-and-Consent-Framework / reference / src / lib / cookie / cookie.js View on Github external
function writeLocalVendorConsentCookie(vendorConsentData) {
	log.debug('Write consent data to local cookie', vendorConsentData);
	return Promise.resolve(writeCookie(VENDOR_CONSENT_COOKIE_NAME,
		encodeVendorConsentData(vendorConsentData),
		VENDOR_CONSENT_COOKIE_MAX_AGE,
		'/'));
}
github evervault / node-secureworker / enclave-autoexec / index.js View on Github external
verify: function (algorithm, key, signature, data) {
            algorithm = normalizeAlgorithmShallow(algorithm);
            signature = normalizeBufferSource(signature);
            switch (algorithm.name) {
            case 'AES-CMAC':
              if (algorithm.length !== 128) throw new Error('length ' + algorithm.length + ' not supported');
              var expectedSignature = _dukEnclaveNative.aescmacSign(key.raw, data);
              return Promise.resolve(equals128(signature, new Uint8Array(expectedSignature)));
            case 'ECDSA':
              algorithm.hash = normalizeAlgorithmShallow(algorithm.hash);
              if (algorithm.hash.name !== 'SHA-256') throw new Error('hash ' + algorithm.hash.name + ' not supported');
              var signatureLE = new ArrayBuffer(64);
              reverse256(new Uint8Array(signatureLE, 0, 32), signature.subarray(0, 32));
              reverse256(new Uint8Array(signatureLE, 32, 32), signature.subarray(32, 64));
              return Promise.resolve(_dukEnclaveNative.ecdsaVerify(key.raw, signatureLE, data));
            default:
              throw new Error('algorithm ' + algorithm.name + ' not supported');
            }
          },
github evervault / node-secureworker / enclave-autoexec / index.js View on Github external
deriveBits: function (algorithm, baseKey, length) {
            algorithm = normalizeAlgorithmShallow(algorithm);
            switch (algorithm.name) {
            case 'ECDH':
              if (length !== 256) throw new Error('length ' + length + ' not supported');
              var bitsLE = _dukEnclaveNative.ecdhDeriveBits(algorithm.public.raw, baseKey.raw);
              var bits = new ArrayBuffer(32);
              reverse256(new Uint8Array(bits, 0, 32), new Uint8Array(bitsLE, 0, 32));
              return Promise.resolve(bits);
            default:
              throw new Error('algorithm ' + algorithm.name + ' not supported');
            }
          },
github InteractiveAdvertisingBureau / GDPR-Transparency-and-Consent-Framework / reference / src / lib / cookie / cookie.js View on Github external
function readLocalVendorConsentCookie() {
	const cookie = readCookie(VENDOR_CONSENT_COOKIE_NAME);
	log.debug('Read consent data from local cookie', cookie);
	return Promise.resolve(cookie && decodeVendorConsentData(cookie));
}
github artf / grapesjs / src / utils / fetch.js View on Github external
            text: () => Promise.resolve(req.responseText)
          });