code: function dedupe(resources, onDupe) {
    // first create a map of name->[array of resources with same name]
    var names = {};
    resources.forEach(function(scriptResource) {
      if (names[scriptResource.name] == null) {
        names[scriptResource.name] = [];
      }
      names[scriptResource.name].push(scriptResource);
    });
  
    // Call the de-dupe function for each set of dupes
    Object.keys(names).forEach(function(name) {
      var clones = names[name];
      if (clones.length > 1) {
        onDupe(clones);
      }
    });
  }
docs: Find resources with the same name, and call onDupe to change the names