index.js
function transform(wanted, available) {
  const browsers = new Set();

  wanted.forEach((browser) => {
    const name = browser.name.toLowerCase();

    if (!available.has(name)) {
      throw new Error(`Browser ${name} is not available`);
    }

    let list = available.get(name).slice().sort(compare);
    let platforms = browser.platform;

    if (platforms === undefined) {
      //
      // Remove all duplicate versions.
      //
      const filtered = [list[0]];
      for (let i = 1; i < list.length; i++) {
        if (list[i].short_version !== list[i - 1].short_version) {
          filtered.push(list[i]);
        }
      }
      list = filtered;
    } else {
      if (!Array.isArray(platforms)) platforms = [platforms];
      //
      // Filter out unwanted platforms.
      //
      platforms = platforms.map((el) => String(el).toLowerCase());
      list = list.filter((el) => ~platforms.indexOf(el.os.toLowerCase()));
    }

    if (list.length === 0) return;

    let versions = browser.version;

    if (versions === undefined) {
      list.forEach((el) => browsers.add(el));
    } else {
      if (!Array.isArray(versions)) versions = [versions];
      versions.forEach((version) => {
        filterByVersion(list, version).forEach((el) => browsers.add(el));
      });
    }
  });

  return Array.from(browsers);
}
function transform(wanted, available) {
  const browsers = new Set();

  wanted.forEach((browser) => {
    const name = browser.name.toLowerCase();

    if (!available.has(name)) {
      throw new Error(`Browser ${name} is not available`);
    }

    let list = available.get(name).slice().sort(compare);
    let platforms = browser.platform;

    if (platforms === undefined) {
      //
      // Remove all duplicate versions.
      //
      const filtered = [list[0]];
      for (let i = 1; i < list.length; i++) {
        if (list[i].short_version !== list[i - 1].short_version) {
          filtered.push(list[i]);
        }
      }
      list = filtered;
    } else {
      if (!Array.isArray(platforms)) platforms = [platforms];
      //
      // Filter out unwanted platforms.
      //
      platforms = platforms.map((el) => String(el).toLowerCase());
      list = list.filter((el) => ~platforms.indexOf(el.os.toLowerCase()));
    }

    if (list.length === 0) return;

    let versions = browser.version;

    if (versions === undefined) {
      list.forEach((el) => browsers.add(el));
    } else {
      if (!Array.isArray(versions)) versions = [versions];
      versions.forEach((version) => {
        filterByVersion(list, version).forEach((el) => browsers.add(el));
      });
    }
  });

  return Array.from(browsers);
}
function transform ( wanted , available ) { const browsers = new Set ( ) ; wanted . forEach ( ( browser ) => { const name = browser . name . toLowerCase ( ) ; if ( ! available . has ( name ) ) { throw new Error ( ` ${ name } ` ) ; } let list = available . get ( name ) . slice ( ) . sort ( compare ) ; let platforms = browser . platform ; if ( platforms === undefined ) { // // Remove all duplicate versions. // const filtered = [ list [ 0 ] ] ; for ( let i = 1 ; i < list . length ; i ++ ) { if ( list [ i ] . short_version !== list [ i - 1 ] . short_version ) { filtered . push ( list [ i ] ) ; } } list = filtered ; } else { if ( ! Array . isArray ( platforms ) ) platforms = [ platforms ] ; // // Filter out unwanted platforms. // platforms = platforms . map ( ( el ) => String ( el ) . toLowerCase ( ) ) ; list = list . filter ( ( el ) => ~ platforms . indexOf ( el . os . toLowerCase ( ) ) ) ; } if ( list . length === 0 ) return ; let versions = browser . version ; if ( versions === undefined ) { list . forEach ( ( el ) => browsers . add ( el ) ) ; } else { if ( ! Array . isArray ( versions ) ) versions = [ versions ] ; versions . forEach ( ( version ) => { filterByVersion ( list , version ) . forEach ( ( el ) => browsers . add ( el ) ) ; } ) ; } } ) ; return Array . from ( browsers ) ; }
Convert a list of platforms in "zuul" format to a list of platforms in
the same format returned by Sauce Labs REST API.

@param {Array} available The list of all supported platforms on Sauce Labs
@param {Array} wanted The list of platforms in "zuul" format
@return {Array} The transformed list
@private
Convert a list of platforms in zuul format to a list of platforms in the same format returned by Sauce Labs REST API .