Skip to content
This repository was archived by the owner on Nov 2, 2020. It is now read-only.

Commit 2cfd15c

Browse files
committed
Fix exports
1 parent 0a98622 commit 2cfd15c

File tree

5 files changed

+72
-78
lines changed

5 files changed

+72
-78
lines changed

dist/browser/clusterws.js

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,35 @@ var ClusterWS = function() {
33
function t(t) {
44
return console.log(t);
55
}
6-
var e = function() {
7-
function e(t, e) {
8-
this.socket = t, this.name = e, this.subscribe();
6+
var n = function() {
7+
function n(t, n) {
8+
this.socket = t, this.name = n, this.subscribe();
99
}
10-
return e.prototype.watch = function(e) {
11-
return "[object Function]" !== {}.toString.call(e) ? t("Listener must be a function") : (this.listener = e,
10+
return n.prototype.watch = function(n) {
11+
return "[object Function]" !== {}.toString.call(n) ? t("Listener must be a function") : (this.listener = n,
1212
this);
13-
}, e.prototype.publish = function(t) {
13+
}, n.prototype.publish = function(t) {
1414
return this.socket.send(this.name, t, "publish"), this;
15-
}, e.prototype.unsubscribe = function() {
15+
}, n.prototype.unsubscribe = function() {
1616
this.socket.send("unsubscribe", this.name, "system"), this.socket.channels[this.name] = null;
17-
}, e.prototype.onMessage = function(t) {
17+
}, n.prototype.onMessage = function(t) {
1818
this.listener && this.listener.call(null, t);
19-
}, e.prototype.subscribe = function() {
19+
}, n.prototype.subscribe = function() {
2020
this.socket.send("subscribe", this.name, "system");
21-
}, e;
22-
}(), n = function() {
23-
function e() {
21+
}, n;
22+
}(), e = function() {
23+
function n() {
2424
this.events = {};
2525
}
26-
return e.prototype.on = function(e, n) {
27-
if ("[object Function]" !== {}.toString.call(n)) return t("Listener must be a function");
28-
this.events[e] = n;
29-
}, e.prototype.emit = function(t) {
30-
for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
31-
this.events[t] && (o = this.events[t]).call.apply(o, [ null ].concat(e));
32-
var o;
33-
}, e.prototype.removeAllEvents = function() {
26+
return n.prototype.on = function(n, e) {
27+
if ("[object Function]" !== {}.toString.call(e)) return t("Listener must be a function");
28+
this.events[n] = e;
29+
}, n.prototype.emit = function(t) {
30+
for (var n, e = [], o = 1; o < arguments.length; o++) e[o - 1] = arguments[o];
31+
this.events[t] && (n = this.events[t]).call.apply(n, [ null ].concat(e));
32+
}, n.prototype.removeAllEvents = function() {
3433
this.events = {};
35-
}, e;
34+
}, n;
3635
}(), o = function() {
3736
function t(t) {
3837
this.socket = t, this.inReconnectionState = !1, this.reconnectionAttempted = 0,
@@ -53,106 +52,105 @@ var ClusterWS = function() {
5352
}, this.socket.options.reconnectionIntervalMin));
5453
}, t;
5554
}();
56-
function i(t, e, n) {
57-
switch (n) {
55+
function i(t, n, e) {
56+
switch (e) {
5857
case "ping":
5958
return t;
6059

6160
case "emit":
6261
return JSON.stringify({
63-
"#": [ "e", t, e ]
62+
"#": [ "e", t, n ]
6463
});
6564

6665
case "publish":
6766
return JSON.stringify({
68-
"#": [ "p", t, e ]
67+
"#": [ "p", t, n ]
6968
});
7069

7170
case "system":
7271
switch (t) {
7372
case "subscribe":
7473
return JSON.stringify({
75-
"#": [ "s", "s", e ]
74+
"#": [ "s", "s", n ]
7675
});
7776

7877
case "unsubscribe":
7978
return JSON.stringify({
80-
"#": [ "s", "u", e ]
79+
"#": [ "s", "u", n ]
8180
});
8281

8382
case "configuration":
8483
return JSON.stringify({
85-
"#": [ "s", "c", e ]
84+
"#": [ "s", "c", n ]
8685
});
8786
}
8887
}
8988
}
90-
var s = function() {
91-
function s(e) {
92-
return this.channels = {}, this.events = new n(), this.missedPing = 0, this.useBinary = !1,
93-
e.url ? (this.options = {
94-
url: e.url,
95-
autoReconnect: e.autoReconnect || !1,
96-
reconnectionAttempts: e.reconnectionAttempts || 0,
97-
reconnectionIntervalMin: e.reconnectionIntervalMin || 1e3,
98-
reconnectionIntervalMax: e.reconnectionIntervalMax || 5e3
89+
return function() {
90+
function s(n) {
91+
return this.channels = {}, this.events = new e(), this.missedPing = 0, this.useBinary = !1,
92+
n.url ? (this.options = {
93+
url: n.url,
94+
autoReconnect: n.autoReconnect || !1,
95+
reconnectionAttempts: n.reconnectionAttempts || 0,
96+
reconnectionIntervalMin: n.reconnectionIntervalMin || 1e3,
97+
reconnectionIntervalMax: n.reconnectionIntervalMax || 5e3
9998
}, this.options.reconnectionIntervalMin > this.options.reconnectionIntervalMax ? t("reconnectionIntervalMin can not be more then reconnectionIntervalMax") : (this.reconnection = new o(this),
10099
void this.create())) : t("Url must be provided and it must be string");
101100
}
102101
return s.prototype.create = function() {
103-
var e = this, n = window.MozWebSocket || window.WebSocket;
104-
this.websocket = new n(this.options.url), this.websocket.binaryType = "arraybuffer",
102+
var n = this, e = window.MozWebSocket || window.WebSocket;
103+
this.websocket = new e(this.options.url), this.websocket.binaryType = "arraybuffer",
105104
this.websocket.onopen = function() {
106-
return e.reconnection.isConnected();
105+
return n.reconnection.isConnected();
107106
}, this.websocket.onerror = function(t) {
108-
return e.events.emit("error", t.message);
109-
}, this.websocket.onmessage = function(n) {
110-
var o = "string" != typeof n.data ? String.fromCharCode.apply(null, new Uint8Array(n.data)) : n.data;
111-
if ("#0" === o) return e.missedPing = 0, e.send("#1", null, "ping");
107+
return n.events.emit("error", t.message);
108+
}, this.websocket.onmessage = function(e) {
109+
var o = "string" != typeof e.data ? String.fromCharCode.apply(null, new Uint8Array(e.data)) : e.data;
110+
if ("#0" === o) return n.missedPing = 0, n.send("#1", null, "ping");
112111
try {
113112
o = JSON.parse(o);
114-
} catch (e) {
115-
return t(e);
113+
} catch (n) {
114+
return t(n);
116115
}
117-
!function(t, e) {
118-
switch (e["#"][0]) {
116+
!function(t, n) {
117+
switch (n["#"][0]) {
119118
case "e":
120-
return t.events.emit(e["#"][1], e["#"][2]);
119+
return t.events.emit(n["#"][1], n["#"][2]);
121120

122121
case "p":
123-
t.channels[e["#"][1]] && t.channels[e["#"][1]].onMessage(e["#"][2]);
122+
t.channels[n["#"][1]] && t.channels[n["#"][1]].onMessage(n["#"][2]);
124123

125124
case "s":
126-
switch (e["#"][1]) {
125+
switch (n["#"][1]) {
127126
case "c":
128127
t.pingInterval = setInterval(function() {
129128
return t.missedPing++ > 2 && t.disconnect(4001, "Did not get pings");
130-
}, e["#"][2].ping), t.useBinary = e["#"][2].binary, t.events.emit("connect");
129+
}, n["#"][2].ping), t.useBinary = n["#"][2].binary, t.events.emit("connect");
131130
}
132131
}
133-
}(e, o);
132+
}(n, o);
134133
}, this.websocket.onclose = function(t) {
135-
if (e.missedPing = 0, clearInterval(e.pingInterval), e.events.emit("disconnect", t.code, t.reason),
136-
e.options.autoReconnect && 1e3 !== t.code) return e.reconnection.reconnect();
137-
e.events.removeAllEvents();
138-
for (var n in e) e[n] && (e[n] = null);
134+
if (n.missedPing = 0, clearInterval(n.pingInterval), n.events.emit("disconnect", t.code, t.reason),
135+
n.options.autoReconnect && 1e3 !== t.code) return n.reconnection.reconnect();
136+
n.events.removeAllEvents();
137+
for (var e in n) n[e] && (n[e] = null);
139138
};
140-
}, s.prototype.on = function(t, e) {
141-
this.events.on(t, e);
142-
}, s.prototype.send = function(t, e, n) {
143-
void 0 === n && (n = "emit"), this.websocket.send(this.useBinary ? function(t) {
144-
for (var e = t.length, n = new Uint8Array(e), o = 0; o < e; o++) n[o] = t.charCodeAt(o);
145-
return n.buffer;
146-
}(i(t, e, n)) : i(t, e, n));
147-
}, s.prototype.disconnect = function(t, e) {
148-
this.websocket.close(t || 1e3, e);
139+
}, s.prototype.on = function(t, n) {
140+
this.events.on(t, n);
141+
}, s.prototype.send = function(t, n, e) {
142+
void 0 === e && (e = "emit"), this.websocket.send(this.useBinary ? function(t) {
143+
for (var n = t.length, e = new Uint8Array(n), o = 0; o < n; o++) e[o] = t.charCodeAt(o);
144+
return e.buffer;
145+
}(i(t, n, e)) : i(t, n, e));
146+
}, s.prototype.disconnect = function(t, n) {
147+
this.websocket.close(t || 1e3, n);
149148
}, s.prototype.getState = function() {
150149
return this.websocket.readyState;
151150
}, s.prototype.subscribe = function(t) {
152-
return this.channels[t] ? this.channels[t] : this.channels[t] = new e(this, t);
151+
return this.channels[t] ? this.channels[t] : this.channels[t] = new n(this, t);
153152
}, s.prototype.getChannelByName = function(t) {
154153
return this.channels[t];
155154
}, s;
156155
}();
157-
return module.exports = s, module.exports.default = s, s;
158156
}();

dist/browser/clusterws.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)