return a promise
545828
function loadBundle(bundleName) {
  if (!_bundleLoad[bundleName]) {
    const mappedBundleName = _paths[bundleName] || bundleName;
    const url = toUrl(mappedBundleName);
    const {nameSpace} = _bundles[bundleName] || {};
    let job;

    // I really hate this.
    // Use script tag, not fetch, only to support sourcemaps.
    // And I don't know how to mock it up, so __skip_script_load_test
    if (!define.__skip_script_load_test &&
        isBrowser &&
        // no name space or browser has support of document.currentScript
        (!nameSpace || 'currentScript' in _global.document)) {
      job = new Promise((resolve, reject) => {
        const script = document.createElement('script');
        if (nameSpace) {
          script.setAttribute('data-namespace', nameSpace);
        }
        script.type = 'text/javascript';
        script.charset = 'utf-8';
        script.async = true;
        script.addEventListener('load', resolve);
        script.addEventListener('error', reject);
        script.src = url;

        // If the script is cached, IE10 executes the script body and the
        // onload handler synchronously here.  That's a spec violation,
        // so be sure to do this asynchronously.
        if (document.documentMode === 10) {
          setTimeout(() => {
            document.head.appendChild(script);
          });
        } else {
          document.head.appendChild(script);
        }
      });
    }

    if (!job) {
      // in nodejs or web worker
      // or need name space in browser doesn't support document.currentScipt
      job = _fetch(mappedBundleName)
      .then(response => response.text())
      .then(text => {
        // ensure default user space
        // the bundle itself may switch to package space in middle of the file
        switchToUserSpace();
        if (!nameSpace) {
          (new Function(text)).call(_global);
        } else {
          const wrapped = function(id, deps, cb) {
            nameSpacedDefine(nameSpace, id, deps, cb);
          };
          wrapped.amd = define.amd;
          wrapped.switchToUserSpace = switchToUserSpace;
          wrapped.switchToPackageSpace = switchToPackageSpace;
          const f = new Function('define', text);
          f.call(_global, wrapped);
        }
      });
    }

    _bundleLoad[bundleName] = job;
  }

  return _bundleLoad[bundleName];
}
209656
function getAPIJSONPromise(oChainObject) {
		return new Promise(function(oResolve, oReject) {
			fs.readFile(sInputFile, 'utf8', (oError, sFileData) => {
				if (oError) {
					oReject(oError);
				} else {
					oChainObject.fileData = JSON.parse(sFileData);
					oResolve(oChainObject);
				}
			});
		});
	}
1054614
def dictPromise(m):
    
    ret = Promise()

    def handleSuccess(v, ret):
        for p in m.values():
            if not p.isFulfilled():
                return

        value = {}
        for k in m:
            value[k] = m[k].value
        ret.fulfill(value)

    for p in m.values():
        p.addCallback(lambda v: handleSuccess(v, ret))
        p.addErrback(lambda r: ret.reject(r))

    # Check to see if all the promises are already fulfilled
    handleSuccess(None, ret)

    return ret
954890
function promisedRequire (name, retries=0) {
  if (Array.isArray(name)) {
    return Promise.all(name.map((n) => {
      return promisedRequire(n);
    }));
  }
  return new Promise(function (resolve, reject) {
    global.requirejs([name], (result) => {
      resolve(result);

    }, (err) => {
      var failedId = err.requireModules && err.requireModules[0];
      if (failedId === name) {
        global.requirejs.undef(name);
        let query = `script[data-requirecontext][data-requiremodule="${name}"]`;
        let script = document.querySelector(query);
        if (script) {
          script.parentNode.removeChild(script);
        }
        if (retries < 1) {
          reject(err);
        } else {
          retries -= 1;
          promisedRequire(name, retries).then(resolve, reject);
        }
      }
    });
  });
}
585614
function() {
		var that = this;
		return new Promise(function(resolve, reject) {
			that.resolve(function(err, val) {
				if (err) {
					reject(err);
				} else {
					resolve(val);
				}
			});
		});
	}
328356
function after(obj, func) {
  if (isPromise(obj)) {
    return obj.then(func);
  } else {
    return func(obj);
  }
}
572945
function Promise(executor) {
  if (typeof executor !== 'function') {
    throw new TypeError();
  }

  if (!(this instanceof Promise)) {
    return new Promise(executor);
  }

  if (executor !== blessed.be) {
    blessed.be(this, executor, true);
  }
}
699207
function mapAfterAllReturn(arr, mapper, returnValue) {
  const results = new Array(arr.length);
  let containsPromise = false;

  for (let i = 0, l = arr.length; i < l; ++i) {
    results[i] = mapper(arr[i]);

    if (isPromise(results[i])) {
      containsPromise = true;
    }
  }

  if (containsPromise) {
    return Promise.all(results).then(() => returnValue);
  } else {
    return returnValue;
  }
}
75512
function wrapParsePromise(promise, parsePromise) {
      ['_rejected', '_rejectedCallbacks', '_resolved', '_resolvedCallbacks', '_result', 'reject', 'resolve']
        .forEach(function (prop) {
          promise[prop] = parsePromise[prop];
        });

      ['_continueWith', '_thenRunCallbacks', 'always', 'done', 'fail'].forEach(function (method) {
        promise[method] = wrap(parsePromise[method]);
      });

      ['then', 'catch'].forEach(function (method) {
        var func = promise[method];
        promise[method] = function wrappedAngularPromise() {
          var args = Array.prototype.slice.call(arguments, 0);
          var promise = func.apply(this, args);
          wrapParsePromise(promise, parsePromise);
          return promise;
        };
      });

      return promise;
    }
511914
function promisesWrapper(func) {
    return (options, callback) => {
        // options is an optional argument
        if (typeof options === 'function') {
            callback = options;
            options = undefined;
        }
        options = options || {};
        // just call the function otherwise wrap a promise around its execution
        if (typeof callback === 'function') {
            func(options, callback);
            return undefined;
        } else {
            return new Promise((fulfill, reject) => {
                func(options, (err, result) => {
                    if (err) {
                        reject(err);
                    } else {
                        fulfill(result);
                    }
                });
            });
        }
    };
}
687318
function makeRequest(params) {
    var QPromiseFactory = function(resolver) {
      return q.Promise(resolver);
    };
    params.retryStrategy = loggingRetryStrategy;
    params.promiseFactory = QPromiseFactory;
    return request(params)
      .then(function (response) {
        if (response.statusCode !== 200) {
          throw new Error('HTTP error (' + response.statusCode + ')');
        }
        return response.body;
      })
      .fail(function (error) {
        throw new WrapperError([
          params.method,
          params.url,
          'failed.'
        ].join(' '), error);
      });
  }
354828
function execPromise (cmd) {
  if (isTest) {
    return Promise.resolve(cmd)
  }
  return new Promise((resolve, reject) => {
    exec(cmd, (err, stdout, stderr) => {
      if (err || stderr) reject(err || stderr)
      else resolve(stdout)
    })
  })
}
790246
function() {
  return Promise.resolve()
  .then(function() { return npm.loadAsync(); })
  .then(function(npm) {
    npm.config.set('spin', false);
    npm.config.set('global', true);
    npm.config.set('depth', 0);
    return Promise.promisify(npm.commands.list)([], true);
  })
  .then(function(data) { return data; });
}
1345297
function httpRequestPromise(method, urlObject) {
  if (method !== 'GET' && method !== 'HEAD') {
    return Promise.reject(new Error('We only support GET or HEAD requests'));
  }

  return new Promise(function (resolve, reject) {
    var httpsRequestOptions = {
      host: urlObject.host,
      method: method,
      path: urlObject.path
    };

    var req = https.request(httpsRequestOptions, function (res) {
      if (res.statusCode !== 200) {
        reject(new Error('Did not get 200 for ' + urlObject.href +
          ', instead got ' + res.statusCode));
        return;
      }

      resolve(res);
    })
    .on('error', function (e) {
      reject(new Error('Got error on ' + urlObject.href + ' - ' + e));
    });

    req.end();
  });
}
1321846
function () {
    const oThis = this
      , promiseArray = [];

    return new Promise(async function (onResolve, onReject) {
      for (var chain in setupConfig.chains) {
        promiseArray.push(oThis._isRunning(chain));
      }
      return Promise.all(promiseArray).then(onResolve);
    });
  }
857246
function reject(err, async) {
    err = toErr(err);
    if (async) {
        return Promise.reject(err);
    } else {
        throw err;
    }
}
79017
function go() {
    return new Promise(handler)
      // Check for invalid `authCode`, this seems to happen at random intervals
      // within the neulion API, so we will only know when a request fails
      .catch(Errors.AuthenticationError, function(err) {

        // Authenticate and then try one more time
        return self
          .auth()
          .then(function() {
            return new Promise(handler)
          })
      })
  }