Code coverage report for 6to5/generation/generators/methods.js

Statements: 100% (51 / 51)      Branches: 96.43% (27 / 28)      Functions: 100% (6 / 6)      Lines: 100% (49 / 49)      Ignored: none     

All files » 6to5/generation/generators/ » methods.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 73 74 75 76 77 78 79 80 81 82 83 84 85 861   1 322   322   322     221 221 5 5         322 2 2     2 2     322     1 38 38 38   38 19 10     19     38 20 20 20   18     38 38 38     1 33 16     33     1   279 279 279 279 279 279 279     1 10 5   5     10 10    
var t = require("../../types");
 
exports._params = function (node, print) {
  var self = this;
 
  this.push("(");
 
  print.join(node.params, {
    separator: ", ",
    iterator: function (param, i) {
      var def = node.defaults && node.defaults[i];
      if (def) {
        self.push(" = ");
        print(def);
      }
    }
  });
 
  if (node.rest) {
    Eif (node.params.length) {
      this.push(", ");
    }
 
    this.push("...");
    print(node.rest);
  }
 
  this.push(")");
};
 
exports._method = function (node, print) {
  var value = node.value;
  var kind  = node.kind;
  var key   = node.key;
 
  if (!kind || kind === "init") {
    if (value.generator) {
      this.push("*");
    }
  } else {
    this.push(kind + " ");
  }
 
  if (node.computed) {
    this.push("[");
    print(key);
    this.push("]");
  } else {
    print(key);
  }
 
  this._params(value, print);
  this.space();
  print(value.body);
};
 
exports.MethodDefinition = function (node, print) {
  if (node.static) {
    this.push("static ");
  }
 
  this._method(node, print);
};
 
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
  this.push("function");
  if (node.generator) this.push("*");
  this.space();
  if (node.id) print(node.id);
  this._params(node, print);
  this.space();
  print(node.body);
};
 
exports.ArrowFunctionExpression = function (node, print) {
  if (node.params.length === 1 && !node.defaults.length && !node.rest && t.isIdentifier(node.params[0])) {
    print(node.params[0]);
  } else {
    this._params(node, print);
  }
 
  this.push(" => ");
  print(node.body);
};