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

Statements: 93.65% (59 / 63)      Branches: 82.35% (28 / 34)      Functions: 100% (7 / 7)      Lines: 96.67% (58 / 60)      Ignored: none     

All files » 6to5/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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 1031 385   385   385   238   238 216 5 5         363 2 2     2 2     363     1 6 6 6   6       6 4 2     2     6 4 4 4   2     6 6     1 2       2     1 202 202 202 202   202     1   374 374 374 374 97 97 97   374 352 352     1 11   11 6   5     11 11    
exports._params = function (node, print) {
  var self = this;
 
  this.push("(");
 
  this.printJoin(print, node.params, ", ", {
    iterator: function (param, i) {
      print(param);
 
      var def = 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;
 
  Iif (value.async) {
    this.push("async ");
  }
 
  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);
  print(value.body);
};
 
exports.MethodDefinition = function (node, print) {
  Iif (node.static) {
    this.push("static ");
  }
 
  this._method(node, print);
};
 
exports.ReturnStatement = function (node, print) {
  this.push("return");
  Eif (node.argument) {
    this.push(" ");
    print(node.argument);
  }
  this.semicolon();
};
 
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
  Iif (node.async) this.push("async ");
  this.push("function");
  if (node.generator) this.push("*");
  if (node.id) {
    this.push(" ");
    print(node.id);
    this.push(" ");
  }
  this._params(node, print);
  this.push(" ");
  print(node.body);
};
 
exports.ArrowFunctionExpression = function (node, print) {
  Iif (node.async) this.push("async ");
 
  if (node.params.length === 1 && !node.defaults.length && !node.rest && node.params[0].type === "Identifier") {
    print(node.params[0]);
  } else {
    this._params(node, print);
  }
 
  this.push(" => ");
  print(node.body);
};