Code coverage report for 6to5/transformation/modules/common-interop.js

Statements: 100% (12 / 12)      Branches: 100% (2 / 2)      Functions: 100% (2 / 2)      Lines: 100% (12 / 12)      Ignored: none     

All files » 6to5/transformation/modules/ » common-interop.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 291   1 1 1   1 11     1   1 16     16 3               13      
module.exports = CommonJSInteropFormatter;
 
var CommonJSFormatter = require("./common");
var util              = require("../../util");
var t                 = require("../../types");
 
function CommonJSInteropFormatter(file) {
  this.file = file;
}
 
util.inherits(CommonJSInteropFormatter, CommonJSFormatter);
 
CommonJSInteropFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
  var variableName = t.getSpecifierName(specifier);
 
  // import foo from "foo";
   if (specifier.default) {
    nodes.push(t.variableDeclaration("var", [
      t.variableDeclarator(variableName,
        t.callExpression(this.file.addDeclaration("interop-require"), [util.template("require", {
          MODULE_NAME: node.source.raw
        })])
      )
    ]));
  } else {
    CommonJSFormatter.prototype.importSpecifier.apply(this, arguments);
  }
};