index.js
function resolve (queries, context) {
  if (Array.isArray(queries)) {
    queries = flatten(queries.map(parse))
  } else {
    queries = parse(queries)
  }

  return queries.reduce(function (result, query, index) {
    var selection = query.queryString

    var isExclude = selection.indexOf('not ') === 0
    if (isExclude) {
      if (index === 0) {
        throw new BrowserslistError(
          'Write any browsers query (for instance, `defaults`) ' +
          'before `' + selection + '`')
      }
      selection = selection.slice(4)
    }

    for (var i = 0; i < QUERIES.length; i++) {
      var type = QUERIES[i]
      var match = selection.match(type.regexp)
      if (match) {
        var args = [context].concat(match.slice(1))
        var array = type.select.apply(browserslist, args).map(function (j) {
          var parts = j.split(' ')
          if (parts[1] === '0') {
            return parts[0] + ' ' + byName(parts[0]).versions[0]
          } else {
            return j
          }
        })

        switch (query.type) {
          case QUERY_AND:
            if (isExclude) {
              return result.filter(function (j) {
                // remove result items that are in array
                // (the relative complement of array in result)
                return array.indexOf(j) === -1
              })
            } else {
              return result.filter(function (j) {
                // remove result items not in array
                // (intersect of result and array)
                return array.indexOf(j) !== -1
              })
            }
          case QUERY_OR:
          default:
            if (isExclude) {
              var filter = { }
              array.forEach(function (j) {
                filter[j] = true
              })
              return result.filter(function (j) {
                return !filter[j]
              })
            }
            // union of result and array
            return result.concat(array)
        }
      }
    }

    throw unknownQuery(selection)
  }, [])
}
function resolve (queries, context) {
  if (Array.isArray(queries)) {
    queries = flatten(queries.map(parse))
  } else {
    queries = parse(queries)
  }

  return queries.reduce(function (result, query, index) {
    var selection = query.queryString

    var isExclude = selection.indexOf('not ') === 0
    if (isExclude) {
      if (index === 0) {
        throw new BrowserslistError(
          'Write any browsers query (for instance, `defaults`) ' +
          'before `' + selection + '`')
      }
      selection = selection.slice(4)
    }

    for (var i = 0; i < QUERIES.length; i++) {
      var type = QUERIES[i]
      var match = selection.match(type.regexp)
      if (match) {
        var args = [context].concat(match.slice(1))
        var array = type.select.apply(browserslist, args).map(function (j) {
          var parts = j.split(' ')
          if (parts[1] === '0') {
            return parts[0] + ' ' + byName(parts[0]).versions[0]
          } else {
            return j
          }
        })

        switch (query.type) {
          case QUERY_AND:
            if (isExclude) {
              return result.filter(function (j) {
                // remove result items that are in array
                // (the relative complement of array in result)
                return array.indexOf(j) === -1
              })
            } else {
              return result.filter(function (j) {
                // remove result items not in array
                // (intersect of result and array)
                return array.indexOf(j) !== -1
              })
            }
          case QUERY_OR:
          default:
            if (isExclude) {
              var filter = { }
              array.forEach(function (j) {
                filter[j] = true
              })
              return result.filter(function (j) {
                return !filter[j]
              })
            }
            // union of result and array
            return result.concat(array)
        }
      }
    }

    throw unknownQuery(selection)
  }, [])
}
function resolve ( queries , context ) { if ( Array . isArray ( queries ) ) { queries = flatten ( queries . map ( parse ) ) } else { queries = parse ( queries ) } return queries . reduce ( function ( result , query , index ) { var selection = query . queryString var isExclude = selection . indexOf ( 'not ' ) === 0 if ( isExclude ) { if ( index === 0 ) { throw new BrowserslistError ( 'Write any browsers query (for instance, `defaults`) ' + 'before `' + selection + '`' ) } selection = selection . slice ( 4 ) } for ( var i = 0 ; i < QUERIES . length ; i ++ ) { var type = QUERIES [ i ] var match = selection . match ( type . regexp ) if ( match ) { var args = [ context ] . concat ( match . slice ( 1 ) ) var array = type . select . apply ( browserslist , args ) . map ( function ( j ) { var parts = j . split ( ' ' ) if ( parts [ 1 ] === '0' ) { return parts [ 0 ] + ' ' + byName ( parts [ 0 ] ) . versions [ 0 ] } else { return j } } ) switch ( query . type ) { case QUERY_AND : if ( isExclude ) { return result . filter ( function ( j ) { // remove result items that are in array // (the relative complement of array in result) return array . indexOf ( j ) === - 1 } ) } else { return result . filter ( function ( j ) { // remove result items not in array // (intersect of result and array) return array . indexOf ( j ) !== - 1 } ) } case QUERY_OR : default : if ( isExclude ) { var filter = { } array . forEach ( function ( j ) { filter [ j ] = true } ) return result . filter ( function ( j ) { return ! filter [ j ] } ) } // union of result and array return result . concat ( array ) } } } throw unknownQuery ( selection ) } , [ ] ) }
Resolves queries into a browser list.
@param {string|string[]} queries Queries to combine.
Either an array of queries or a long string of queries.
@param {object} [context] Optional arguments to
the select function in `queries`.
@returns {string[]} A list of browsers
Resolves queries into a browser list .