diff --git a/lib/carto/index.js b/lib/carto/index.js index 326b591..64ed5b4 100644 --- a/lib/carto/index.js +++ b/lib/carto/index.js @@ -1,13 +1,13 @@ -var util = require('util'); -var fs = require('fs'); -var path = require('path'); +var util = require('util'), + fs = require('fs'), + path = require('path'); function getVersion() { - if (parseInt(process.version.split('.')[1]) > 4) { + if (parseInt(process.version.split('.')[1], 10) > 4) { return require('../../package.json').version.split('.'); } else { // older node - var package_json = JSON.parse(fs.readFileSync(path.join(__dirname,'../../package.json'))) + var package_json = JSON.parse(fs.readFileSync(path.join(__dirname,'../../package.json'))); return package_json.version.split('.'); } } @@ -90,4 +90,3 @@ function stylize(str, style) { return '\033[' + styles[style][0] + 'm' + str + '\033[' + styles[style][1] + 'm'; } - diff --git a/lib/carto/parser.js b/lib/carto/parser.js index 45f172a..6ab1390 100644 --- a/lib/carto/parser.js +++ b/lib/carto/parser.js @@ -204,7 +204,7 @@ carto.Parser = function Parser(env) { this.env.inputs = this.env.inputs || {}; // The Parser - return parser = { + parser = { imports: imports, // @@ -245,7 +245,8 @@ carto.Parser = function Parser(env) { if (!inString && c === '/') { cc = input.charAt(i + 1); if (cc === '/' || cc === '*') { - if (match = comment.exec(input)) { + match = comment.exec(input); + if (match) { if (match.index === i) { i += match[0].length - 1; chunk.push(match[0]); @@ -383,7 +384,7 @@ carto.Parser = function Parser(env) { while ((node = $(this.rule) || $(this.ruleset) || $(this.comment)) || $(/^[\s\n]+/) || (node = $(this.invalid))) { - node && root.push(node); + if (node) root.push(node); } return root; }, @@ -809,7 +810,6 @@ carto.Parser = function Parser(env) { // Expressions either represent mathematical operations, // or white-space delimited Entities. // - // 1px solid black // @var * 2 expression: function() { var e, delim, entities = [], d; @@ -827,5 +827,6 @@ carto.Parser = function Parser(env) { } } }; + return parser; }; diff --git a/lib/carto/tree/color.js b/lib/carto/tree/color.js index 24b94de..f0b5803 100644 --- a/lib/carto/tree/color.js +++ b/lib/carto/tree/color.js @@ -3,12 +3,10 @@ // RGB Colors - #ff0014, #eee // tree.Color = function Color(rgb, a) { - // // The end goal here, is to parse the arguments // into an integer triplet, such as `128, 255, 0` // // This facilitates operations and conversions. - // if (Array.isArray(rgb)) { this.rgb = rgb; } else if (rgb.length == 6) { @@ -25,7 +23,7 @@ tree.Color = function Color(rgb, a) { tree.Color.prototype = { is: 'color', - eval: function() { return this; }, + 'eval': function() { return this; }, // If we have some transparency, the only way to represent it // is via `rgba`. Otherwise, we use the hex representation, @@ -87,5 +85,4 @@ tree.Color.prototype = { } }; - })(require('../tree')); diff --git a/lib/carto/tree/comment.js b/lib/carto/tree/comment.js index f7e0d90..0338202 100644 --- a/lib/carto/tree/comment.js +++ b/lib/carto/tree/comment.js @@ -9,7 +9,7 @@ tree.Comment.prototype = { toString: function(env) { return ''; }, - eval: function() { return this; } + 'eval': function() { return this; } }; })(require('../tree')); diff --git a/lib/carto/tree/dimension.js b/lib/carto/tree/dimension.js index 4d061da..aa631da 100644 --- a/lib/carto/tree/dimension.js +++ b/lib/carto/tree/dimension.js @@ -11,7 +11,7 @@ tree.Dimension = function Dimension(value, unit, index) { tree.Dimension.prototype = { is: 'float', - eval: function (env) { + 'eval': function (env) { if (this.unit && ['px', '%'].indexOf(this.unit) === -1) { env.error({ message: "Invalid unit: '" + this.unit + "'", diff --git a/lib/carto/tree/filter.js b/lib/carto/tree/filter.js index b02a49c..29d3c1d 100644 --- a/lib/carto/tree/filter.js +++ b/lib/carto/tree/filter.js @@ -39,10 +39,11 @@ var ops = { }; tree.Filter.prototype.toXML = function(env) { - if (this.val.eval) this._val = this.val.eval(env); - if (this.key.eval) this._key = this.key.eval(env); - if (this._key) var key = this._key.toString(false); - if (this._val) var val = this._val.toString(this._val.is == 'string'); + var val, key; + if (this.val['eval']) this._val = this.val['eval'](env); + if (this.key['eval']) this._key = this.key['eval'](env); + if (this._key) key = this._key.toString(false); + if (this._val) val = this._val.toString(this._val.is == 'string'); if ( (ops[this.op][1] == 'numeric' && isNaN(this.val)) || diff --git a/lib/carto/tree/layer.js b/lib/carto/tree/layer.js index 1a9e676..f36cfcf 100644 --- a/lib/carto/tree/layer.js +++ b/lib/carto/tree/layer.js @@ -17,8 +17,8 @@ tree.Layer.prototype.toXML = function() { } var prop_string = ''; - for (var i in this.properties) { - prop_string += ' ' + i + '="' + this.properties[i] + '"\n'; + for (var prop in this.properties) { + prop_string += ' ' + prop + '="' + this.properties[prop] + '"\n'; } return '" ], - "licenses": [ - { + "licenses": [{ "type": "Apache" - } - ], + }], "bin": { "carto": "./bin/carto", "mml2json.js": "./bin/mml2json.js"