@nxtedition/deepstream.io-client-js 24.2.8 → 24.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.2.8",
3
+ "version": "24.2.9",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -101,17 +101,20 @@ Connection.prototype.close = function () {
101
101
  }
102
102
 
103
103
  Connection.prototype._createEndpoint = function () {
104
+ const decoder = new TextDecoder()
104
105
  if (NodeWebSocket) {
105
106
  this._endpoint = new NodeWebSocket(this._url, {
106
107
  generateMask() {},
107
108
  })
108
- this._endpoint.onmessage = ({ data }) => this._onMessage(data.toString())
109
109
  } else {
110
110
  this._endpoint = new BrowserWebSocket(this._url)
111
111
  this._endpoint.binaryType = 'arraybuffer'
112
- const decoder = new TextDecoder()
113
- this._endpoint.onmessage = ({ data }) => this._onMessage(decoder.decode(data))
114
112
  }
113
+
114
+ this._endpoint.onmessage = ({ data }) => {
115
+ this._onMessage(typeof data === 'string' ? data : decoder.decode(data))
116
+ }
117
+
115
118
  this._corked = false
116
119
 
117
120
  this._endpoint.onopen = this._onOpen.bind(this)