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

Statements: 97.96% (48 / 49)      Branches: 100% (27 / 27)      Functions: 83.33% (5 / 6)      Lines: 97.96% (48 / 49)      Ignored: none     

All files » 6to5/generation/generators/ » modules.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 871 1   1   15 15 9 9       1       1 10   10   10 2     10 5   5 1   4 4 3 3 3   4     5 3 3       10     1 7   7   7 7 6   6 11 5     11 4 4     11     6 4     6     7 7     1 1 1    
var t = require("../../types");
var _ = require("lodash");
 
exports.ImportSpecifier =
exports.ExportSpecifier = function (node, print) {
  print(node.id);
  if (node.name) {
    this.push(" as ");
    print(node.name);
  }
};
 
exports.ExportBatchSpecifier = function () {
  this.push("*");
};
 
exports.ExportDeclaration = function (node, print) {
  this.push("export ");
 
  var specifiers = node.specifiers;
 
  if (node.default) {
    this.push("default ");
  }
 
  if (node.declaration) {
    print(node.declaration);
  } else {
    if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
      this.push("*");
    } else {
      this.push("{");
      if (specifiers.length) {
        this.space();
        print.join(specifiers, { separator: ", " });
        this.space();
      }
      this.push("}");
    }
 
    if (node.source) {
      this.push(" from ");
      print(node.source);
    }
  }
 
  this.ensureSemicolon();
};
 
exports.ImportDeclaration = function (node, print) {
  var self = this;
 
  this.push("import ");
 
  var specfiers = node.specifiers;
  if (specfiers && specfiers.length) {
    var foundImportSpecifier = false;
 
    _.each(node.specifiers, function (spec, i) {
      if (+i > 0) {
        self.push(", ");
      }
 
      if (!spec.default && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
        foundImportSpecifier = true;
        self.push("{ ");
      }
 
      print(spec);
    });
 
    if (foundImportSpecifier) {
      this.push(" }");
    }
 
    this.push(" from ");
  }
 
  print(node.source);
  this.semicolon();
};
 
exports.ImportBatchSpecifier = function (node, print) {
  this.push("* as ");
  print(node.name);
};