Code coverage report for 6to5/transformation/transformers/spec-no-duplicate-properties.js

Statements: 93.75% (15 / 16)      Branches: 90% (9 / 10)      Functions: 100% (1 / 1)      Lines: 93.33% (14 / 15)      Ignored: none     

All files » 6to5/transformation/transformers/ » spec-no-duplicate-properties.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 261   1 112   112 196 196   174 174 168 6 6         174 3   171        
var t = require("../../types");
 
exports.ObjectExpression = function (node, parent, file) {
  var keys = [];
 
  for (var i in node.properties) {
    var prop = node.properties[i];
    if (prop.computed || prop.kind !== "init") continue;
 
    var key = prop.key;
    if (t.isIdentifier(key)) {
      key = key.name;
    } else Eif (t.isLiteral(key)) {
      key = key.value;
    } else {
      continue;
    }
 
    if (keys.indexOf(key) >= 0) {
      throw file.errorWithNode(prop.key, "Duplicate property key");
    } else {
      keys.push(key);
    }
  }
};