Code coverage report for 6to5/lib/6to5/transformation/transformers/_declarations.js

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

All files » 6to5/lib/6to5/transformation/transformers/ » _declarations.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 331 1   1   1   132111 132111   132111 132111 196   196 196   196 43 43   153       132111 16       132111    
var useStrict = require("./use-strict");
var t         = require("../../types");
 
exports.secondPass = true;
 
exports.BlockStatement =
exports.Program = function (node) {
  var kinds = {};
  var kind;
 
  useStrict._wrap(node, function () {
    for (var i in node._declarations) {
      var declar = node._declarations[i];
 
      kind = declar.kind || "var";
      var declarNode = t.variableDeclarator(declar.id, declar.init);
 
      if (!declar.init) {
        kinds[kind] = kinds[kind] || [];
        kinds[kind].push(declarNode);
      } else {
        node.body.unshift(t.variableDeclaration(kind, [declarNode]));
      }
    }
 
    for (kind in kinds) {
      node.body.unshift(t.variableDeclaration(kind, kinds[kind]));
    }
  });
 
  node._declarations = null;
};