How to use the asyncbox.asyncmap 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 / commands / touch.js View on Github external
helpers.parseTouch = async function parseTouch (gestures, multi) {
  // because multi-touch releases at the end by default
  if (multi && _.last(gestures).action === 'release') {
    gestures.pop();
  }

  let touchStateObjects = await asyncmap(gestures, async (gesture) => {
    let options = gesture.options || {};
    if (_.includes(['press', 'moveTo', 'tap', 'longPress'], gesture.action)) {
      options.offset = false;
      let elementId = gesture.options.element;
      if (elementId) {
        let pos = await this.getLocationInView(elementId);
        if (gesture.options.x || gesture.options.y) {
          options.x = pos.x + (gesture.options.x || 0);
          options.y = pos.y + (gesture.options.y || 0);
        } else {
          const {width, height} = await this.getSize(elementId);
          options.x = pos.x + (width / 2);
          options.y = pos.y + (height / 2);
        }
        let touchStateObject = {
          action: gesture.action,
github appium / appium-chromedriver / lib / chromedriver.js View on Github external
async getChromedrivers (mapping) {
    // go through the versions available
    const executables = await fs.glob(`${this.executableDir}/*`);
    log.debug(`Found ${executables.length} executable${executables.length === 1 ? '' : 's'} ` +
      `in '${this.executableDir}'`);
    const cds = (await asyncmap(executables, async function mapChromedriver (executable) {
      const logError = ({message, stdout = null, stderr = null}) => {
        let errMsg = `Cannot retrieve version number from '${path.basename(executable)}' Chromedriver binary. ` +
          `Make sure it returns a valid version string in response to '--version' command line argument. ${message}`;
        if (stdout) {
          errMsg += `\nStdout: ${stdout}`;
        }
        if (stderr) {
          errMsg += `\nStderr: ${stderr}`;
        }
        log.warn(errMsg);
        return null;
      };

      let stdout;
      let stderr;
      try {
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
async isFresh () {
    // if the following files don't exist, it hasn't been booted.
    // THIS IS NOT AN EXHAUSTIVE LIST
    let files = this.isFreshFiles;

    let pv = await this.getPlatformVersion();
    if (pv !== '7.1') {
      files.push('Library/Preferences/com.apple.Preferences.plist');
    } else {
      files.push('Applications');
    }

    const dir = this.getDir();
    files = files.map((s) => path.resolve(dir, s));

    const existences = await asyncmap(files, async (f) => await fs.hasAccess(f));
    const fresh = _.compact(existences).length !== files.length;
    log.debug(`Checking whether simulator has been run before: ${fresh ? 'no' : 'yes'}`);

    return fresh;
  }
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
};
      // given a directory, return the path and bundle id associated with it
      pathBundlePair = async (dir) => {
        dir = path.resolve(applicationList, dir);
        let bundleId = await readBundleId(dir);
        return {path: dir, bundleId};
      };
    }

    if (!await fs.exists(applicationList)) {
      log.warn(`No directory path '${applicationList}'`);
      return {};
    }

    let bundlePathDirs = await fs.readdir(applicationList);
    let bundlePathPairs = await asyncmap(bundlePathDirs, async (dir) => {
      return await pathBundlePair(dir);
    }, false);

    // reduce the list of path-bundle pairs to an object where bundleIds are mapped to paths
    return bundlePathPairs.reduce((bundleMap, bundlePath) => {
      bundleMap[bundlePath.bundleId] = bundlePath.path;
      return bundleMap;
    }, {});
  }
github appium / appium-android-driver / lib / webview-helpers.js View on Github external
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;
  }

  webviews = await asyncmap(webviews, async (webviewName) => {
    let pkg = await helpers.procFromWebview(adb, webviewName);
    return WEBVIEW_BASE + pkg;
  });
  logger.debug(`Found webviews: ${JSON.stringify(webviews)}`);
  return webviews;
};
github appium / appium-ios-simulator / test / unit / settings-specs.js View on Github external
async function getData () {
      return await asyncmap(realFiles, (file) => {
        return settings.read(file);
      }, true);
    }

asyncbox

A collection of small async/await utilities

Apache-2.0
Latest version published 12 months ago

Package Health Score

64 / 100
Full package analysis