@nxtedition/deepstream.io-client-js 23.4.1 → 23.4.3
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.
|
@@ -342,4 +342,12 @@ describe('plain JSON', () => {
|
|
|
342
342
|
)
|
|
343
343
|
expect(res.date).toEqual(date.toISOString())
|
|
344
344
|
})
|
|
345
|
+
|
|
346
|
+
it('remove property on undefined', () => {
|
|
347
|
+
const y = {
|
|
348
|
+
time: {},
|
|
349
|
+
}
|
|
350
|
+
const res = jsonPath.set(y, 'time', undefined)
|
|
351
|
+
expect(Object.keys(res)).toEqual([])
|
|
352
|
+
})
|
|
345
353
|
})
|
package/package.json
CHANGED
package/src/record/json-path.js
CHANGED
|
@@ -68,7 +68,11 @@ function set(data, path, value, isPlainJSON = false) {
|
|
|
68
68
|
for (let i = 0; i < tokens.length; i++) {
|
|
69
69
|
const token = tokens[i]
|
|
70
70
|
if (i === tokens.length - 1) {
|
|
71
|
-
|
|
71
|
+
if (newValue !== undefined) {
|
|
72
|
+
node[token] = newValue
|
|
73
|
+
} else {
|
|
74
|
+
delete node[token]
|
|
75
|
+
}
|
|
72
76
|
} else if (node[token] != null && typeof node[token] === 'object') {
|
|
73
77
|
node = node[token] = utils.shallowCopy(node[token])
|
|
74
78
|
} else if (tokens[i + 1] && !isNaN(tokens[i + 1])) {
|
|
@@ -77,6 +81,7 @@ function set(data, path, value, isPlainJSON = false) {
|
|
|
77
81
|
node = node[token] = {}
|
|
78
82
|
}
|
|
79
83
|
}
|
|
84
|
+
|
|
80
85
|
return result
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -144,7 +149,10 @@ function patch(oldValue, newValue, isPlainJSON) {
|
|
|
144
149
|
obj[newKeys[j]] = oldValue[newKeys[j]]
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
|
-
|
|
152
|
+
|
|
153
|
+
if (val !== undefined) {
|
|
154
|
+
obj[key] = val
|
|
155
|
+
}
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
return obj || oldValue
|
|
@@ -48,7 +48,17 @@ class RecordHandler {
|
|
|
48
48
|
|
|
49
49
|
this._client.on(C.EVENT.CONNECTED, this._onConnectionStateChange.bind(this))
|
|
50
50
|
|
|
51
|
+
const _prune = () => {
|
|
52
|
+
if (!this._pruning) {
|
|
53
|
+
this._pruning = true
|
|
54
|
+
this._schedule(prune)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
const prune = () => {
|
|
59
|
+
this._now = Date.now()
|
|
60
|
+
this._pruning = false
|
|
61
|
+
|
|
52
62
|
let counter = 0
|
|
53
63
|
for (const [rec, timestamp] of this._prune) {
|
|
54
64
|
if (this._now - timestamp < 1e3) {
|
|
@@ -65,22 +75,13 @@ class RecordHandler {
|
|
|
65
75
|
this._prune.delete(rec)
|
|
66
76
|
|
|
67
77
|
if (counter++ > 1024) {
|
|
68
|
-
|
|
69
|
-
return
|
|
78
|
+
_prune()
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
|
-
|
|
73
|
-
this._pruning = false
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!this._pruning) {
|
|
79
|
-
this._pruning = true
|
|
80
|
-
this._schedule(prune)
|
|
81
|
-
}
|
|
82
|
-
}, 1e3)
|
|
83
|
-
pruneInterval.unref?.()
|
|
83
|
+
this._pruneInterval = setInterval(_prune, 1e3)
|
|
84
|
+
this._pruneInterval.unref?.()
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
_onRef(rec) {
|