Code coverage report for 6to5/transformers/use-strict.js

Statements: 81.82% (9 / 11)      Branches: 80% (8 / 10)      Functions: 100% (1 / 1)      Lines: 100% (9 / 9)      Ignored: none     

All files » 6to5/transformers/ » use-strict.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161   1 185 185   185   185 184 184   1      
var b = require("../builders");
 
module.exports = function (ast, file) {
  var body = ast.program.body;
  var first = body[0];
 
  var noStrict = !first || first.type !== "ExpressionStatement" || first.expression.type !== "Literal" || first.expression.value !== "use strict";
 
  if (noStrict) {
    Iif (file.opts._noStrict) return;
    body.unshift(b.expressionStatement(b.literal("use strict")));
  } else {
    Iif (file.opts._noStrict) body.shift();
  }
};