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

Statements: 100% (14 / 14)      Branches: 100% (8 / 8)      Functions: 100% (3 / 3)      Lines: 100% (14 / 14)      Ignored: none     

All files » 6to5/lib/6to5/transformation/transformers/ » use-strict.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 281   1 132504 132504     1 132145 132145 1354     132145   132145 1354       1   347 346        
var t = require("../../types");
 
exports._has = function (node) {
  var first = node.body[0];
  return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" });
};
 
exports._wrap = function (node, callback) {
  var useStrictNode;
  if (exports._has(node)) {
    useStrictNode = node.body.shift();
  }
 
  callback();
 
  if (useStrictNode) {
    node.body.unshift(useStrictNode);
  }
};
 
exports.ast = {
  exit: function (ast) {
    if (!exports._has(ast.program)) {
      ast.program.body.unshift(t.expressionStatement(t.literal("use strict")));
    }
  }
};