react-event-socket
Advanced tools
Comparing version 1.1.0-beta.4 to 1.1.0-beta.5
@@ -24,3 +24,3 @@ import g from "react"; | ||
return Object.assign(s, e), s; | ||
}, A = (t) => C, O = (t) => t.charAt(0).toUpperCase() + t.slice(1), l = (t) => t.split("-").reduce((e, s) => `${e}${O(s)}`, ""), S = { | ||
}, A = (t) => C, O = (t) => t.charAt(0).toUpperCase() + t.slice(1), u = (t) => t.split("-").reduce((e, s) => `${e}${O(s)}`, ""), b = { | ||
1e3: "Normal closure, meaning that the purpose for which the connection was established has been fulfilled.", | ||
@@ -51,11 +51,9 @@ 1001: 'An endpoint is "going away", such as a server going down or a browser having navigated away from a page.', | ||
return !1; | ||
}, u = (t) => { | ||
if (Buffer.isBuffer(t)) | ||
return t.toString(); | ||
}, l = (t) => { | ||
if (Array.isArray(t)) | ||
return t.map(u); | ||
return t.map(l); | ||
if (t !== null && typeof t == "object") { | ||
const e = {}; | ||
return Object.keys(t).forEach((s) => { | ||
e[s] = u(t[s]); | ||
e[s] = l(t[s]); | ||
}), e; | ||
@@ -66,5 +64,5 @@ } | ||
const e = JSON.parse(t); | ||
return u(e); | ||
return l(e); | ||
}, $ = (t) => Object.keys(t.getState()).reduce((e, s) => { | ||
const n = s, o = `set${l(s)}`, i = (c) => { | ||
const n = s, o = `set${u(s)}`, i = (c) => { | ||
t.setState({ [n]: c }); | ||
@@ -74,5 +72,5 @@ }; | ||
}, {}), T = (t) => Object.keys(t.getState()).reduce((e, s) => { | ||
const n = s, o = `use${l(s)}`; | ||
const n = s, o = `use${u(s)}`; | ||
return { ...e, [o]: () => t((i) => i[n]) }; | ||
}, {}), b = (t) => { | ||
}, {}), S = (t) => { | ||
const e = t.reduce( | ||
@@ -87,3 +85,3 @@ (i, c) => ({ | ||
}; | ||
class N { | ||
class I { | ||
constructor(e, s) { | ||
@@ -113,3 +111,3 @@ this.predicates = {}, this.selects = {}, this.address = e, this.verbose = s ?? !1, console.log(s); | ||
this.verbose && console.info(`${i}`, h); | ||
const a = `set${l(i)}`; | ||
const a = `set${u(i)}`; | ||
s[a](); | ||
@@ -126,4 +124,4 @@ return; | ||
}, e.onclose = (o) => { | ||
this.verbose && console.info("Socket Closed:", o), n.setStatus("closed"), o.code in S ? n.setCloseMessage( | ||
S[o.code] | ||
this.verbose && console.info("Socket Closed:", o), n.setStatus("closed"), o.code in b ? n.setCloseMessage( | ||
b[o.code] | ||
) : n.setCloseMessage("Unknown reason"); | ||
@@ -144,5 +142,5 @@ }, e.onmessage = (o) => { | ||
build() { | ||
const [e, s] = b( | ||
const [e, s] = S( | ||
Object.keys(this.predicates) | ||
), [n, o] = b([ | ||
), [n, o] = S([ | ||
"error", | ||
@@ -173,3 +171,3 @@ "status", | ||
export { | ||
N as ReactSocket | ||
I as ReactSocket | ||
}; |
@@ -67,3 +67,3 @@ { | ||
}, | ||
"version": "1.1.0-beta.4" | ||
"version": "1.1.0-beta.5" | ||
} |
Sorry, the diff of this file is not supported yet
18931
251