var MessageQueue __indexOf indexOf function item for var this length i

 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
var MessageQueue,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
MessageQueue = (function() {
function MessageQueue() {
this.listeners = {};
}
MessageQueue.send = function(type, data) {
var listener, _i, _len, _ref, _results;
_ref = this.listeners[type];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
listener = _ref[_i];
_results.push(listener(data));
}
return _results;
};
MessageQueue.subscribe = function(type, listener) {
var _ref;
if (_ref = !type, __indexOf.call(this.listeners, _ref) >= 0) {
this.listeners[type] = [];
}
return this.listeners[type].push(listener);
};
return MessageQueue;
})();