@nxtedition/deepstream.io-client-js 24.3.0 → 24.3.1

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.3.0",
3
+ "version": "24.3.1",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -7,6 +7,8 @@ const invariant = require('invariant')
7
7
  const cloneDeep = require('lodash.clonedeep')
8
8
  const timers = require('../utils/timers')
9
9
 
10
+ const encoder = new TextEncoder()
11
+
10
12
  class Record {
11
13
  static STATE = C.RECORD_STATE
12
14
 
@@ -16,15 +18,17 @@ class Record {
16
18
  this._handler = handler
17
19
 
18
20
  this._name = name
19
- this._key = connection.hasher?.h64(name) ?? name
21
+ this._key = name
20
22
  this._version = ''
21
23
  this._data = jsonPath.EMPTY
22
24
  this._state = C.RECORD_STATE.VOID
23
25
  this._refs = 0
24
26
  this._subscriptions = []
25
27
  this._emitting = false
28
+
26
29
  /** @type Map? */ this._updating = null
27
30
  /** @type Array? */ this._patching = null
31
+ this._hashName()
28
32
  this._subscribed = connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, [
29
33
  this._name,
30
34
  this._key,
@@ -312,6 +316,16 @@ class Record {
312
316
  })
313
317
  }
314
318
 
319
+ _hashName() {
320
+ // TODO (fix): It's hacky that hasher is not always available...
321
+ this._key =
322
+ typeof this._key === 'bigint'
323
+ ? this._key
324
+ : this._name.length <= 8 && encoder.encode(this._name).byteLength === 8
325
+ ? this._name
326
+ : this._handler.connection.hasher?.h64(this._name)
327
+ }
328
+
315
329
  _$onMessage(message) {
316
330
  if (message.action === C.ACTIONS.UPDATE) {
317
331
  this._onUpdate(message.data)
@@ -328,7 +342,7 @@ class Record {
328
342
  const connection = this._handler._connection
329
343
 
330
344
  if (connected) {
331
- this._key = typeof this._key === 'bigint' ? this._key : connection.hasher?.h64(this._name)
345
+ this._hashName()
332
346
  this._subscribed =
333
347
  this._refs > 0 &&
334
348
  connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, [this._name, this._key])