Socket
Socket
Sign inDemoInstall

css-mq-parser

Package Overview
Dependencies
0
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-mq-parser

Parses CSS media queries


Version published
Weekly downloads
2.4K
increased by4.21%
Maintainers
2
Install size
15.4 kB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 01 Oct 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc