How to use the asyncbox.asyncfilter function in asyncbox

To help you get started, we’ve selected a few asyncbox 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 appium / appium-android-driver / lib / webview-helpers.js View on Github external
helpers.getWebviews = async function getWebviews (adb, {
  androidDeviceSocket = null,
  ensureWebviewsHavePages = null,
  webviewDevtoolsPort = null
} = {}) {

  logger.debug('Getting a list of available webviews');
  let webviewProcs = await webviewsFromProcs(adb, androidDeviceSocket);

  if (ensureWebviewsHavePages) {
    logger.info('Retrieved potential webviews; will filter out ones with no active pages');
    webviewProcs = await asyncfilter(webviewProcs,
      async (wp) => await webviewHasPages(adb, wp, webviewDevtoolsPort),
      false /*ensure serial operation*/);
  } else {
    logger.info('Not checking whether webviews have active pages; use the ' +
                "'ensureWebviewsHavePages' cap to turn this check on");
  }

  // webviewProcs contains procs, which we only care about for ensuring
  // presence of pages above, so we can now discard them and rely on just the
  // webview names
  let webviews = webviewProcs.map((wp) => wp.webview);

  if (androidDeviceSocket) {
    return webviews;
  }

asyncbox

A collection of small async/await utilities

Apache-2.0
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis