rm-mediaquery

remove all mediaquery from a stylesheet

npm install rm-mediaquery
2 downloads in the last week
8 downloads in the last month
<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"><meta charset="utf-8"></head><body><h1>rm-mediaquery</h1>
<p><strong>(c)<a href="http://www.bumblehead.com" title="bumblehead">Bumblehead</a>, 2013</strong> <a href="#license">MIT-license</a>  </p>
<h3>OVERVIEW:</h3>
<p>Remove all mediaquery from a stylesheet.</p>
<hr>
<h4><a id="install"></a>INSTALL:</h4>
<p>rm-mediaquery may be downloaded directly or installed through <code>npm</code>.</p>
<ul>
<li><p><strong>npm</strong>   </p>
<pre><code class="lang-bash">$ npm install rm-mediaquery</code></pre>
</li>
<li><p><strong>Direct Download</strong></p>
<pre><code class="lang-bash">$ git clone https://github.com/iambumblehead/rm-mediaquery.git
$ cd rm-mediaquery &amp;&amp; npm install</code></pre>
</li>
</ul>
<hr>
<h4><a id="test"></a>Test:</h4>
<p> to run tests, use <code>npm test</code> from a shell.</p>
<pre><code class="lang-bash"> $ npm test</code></pre>
<hr>
<h4><a id="get-started">GET STARTED:</h4>
<pre><code class="lang-javascript">  var rmMediaquery = require(&#39;rmMediaquery&#39;);

  var styleStr_regular = &#39;&#39; +
  &#39;.regular {\n&#39; +
  &#39;  color:black;\n&#39; +
  &#39;}\n&#39; +
  &#39;@media screen and (max-width: 1025px) {\n&#39; +
  &#39;  .container .grid1 { display: none; }\n&#39; +
  &#39;}\n&#39; +
  &#39;.regular2 {\n&#39; +
  &#39;  color:red;\n&#39; +
  &#39;}\n&#39; +
  &#39;@media screen and (max-width: 900px) {\n&#39; +
  &#39;  @media screen and (max-width: 500px) {\n&#39; +
  &#39;    .container .grid1 { display: none; }\n&#39; +
  &#39;  }\n&#39; +
  &#39;}\n&#39;;

  console.log(rmMediaquery(styleStr_regular));
  //.regular {
  //  color:black;
  //}
  //
  //.regular2 {
  //  color:red;
  //}</code></pre>
<p>This result is achieved with fewer lines than the example uses. Here it is:</p>
<pre><code class="lang-javascript">  var bgnMediaRe = /@media[^{]*{[\s\S]*/mi,
      endMediaRe = /}[}\s]*}/mi;

  function rmMedia (str) {
    if (str.match(endMediaRe)) {
      return str.split(endMediaRe).map(rmMedia).join(&#39; &#39;);
    } else {
      return str.replace(bgnMediaRe, &#39; &#39;);
    }
  }</code></pre>
<hr>
<h4><a id="license">License:</h4>
<p> <img src="http://github.com/iambumblehead/scroungejs/raw/master/img/hand.png" alt="scrounge"> </p>
<p>(The MIT License)</p>
<p>Copyright (c) 2012 <a href="http://www.bumblehead.com" title="bumblehead">Bumblehead</a> <a href="&#x6d;&#x61;&#x69;&#108;&#116;&#x6f;&#x3a;&#99;&#x68;&#x72;&#105;&#115;&#64;&#x62;&#117;&#109;&#98;&#x6c;&#101;&#x68;&#101;&#97;&#x64;&#x2e;&#x63;&#111;&#109;">&#99;&#x68;&#x72;&#105;&#115;&#64;&#x62;&#117;&#109;&#98;&#x6c;&#101;&#x68;&#101;&#97;&#x64;&#x2e;&#x63;&#111;&#109;</a></p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &#39;Software&#39;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED &#39;AS IS&#39;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</body></html>
npm loves you