@nxtedition/deepstream.io-client-js 23.4.2 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "23.4.2",
3
+ "version": "23.4.3",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -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
- node[token] = newValue
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
- obj[key] = val
152
+
153
+ if (val !== undefined) {
154
+ obj[key] = val
155
+ }
148
156
  }
149
157
 
150
158
  return obj || oldValue