function matchQuery(mediaQuery, values) {
  return parseQuery(mediaQuery).some(function (query) {
    const inverse = query.inverse;

    // Either the parsed or specified `type` is "all", or the types must be
    // equal for a match.
    const typeMatch = query.type === 'all' || values.type === query.type;

    // Quit early when `type` doesn't match, but take "not" into account.
    if ((typeMatch && inverse) || !(typeMatch || inverse)) {
      return false;
    }

    const expressionsMatch = query.expressions.every(function (expression) {
      const feature = expression.feature;
      const modifier = expression.modifier;
      let expValue = expression.value;
      let value = values[feature];

      // Missing or falsy values don't match.
      if (!value && value !== 0) {
        return false;
      }

      switch (feature) {
        case 'orientation':
        case 'scan':
          return value.toLowerCase() === expValue.toLowerCase();

        case 'width':
        case 'height':
        case 'device-width':
        case 'device-height':
          expValue = toPx(expValue);
          value = toPx(value);
          break;

        case 'resolution':
          expValue = toDpi(expValue);
          value = toDpi(value);
          break;

        case 'aspect-ratio':
        case 'device-aspect-ratio':
          expValue = toDecimal(expValue);
          value = toDecimal(value);
          break;

        case 'grid':
        case 'color':
        case 'color-index':
        case 'monochrome':
          expValue = parseInt(expValue, 10) || 1;
          value = parseInt(value, 10) || 0;
          break;

        default:
          break;
      }

      switch (modifier) {
        case 'min':
          return value >= expValue;
        case 'max':
          return value <= expValue;
        default:
          return value === expValue;
      }
    });

    return (expressionsMatch && !inverse) || (!expressionsMatch && inverse);
  });
}
Parses and determines if a given CSS Media Query matches a set of values via
JavaScript. This package has two exports: `parse()` and `match()`.

**Matching**

The `match()` method lets you compare a media query expression with a JavaScript
object and determine if a media query matches a given set of values.

    const isMatch = mediaQuery.match(mediaQueryString, stateObject);

A `type` value must be included in the state and it can't be "all".

Parsing

You can parse a media query expression and get an AST back by using the
`parse()` method.

    const ast = mediaQuery.parse(mediaQueryString);

The AST has the following shape:

    [{
       inverse: false,
       type: 'screen',
       expressions: [{
         modifier: 'min',
         feature : 'width',
         value   : '48em'
       }]
     }]