tinybase 7.3.2 → 7.3.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.
Files changed (135) hide show
  1. package/min/omni/index.js +1 -1
  2. package/min/omni/index.js.gz +0 -0
  3. package/min/omni/with-schemas/index.js +1 -1
  4. package/min/omni/with-schemas/index.js.gz +0 -0
  5. package/min/persisters/index.js +1 -1
  6. package/min/persisters/index.js.gz +0 -0
  7. package/min/persisters/persister-browser/index.js +1 -1
  8. package/min/persisters/persister-browser/index.js.gz +0 -0
  9. package/min/persisters/persister-browser/with-schemas/index.js +1 -1
  10. package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
  11. package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  12. package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
  13. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  14. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
  15. package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
  16. package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
  17. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  18. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
  19. package/min/persisters/persister-electric-sql/index.js +1 -1
  20. package/min/persisters/persister-electric-sql/index.js.gz +0 -0
  21. package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  22. package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
  23. package/min/persisters/persister-expo-sqlite/index.js +1 -1
  24. package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
  25. package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  26. package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
  27. package/min/persisters/persister-file/index.js +1 -1
  28. package/min/persisters/persister-file/index.js.gz +0 -0
  29. package/min/persisters/persister-file/with-schemas/index.js +1 -1
  30. package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
  31. package/min/persisters/persister-libsql/index.js +1 -1
  32. package/min/persisters/persister-libsql/index.js.gz +0 -0
  33. package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
  34. package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
  35. package/min/persisters/persister-partykit-client/index.js +1 -1
  36. package/min/persisters/persister-partykit-client/index.js.gz +0 -0
  37. package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  38. package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  39. package/min/persisters/persister-partykit-server/index.js +1 -1
  40. package/min/persisters/persister-partykit-server/index.js.gz +0 -0
  41. package/min/persisters/persister-partykit-server/with-schemas/index.js +1 -1
  42. package/min/persisters/persister-partykit-server/with-schemas/index.js.gz +0 -0
  43. package/min/persisters/persister-pglite/index.js +1 -1
  44. package/min/persisters/persister-pglite/index.js.gz +0 -0
  45. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  46. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  47. package/min/persisters/persister-postgres/index.js +1 -1
  48. package/min/persisters/persister-postgres/index.js.gz +0 -0
  49. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  50. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  51. package/min/persisters/persister-powersync/index.js +1 -1
  52. package/min/persisters/persister-powersync/index.js.gz +0 -0
  53. package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
  54. package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
  55. package/min/persisters/persister-react-native-sqlite/index.js +1 -1
  56. package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
  57. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  58. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
  59. package/min/persisters/persister-sqlite-bun/index.js +1 -1
  60. package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
  61. package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  62. package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
  63. package/min/persisters/persister-sqlite-wasm/index.js +1 -1
  64. package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
  65. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  66. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
  67. package/min/persisters/persister-sqlite3/index.js +1 -1
  68. package/min/persisters/persister-sqlite3/index.js.gz +0 -0
  69. package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  70. package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
  71. package/min/persisters/with-schemas/index.js +1 -1
  72. package/min/persisters/with-schemas/index.js.gz +0 -0
  73. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  74. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  75. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  76. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  77. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  78. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  79. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  80. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  81. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  82. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
  83. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  84. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
  85. package/min/ui-react-inspector/index.js +1 -1
  86. package/min/ui-react-inspector/index.js.gz +0 -0
  87. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  88. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  89. package/omni/index.js +16 -3
  90. package/omni/with-schemas/index.js +16 -3
  91. package/package.json +13 -13
  92. package/persisters/index.js +10 -1
  93. package/persisters/persister-browser/index.js +17 -1
  94. package/persisters/persister-browser/with-schemas/index.js +17 -1
  95. package/persisters/persister-cr-sqlite-wasm/index.js +10 -1
  96. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +10 -1
  97. package/persisters/persister-durable-object-sql-storage/index.js +10 -1
  98. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +10 -1
  99. package/persisters/persister-electric-sql/index.js +10 -1
  100. package/persisters/persister-electric-sql/with-schemas/index.js +10 -1
  101. package/persisters/persister-expo-sqlite/index.js +10 -1
  102. package/persisters/persister-expo-sqlite/with-schemas/index.js +10 -1
  103. package/persisters/persister-file/index.js +17 -1
  104. package/persisters/persister-file/with-schemas/index.js +17 -1
  105. package/persisters/persister-libsql/index.js +10 -1
  106. package/persisters/persister-libsql/with-schemas/index.js +10 -1
  107. package/persisters/persister-partykit-client/index.js +27 -2
  108. package/persisters/persister-partykit-client/with-schemas/index.js +27 -2
  109. package/persisters/persister-partykit-server/index.js +37 -2
  110. package/persisters/persister-partykit-server/with-schemas/index.js +37 -2
  111. package/persisters/persister-pglite/index.js +10 -1
  112. package/persisters/persister-pglite/with-schemas/index.js +10 -1
  113. package/persisters/persister-postgres/index.js +10 -1
  114. package/persisters/persister-postgres/with-schemas/index.js +10 -1
  115. package/persisters/persister-powersync/index.js +10 -1
  116. package/persisters/persister-powersync/with-schemas/index.js +10 -1
  117. package/persisters/persister-react-native-sqlite/index.js +10 -1
  118. package/persisters/persister-react-native-sqlite/with-schemas/index.js +10 -1
  119. package/persisters/persister-sqlite-bun/index.js +10 -1
  120. package/persisters/persister-sqlite-bun/with-schemas/index.js +10 -1
  121. package/persisters/persister-sqlite-wasm/index.js +10 -1
  122. package/persisters/persister-sqlite-wasm/with-schemas/index.js +10 -1
  123. package/persisters/persister-sqlite3/index.js +10 -1
  124. package/persisters/persister-sqlite3/with-schemas/index.js +10 -1
  125. package/persisters/with-schemas/index.js +10 -1
  126. package/readme.md +9 -1
  127. package/releases.md +1 -1
  128. package/synchronizers/synchronizer-ws-client/index.js +14 -1
  129. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +14 -1
  130. package/synchronizers/synchronizer-ws-server/index.js +14 -1
  131. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +14 -1
  132. package/synchronizers/synchronizer-ws-server-durable-object/index.js +14 -1
  133. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +14 -1
  134. package/ui-react-inspector/index.js +10 -1
  135. package/ui-react-inspector/with-schemas/index.js +10 -1
@@ -479,7 +479,16 @@ const jsonParse = JSON.parse;
479
479
  const jsonStringWithUndefined = (obj) =>
480
480
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
481
481
  const jsonParseWithUndefined = (str) =>
482
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
482
+ // JSON.parse reviver removes properties with undefined values
483
+ replaceUndefinedString(jsonParse(str));
484
+ const replaceUndefinedString = (obj) =>
485
+ obj === UNDEFINED
486
+ ? void 0
487
+ : isArray(obj)
488
+ ? arrayMap(obj, replaceUndefinedString)
489
+ : isObject(obj)
490
+ ? objMap(obj, replaceUndefinedString)
491
+ : obj;
483
492
 
484
493
  const textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();
485
494
  const getHash = (string) => {
@@ -26,12 +26,14 @@ const tryCatch = async (action, then1, then2) => {
26
26
  };
27
27
 
28
28
  const arrayForEach = (array, cb) => array.forEach(cb);
29
+ const arrayMap = (array, cb) => array.map(cb);
29
30
  const arrayClear = (array, to) => array.splice(0, to);
30
31
  const arrayPush = (array, ...values) => array.push(...values);
31
32
  const arrayShift = (array) => array.shift();
32
33
 
33
34
  const object = Object;
34
35
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
36
+ const objEntries = object.entries;
35
37
  const isObject = (obj) =>
36
38
  !isNullish(obj) &&
37
39
  ifNotNullish(
@@ -45,6 +47,11 @@ const isObject = (obj) =>
45
47
  );
46
48
  const objIds = object.keys;
47
49
  const objFreeze = object.freeze;
50
+ const objNew = (entries = []) => object.fromEntries(entries);
51
+ const objToArray = (obj, cb) =>
52
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
53
+ const objMap = (obj, cb) =>
54
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
48
55
  const objSize = (obj) => size(objIds(obj));
49
56
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
50
57
 
@@ -53,7 +60,16 @@ const jsonParse = JSON.parse;
53
60
  const jsonStringWithUndefined = (obj) =>
54
61
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
55
62
  const jsonParseWithUndefined = (str) =>
56
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
63
+ // JSON.parse reviver removes properties with undefined values
64
+ replaceUndefinedString(jsonParse(str));
65
+ const replaceUndefinedString = (obj) =>
66
+ obj === UNDEFINED
67
+ ? void 0
68
+ : isArray(obj)
69
+ ? arrayMap(obj, replaceUndefinedString)
70
+ : isObject(obj)
71
+ ? objMap(obj, replaceUndefinedString)
72
+ : obj;
57
73
 
58
74
  const collSize = (coll) => coll?.size ?? 0;
59
75
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -26,12 +26,14 @@ const tryCatch = async (action, then1, then2) => {
26
26
  };
27
27
 
28
28
  const arrayForEach = (array, cb) => array.forEach(cb);
29
+ const arrayMap = (array, cb) => array.map(cb);
29
30
  const arrayClear = (array, to) => array.splice(0, to);
30
31
  const arrayPush = (array, ...values) => array.push(...values);
31
32
  const arrayShift = (array) => array.shift();
32
33
 
33
34
  const object = Object;
34
35
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
36
+ const objEntries = object.entries;
35
37
  const isObject = (obj) =>
36
38
  !isNullish(obj) &&
37
39
  ifNotNullish(
@@ -45,6 +47,11 @@ const isObject = (obj) =>
45
47
  );
46
48
  const objIds = object.keys;
47
49
  const objFreeze = object.freeze;
50
+ const objNew = (entries = []) => object.fromEntries(entries);
51
+ const objToArray = (obj, cb) =>
52
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
53
+ const objMap = (obj, cb) =>
54
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
48
55
  const objSize = (obj) => size(objIds(obj));
49
56
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
50
57
 
@@ -53,7 +60,16 @@ const jsonParse = JSON.parse;
53
60
  const jsonStringWithUndefined = (obj) =>
54
61
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
55
62
  const jsonParseWithUndefined = (str) =>
56
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
63
+ // JSON.parse reviver removes properties with undefined values
64
+ replaceUndefinedString(jsonParse(str));
65
+ const replaceUndefinedString = (obj) =>
66
+ obj === UNDEFINED
67
+ ? void 0
68
+ : isArray(obj)
69
+ ? arrayMap(obj, replaceUndefinedString)
70
+ : isObject(obj)
71
+ ? objMap(obj, replaceUndefinedString)
72
+ : obj;
57
73
 
58
74
  const collSize = (coll) => coll?.size ?? 0;
59
75
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -99,7 +99,16 @@ const jsonParse = JSON.parse;
99
99
  const jsonStringWithUndefined = (obj) =>
100
100
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
101
101
  const jsonParseWithUndefined = (str) =>
102
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
102
+ // JSON.parse reviver removes properties with undefined values
103
+ replaceUndefinedString(jsonParse(str));
104
+ const replaceUndefinedString = (obj) =>
105
+ obj === UNDEFINED
106
+ ? void 0
107
+ : isArray(obj)
108
+ ? arrayMap(obj, replaceUndefinedString)
109
+ : isObject(obj)
110
+ ? objMap(obj, replaceUndefinedString)
111
+ : obj;
103
112
 
104
113
  const collSize = (coll) => coll?.size ?? 0;
105
114
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -99,7 +99,16 @@ const jsonParse = JSON.parse;
99
99
  const jsonStringWithUndefined = (obj) =>
100
100
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
101
101
  const jsonParseWithUndefined = (str) =>
102
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
102
+ // JSON.parse reviver removes properties with undefined values
103
+ replaceUndefinedString(jsonParse(str));
104
+ const replaceUndefinedString = (obj) =>
105
+ obj === UNDEFINED
106
+ ? void 0
107
+ : isArray(obj)
108
+ ? arrayMap(obj, replaceUndefinedString)
109
+ : isObject(obj)
110
+ ? objMap(obj, replaceUndefinedString)
111
+ : obj;
103
112
 
104
113
  const collSize = (coll) => coll?.size ?? 0;
105
114
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -306,7 +306,16 @@ const jsonParse = JSON.parse;
306
306
  const jsonStringWithUndefined = (obj) =>
307
307
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
308
308
  const jsonParseWithUndefined = (str) =>
309
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
309
+ // JSON.parse reviver removes properties with undefined values
310
+ replaceUndefinedString(jsonParse(str));
311
+ const replaceUndefinedString = (obj) =>
312
+ obj === UNDEFINED
313
+ ? void 0
314
+ : isArray(obj)
315
+ ? arrayMap(obj, replaceUndefinedString)
316
+ : isObject(obj)
317
+ ? objMap(obj, replaceUndefinedString)
318
+ : obj;
310
319
 
311
320
  const INTEGER = /^\d+$/;
312
321
  const getPoolFunctions = () => {
@@ -306,7 +306,16 @@ const jsonParse = JSON.parse;
306
306
  const jsonStringWithUndefined = (obj) =>
307
307
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
308
308
  const jsonParseWithUndefined = (str) =>
309
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
309
+ // JSON.parse reviver removes properties with undefined values
310
+ replaceUndefinedString(jsonParse(str));
311
+ const replaceUndefinedString = (obj) =>
312
+ obj === UNDEFINED
313
+ ? void 0
314
+ : isArray(obj)
315
+ ? arrayMap(obj, replaceUndefinedString)
316
+ : isObject(obj)
317
+ ? objMap(obj, replaceUndefinedString)
318
+ : obj;
310
319
 
311
320
  const INTEGER = /^\d+$/;
312
321
  const getPoolFunctions = () => {
@@ -28,12 +28,14 @@ const tryCatch = async (action, then1, then2) => {
28
28
  };
29
29
 
30
30
  const arrayForEach = (array, cb) => array.forEach(cb);
31
+ const arrayMap = (array, cb) => array.map(cb);
31
32
  const arrayClear = (array, to) => array.splice(0, to);
32
33
  const arrayPush = (array, ...values) => array.push(...values);
33
34
  const arrayShift = (array) => array.shift();
34
35
 
35
36
  const object = Object;
36
37
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
38
+ const objEntries = object.entries;
37
39
  const isObject = (obj) =>
38
40
  !isNullish(obj) &&
39
41
  ifNotNullish(
@@ -47,6 +49,11 @@ const isObject = (obj) =>
47
49
  );
48
50
  const objIds = object.keys;
49
51
  const objFreeze = object.freeze;
52
+ const objNew = (entries = []) => object.fromEntries(entries);
53
+ const objToArray = (obj, cb) =>
54
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
55
+ const objMap = (obj, cb) =>
56
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
50
57
  const objSize = (obj) => size(objIds(obj));
51
58
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
52
59
 
@@ -55,7 +62,16 @@ const jsonParse = JSON.parse;
55
62
  const jsonStringWithUndefined = (obj) =>
56
63
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
57
64
  const jsonParseWithUndefined = (str) =>
58
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
65
+ // JSON.parse reviver removes properties with undefined values
66
+ replaceUndefinedString(jsonParse(str));
67
+ const replaceUndefinedString = (obj) =>
68
+ obj === UNDEFINED
69
+ ? void 0
70
+ : isArray(obj)
71
+ ? arrayMap(obj, replaceUndefinedString)
72
+ : isObject(obj)
73
+ ? objMap(obj, replaceUndefinedString)
74
+ : obj;
59
75
 
60
76
  const collSize = (coll) => coll?.size ?? 0;
61
77
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -28,12 +28,14 @@ const tryCatch = async (action, then1, then2) => {
28
28
  };
29
29
 
30
30
  const arrayForEach = (array, cb) => array.forEach(cb);
31
+ const arrayMap = (array, cb) => array.map(cb);
31
32
  const arrayClear = (array, to) => array.splice(0, to);
32
33
  const arrayPush = (array, ...values) => array.push(...values);
33
34
  const arrayShift = (array) => array.shift();
34
35
 
35
36
  const object = Object;
36
37
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
38
+ const objEntries = object.entries;
37
39
  const isObject = (obj) =>
38
40
  !isNullish(obj) &&
39
41
  ifNotNullish(
@@ -47,6 +49,11 @@ const isObject = (obj) =>
47
49
  );
48
50
  const objIds = object.keys;
49
51
  const objFreeze = object.freeze;
52
+ const objNew = (entries = []) => object.fromEntries(entries);
53
+ const objToArray = (obj, cb) =>
54
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
55
+ const objMap = (obj, cb) =>
56
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
50
57
  const objSize = (obj) => size(objIds(obj));
51
58
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
52
59
 
@@ -55,7 +62,16 @@ const jsonParse = JSON.parse;
55
62
  const jsonStringWithUndefined = (obj) =>
56
63
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
57
64
  const jsonParseWithUndefined = (str) =>
58
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
65
+ // JSON.parse reviver removes properties with undefined values
66
+ replaceUndefinedString(jsonParse(str));
67
+ const replaceUndefinedString = (obj) =>
68
+ obj === UNDEFINED
69
+ ? void 0
70
+ : isArray(obj)
71
+ ? arrayMap(obj, replaceUndefinedString)
72
+ : isObject(obj)
73
+ ? objMap(obj, replaceUndefinedString)
74
+ : obj;
59
75
 
60
76
  const collSize = (coll) => coll?.size ?? 0;
61
77
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -2,6 +2,7 @@ const getTypeOf = (thing) => typeof thing;
2
2
  const EMPTY_STRING = '';
3
3
  const STRING = getTypeOf(EMPTY_STRING);
4
4
  const MESSAGE = 'message';
5
+ const UNDEFINED = '\uFFFC';
5
6
  const strStartsWith = (str, prefix) => str.startsWith(prefix);
6
7
 
7
8
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
@@ -30,12 +31,14 @@ const tryCatch = async (action, then1, then2) => {
30
31
  };
31
32
 
32
33
  const arrayForEach = (array, cb) => array.forEach(cb);
34
+ const arrayMap = (array, cb) => array.map(cb);
33
35
  const arrayClear = (array, to) => array.splice(0, to);
34
36
  const arrayPush = (array, ...values) => array.push(...values);
35
37
  const arrayShift = (array) => array.shift();
36
38
 
37
39
  const object = Object;
38
40
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
41
+ const objEntries = object.entries;
39
42
  const isObject = (obj) =>
40
43
  !isNullish(obj) &&
41
44
  ifNotNullish(
@@ -49,6 +52,11 @@ const isObject = (obj) =>
49
52
  );
50
53
  const objIds = object.keys;
51
54
  const objFreeze = object.freeze;
55
+ const objNew = (entries = []) => object.fromEntries(entries);
56
+ const objToArray = (obj, cb) =>
57
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
58
+ const objMap = (obj, cb) =>
59
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
52
60
  const objSize = (obj) => size(objIds(obj));
53
61
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
54
62
 
@@ -58,6 +66,19 @@ const jsonStringWithMap = (obj) =>
58
66
  jsonString(obj, (_key, value) =>
59
67
  isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
60
68
  );
69
+ const jsonStringWithUndefined = (obj) =>
70
+ jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
71
+ const jsonParseWithUndefined = (str) =>
72
+ // JSON.parse reviver removes properties with undefined values
73
+ replaceUndefinedString(jsonParse(str));
74
+ const replaceUndefinedString = (obj) =>
75
+ obj === UNDEFINED
76
+ ? void 0
77
+ : isArray(obj)
78
+ ? arrayMap(obj, replaceUndefinedString)
79
+ : isObject(obj)
80
+ ? objMap(obj, replaceUndefinedString)
81
+ : obj;
61
82
 
62
83
  const collSize = (coll) => coll?.size ?? 0;
63
84
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -435,13 +456,17 @@ const SET_CHANGES = 's';
435
456
  const STORE_PATH = '/store';
436
457
  const PUT = 'PUT';
437
458
  const construct = (prefix, type, payload) =>
438
- prefix + type + (isString(payload) ? payload : jsonStringWithMap(payload));
459
+ prefix +
460
+ type +
461
+ (isString(payload) ? payload : jsonStringWithUndefined(payload));
439
462
  const deconstruct = (prefix, message, stringified) => {
440
463
  const prefixSize = size(prefix);
441
464
  return strStartsWith(message, prefix)
442
465
  ? [
443
466
  message[prefixSize],
444
- (stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
467
+ (stringified ? jsonParseWithUndefined : String)(
468
+ slice(message, prefixSize + 1),
469
+ ),
445
470
  ]
446
471
  : void 0;
447
472
  };
@@ -2,6 +2,7 @@ const getTypeOf = (thing) => typeof thing;
2
2
  const EMPTY_STRING = '';
3
3
  const STRING = getTypeOf(EMPTY_STRING);
4
4
  const MESSAGE = 'message';
5
+ const UNDEFINED = '\uFFFC';
5
6
  const strStartsWith = (str, prefix) => str.startsWith(prefix);
6
7
 
7
8
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
@@ -30,12 +31,14 @@ const tryCatch = async (action, then1, then2) => {
30
31
  };
31
32
 
32
33
  const arrayForEach = (array, cb) => array.forEach(cb);
34
+ const arrayMap = (array, cb) => array.map(cb);
33
35
  const arrayClear = (array, to) => array.splice(0, to);
34
36
  const arrayPush = (array, ...values) => array.push(...values);
35
37
  const arrayShift = (array) => array.shift();
36
38
 
37
39
  const object = Object;
38
40
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
41
+ const objEntries = object.entries;
39
42
  const isObject = (obj) =>
40
43
  !isNullish(obj) &&
41
44
  ifNotNullish(
@@ -49,6 +52,11 @@ const isObject = (obj) =>
49
52
  );
50
53
  const objIds = object.keys;
51
54
  const objFreeze = object.freeze;
55
+ const objNew = (entries = []) => object.fromEntries(entries);
56
+ const objToArray = (obj, cb) =>
57
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
58
+ const objMap = (obj, cb) =>
59
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
52
60
  const objSize = (obj) => size(objIds(obj));
53
61
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
54
62
 
@@ -58,6 +66,19 @@ const jsonStringWithMap = (obj) =>
58
66
  jsonString(obj, (_key, value) =>
59
67
  isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
60
68
  );
69
+ const jsonStringWithUndefined = (obj) =>
70
+ jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
71
+ const jsonParseWithUndefined = (str) =>
72
+ // JSON.parse reviver removes properties with undefined values
73
+ replaceUndefinedString(jsonParse(str));
74
+ const replaceUndefinedString = (obj) =>
75
+ obj === UNDEFINED
76
+ ? void 0
77
+ : isArray(obj)
78
+ ? arrayMap(obj, replaceUndefinedString)
79
+ : isObject(obj)
80
+ ? objMap(obj, replaceUndefinedString)
81
+ : obj;
61
82
 
62
83
  const collSize = (coll) => coll?.size ?? 0;
63
84
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -435,13 +456,17 @@ const SET_CHANGES = 's';
435
456
  const STORE_PATH = '/store';
436
457
  const PUT = 'PUT';
437
458
  const construct = (prefix, type, payload) =>
438
- prefix + type + (isString(payload) ? payload : jsonStringWithMap(payload));
459
+ prefix +
460
+ type +
461
+ (isString(payload) ? payload : jsonStringWithUndefined(payload));
439
462
  const deconstruct = (prefix, message, stringified) => {
440
463
  const prefixSize = size(prefix);
441
464
  return strStartsWith(message, prefix)
442
465
  ? [
443
466
  message[prefixSize],
444
- (stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
467
+ (stringified ? jsonParseWithUndefined : String)(
468
+ slice(message, prefixSize + 1),
469
+ ),
445
470
  ]
446
471
  : void 0;
447
472
  };
@@ -3,15 +3,19 @@ const EMPTY_STRING = '';
3
3
  const STRING = getTypeOf(EMPTY_STRING);
4
4
  const T = 't';
5
5
  const V = 'v';
6
+ const UNDEFINED = '\uFFFC';
6
7
  const strStartsWith = (str, prefix) => str.startsWith(prefix);
7
8
 
8
9
  const promise = Promise;
9
10
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
10
11
  predicate(value) ? otherwise?.() : then(value);
11
12
  const isInstanceOf = (thing, cls) => thing instanceof cls;
13
+ const isNullish = (thing) => thing == null;
12
14
  const isUndefined = (thing) => thing === void 0;
15
+ const ifNotNullish = getIfNotFunction(isNullish);
13
16
  const ifNotUndefined = getIfNotFunction(isUndefined);
14
17
  const isString = (thing) => getTypeOf(thing) == STRING;
18
+ const isArray = (thing) => Array.isArray(thing);
15
19
  const slice = (arrayOrString, start, end) => arrayOrString.slice(start, end);
16
20
  const size = (arrayOrString) => arrayOrString.length;
17
21
  const promiseAll = async (promises) => promise.all(promises);
@@ -23,11 +27,25 @@ const arrayPush = (array, ...values) => array.push(...values);
23
27
  const arrayUnshift = (array, ...values) => array.unshift(...values);
24
28
 
25
29
  const object = Object;
30
+ const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
26
31
  const objEntries = object.entries;
32
+ const isObject = (obj) =>
33
+ !isNullish(obj) &&
34
+ ifNotNullish(
35
+ getPrototypeOf(obj),
36
+ (objPrototype) =>
37
+ objPrototype == object.prototype ||
38
+ isNullish(getPrototypeOf(objPrototype)),
39
+
40
+ /* istanbul ignore next */
41
+ () => true,
42
+ );
27
43
  const objNew = (entries = []) => object.fromEntries(entries);
28
44
  const objHas = (obj, id) => id in obj;
29
45
  const objToArray = (obj, cb) =>
30
46
  arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
47
+ const objMap = (obj, cb) =>
48
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
31
49
  const objEnsure = (obj, id, getDefaultValue) => {
32
50
  if (!objHas(obj, id)) {
33
51
  obj[id] = getDefaultValue();
@@ -41,6 +59,19 @@ const jsonStringWithMap = (obj) =>
41
59
  jsonString(obj, (_key, value) =>
42
60
  isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
43
61
  );
62
+ const jsonStringWithUndefined = (obj) =>
63
+ jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
64
+ const jsonParseWithUndefined = (str) =>
65
+ // JSON.parse reviver removes properties with undefined values
66
+ replaceUndefinedString(jsonParse(str));
67
+ const replaceUndefinedString = (obj) =>
68
+ obj === UNDEFINED
69
+ ? void 0
70
+ : isArray(obj)
71
+ ? arrayMap(obj, replaceUndefinedString)
72
+ : isObject(obj)
73
+ ? objMap(obj, replaceUndefinedString)
74
+ : obj;
44
75
 
45
76
  const collForEach = (coll, cb) => coll?.forEach(cb);
46
77
 
@@ -51,13 +82,17 @@ const SET_CHANGES = 's';
51
82
  const STORE_PATH = '/store';
52
83
  const PUT = 'PUT';
53
84
  const construct = (prefix, type, payload) =>
54
- prefix + type + (isString(payload) ? payload : jsonStringWithMap(payload));
85
+ prefix +
86
+ type +
87
+ (isString(payload) ? payload : jsonStringWithUndefined(payload));
55
88
  const deconstruct = (prefix, message, stringified) => {
56
89
  const prefixSize = size(prefix);
57
90
  return strStartsWith(message, prefix)
58
91
  ? [
59
92
  message[prefixSize],
60
- (stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
93
+ (stringified ? jsonParseWithUndefined : String)(
94
+ slice(message, prefixSize + 1),
95
+ ),
61
96
  ]
62
97
  : void 0;
63
98
  };