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

Statements: 94.44% (17 / 18)      Branches: 75% (3 / 4)      Functions: 100% (1 / 1)      Lines: 94.44% (17 / 18)      Ignored: none     

All files » 6to5/transformation/transformers/ » 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 11 11   11 11   11 1 10 10             11           11   11 11 11   11    
var util = require("../../util");
var t    = require("../../types");
 
exports.ForOfStatement = function (node, parent, file, scope) {
  var left = node.left;
  var declar;
 
  var stepKey = t.identifier(file.generateUid("step", scope));
  var stepValueId = t.memberExpression(stepKey, t.identifier("value"));
 
  if (t.isIdentifier(left)) {
    declar = t.expressionStatement(t.assignmentExpression("=", left, stepValueId));
  } else Eif (t.isVariableDeclaration(left)) {
    declar = t.variableDeclaration(left.kind, [
      t.variableDeclarator(left.declarations[0].id, stepValueId)
    ]);
  } else {
    return;
  }
 
  var node2 = util.template("for-of", {
    ITERATOR_KEY: file.generateUid("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;
};