@signaldb/core 1.5.3 → 1.6.0

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 (64) hide show
  1. package/dist/.vite/manifest.json +28 -27
  2. package/dist/Collection/createIndex.d.ts +1 -1
  3. package/dist/Collection/index.d.ts +1 -0
  4. package/dist/index.cjs.js +14 -12
  5. package/dist/index.cjs10.js +27 -10
  6. package/dist/index.cjs11.js +10 -3
  7. package/dist/index.cjs12.js +3 -136
  8. package/dist/index.cjs13.js +131 -61
  9. package/dist/index.cjs14.js +72 -5
  10. package/dist/index.cjs15.js +8 -41
  11. package/dist/index.cjs16.js +25 -11
  12. package/dist/index.cjs17.js +143 -23
  13. package/dist/index.cjs18.js +5 -262
  14. package/dist/index.cjs19.js +36 -63
  15. package/dist/index.cjs2.js +210 -731
  16. package/dist/index.cjs20.js +13 -85
  17. package/dist/index.cjs21.js +24 -8
  18. package/dist/index.cjs22.js +67 -24
  19. package/dist/index.cjs23.js +72 -131
  20. package/dist/index.cjs24.js +16 -5
  21. package/dist/index.cjs25.js +22 -11
  22. package/dist/index.cjs26.js +7 -27
  23. package/dist/index.cjs27.js +5 -27
  24. package/dist/index.cjs28.js +27 -7
  25. package/dist/index.cjs3.js +757 -136
  26. package/dist/index.cjs4.js +165 -62
  27. package/dist/index.cjs5.js +67 -3
  28. package/dist/index.cjs6.js +2 -2
  29. package/dist/index.cjs7.js +2 -2
  30. package/dist/index.cjs8.js +2 -2
  31. package/dist/index.cjs9.js +3 -27
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.mjs +14 -12
  34. package/dist/index10.mjs +27 -10
  35. package/dist/index11.mjs +10 -3
  36. package/dist/index12.mjs +3 -136
  37. package/dist/index13.mjs +131 -60
  38. package/dist/index14.mjs +71 -5
  39. package/dist/index15.mjs +8 -40
  40. package/dist/index16.mjs +25 -11
  41. package/dist/index17.mjs +143 -23
  42. package/dist/index18.mjs +5 -261
  43. package/dist/index19.mjs +36 -63
  44. package/dist/index2.mjs +210 -732
  45. package/dist/index20.mjs +13 -84
  46. package/dist/index21.mjs +24 -8
  47. package/dist/index22.mjs +66 -24
  48. package/dist/index23.mjs +71 -131
  49. package/dist/index24.mjs +16 -5
  50. package/dist/index25.mjs +22 -11
  51. package/dist/index26.mjs +7 -27
  52. package/dist/index27.mjs +5 -27
  53. package/dist/index28.mjs +27 -7
  54. package/dist/index3.mjs +757 -136
  55. package/dist/index4.mjs +165 -61
  56. package/dist/index5.mjs +66 -3
  57. package/dist/index6.mjs +2 -2
  58. package/dist/index7.mjs +2 -2
  59. package/dist/index8.mjs +2 -2
  60. package/dist/index9.mjs +3 -27
  61. package/dist/types/IndexProvider.d.ts +2 -0
  62. package/dist/utils/getMatchingKeys.d.ts +2 -2
  63. package/dist/utils/serializeValue.d.ts +1 -1
  64. package/package.json +1 -1
@@ -1,70 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const intersection = require("./index.cjs24.js");
4
- function getMergedIndexInfo(indexProviders, selector) {
5
- return indexProviders.reduce((memo, indexProvider) => {
6
- const info = indexProvider.query(selector);
7
- if (!info.matched)
8
- return memo;
9
- const optimizedSelector = Object.fromEntries(Object.entries(memo.optimizedSelector).filter(([key]) => !info.fields.includes(key)));
10
- return {
11
- matched: true,
12
- positions: [...new Set(memo.matched ? intersection(memo.positions, info.positions) : info.positions)],
13
- optimizedSelector
14
- };
15
- }, {
16
- matched: false,
17
- positions: [],
18
- optimizedSelector: { ...selector }
19
- });
20
- }
21
- function getIndexInfo(indexProviders, selector) {
22
- if (selector == null || Object.keys(selector).length <= 0) {
23
- return { matched: false, positions: [], optimizedSelector: selector };
3
+ function clone(value) {
4
+ if (typeof value === "function")
5
+ throw new Error("Cloning functions is not supported");
6
+ if (value === null || typeof value !== "object")
7
+ return value;
8
+ if (value instanceof Date)
9
+ return new Date(value);
10
+ if (Array.isArray(value))
11
+ return value.map((item) => clone(item));
12
+ if (value instanceof Map) {
13
+ const result2 = /* @__PURE__ */ new Map();
14
+ value.forEach((currentValue, key) => {
15
+ result2.set(key, clone(currentValue));
16
+ });
17
+ return result2;
24
18
  }
25
- const { $and, $or, ...rest } = selector;
26
- const flatInfo = getMergedIndexInfo(indexProviders, rest);
27
- let { matched, positions } = flatInfo;
28
- const newSelector = flatInfo.optimizedSelector;
29
- if (Array.isArray($and)) {
30
- const $andNew = [];
31
- for (const sel of $and) {
32
- const { matched: selMatched, positions: selPositions, optimizedSelector } = getIndexInfo(indexProviders, sel);
33
- if (selMatched) {
34
- positions = matched ? intersection(positions, selPositions) : selPositions;
35
- matched = true;
36
- if (Object.keys(optimizedSelector).length > 0) {
37
- $andNew.push(optimizedSelector);
38
- }
39
- } else {
40
- $andNew.push(sel);
41
- }
42
- }
43
- if ($andNew.length > 0)
44
- newSelector.$and = $andNew;
19
+ if (value instanceof Set) {
20
+ const result2 = /* @__PURE__ */ new Set();
21
+ value.forEach((currentValue) => {
22
+ result2.add(clone(currentValue));
23
+ });
24
+ return result2;
45
25
  }
46
- if (Array.isArray($or)) {
47
- const $orNew = [];
48
- for (const sel of $or) {
49
- const { matched: selMatched, positions: selPositions, optimizedSelector } = getIndexInfo(indexProviders, sel);
50
- if (selMatched) {
51
- positions = [.../* @__PURE__ */ new Set([...positions, ...selPositions])];
52
- matched = true;
53
- if (Object.keys(optimizedSelector).length > 0) {
54
- $orNew.push(optimizedSelector);
55
- }
56
- } else {
57
- $orNew.push(sel);
58
- }
26
+ if (value instanceof RegExp)
27
+ return new RegExp(value);
28
+ const result = {};
29
+ for (const key in value) {
30
+ if (Object.hasOwnProperty.call(value, key)) {
31
+ result[key] = clone(value[key]);
59
32
  }
60
- if ($orNew.length > 0)
61
- newSelector.$or = $orNew;
62
33
  }
63
- return {
64
- matched,
65
- positions: positions || [],
66
- optimizedSelector: newSelector
67
- };
34
+ return result;
35
+ }
36
+ function deepClone(object) {
37
+ if (typeof structuredClone === "function")
38
+ return structuredClone(object);
39
+ /* istanbul ignore next -- @preserve */
40
+ return clone(object);
68
41
  }
69
- exports.default = getIndexInfo;
70
- exports.getMergedIndexInfo = getMergedIndexInfo;
42
+ exports.clone = clone;
43
+ exports.default = deepClone;