Code coverage report for 6to5/transformation/transformers/es6-for-of.js

Statements: 100% (18 / 18)      Branches: 100% (4 / 4)      Functions: 100% (1 / 1)      Lines: 100% (18 / 18)      Ignored: none     

All files » 6to5/transformation/transformers/ » es6-for-of.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 351 1   1 18 18   18 18   18 2 16 15       1     17           17   17 17 17   17    
var util = require("../../util");
var t    = require("../../types");
 
exports.ForOfStatement = function (node, parent, file, scope) {
  var left = node.left;
  var declar;
 
  var stepKey   = file.generateUidIdentifier("step", scope);
  var stepValue = t.memberExpression(stepKey, t.identifier("value"));
 
  if (t.isIdentifier(left)) {
    declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
  } else if (t.isVariableDeclaration(left)) {
    declar = t.variableDeclaration(left.kind, [
      t.variableDeclarator(left.declarations[0].id, stepValue)
    ]);
  } else {
    throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
  }
 
  var node2 = util.template("for-of", {
    ITERATOR_KEY: file.generateUidIdentifier("iterator", scope),
    STEP_KEY:     stepKey,
    OBJECT:       node.right
  });
 
  t.ensureBlock(node);
 
  var block = node2.body;
  block.body.push(declar);
  block.body = block.body.concat(node.body.body);
 
  return node2;
};