statebus 7.0.18 → 7.0.20

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/statebus.js +15 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statebus",
3
- "version": "7.0.18",
3
+ "version": "7.0.20",
4
4
  "description": "Synchronize state.",
5
5
  "main": "statebus.js",
6
6
  "scripts": {
package/statebus.js CHANGED
@@ -198,11 +198,11 @@
198
198
  var key = obj,
199
199
  obj = bus.cache[key]
200
200
 
201
- console.log('set.fire: applying the patch!', {
202
- key: key,
203
- obj: obj,
204
- patch: t.patch[0]
205
- })
201
+ // console.log('set.fire: applying the patch!', {
202
+ // key: key,
203
+ // obj: obj,
204
+ // patch: t.patch[0]
205
+ // })
206
206
  obj.val = apply_patch(obj.val, t.patch[0])
207
207
  }
208
208
 
@@ -1360,7 +1360,13 @@
1360
1360
  return o.hasOwnProperty(proxied_2_keyed(k))
1361
1361
  },
1362
1362
  deleteProperty: function del (o, k) {
1363
+ var new_path = path + '[' + JSON.stringify(k) + ']'
1363
1364
  delete o[proxied_2_keyed(k)]
1365
+ bus.set(
1366
+ base,
1367
+ // Forward the patch too
1368
+ {patch: [new_path + ' = ']}
1369
+ )
1364
1370
  return true // Report success to Proxy
1365
1371
  }
1366
1372
  // For function proxies:
@@ -1778,9 +1784,9 @@
1778
1784
  // The final object can be a slice
1779
1785
  // Set the value in the final object
1780
1786
 
1781
- var x = patch.match(/(.*) = (.*)/),
1782
- path = x[1],
1783
- new_stuff = JSON.parse(x[2])
1787
+ var match = patch.match(/(.*) = (.*)/),
1788
+ path = match[1],
1789
+ new_stuff = match[2].length ? JSON.parse(match[2]) : undefined
1784
1790
 
1785
1791
  var path_segment = /^(\.?([^\.\[]+))|(\[((-?\d+):)?(-?\d+)\])|\[("(\\"|[^"])*")\]/
1786
1792
  var curr_obj = obj,
@@ -1791,7 +1797,7 @@
1791
1797
  : parseInt(numstr)
1792
1798
  }
1793
1799
 
1794
- console.log('Getting path', JSON.stringify(path), 'in obj', obj)
1800
+ // console.log('Getting path', JSON.stringify(path), 'in obj', obj)
1795
1801
 
1796
1802
  while (true) {
1797
1803
  var match = path_segment.exec(path),