@signaldb/core 1.3.0 → 1.3.1

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.
@@ -10,14 +10,38 @@ function createExternalIndex(field, index) {
10
10
  const keys = getMatchingKeys(field, selector);
11
11
  if (keys.include == null && keys.exclude == null)
12
12
  return { matched: false };
13
- const includedKeys = keys.include == null ? [...index.values()].reduce((memo, set) => [...memo, ...set], []) : keys.include.reduce((memo, key) => [...memo, ...index.get(key) || []], []);
14
- const itemPositions = keys.exclude == null ? includedKeys : keys.exclude.reduce((memo, key) => memo.filter((i) => {
15
- var _a;
16
- return !((_a = index.get(key)) == null ? void 0 : _a.has(i));
17
- }), includedKeys);
13
+ let includedPositions = [];
14
+ if (keys.include == null) {
15
+ for (const set of index.values()) {
16
+ for (const pos of set) {
17
+ includedPositions.push(pos);
18
+ }
19
+ }
20
+ } else {
21
+ for (const key of keys.include) {
22
+ const posSet = index.get(key);
23
+ if (posSet) {
24
+ for (const pos of posSet) {
25
+ includedPositions.push(pos);
26
+ }
27
+ }
28
+ }
29
+ }
30
+ if (keys.exclude != null) {
31
+ const excludeSet = /* @__PURE__ */ new Set();
32
+ for (const key of keys.exclude) {
33
+ const posSet = index.get(key);
34
+ if (posSet) {
35
+ for (const pos of posSet) {
36
+ excludeSet.add(pos);
37
+ }
38
+ }
39
+ }
40
+ includedPositions = includedPositions.filter((pos) => !excludeSet.has(pos));
41
+ }
18
42
  return {
19
43
  matched: true,
20
- positions: itemPositions,
44
+ positions: includedPositions,
21
45
  fields: [field]
22
46
  };
23
47
  },
package/dist/index13.mjs CHANGED
@@ -8,14 +8,38 @@ function createExternalIndex(field, index) {
8
8
  const keys = getMatchingKeys(field, selector);
9
9
  if (keys.include == null && keys.exclude == null)
10
10
  return { matched: false };
11
- const includedKeys = keys.include == null ? [...index.values()].reduce((memo, set) => [...memo, ...set], []) : keys.include.reduce((memo, key) => [...memo, ...index.get(key) || []], []);
12
- const itemPositions = keys.exclude == null ? includedKeys : keys.exclude.reduce((memo, key) => memo.filter((i) => {
13
- var _a;
14
- return !((_a = index.get(key)) == null ? void 0 : _a.has(i));
15
- }), includedKeys);
11
+ let includedPositions = [];
12
+ if (keys.include == null) {
13
+ for (const set of index.values()) {
14
+ for (const pos of set) {
15
+ includedPositions.push(pos);
16
+ }
17
+ }
18
+ } else {
19
+ for (const key of keys.include) {
20
+ const posSet = index.get(key);
21
+ if (posSet) {
22
+ for (const pos of posSet) {
23
+ includedPositions.push(pos);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ if (keys.exclude != null) {
29
+ const excludeSet = /* @__PURE__ */ new Set();
30
+ for (const key of keys.exclude) {
31
+ const posSet = index.get(key);
32
+ if (posSet) {
33
+ for (const pos of posSet) {
34
+ excludeSet.add(pos);
35
+ }
36
+ }
37
+ }
38
+ includedPositions = includedPositions.filter((pos) => !excludeSet.has(pos));
39
+ }
16
40
  return {
17
41
  matched: true,
18
- positions: itemPositions,
42
+ positions: includedPositions,
19
43
  fields: [field]
20
44
  };
21
45
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaldb/core",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && vite build"