@signaldb/core 1.2.4 → 1.3.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.
- package/dist/.vite/manifest.json +28 -47
- package/dist/index.cjs.js +12 -18
- package/dist/index.cjs10.js +6 -27
- package/dist/index.cjs11.js +3 -6
- package/dist/index.cjs12.js +136 -3
- package/dist/index.cjs13.js +40 -134
- package/dist/index.cjs14.js +5 -38
- package/dist/index.cjs15.js +42 -2
- package/dist/index.cjs16.js +11 -5
- package/dist/index.cjs17.js +17 -40
- package/dist/index.cjs18.js +262 -11
- package/dist/index.cjs19.js +66 -16
- package/dist/index.cjs2.js +688 -96
- package/dist/index.cjs20.js +71 -247
- package/dist/index.cjs21.js +8 -68
- package/dist/index.cjs22.js +22 -83
- package/dist/index.cjs23.js +144 -8
- package/dist/index.cjs24.js +5 -25
- package/dist/index.cjs25.js +16 -144
- package/dist/index.cjs26.js +27 -5
- package/dist/index.cjs27.js +39 -15
- package/dist/index.cjs28.js +25 -24
- package/dist/index.cjs29.js +7 -40
- package/dist/index.cjs3.js +139 -664
- package/dist/index.cjs4.js +62 -166
- package/dist/index.cjs5.js +3 -67
- package/dist/index.cjs6.js +2 -2
- package/dist/index.cjs7.js +2 -2
- package/dist/index.cjs8.js +2 -2
- package/dist/index.cjs9.js +27 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +12 -18
- package/dist/index10.mjs +6 -27
- package/dist/index11.mjs +3 -6
- package/dist/index12.mjs +136 -3
- package/dist/index13.mjs +39 -134
- package/dist/index14.mjs +5 -37
- package/dist/index15.mjs +41 -2
- package/dist/index16.mjs +11 -5
- package/dist/index17.mjs +17 -39
- package/dist/index18.mjs +261 -11
- package/dist/index19.mjs +65 -16
- package/dist/index2.mjs +688 -94
- package/dist/index20.mjs +71 -247
- package/dist/index21.mjs +8 -67
- package/dist/index22.mjs +22 -82
- package/dist/index23.mjs +144 -8
- package/dist/index24.mjs +5 -25
- package/dist/index25.mjs +16 -144
- package/dist/index26.mjs +27 -5
- package/dist/index27.mjs +39 -15
- package/dist/index28.mjs +25 -24
- package/dist/index29.mjs +7 -40
- package/dist/index3.mjs +139 -664
- package/dist/index4.mjs +61 -166
- package/dist/index5.mjs +3 -66
- package/dist/index6.mjs +2 -2
- package/dist/index7.mjs +2 -2
- package/dist/index8.mjs +2 -2
- package/dist/index9.mjs +27 -3
- package/dist/utils/getMatchingKeys.d.ts +11 -6
- package/package.json +1 -1
- package/dist/devtools.d.ts +0 -4
- package/dist/index.cjs30.js +0 -29
- package/dist/index.cjs31.js +0 -9
- package/dist/index30.mjs +0 -30
- package/dist/index31.mjs +0 -10
package/dist/index23.mjs
CHANGED
|
@@ -1,11 +1,147 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import isEqual from "./index9.mjs";
|
|
5
|
+
import uniqueBy from "./index29.mjs";
|
|
6
|
+
class Observer {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new instance of the `Observer` class.
|
|
9
|
+
* Sets up event bindings and initializes the callbacks for tracking changes in a collection.
|
|
10
|
+
* @param bindEvents - A function to bind external events to the observer. Must return a cleanup function to unbind those events.
|
|
11
|
+
*/
|
|
12
|
+
constructor(bindEvents) {
|
|
13
|
+
__publicField(this, "previousItems", []);
|
|
14
|
+
__publicField(this, "callbacks");
|
|
15
|
+
__publicField(this, "unbindEvents");
|
|
16
|
+
this.callbacks = {
|
|
17
|
+
added: [],
|
|
18
|
+
addedBefore: [],
|
|
19
|
+
changed: [],
|
|
20
|
+
changedField: [],
|
|
21
|
+
movedBefore: [],
|
|
22
|
+
removed: []
|
|
23
|
+
};
|
|
24
|
+
this.unbindEvents = bindEvents();
|
|
25
|
+
}
|
|
26
|
+
call(event, ...args) {
|
|
27
|
+
this.callbacks[event].forEach(({ callback, options }) => {
|
|
28
|
+
if (!options.skipInitial || !options.isInitial) {
|
|
29
|
+
callback(...args);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
hasCallbacks(events) {
|
|
34
|
+
return events.some((event) => this.callbacks[event].length > 0);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determines if the observer has no active callbacks registered for any events.
|
|
38
|
+
* @returns A boolean indicating whether the observer is empty (i.e., no callbacks are registered).
|
|
39
|
+
*/
|
|
40
|
+
isEmpty() {
|
|
41
|
+
return !this.hasCallbacks([
|
|
42
|
+
"added",
|
|
43
|
+
"addedBefore",
|
|
44
|
+
"changed",
|
|
45
|
+
"changedField",
|
|
46
|
+
"movedBefore",
|
|
47
|
+
"removed"
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Compares the previous state of items with the new state and triggers the appropriate callbacks
|
|
52
|
+
* for events such as added, removed, changed, or moved items.
|
|
53
|
+
* @param newItems - The new list of items to compare against the previous state.
|
|
54
|
+
*/
|
|
55
|
+
runChecks(newItems) {
|
|
56
|
+
const oldItemsMap = new Map(this.previousItems.map((item, index) => [
|
|
57
|
+
item.id,
|
|
58
|
+
{ item, index, beforeItem: this.previousItems[index + 1] || null }
|
|
59
|
+
]));
|
|
60
|
+
const newItemsMap = new Map(newItems.map((item, index) => [
|
|
61
|
+
item.id,
|
|
62
|
+
{ item, index, beforeItem: newItems[index + 1] || null }
|
|
63
|
+
]));
|
|
64
|
+
if (this.hasCallbacks(["changed", "changedField", "movedBefore", "removed"])) {
|
|
65
|
+
oldItemsMap.forEach(({ item: oldItem, index, beforeItem: oldBeforeItem }) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const newItem = newItemsMap.get(oldItem.id);
|
|
68
|
+
if (newItem) {
|
|
69
|
+
if (this.hasCallbacks(["changed", "changedField"]) && !isEqual(newItem.item, oldItem)) {
|
|
70
|
+
this.call("changed", newItem.item);
|
|
71
|
+
if (this.hasCallbacks(["changedField"])) {
|
|
72
|
+
const keys = uniqueBy([
|
|
73
|
+
...Object.keys(newItem.item),
|
|
74
|
+
...Object.keys(oldItem)
|
|
75
|
+
], (value) => value);
|
|
76
|
+
keys.forEach((key) => {
|
|
77
|
+
if (isEqual(newItem.item[key], oldItem[key]))
|
|
78
|
+
return;
|
|
79
|
+
this.call("changedField", newItem.item, key, oldItem[key], newItem.item[key]);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (newItem.index !== index && ((_a = newItem.beforeItem) == null ? void 0 : _a.id) !== (oldBeforeItem == null ? void 0 : oldBeforeItem.id)) {
|
|
84
|
+
this.call("movedBefore", newItem.item, newItem.beforeItem);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
this.call("removed", oldItem);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (this.hasCallbacks(["added", "addedBefore"])) {
|
|
92
|
+
newItems.forEach((newItem, index) => {
|
|
93
|
+
const oldItem = oldItemsMap.get(newItem.id);
|
|
94
|
+
if (oldItem)
|
|
95
|
+
return;
|
|
96
|
+
this.call("added", newItem);
|
|
97
|
+
this.call("addedBefore", newItem, newItems[index + 1] || null);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
this.previousItems = newItems;
|
|
101
|
+
Object.keys(this.callbacks).forEach((key) => {
|
|
102
|
+
const event = key;
|
|
103
|
+
const callbacks = this.callbacks[event];
|
|
104
|
+
this.callbacks[event] = callbacks.map((callback) => ({
|
|
105
|
+
...callback,
|
|
106
|
+
options: {
|
|
107
|
+
...callback.options,
|
|
108
|
+
isInitial: false
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Stops the observer by unbinding all events and cleaning up resources.
|
|
115
|
+
*/
|
|
116
|
+
stop() {
|
|
117
|
+
this.unbindEvents();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Registers callbacks for specific events to observe changes in the collection.
|
|
121
|
+
* @param callbacks - An object containing the callbacks for various events (e.g., 'added', 'removed').
|
|
122
|
+
* @param skipInitial - A boolean indicating whether to skip invoking the callbacks for the initial state of the collection.
|
|
123
|
+
*/
|
|
124
|
+
addCallbacks(callbacks, skipInitial = false) {
|
|
125
|
+
Object.keys(callbacks).forEach((key) => {
|
|
126
|
+
const typedKey = key;
|
|
127
|
+
this.callbacks[typedKey].push({
|
|
128
|
+
callback: callbacks[typedKey],
|
|
129
|
+
options: { skipInitial, isInitial: true }
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Removes the specified callbacks for specific events, unregistering them from the observer.
|
|
135
|
+
* @param callbacks - An object containing the callbacks to be removed for various events.
|
|
136
|
+
*/
|
|
137
|
+
removeCallbacks(callbacks) {
|
|
138
|
+
Object.keys(callbacks).forEach((key) => {
|
|
139
|
+
const typedKey = key;
|
|
140
|
+
const index = this.callbacks[typedKey].findIndex(({ callback }) => callback === callbacks[typedKey]);
|
|
141
|
+
this.callbacks[typedKey].splice(index, 1);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
8
144
|
}
|
|
9
145
|
export {
|
|
10
|
-
|
|
146
|
+
Observer as default
|
|
11
147
|
};
|
package/dist/index24.mjs
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (allFieldsDeactivated) {
|
|
6
|
-
const result2 = { ...item };
|
|
7
|
-
Object.keys(fields).forEach((key) => {
|
|
8
|
-
const fieldValue = get(item, key);
|
|
9
|
-
if (fieldValue === void 0)
|
|
10
|
-
return;
|
|
11
|
-
set(result2, key, void 0, true);
|
|
12
|
-
});
|
|
13
|
-
return result2;
|
|
14
|
-
}
|
|
15
|
-
const result = {};
|
|
16
|
-
Object.entries(fields).forEach(([key, value]) => {
|
|
17
|
-
const fieldValue = get(item, key);
|
|
18
|
-
if (fieldValue === void 0)
|
|
19
|
-
return;
|
|
20
|
-
if (fieldValue == null && value !== 1)
|
|
21
|
-
return;
|
|
22
|
-
set(result, key, value === 1 ? fieldValue : void 0);
|
|
23
|
-
});
|
|
24
|
-
return result;
|
|
1
|
+
function intersection(...arrays) {
|
|
2
|
+
if (arrays.length === 0)
|
|
3
|
+
return [];
|
|
4
|
+
return [...new Set(arrays.reduce((a, b) => a.filter((c) => b.includes(c))))];
|
|
25
5
|
}
|
|
26
6
|
export {
|
|
27
|
-
|
|
7
|
+
intersection as default
|
|
28
8
|
};
|
package/dist/index25.mjs
CHANGED
|
@@ -1,147 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.callbacks = {
|
|
17
|
-
added: [],
|
|
18
|
-
addedBefore: [],
|
|
19
|
-
changed: [],
|
|
20
|
-
changedField: [],
|
|
21
|
-
movedBefore: [],
|
|
22
|
-
removed: []
|
|
23
|
-
};
|
|
24
|
-
this.unbindEvents = bindEvents();
|
|
25
|
-
}
|
|
26
|
-
call(event, ...args) {
|
|
27
|
-
this.callbacks[event].forEach(({ callback, options }) => {
|
|
28
|
-
if (!options.skipInitial || !options.isInitial) {
|
|
29
|
-
callback(...args);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
hasCallbacks(events) {
|
|
34
|
-
return events.some((event) => this.callbacks[event].length > 0);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Determines if the observer has no active callbacks registered for any events.
|
|
38
|
-
* @returns A boolean indicating whether the observer is empty (i.e., no callbacks are registered).
|
|
39
|
-
*/
|
|
40
|
-
isEmpty() {
|
|
41
|
-
return !this.hasCallbacks([
|
|
42
|
-
"added",
|
|
43
|
-
"addedBefore",
|
|
44
|
-
"changed",
|
|
45
|
-
"changedField",
|
|
46
|
-
"movedBefore",
|
|
47
|
-
"removed"
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Compares the previous state of items with the new state and triggers the appropriate callbacks
|
|
52
|
-
* for events such as added, removed, changed, or moved items.
|
|
53
|
-
* @param newItems - The new list of items to compare against the previous state.
|
|
54
|
-
*/
|
|
55
|
-
runChecks(newItems) {
|
|
56
|
-
const oldItemsMap = new Map(this.previousItems.map((item, index) => [
|
|
57
|
-
item.id,
|
|
58
|
-
{ item, index, beforeItem: this.previousItems[index + 1] || null }
|
|
59
|
-
]));
|
|
60
|
-
const newItemsMap = new Map(newItems.map((item, index) => [
|
|
61
|
-
item.id,
|
|
62
|
-
{ item, index, beforeItem: newItems[index + 1] || null }
|
|
63
|
-
]));
|
|
64
|
-
if (this.hasCallbacks(["changed", "changedField", "movedBefore", "removed"])) {
|
|
65
|
-
oldItemsMap.forEach(({ item: oldItem, index, beforeItem: oldBeforeItem }) => {
|
|
66
|
-
var _a;
|
|
67
|
-
const newItem = newItemsMap.get(oldItem.id);
|
|
68
|
-
if (newItem) {
|
|
69
|
-
if (this.hasCallbacks(["changed", "changedField"]) && !isEqual(newItem.item, oldItem)) {
|
|
70
|
-
this.call("changed", newItem.item);
|
|
71
|
-
if (this.hasCallbacks(["changedField"])) {
|
|
72
|
-
const keys = uniqueBy([
|
|
73
|
-
...Object.keys(newItem.item),
|
|
74
|
-
...Object.keys(oldItem)
|
|
75
|
-
], (value) => value);
|
|
76
|
-
keys.forEach((key) => {
|
|
77
|
-
if (isEqual(newItem.item[key], oldItem[key]))
|
|
78
|
-
return;
|
|
79
|
-
this.call("changedField", newItem.item, key, oldItem[key], newItem.item[key]);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (newItem.index !== index && ((_a = newItem.beforeItem) == null ? void 0 : _a.id) !== (oldBeforeItem == null ? void 0 : oldBeforeItem.id)) {
|
|
84
|
-
this.call("movedBefore", newItem.item, newItem.beforeItem);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
this.call("removed", oldItem);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (this.hasCallbacks(["added", "addedBefore"])) {
|
|
92
|
-
newItems.forEach((newItem, index) => {
|
|
93
|
-
const oldItem = oldItemsMap.get(newItem.id);
|
|
94
|
-
if (oldItem)
|
|
95
|
-
return;
|
|
96
|
-
this.call("added", newItem);
|
|
97
|
-
this.call("addedBefore", newItem, newItems[index + 1] || null);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
this.previousItems = newItems;
|
|
101
|
-
Object.keys(this.callbacks).forEach((key) => {
|
|
102
|
-
const event = key;
|
|
103
|
-
const callbacks = this.callbacks[event];
|
|
104
|
-
this.callbacks[event] = callbacks.map((callback) => ({
|
|
105
|
-
...callback,
|
|
106
|
-
options: {
|
|
107
|
-
...callback.options,
|
|
108
|
-
isInitial: false
|
|
109
|
-
}
|
|
110
|
-
}));
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Stops the observer by unbinding all events and cleaning up resources.
|
|
115
|
-
*/
|
|
116
|
-
stop() {
|
|
117
|
-
this.unbindEvents();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Registers callbacks for specific events to observe changes in the collection.
|
|
121
|
-
* @param callbacks - An object containing the callbacks for various events (e.g., 'added', 'removed').
|
|
122
|
-
* @param skipInitial - A boolean indicating whether to skip invoking the callbacks for the initial state of the collection.
|
|
123
|
-
*/
|
|
124
|
-
addCallbacks(callbacks, skipInitial = false) {
|
|
125
|
-
Object.keys(callbacks).forEach((key) => {
|
|
126
|
-
const typedKey = key;
|
|
127
|
-
this.callbacks[typedKey].push({
|
|
128
|
-
callback: callbacks[typedKey],
|
|
129
|
-
options: { skipInitial, isInitial: true }
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Removes the specified callbacks for specific events, unregistering them from the observer.
|
|
135
|
-
* @param callbacks - An object containing the callbacks to be removed for various events.
|
|
136
|
-
*/
|
|
137
|
-
removeCallbacks(callbacks) {
|
|
138
|
-
Object.keys(callbacks).forEach((key) => {
|
|
139
|
-
const typedKey = key;
|
|
140
|
-
const index = this.callbacks[typedKey].findIndex(({ callback }) => callback === callbacks[typedKey]);
|
|
141
|
-
this.callbacks[typedKey].splice(index, 1);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
1
|
+
function get(value, path) {
|
|
2
|
+
const segments = path.split(/[.[\]]/g);
|
|
3
|
+
if (segments[0] === "")
|
|
4
|
+
segments.shift();
|
|
5
|
+
if (segments.at(-1) === "")
|
|
6
|
+
segments.pop();
|
|
7
|
+
let current = value;
|
|
8
|
+
for (const key of segments) {
|
|
9
|
+
if (current == null || key.trim() === "")
|
|
10
|
+
return;
|
|
11
|
+
current = current[key];
|
|
12
|
+
}
|
|
13
|
+
if (current === void 0)
|
|
14
|
+
return;
|
|
15
|
+
return current;
|
|
144
16
|
}
|
|
145
17
|
export {
|
|
146
|
-
|
|
18
|
+
get as default
|
|
147
19
|
};
|
package/dist/index26.mjs
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import isFieldExpression from "./index27.mjs";
|
|
2
|
+
import serializeValue from "./index16.mjs";
|
|
3
|
+
function getMatchingKeys(field, selector) {
|
|
4
|
+
const result = { include: null, exclude: null };
|
|
5
|
+
const fieldSelector = selector[field];
|
|
6
|
+
if (fieldSelector instanceof RegExp)
|
|
7
|
+
return result;
|
|
8
|
+
if (fieldSelector == null)
|
|
9
|
+
return result;
|
|
10
|
+
if (isFieldExpression(fieldSelector)) {
|
|
11
|
+
if (fieldSelector.$ne != null) {
|
|
12
|
+
result.exclude = [serializeValue(fieldSelector.$ne)];
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
|
|
16
|
+
result.include = fieldSelector.$in.map(serializeValue);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
|
|
20
|
+
result.exclude = fieldSelector.$nin.map(serializeValue);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
return { include: null, exclude: null };
|
|
24
|
+
}
|
|
25
|
+
result.include = [serializeValue(fieldSelector)];
|
|
26
|
+
return result;
|
|
5
27
|
}
|
|
6
28
|
export {
|
|
7
|
-
|
|
29
|
+
getMatchingKeys as default
|
|
8
30
|
};
|
package/dist/index27.mjs
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
const expressionKeys = /* @__PURE__ */ new Set([
|
|
2
|
+
"$eq",
|
|
3
|
+
"$gt",
|
|
4
|
+
"$gte",
|
|
5
|
+
"$lt",
|
|
6
|
+
"$lte",
|
|
7
|
+
"$in",
|
|
8
|
+
"$nin",
|
|
9
|
+
"$ne",
|
|
10
|
+
"$exists",
|
|
11
|
+
"$not",
|
|
12
|
+
"$expr",
|
|
13
|
+
"$jsonSchema",
|
|
14
|
+
"$mod",
|
|
15
|
+
"$regex",
|
|
16
|
+
"$options",
|
|
17
|
+
"$text",
|
|
18
|
+
"$where",
|
|
19
|
+
"$all",
|
|
20
|
+
"$elemMatch",
|
|
21
|
+
"$size",
|
|
22
|
+
"$bitsAllClear",
|
|
23
|
+
"$bitsAllSet",
|
|
24
|
+
"$bitsAnyClear",
|
|
25
|
+
"$bitsAnySet"
|
|
26
|
+
]);
|
|
27
|
+
function isFieldExpression(expression) {
|
|
28
|
+
if (typeof expression !== "object" || expression == null) {
|
|
29
|
+
return false;
|
|
12
30
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
const keys = Object.keys(expression);
|
|
32
|
+
if (keys.length === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
|
|
36
|
+
if (hasInvalidKeys)
|
|
37
|
+
return false;
|
|
38
|
+
const hasValidKeys = keys.every((key) => expressionKeys.has(key));
|
|
39
|
+
return hasValidKeys;
|
|
16
40
|
}
|
|
17
41
|
export {
|
|
18
|
-
|
|
42
|
+
isFieldExpression as default
|
|
19
43
|
};
|
package/dist/index28.mjs
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
delete optimizedSelector[field].$in;
|
|
16
|
-
if (Object.keys(optimizedSelector[field]).length === 0) {
|
|
17
|
-
delete optimizedSelector[field];
|
|
18
|
-
}
|
|
19
|
-
return fieldSelector.$in.map(serializeValue);
|
|
1
|
+
function set(object, path, value, deleteIfUndefined = false) {
|
|
2
|
+
if (object == null)
|
|
3
|
+
return object;
|
|
4
|
+
const segments = path.split(/[.[\]]/g);
|
|
5
|
+
if (segments[0] === "")
|
|
6
|
+
segments.shift();
|
|
7
|
+
if (segments.at(-1) === "")
|
|
8
|
+
segments.pop();
|
|
9
|
+
const apply = (node) => {
|
|
10
|
+
if (segments.length > 1) {
|
|
11
|
+
const key = segments.shift();
|
|
12
|
+
const nextIsNumber = !Number.isNaN(Number.parseInt(segments[0], 10));
|
|
13
|
+
if (node[key] === void 0) {
|
|
14
|
+
node[key] = nextIsNumber ? [] : {};
|
|
20
15
|
}
|
|
21
|
-
|
|
16
|
+
apply(node[key]);
|
|
17
|
+
} else {
|
|
18
|
+
if (deleteIfUndefined && value === void 0) {
|
|
19
|
+
delete node[segments[0]];
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
node[segments[0]] = value;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
24
|
+
};
|
|
25
|
+
apply(object);
|
|
26
|
+
return object;
|
|
26
27
|
}
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
+
set as default
|
|
29
30
|
};
|
package/dist/index29.mjs
CHANGED
|
@@ -1,43 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"$in",
|
|
8
|
-
"$nin",
|
|
9
|
-
"$ne",
|
|
10
|
-
"$exists",
|
|
11
|
-
"$not",
|
|
12
|
-
"$expr",
|
|
13
|
-
"$jsonSchema",
|
|
14
|
-
"$mod",
|
|
15
|
-
"$regex",
|
|
16
|
-
"$options",
|
|
17
|
-
"$text",
|
|
18
|
-
"$where",
|
|
19
|
-
"$all",
|
|
20
|
-
"$elemMatch",
|
|
21
|
-
"$size",
|
|
22
|
-
"$bitsAllClear",
|
|
23
|
-
"$bitsAllSet",
|
|
24
|
-
"$bitsAnyClear",
|
|
25
|
-
"$bitsAnySet"
|
|
26
|
-
]);
|
|
27
|
-
function isFieldExpression(expression) {
|
|
28
|
-
if (typeof expression !== "object" || expression == null) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const keys = Object.keys(expression);
|
|
32
|
-
if (keys.length === 0) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
|
|
36
|
-
if (hasInvalidKeys)
|
|
37
|
-
return false;
|
|
38
|
-
const hasValidKeys = keys.every((key) => expressionKeys.has(key));
|
|
39
|
-
return hasValidKeys;
|
|
1
|
+
function uniqueBy(array, fn) {
|
|
2
|
+
const set = /* @__PURE__ */ new Set();
|
|
3
|
+
return array.filter((element) => {
|
|
4
|
+
const value = typeof fn === "function" ? fn(element) : element[fn];
|
|
5
|
+
return !set.has(value) && set.add(value);
|
|
6
|
+
});
|
|
40
7
|
}
|
|
41
8
|
export {
|
|
42
|
-
|
|
9
|
+
uniqueBy as default
|
|
43
10
|
};
|