🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

css-mq-parser

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-mq-parser

Parses CSS media queries

0.0.3
latest
Version published
Maintainers
2
Created

CSS Media Query Parser

npm version Build Status Coverage Status devDependency Status

Parses CSS media query expressions.

Installation

Install via npm:

$ npm install css-mq-parser

Usage

This package exports one function, which can parse CSS media query expressions and return an AST. The parser tolerates several known CSS media query browser hacks, but will throw a SyntaxError if the media query expression is severely malformed. Note that this module implements a lax/liberal/non-validating parser; even modulo browser hacks, the fact that it parses a given expression successfully does not guarantee that the expression is valid per the relevant CSS specifications.

var parseMediaQuery = require('css-mq-parser');
var ast = parseMediaQuery('screen and (min-width: 48em)');

The ast variable will have the following payload:

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

License & Acknowledgements

This project is a fork of css-mediaquery. This software is free to use under the New/Revised BSD License. See the LICENSE file for license text and copyright information.

FAQs

Package last updated on 01 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts