(function(app) {
  'use strict';

  var Events = app.Events || require('./events.js');

  var Collection = function() {
    this.items = [];
    this.events = new Events();
  };

  Collection.prototype.add = function(item) {
    this.items.push(item);
    this.events.emit('add', item);
  };

  Collection.prototype.remove = function(item) {
    var index = this.items.lastIndexOf(item);
    if (index === -1) {
      return;
    }
    this.items.splice(index, 1);
    this.events.emit('remove', item);
  };

  Collection.prototype.reset = function(items) {
    this.items = items || [];
    this.events.emit('reset', this.items);
  };

  Collection.prototype.forEach = function() {
    return Array.prototype.forEach.apply(this.items, arguments);
  };

  Collection.prototype.map = function() {
    return Array.prototype.map.apply(this.items, arguments);
  };

  Collection.prototype.find = function(callback) {
    for (var i = 0, len = this.items.length; i < len; i++) {
      if (callback(this.items[i], i, this.items)) {
        return this.items[i];
      }
    }
    return null;
  };

  Collection.prototype.on = function() {
    return Events.prototype.on.apply(this.events, arguments);
  };

  Collection.prototype.off = function() {
    return Events.prototype.off.apply(this.events, arguments);
  };

  Collection.prototype.removeAllListeners = function() {
    return Events.prototype.removeAllListeners.apply(this.events, arguments);
  };

  if (typeof module !== 'undefined' && module.exports) {
    module.exports = Collection;
  } else {
    app.Collection = Collection;
  }
})(this.app || (this.app = {}));

@@ -114,32 +114,33 @@
 on() %7B%0A    this.
+_
 items = %5B%5D;%0A    
@@ -140,24 +140,25 @@
 %5D;%0A    this.
+_
 events = new
@@ -225,24 +225,25 @@
  %7B%0A    this.
+_
 items.push(i
@@ -249,32 +249,33 @@
 item);%0A    this.
+_
 events.emit('add
@@ -356,24 +356,25 @@
 ndex = this.
+_
 items.lastIn
@@ -435,24 +435,25 @@
  %7D%0A    this.
+_
 items.splice
@@ -465,32 +465,33 @@
 x, 1);%0A    this.
+_
 events.emit('rem
@@ -563,24 +563,25 @@
  %7B%0A    this.
+_
 items = item
@@ -594,24 +594,25 @@
 %5D;%0A    this.
+_
 events.emit(
@@ -621,24 +621,25 @@
 eset', this.
+_
 items);%0A  %7D;
@@ -724,32 +724,33 @@
 Each.apply(this.
+_
 items, arguments
@@ -838,24 +838,25 @@
 .apply(this.
+_
 items, argum
@@ -946,24 +946,25 @@
  len = this.
+_
 items.length
@@ -1001,24 +1001,25 @@
 llback(this.
+_
 items%5Bi%5D, i,
@@ -1020,24 +1020,25 @@
 i%5D, i, this.
+_
 items)) %7B%0A  
@@ -1055,16 +1055,17 @@
 rn this.
+_
 items%5Bi%5D
@@ -1178,32 +1178,33 @@
 e.on.apply(this.
+_
 events, argument
@@ -1290,32 +1290,33 @@
 .off.apply(this.
+_
 events, argument
@@ -1440,16 +1440,17 @@
 ly(this.
+_
 events, 

Refactor code of collection