Code coverage report for 6to5/lib/6to5/generation/node/whitespace.js

Statements: 86.36% (19 / 22)      Branches: 100% (10 / 10)      Functions: 72.73% (8 / 11)      Lines: 85.71% (18 / 21)      Ignored: none     

All files » 6to5/lib/6to5/generation/node/ » whitespace.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 731 1   1     897 417                 13 3         251 29           1     345 76             667                         1                     9   9 13 1375        
var _ = require("lodash");
var t = require("../../types");
 
exports.before = {
  nodes: {
    Property: function (node, parent) {
      if (parent.properties[0] === node) {
        return 1;
      }
    },
 
    SpreadProperty: function (node, parent) {
      return exports.before.nodes.Property(node, parent);
    },
 
    SwitchCase: function (node, parent) {
      if (parent.cases[0] === node) {
        return 1;
      }
    },
 
    CallExpression: function (node) {
      if (t.isFunction(node.callee)) {
        return 1;
      }
    }
  }
};
 
exports.after = {
  nodes: {
    AssignmentExpression: function (node) {
      if (t.isFunction(node.right)) {
        return 1;
      }
    }
  },
 
  list: {
    VariableDeclaration: function (node) {
      return _.map(node.declarations, "init");
    },
 
    ArrayExpression: function (node) {
      return node.elements;
    },
 
    ObjectExpression: function (node) {
      return node.properties;
    }
  }
};
 
_.each({
  Function: 1,
  Class: 1,
  For: 1,
  ArrayExpression: { after: 1 },
  ObjectExpression: { after: 1 },
  SwitchStatement: 1,
  IfStatement: { before: 1 },
  CallExpression: { after: 1 },
  Literal: { after: 1 }
}, function (amounts, type) {
  if (_.isNumber(amounts)) amounts = { after: amounts, before: amounts };
 
  _.each(amounts, function (amount, key) {
    exports[key].nodes[type] = function () {
      return amount;
    };
  });
});