@nxtedition/deepstream.io-client-js 32.0.24 → 32.0.26

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": "32.0.24",
3
+ "version": "32.0.26",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -96,18 +96,22 @@ Connection.prototype._createEndpoint = function () {
96
96
  })
97
97
  this._endpoint.binaryType = 'nodebuffer'
98
98
  this._endpoint.onmessage = ({ data: buf }) => {
99
- this._onMessage(buf.toString('utf8', buf[0] >= 128 ? buf[0] - 128 : 0, buf.length))
99
+ this._onMessage(buf.toString('utf8', buf[0] > 128 ? buf[0] - 128 : 0))
100
100
  }
101
101
  } else {
102
102
  const decoder = new globalThis.TextDecoder()
103
103
  this._endpoint = new BrowserWebSocket(this._url)
104
104
  this._endpoint.binaryType = 'arraybuffer'
105
105
  this._endpoint.onmessage = ({ data }) => {
106
- let buf = new Uint8Array(data)
107
- if (buf[0] >= 128) {
108
- buf = buf.subarray(buf[0] - 128)
106
+ if (typeof data === 'string') {
107
+ this._onMessage(data)
108
+ } else {
109
+ let buf = new Uint8Array(data)
110
+ if (buf[0] > 128) {
111
+ buf = buf.subarray(buf[0] - 128)
112
+ }
113
+ this._onMessage(decoder.decode(buf))
109
114
  }
110
- this._onMessage(decoder.decode(buf))
111
115
  }
112
116
  }
113
117