Minor style changes.
authorXhmikosR <xhmikosr@users.sourceforge.net>
Fri, 8 Nov 2013 16:39:54 +0000 (18:39 +0200)
committerXhmikosR <xhmikosr@users.sourceforge.net>
Sat, 9 Nov 2013 14:22:21 +0000 (16:22 +0200)
13 files changed:
lib/clean.js
lib/images/url-rebase.js
lib/images/url-rewriter.js
lib/imports/inliner.js
lib/selectors/empty-removal.js
lib/selectors/optimizer.js
lib/text/comments.js
lib/text/expressions.js
lib/text/free.js
lib/text/urls.js
test/bench.js
test/module-test.js
test/unit-test.js

index af9c7e0..9b1f4ff 100644 (file)
@@ -63,7 +63,7 @@ module.exports = function(options) {
         originalReplace(pattern, replacement);
 
         var itTook = process.hrtime(start);
-        console.log('%d ms: ' + name, 1000 * itTook[0] + itTook[1] / 1000000.0);
+        console.log('%d ms: ' + name, 1000 * itTook[0] + itTook[1] / 1000000);
       };
     }
 
@@ -92,7 +92,7 @@ module.exports = function(options) {
     });
 
     // replace all escaped line breaks
-    replace(/\\(\r\n|\n)/mg, '');
+    replace(/\\(\r\n|\n)/gm, '');
 
     // strip parentheses in urls if possible (no spaces inside)
     replace(/url\((['"])([^\)]+)['"]\)/g, function(match, quote, url) {
index 5b24954..8d5c59b 100644 (file)
@@ -28,7 +28,5 @@ module.exports = function UrlRebase(options, context) {
     return UrlRewriter.process(data, rebaseOpts);
   };
 
-  return {
-    process: process
-  };
+  return { process: process };
 };
index b41056f..14df441 100644 (file)
@@ -7,7 +7,7 @@ module.exports = {
     var nextEnd = 0;
     var cursor = 0;
 
-    for (; nextEnd < data.length; ) {
+    for (; nextEnd < data.length;) {
       nextStart = data.indexOf('url(', nextEnd);
       if (nextStart == -1)
         break;
index f0c793a..acd5d71 100644 (file)
@@ -15,7 +15,7 @@ module.exports = function Inliner(context) {
     options._baseRelativeTo = options._baseRelativeTo || options.relativeTo;
     options.visited = options.visited || [];
 
-    for (; nextEnd < data.length; ) {
+    for (; nextEnd < data.length;) {
       nextStart = data.indexOf('@import', cursor);
       if (nextStart == -1)
         break;
@@ -137,8 +137,6 @@ module.exports = function Inliner(context) {
       inlinedData;
   };
 
-  return {
-    // Inlines all imports taking care of repetitions, unknown files, and circular dependencies
-    process: process
-  };
+  // Inlines all imports taking care of repetitions, unknown files, and circular dependencies
+  return { process: process };
 };
index ee193c1..7af188d 100644 (file)
@@ -4,7 +4,7 @@ module.exports = function EmptyRemoval(data) {
     var nextEmpty = 0;
     var cursor = 0;
 
-    for (; nextEmpty < cssData.length; ) {
+    for (; nextEmpty < cssData.length;) {
       nextEmpty = cssData.indexOf('{}', cursor);
       if (nextEmpty == -1)
         break;
index 2d406d7..8a344e9 100644 (file)
@@ -32,7 +32,7 @@ module.exports = function Optimizer(data, options) {
     var forRemoval = [];
 
     for (var i = 0, l = tokens.length; i < l; i++) {
-      if (typeof(tokens[i]) == 'string' || tokens[i].block)
+      if (typeof tokens[i] == 'string' || tokens[i].block)
         continue;
 
       var selector = tokens[i].selector;
@@ -48,7 +48,9 @@ module.exports = function Optimizer(data, options) {
       }
     }
 
-    forRemoval = forRemoval.sort(function(a, b) { return a > b ? 1 : -1; });
+    forRemoval = forRemoval.sort(function(a, b) {
+      return a > b ? 1 : -1;
+    });
     for (var j = 0, n = forRemoval.length; j < n; j++) {
       tokens.splice(forRemoval[j] - j, 1);
     }
@@ -61,7 +63,7 @@ module.exports = function Optimizer(data, options) {
     for (var i = 0, l = tokens.length; i < l; i++) {
       var token = tokens[i];
 
-      if (typeof(token) == 'string' || token.block)
+      if (typeof token == 'string' || token.block)
         continue;
 
       if (token.selector == lastToken.selector) {
@@ -94,7 +96,7 @@ module.exports = function Optimizer(data, options) {
       token = tokens[i];
       selector = token.selector;
 
-      if (typeof(token) == 'string' || token.block)
+      if (typeof token == 'string' || token.block)
         continue;
 
       selectors = selector.split(',');
@@ -131,7 +133,7 @@ module.exports = function Optimizer(data, options) {
       var currentMatch = matchPositions.length - 1;
 
       while (currentMatch >= 0) {
-        if (bodies[currentMatch].indexOf(optimizedTokens[k]) > - 1) {
+        if (bodies[currentMatch].indexOf(optimizedTokens[k]) > -1) {
           k -= 1;
           continue;
         }
@@ -180,7 +182,7 @@ module.exports = function Optimizer(data, options) {
   };
 
   var optimize = function(tokens) {
-    tokens = (Array.isArray(tokens) ? tokens : [tokens]);
+    tokens = Array.isArray(tokens) ? tokens : [tokens];
     for (var i = 0, l = tokens.length; i < l; i++) {
       var token = tokens[i];
 
index 5667e7e..8aa7d3c 100644 (file)
@@ -13,7 +13,7 @@ module.exports = function Comments(keepSpecialComments, keepBreaks, lineBreak) {
       var nextEnd = 0;
       var cursor = 0;
 
-      for (; nextEnd < data.length; ) {
+      for (; nextEnd < data.length;) {
         nextStart = data.indexOf('/*', nextEnd);
         nextEnd = data.indexOf('*/', nextStart + 2);
         if (nextStart == -1 || nextEnd == -1)
index 2ca193b..da1f52e 100644 (file)
@@ -8,7 +8,7 @@ module.exports = function Expressions() {
     var level = 0;
     var quoted = false;
 
-    while(true) {
+    while (true) {
       var next = data[end++];
 
       if (quoted) {
@@ -43,7 +43,7 @@ module.exports = function Expressions() {
       var cursor = 0;
       var tempData = [];
 
-      for (; nextEnd < data.length; ) {
+      for (; nextEnd < data.length;) {
         nextStart = data.indexOf('expression(', nextEnd);
         if (nextStart == -1)
           break;
index 7ffee63..ea30368 100644 (file)
@@ -33,7 +33,7 @@ module.exports = function Free() {
       var doubleParenthesis = '"';
       var dataLength = data.length;
 
-      for (; nextEnd < data.length; ) {
+      for (; nextEnd < data.length;) {
         var nextStartSingle = data.indexOf(singleParenthesis, nextEnd + 1);
         var nextStartDouble = data.indexOf(doubleParenthesis, nextEnd + 1);
 
index 007e41d..8f7fee8 100644 (file)
@@ -13,7 +13,7 @@ module.exports = function Urls() {
       var cursor = 0;
       var tempData = [];
 
-      for (; nextEnd < data.length; ) {
+      for (; nextEnd < data.length;) {
         nextStart = data.indexOf('url(', nextEnd);
         if (nextStart == -1)
           break;
index 93e24f5..f09e183 100644 (file)
@@ -13,4 +13,4 @@ var start = process.hrtime();
 new CleanCSS({ benchmark: true, root: benchDir }).minify(cssData);
 
 var itTook = process.hrtime(start);
-console.log('complete minification: %d ms', 1000 * itTook[0] + itTook[1] / 1000000.0);
+console.log('complete minification: %d ms', 1000 * itTook[0] + itTook[1] / 1000000);
index 16302e2..eac87a4 100644 (file)
@@ -52,7 +52,10 @@ vows.describe('module tests').addBatch({
   },
   'warnings': {
     topic: function() {
-      var minifier = new CleanCSS({ root: 'test/data', target: 'custom-warnings.css' });
+      var minifier = new CleanCSS({
+          root: 'test/data',
+          target: 'custom-warnings.css'
+        });
       minifier.minify('a{color:red}');
       return minifier;
     },
@@ -82,5 +85,5 @@ vows.describe('module tests').addBatch({
       assert.equal(minifier.errors.length, 1);
       assert.equal(minifier.errors[0], 'Broken @import declaration of "/some/fake/file"');
     }
-  },
+  }
 }).export(module);
index 76dfc4f..9faaa43 100644 (file)
@@ -171,8 +171,8 @@ vows.describe('clean-units').addBatch({
       '@media\nonly screen and (max-width: 1319px) and (min--moz-device-pixel-ratio: 1.5),\nonly screen and (max-width: 1319px) and (-moz-min-device-pixel-ratio: 1.5)\n{ a { color:#000 } }',
       '@media only screen and (max-width:1319px) and (min--moz-device-pixel-ratio:1.5),only screen and (max-width:1319px) and (-moz-min-device-pixel-ratio:1.5){a{color:#000}}'
     ],
-    'in content preceded by #content': '#content{display:block}#foo{content:"\00BB  "}',
-    'in content preceded by .content': '.content{display:block}#foo{content:"\00BB  "}',
+    'in content preceded by #content': '#content{display:block}#foo{content:"\0BB  "}',
+    'in content preceded by .content': '.content{display:block}#foo{content:"\0BB  "}',
     'in content preceded by line break': [
       '.content{display:block}#foo{' + lineBreak + 'content:"x"}',
       '.content{display:block}#foo{content:"x"}'
@@ -709,7 +709,10 @@ path")}',
       '@import url(/test/data/partials-relative/base.css);',
       'a{background:url(/test/data/partials/extra/down.gif) 0 0 no-repeat}'
     ]
-  }, { root: process.cwd(), relativeTo: path.join('test', 'data', 'partials-relative') }),
+  }, {
+    root: process.cwd(),
+    relativeTo: path.join('test', 'data', 'partials-relative')
+  }),
   'urls rewriting - no root but target': cssContext({
     'no @import': [
       'a{background:url(../partials/extra/down.gif) 0 0 no-repeat}',
@@ -723,7 +726,10 @@ path")}',
       '@import url(/test/data/partials-relative/base.css);',
       'a{background:url(test/data/partials/extra/down.gif) 0 0 no-repeat}'
     ]
-  }, { target: path.join(process.cwd(), 'test.css'), relativeTo: path.join('test', 'data', 'partials-relative') }),
+  }, {
+    target: path.join(process.cwd(), 'test.css'),
+    relativeTo: path.join('test', 'data', 'partials-relative')
+  }),
   'urls rewriting - root and target': cssContext({
     'no @import': [
       'a{background:url(../partials/extra/down.gif) 0 0 no-repeat}',
@@ -737,7 +743,11 @@ path")}',
       '@import url(/test/data/partials-relative/base.css);',
       'a{background:url(/test/data/partials/extra/down.gif) 0 0 no-repeat}'
     ]
-  }, { root: process.cwd(), target: path.join(process.cwd(), 'test.css'), relativeTo: path.join('test', 'data', 'partials-relative') }),
+  }, {
+    root: process.cwd(),
+    target: path.join(process.cwd(), 'test.css'),
+    relativeTo: path.join('test', 'data', 'partials-relative')
+  }),
   'fonts': cssContext({
     'keep format quotation': "@font-face{font-family:PublicVintage;src:url(/PublicVintage.otf) format('opentype')}",
     'remove font family quotation': [
@@ -1192,8 +1202,8 @@ title']{display:block}",
       '.one,.two{color:red;line-height:1em}'
     ],
     'two adjacent with hex color definitions': [
-      "a:link,a:visited{color:#fff}.one{display:block}a:link,a:visited{color:red}",
-      ".one{display:block}a:link,a:visited{color:red}"
+      'a:link,a:visited{color:#fff}.one{display:block}a:link,a:visited{color:red}',
+      '.one{display:block}a:link,a:visited{color:red}'
     ]
   }),
   'same non-adjacent selectors': cssContext({