@nxtedition/deepstream.io-client-js 26.0.2 → 26.0.4
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 +1 -1
- package/src/client.js +4 -4
- package/src/default-options.js +1 -1
- package/src/event/event-handler.js +8 -8
- package/src/message/connection.js +39 -76
- package/src/message/message-builder.js +6 -5
- package/src/message/message-parser.js +50 -1
- package/src/record/record-handler.js +59 -59
- package/src/record/record.js +47 -60
- package/src/rpc/rpc-handler.js +10 -10
- package/src/rpc/rpc-response.js +2 -2
- package/src/utils/fixed-queue.js +9 -9
- package/src/utils/multicast-listener.js +16 -20
- package/src/utils/timers.js +7 -7
- package/src/utils/unicast-listener.js +11 -15
- package/src/utils/utils.js +13 -13
|
@@ -18,11 +18,11 @@ const PIPE = rxjs.pipe(
|
|
|
18
18
|
|
|
19
19
|
return data
|
|
20
20
|
}),
|
|
21
|
-
rx.distinctUntilChanged()
|
|
21
|
+
rx.distinctUntilChanged()
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
class Listener {
|
|
25
|
-
constructor(topic, pattern, callback, handler, opts) {
|
|
25
|
+
constructor (topic, pattern, callback, handler, opts) {
|
|
26
26
|
if (opts.recursive) {
|
|
27
27
|
throw new Error('invalid argument: recursive')
|
|
28
28
|
}
|
|
@@ -42,17 +42,17 @@ class Listener {
|
|
|
42
42
|
this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
get stats() {
|
|
45
|
+
get stats () {
|
|
46
46
|
return {
|
|
47
|
-
subscriptions: this._subscriptions.size
|
|
47
|
+
subscriptions: this._subscriptions.size
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
_$destroy() {
|
|
51
|
+
_$destroy () {
|
|
52
52
|
this._reset()
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
_$onMessage(message) {
|
|
55
|
+
_$onMessage (message) {
|
|
56
56
|
const name = message.data[1]
|
|
57
57
|
|
|
58
58
|
if (message.action === C.ACTIONS.LISTEN_ACCEPT) {
|
|
@@ -86,7 +86,7 @@ class Listener {
|
|
|
86
86
|
this._error(name, err)
|
|
87
87
|
this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, key])
|
|
88
88
|
this._subscriptions.delete(name)
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
})
|
|
91
91
|
this._subscriptions.set(name, subscription)
|
|
92
92
|
} else {
|
|
@@ -107,7 +107,7 @@ class Listener {
|
|
|
107
107
|
return true
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
_$onConnectionStateChange(connected) {
|
|
110
|
+
_$onConnectionStateChange (connected) {
|
|
111
111
|
if (connected) {
|
|
112
112
|
this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
|
|
113
113
|
} else {
|
|
@@ -115,15 +115,11 @@ class Listener {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
_error(name, err) {
|
|
119
|
-
this._client._$onError(this._topic, C.EVENT.LISTENER_ERROR, err, [
|
|
120
|
-
this._pattern,
|
|
121
|
-
name,
|
|
122
|
-
this._handler.getKey(name).toString(),
|
|
123
|
-
])
|
|
118
|
+
_error (name, err) {
|
|
119
|
+
this._client._$onError(this._topic, C.EVENT.LISTENER_ERROR, err, [this._pattern, name])
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
_reset() {
|
|
122
|
+
_reset () {
|
|
127
123
|
for (const subscription of this._subscriptions.values()) {
|
|
128
124
|
subscription.unsubscribe()
|
|
129
125
|
}
|
package/src/utils/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ const NODE_ENV = typeof process !== 'undefined' && process.env && process.env.NO
|
|
|
2
2
|
export const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
|
|
3
3
|
export const isProduction = NODE_ENV === 'production'
|
|
4
4
|
|
|
5
|
-
export function deepFreeze(o) {
|
|
5
|
+
export function deepFreeze (o) {
|
|
6
6
|
if (isProduction) {
|
|
7
7
|
return o
|
|
8
8
|
}
|
|
@@ -18,7 +18,7 @@ export function deepFreeze(o) {
|
|
|
18
18
|
return o
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function splitRev(s) {
|
|
21
|
+
export function splitRev (s) {
|
|
22
22
|
if (!s) {
|
|
23
23
|
return [-1, '00000000000000']
|
|
24
24
|
}
|
|
@@ -29,7 +29,7 @@ export function splitRev(s) {
|
|
|
29
29
|
return [ver.charAt(0) === 'I' ? Infinity : parseInt(ver, 10), s.slice(i + 1)]
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function isPlainObject(value, isPlainJSON) {
|
|
32
|
+
export function isPlainObject (value, isPlainJSON) {
|
|
33
33
|
if (isPlainJSON) {
|
|
34
34
|
return value && typeof value === 'object' && !Array.isArray(value)
|
|
35
35
|
}
|
|
@@ -50,13 +50,13 @@ export function isPlainObject(value, isPlainJSON) {
|
|
|
50
50
|
return Object.getPrototypeOf(value) === proto
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export function isSameOrNewer(a, b) {
|
|
53
|
+
export function isSameOrNewer (a, b) {
|
|
54
54
|
const [av, ar] = splitRev(a)
|
|
55
55
|
const [bv, br] = splitRev(b)
|
|
56
56
|
return av > bv || (av === bv && ar >= br)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export function shallowCopy(obj) {
|
|
59
|
+
export function shallowCopy (obj) {
|
|
60
60
|
if (Array.isArray(obj)) {
|
|
61
61
|
return obj.slice(0)
|
|
62
62
|
}
|
|
@@ -69,7 +69,7 @@ export function shallowCopy(obj) {
|
|
|
69
69
|
return copy
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function setTimeout(callback, timeoutDuration) {
|
|
72
|
+
export function setTimeout (callback, timeoutDuration) {
|
|
73
73
|
if (timeoutDuration !== null) {
|
|
74
74
|
return globalThis.setTimeout(callback, timeoutDuration)
|
|
75
75
|
} else {
|
|
@@ -77,7 +77,7 @@ export function setTimeout(callback, timeoutDuration) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export function setInterval(callback, intervalDuration) {
|
|
80
|
+
export function setInterval (callback, intervalDuration) {
|
|
81
81
|
if (intervalDuration !== null) {
|
|
82
82
|
return setInterval(callback, intervalDuration)
|
|
83
83
|
} else {
|
|
@@ -85,7 +85,7 @@ export function setInterval(callback, intervalDuration) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function compareRev(a, b) {
|
|
88
|
+
export function compareRev (a, b) {
|
|
89
89
|
if (!a) {
|
|
90
90
|
return b ? -1 : 0
|
|
91
91
|
}
|
|
@@ -116,14 +116,14 @@ export function compareRev(a, b) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export class AbortError extends Error {
|
|
119
|
-
constructor() {
|
|
119
|
+
constructor () {
|
|
120
120
|
super('The operation was aborted')
|
|
121
121
|
this.code = 'ABORT_ERR'
|
|
122
122
|
this.name = 'AbortError'
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
function defaultSchedule(fn) {
|
|
126
|
+
function defaultSchedule (fn) {
|
|
127
127
|
setTimeout(fn, 0)
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -139,7 +139,7 @@ const onAbort = function () {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
export function addAbortListener(signal, handler) {
|
|
142
|
+
export function addAbortListener (signal, handler) {
|
|
143
143
|
if (!signal) {
|
|
144
144
|
return
|
|
145
145
|
}
|
|
@@ -157,7 +157,7 @@ export function addAbortListener(signal, handler) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export function removeAbortListener(signal, handler) {
|
|
160
|
+
export function removeAbortListener (signal, handler) {
|
|
161
161
|
if (!signal) {
|
|
162
162
|
return
|
|
163
163
|
}
|
|
@@ -175,7 +175,7 @@ export function removeAbortListener(signal, handler) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
export function readBigUInt64BE(buf, offset = 0) {
|
|
178
|
+
export function readBigUInt64BE (buf, offset = 0) {
|
|
179
179
|
const first = buf[offset]
|
|
180
180
|
const last = buf[offset + 7]
|
|
181
181
|
|