Returns a Promise that resovles static when a steamvr controller is found
184393
function getController(hand, config) {
	const findGamepad = (resolve, reject) => {
		const gamepad = altspace.getGamepads().find((g) => g.mapping === 'steamvr' && g.hand === hand);
		if (gamepad) {
			if(config.logging) console.log("SteamVR input device found", gamepad);
			resolve(gamepad);
		} else {
			if(config.logging) console.log("SteamVR input device not found trying again in 500ms...");
			setTimeout(findGamepad, 500, resolve, reject);
		}
	};

	return new Promise(findGamepad);
}
1001277
function (sessionInfo) {
    var defer = Q.defer();
    this.sessionStatus = JSON.parse(sessionInfo).value;
    this.events.emit('driver:sessionStatus:sauce:' + this.browserName, this.sessionStatus);
    defer.resolve();
    return defer.promise;
  }
975972
function (req, res, next) {
            if (!req.miajs.controllerDebugInfo) {
                req.miajs.controllerDebugInfo = {};
            }
            if (controller.name && controller.version) {
                req.miajs.controllerDebugInfo[controller.name + '_' + controller.version] = {'runtime': Date.now() - req.miajs.controllerStart};
            }
            next();
        }
376875
function Middleware(...middleware) {
    return (ctr) => {
        if (middleware != undefined) {
            let c = exports.globalKCState.getOrInsertController(ctr);
            c.middleware = middleware.concat(c.middleware);
        }
    };
}
791713
function trackController (incoming, controller) {
    return incoming
        .withLatestFrom(controller)
        .flatMap(x => {

            const incomingEvent     = x[0];
            const currentController = x[1];

            /**
             * Controller has not been set, therefore we allow this event
             * through (as this will in turn cause the controller to be set)
             */
            if (currentController.id === '') {
                return just({locked: false, id: incomingEvent.id, socketId: incomingEvent.socketId});
            }

            /**
             * If the controller ID matches the incoming event ID
             * we return the controller, but re-set the socketId
             * as this could change (ie: every time the browser reloads)
             */
            if (currentController.id === incomingEvent.id) {
                return just(Object.assign(currentController, {socketId: incomingEvent.socketId}));
            }

            /**
             * If we reach here, the controller was set, but the
             * controller.id didn't match the incoming event.id. So we bail here
             * and don't pass any value through. This is how we essentially
             * ignore all events from any browser that is not currently deemed
             * the controller.
             */
            return empty();
        })
        .distinctUntilChanged();
}
80254
function (iter, fn) {
      return new Promise(function (resolve) {
        var i = 0;
        function next() {
          return iter.next().then(function (result) {
            if (result.done) {
              return result.value;
            }
            fn(result.value, i++);
            return next();
          });
        }
        resolve(next());
      });
    }
775415
function reject(vReason) {
			vResult = vReason;
			iState = -1;

			if (!bCaught && SyncPromise.listener) {
				SyncPromise.listener(that, false);
			}

			if (fnReject) {
				fnReject(vReason);
				fnReject = fnResolve = null; // be nice to the garbage collector
			}
		}
591391
function triggerPromise() {
        var me = this;
        var args = arguments;

        var canHandlePromise =
            this.children.indexOf("completed") >= 0 &&
            this.children.indexOf("failed") >= 0;

        var createdPromise = new PromiseFactory(function(resolve, reject) {
            // If `listenAndPromise` is listening
            // patch `promise` w/ context-loaded resolve/reject
            if (me.willCallPromise) {
                _.nextTick(function() {
                    var previousPromise = me.promise;
                    me.promise = function (inputPromise) {
                        inputPromise.then(resolve, reject);
                        // Back to your regularly schedule programming.
                        me.promise = previousPromise;
                        return me.promise.apply(me, arguments);
                    };
                    me.trigger.apply(me, args);
                });
                return;
            }

            if (canHandlePromise) {
                var removeSuccess = me.completed.listen(function () {
                    var args = Array.prototype.slice.call(arguments);
                    removeSuccess();
                    removeFailed();
                    resolve(args.length > 1 ? args : args[0]);
                });

                var removeFailed = me.failed.listen(function () {
                    var args = Array.prototype.slice.call(arguments);
                    removeSuccess();
                    removeFailed();
                    reject(args.length > 1 ? args : args[0]);
                });
            }

            _.nextTick(function () {
                me.trigger.apply(me, args);
            });

            if (!canHandlePromise) {
                resolve();
            }
        });

        // Ensure that the promise does trigger "Uncaught (in promise)" errors in console if no error handler is added
        // See: https://github.com/reflux/reflux-promise/issues/4
        createdPromise.catch(function() {});

        return createdPromise;
    }
1114765
static function now($val, $default=null) {
		if ( $val instanceof PromiseInterface ) {
			return ( $val->getState() === PromiseInterface::PENDING ) ? $default : $val->wait();
		}
		return $val;
	}
174114
function(moveBack) {
        return new Promise(function(resolve, reject) {
            exec(resolve, reject, APP_PLUGIN_NAME, "minimizeApp", [moveBack || false]);
        });
    }
312741
function syncPromise(promise) {
  let isDone = false;
  let res, err;

  promise.then(
    value => {
      res = value;
      isDone = true;
    },
    error => {
      err = error;
      isDone = true;
    }
  );

  deasync.loopWhile(() => !isDone);

  if (err) {
    throw err;
  }

  return res;
}
837914
function toResolve() {
  return {
    compare(actual) {
      assertPromise(actual);
      const success = jasmine.createSpy('Promise success callback');
      actual.then(success, angular.noop);
      createScope().$digest();

      const pass = isJasmine2 ? success.calls.any() : success.calls.length > 0;
      const message = 'Expected promise {not} to have been resolved';
      return getResult('toResolve', pass, message);
    }
  };
}
1144838
function loadAndSaveShoots(settings, folderPath) {
  var promisesPool = [];
  var semaphore = new Semaphore({rooms: 6});

  settings.pages.forEach((page) => {
    settings.sizes.forEach((size) => {

      promisesPool.push(semaphore.add(() => {
        return new Promise((resolve, reject) => {

          console.log(`Start ${page.name} for ${size.width}x${size.height}`);

          screenshot({
            url : settings.urlBase + page.url,
            width : size.width,
            height : size.height,
            page: size.page === undefined ? true : size.page,
            cookies: settings.cookies,
            auth: settings.auth,
            delay: settings.delay,
          })
          .then(function(img){
            var fileName = getFileName(page, size);

            fs.writeFile(path.join(folderPath, fileName), img.data, function(err){
              if (err) {
                console.info(`Failed to save ${fileName}`, err)
              }

              resolve();
            });
          })
          .catch((err) => {
            console.info(`Failed to retrieve ${page.url}`, err)
            resolve();
          })

        })
      }))

    })
  })

  var promise = Promise.all(promisesPool);

  // Close screenshot service
  promise = promise.then(() => {
    console.log(`Done`)
    screenshot.close();
  }).catch(() => {
    console.log(`Done with errors`)
    screenshot.close();
  })

  return promise
}
197554
function (deferred, desiredCapabilities, defaults) {
    var viewport = this.config.get('viewport');

    // start a session, transmit the desired capabilities
    var promise = this.webdriverClient.createSession({desiredCapabilities: desiredCapabilities});
    
    // set the default viewport if supported by the browser
    if (defaults.viewport) {
      promise = promise.then(this.webdriverClient.setWindowSize.bind(this.webdriverClient, viewport.width, viewport.height));
    }

    // get the driver status if supported by the browser
    if (defaults.status === true) {
      promise = promise
        .then(this.webdriverClient.status.bind(this.webdriverClient))
        .then(this._driverStatus.bind(this));
    } else {
      promise = promise.then(this._driverStatus.bind(this, JSON.stringify({value: defaults.status})));
    }

    // get the session info if supported by the browser
    if (defaults.sessionInfo === true) {
      promise = promise
        .then(this.webdriverClient.sessionInfo.bind(this.webdriverClient))
        .then(this._sessionStatus.bind(this));
    } else {
      promise = promise.then(this._driverStatus.bind(this, JSON.stringify({value: defaults.sessionInfo})));
    }

    // finally resolve the deferred
    promise.then(deferred.resolve);
    return this;
  }
1294637
public GVRCursorController findCursorController(GVRControllerType type) {
        for (int index = 0, size = cache.size(); index < size; index++)
        {
            int key = cache.keyAt(index);
            GVRCursorController controller = cache.get(key);
            if (controller.getControllerType().equals(type)) {
                return controller;
            }
        }
        return null;
    }
501972
function fromAsync(fn) {
  return new ReadableStream({
    pull: async controller => {
      try {
        controller.enqueue(await fn());
        controller.close();
      } catch(e) {
        controller.error(e);
      }
    }
  });
}
367340
function needToGetManifest () {
        var requiresSimulcastSeekingData = {
          restartable: true,
          seekable: true,
          playable: false,
          none: false
        };

        return windowType !== WindowTypes.STATIC && requiresSimulcastSeekingData[getLiveSupport(device)];
      }