@nxtedition/deepstream.io-client-js 24.0.0 → 24.0.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.0.0",
3
+ "version": "24.0.1",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -13,8 +13,6 @@ const timers = require('../utils/timers')
13
13
 
14
14
  const kEmpty = Symbol('kEmpty')
15
15
 
16
- function noop() {}
17
-
18
16
  function onUpdate(record, subscription) {
19
17
  if (subscription.state && record.state < subscription.state) {
20
18
  return
@@ -172,6 +170,10 @@ class RecordHandler {
172
170
  return this._stats
173
171
  }
174
172
 
173
+ /**
174
+ * @param {string} name
175
+ * @returns {Record}
176
+ */
175
177
  getRecord(name) {
176
178
  invariant(
177
179
  typeof name === 'string' && name.length > 0 && name !== '[object Object]',
@@ -351,17 +353,18 @@ class RecordHandler {
351
353
  dataOnly,
352
354
  data: kEmpty,
353
355
  timeout: null,
354
- abort: noop,
356
+ /** @type {Record?} */ record: null,
357
+ /** @type {Function?} */ abort: null,
355
358
  unsubscribe() {
356
359
  if (this.timeout) {
357
360
  timers.clearTimeout(this.timeout)
358
361
  this.timeout = null
359
362
  }
360
363
 
361
- if (this.ignal) {
364
+ if (this.signal) {
362
365
  utils.removeAbortListener(this.signal, this.abort)
363
366
  this.signal = null
364
- this.abort = noop
367
+ this.abort = null
365
368
  }
366
369
 
367
370
  if (this.record) {
@@ -372,14 +375,14 @@ class RecordHandler {
372
375
  },
373
376
  }
374
377
 
375
- const record = this.getRecord(name).subscribe(onUpdate, subscription)
378
+ subscription.record = this.getRecord(name).subscribe(onUpdate, subscription)
376
379
 
377
- if (timeout && subscription.state && record.state < subscription.state) {
380
+ if (timeout && subscription.state && subscription.record.state < subscription.state) {
378
381
  subscription.timeout = timers.setTimeout(onTimeout, timeout, subscription)
379
382
  }
380
383
 
381
- if (record.version) {
382
- onUpdate(record, subscription)
384
+ if (subscription.record.version) {
385
+ onUpdate(subscription.record, subscription)
383
386
  }
384
387
 
385
388
  if (subscription.signal) {
@@ -47,6 +47,10 @@ class Record {
47
47
  return this._refs
48
48
  }
49
49
 
50
+ /**
51
+ *
52
+ * @returns {Record}
53
+ */
50
54
  ref() {
51
55
  this._refs += 1
52
56
  if (this._refs === 1) {
@@ -56,6 +60,10 @@ class Record {
56
60
  return this
57
61
  }
58
62
 
63
+ /**
64
+ *
65
+ * @returns {Record}
66
+ */
59
67
  unref() {
60
68
  this._refs -= 1
61
69
  if (this._refs === 0) {
@@ -64,6 +72,12 @@ class Record {
64
72
  return this
65
73
  }
66
74
 
75
+ /**
76
+ *
77
+ * @param {*} fn
78
+ * @param {*} opaque
79
+ * @returns {Record}
80
+ */
67
81
  subscribe(fn, opaque = null) {
68
82
  if (this._emitting) {
69
83
  this._subscriptions = this._subscriptions.slice()
@@ -75,6 +89,12 @@ class Record {
75
89
  return this
76
90
  }
77
91
 
92
+ /**
93
+ *
94
+ * @param {*} fn
95
+ * @param {*} opaque
96
+ * @returns {Record}
97
+ */
78
98
  unsubscribe(fn, opaque = null) {
79
99
  if (this._emitting) {
80
100
  this._subscriptions = this._subscriptions.slice()