import DS from 'ember-data';

export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {

  attrs: {
    events: { embedded: 'always' }
  },

  extract: function(store, type, payload, id, requestType) {
    var results = {};
    results['characters'] = payload.data.results;
    results['meta'] = payload.data;
    for (var character of results['characters']) {
      character.events = this.addIdToEvents(character.events.items);
    }
    return this._super(store, type, results, id, requestType);
  },

  extractSingle: function(store, type, payload, id) {
    var results = {};
    results['character'] = payload.characters[0];
    return this._super(store, type, results, id);
  },

  addIdToEvents: function(events) {
    var results = [];
    for (var event of events) {
      event.id = event.resourceURI.substr(event.resourceURI.lastIndexOf('/') + 1);
      results.push(event);
    }
    return results;
  }

});

@@ -747,40 +747,33 @@
 s = 
-%5B%5D;%0A    for (var event of 
+events.map(function(
 event
-s
 ) %7B%0A
@@ -867,32 +867,27 @@
   re
-sults.push(
+turn 
 event
-)
 ;%0A    %7D
+);
 %0A   

Use map instead of loop whilst normalising events