datafolder 1.0.2 → 1.0.4

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 (84) hide show
  1. package/README.md +34 -31
  2. package/index.js +1 -3
  3. package/package.json +5 -3
  4. package/sample.js +37 -37
  5. package/scripts/airbnb.js +10 -11
  6. package/scripts/airbnb2.js +10 -11
  7. package/scripts/airbnb2_queries.js +20 -22
  8. package/scripts/airbnb_queries.js +23 -22
  9. package/scripts/downloadFile.js +29 -31
  10. package/scripts/express.js +7 -5
  11. package/scripts/fastify.js +12 -11
  12. package/scripts/flights.js +9 -9
  13. package/scripts/flights2.js +9 -9
  14. package/scripts/flights2_queries.js +107 -105
  15. package/scripts/flights_queries.js +113 -109
  16. package/src/QyAcl.js +153 -152
  17. package/src/QyAclSaver.js +16 -10
  18. package/src/QyAclSaver_Worker.js +21 -15
  19. package/src/QyAclWriter.js +23 -13
  20. package/src/QyBatch.js +298 -263
  21. package/src/QyBinWriter.js +49 -37
  22. package/src/QyCD.js +13 -14
  23. package/src/QyCache.js +177 -140
  24. package/src/QyCompressor.js +71 -45
  25. package/src/QyCompressor_Worker.js +17 -9
  26. package/src/QyDB.js +67 -12
  27. package/src/QyDefaultOptions.js +13 -10
  28. package/src/QyDir.js +89 -53
  29. package/src/QyFetch.js +27 -24
  30. package/src/QyFile.js +89 -77
  31. package/src/QyFileContentUtils.js +129 -132
  32. package/src/QyFileLogger.js +63 -41
  33. package/src/QyIndex.js +175 -197
  34. package/src/QyIndexPropTree.js +25 -25
  35. package/src/QyIntersectNode.js +34 -31
  36. package/src/QyItem.js +54 -52
  37. package/src/QyJsonSaver.js +12 -6
  38. package/src/QyKVData.js +279 -245
  39. package/src/QyKVDataCleaner.js +12 -6
  40. package/src/QyKVDataCleaner_Worker.js +77 -59
  41. package/src/QyKVDataLoader.js +67 -46
  42. package/src/QyKVDataSaver.js +15 -9
  43. package/src/QyKVDataSaver_Worker.js +83 -60
  44. package/src/QyLogFileSaver.js +12 -6
  45. package/src/QyLogFileSaver_Worker.js +24 -14
  46. package/src/QyLogger.js +51 -40
  47. package/src/QyMessageWorker.js +43 -29
  48. package/src/QyMessager.js +74 -54
  49. package/src/QyMessager_Run.js +20 -7
  50. package/src/QyMod.js +15 -11
  51. package/src/QyOpRunner.js +58 -41
  52. package/src/QyQueue.js +35 -30
  53. package/src/QySaver.js +52 -29
  54. package/src/QySnapshotCompactor.js +15 -9
  55. package/src/QySnapshotCompactor_Worker.js +131 -110
  56. package/src/QySnapshotSaver.js +15 -9
  57. package/src/QySnapshotSaver_Worker.js +125 -110
  58. package/src/QySnapshots.js +264 -242
  59. package/src/QyStructure.js +35 -27
  60. package/src/QyTrigger.js +62 -55
  61. package/src/QyUnionNode.js +54 -56
  62. package/src/QyUtils.js +170 -158
  63. package/src/QyWorker.js +34 -20
  64. package/src/hackernews.js +63 -71
  65. package/src/rpc/getFileContent.js +7 -7
  66. package/src/rpc/getSubItems.js +12 -28
  67. package/src/rpc/queryFiles.js +2 -25
  68. package/src/simulate.js +85 -80
  69. package/src/simulate2.js +77 -78
  70. package/src/soc_pokec.js +44 -32
  71. package/static/datafolderui/QyStyledElement.js +12 -12
  72. package/static/datafolderui/QyUIFolderTree.js +20 -20
  73. package/static/datafolderui/QyUIUtils.js +8 -8
  74. package/static/datafolderui/explore-tree.js +31 -31
  75. package/static/datafolderui/folder-tree.js +2 -2
  76. package/static/datafolderui/hscrpt.js +9 -17
  77. package/static/datafolderui/json-view.js +3 -5
  78. package/static/datafolderui/kv-input.js +15 -15
  79. package/static/datafolderui/list-input.js +17 -17
  80. package/static/datafolderui/main-page.js +18 -18
  81. package/static/datafolderui/num-input.js +5 -5
  82. package/static/datafolderui/query-editor.js +6 -1
  83. package/static/datafolderui/querySelectorShadowRoot.js +15 -19
  84. package/static/datafolderui/resizable-input.js +18 -18
package/src/QyIndex.js CHANGED
@@ -1,237 +1,215 @@
1
- let {
2
- pathSplit,
3
- isSimpleType,
4
- isFunction,
5
- isString,
6
- isNotNullObj,
7
- SpecialOperators,
8
- getSuffix,
9
- fromSingleName,
10
- toSingleName
11
- } = require("./QyUtils.js"), getValByNamePath = require("./QyFileContentUtils.js").getValByNamePath, QyUnionNode = require("./QyUnionNode.js").QyUnionNode, QyIntersectNode = require("./QyIntersectNode.js").QyIntersectNode, isArray = Array.isArray, {
12
- $or,
13
- $and
14
- } = SpecialOperators, Empty_Union_Node = new QyUnionNode();
15
-
16
- function getIndexPropPaths(e) {
17
- if (null != e && !isString(e)) return _getIndexPropPaths_rec(e, e = {}, [], 0),
18
- Object.keys(e).map(e => fromSingleName(e));
1
+ import {
2
+ pathSplit as a,
3
+ isSimpleType as d,
4
+ isFunction as g,
5
+ isString as s,
6
+ isNotNullObj as c,
7
+ SpecialOperators as i,
8
+ getSuffix as p,
9
+ fromSingleName as r,
10
+ toSingleName as o
11
+ } from "./QyUtils.js";
12
+
13
+ import {
14
+ getValByNamePath as v
15
+ } from "./QyFileContentUtils.js";
16
+
17
+ import {
18
+ QyUnionNode as m
19
+ } from "./QyUnionNode.js";
20
+
21
+ import {
22
+ QyIntersectNode as y
23
+ } from "./QyIntersectNode.js";
24
+
25
+ let h = Array.isArray, {
26
+ $or: b,
27
+ $and: S
28
+ } = i, N = new m(), l = [];
29
+
30
+ function e(e) {
31
+ if (null != e && !s(e)) return function r(i, n, t, l) {
32
+ if (H(i)) 0 < t.length && (n[o(t)] = 1); else {
33
+ let e = i[b] || i[S];
34
+ if (null != e) if (h(e)) for (var f of e) r(f, n, t, l), t.length = l; else r(e, n, t, l),
35
+ t.length = l; else for (var u in i) t.push(u), r(i[u], n, t, l + 1),
36
+ t.length = l;
37
+ }
38
+ }(e, e = {}, [], 0), Object.keys(e).map(e => r(e));
19
39
  }
20
40
 
21
- function calDifferenceList(e, r, i, t, n, l) {
22
- t = getValByNamePath(t, r), n = getValByNamePath(n, r);
23
- if (t !== n) {
24
- var o, a, s, u, l = isArray(n) || isArray(getValByNamePath(l, r)), f = Object.fromEntries(_itemToPropValList(t, l).map(e => [ JSON.stringify(e), e ])), d = Object.fromEntries(_itemToPropValList(n, l).map(e => [ JSON.stringify(e), e ])), c = [], y = [];
25
- for (o in f) d[o] || (a = f[o], (a = e.searchSubdir(a)) && (a = a.getFile(i)) && y.push(a));
26
- for (s in d) f[s] || (u = d[s], u = e.searchOrCreateSubdir(u), c.push(u.getOrCreateFile(i)));
41
+ function n(e, r, i, n, t, l) {
42
+ n = v(n, r), t = v(t, r);
43
+ if (n !== t) {
44
+ var f, u, o, a, l = h(t) || h(v(l, r)), s = Object.fromEntries(R(n, l).map(e => [ JSON.stringify(e), e ])), d = Object.fromEntries(R(t, l).map(e => [ JSON.stringify(e), e ])), g = [], c = [];
45
+ for (f in s) d[f] || (u = s[f], (u = e.searchSubdir(u)) && (u = u.getFile(i)) && c.push(u));
46
+ for (o in d) s[o] || (a = d[o], a = e.searchOrCreateSubdir(a), g.push(a.getOrCreateFile(i)));
27
47
  return {
28
- toAddFileList: c,
29
- toDelFileList: y
48
+ toAddFileList: g,
49
+ toDelFileList: c
30
50
  };
31
51
  }
32
52
  }
33
53
 
34
- function parseNamePathAndQuery(e, r, i, t, n, l) {
35
- if (isString(t) || isNotNullObj(t)) if (e.isDir) _queryIndexHostDir(e, i, t, n, l); else {
36
- var o = e.$or;
37
- if (o) {
38
- for (var a of o) if (parseNamePathAndQuery(a, r, i, t, n, l), l?.isFull) return;
39
- } else for (var s of _getMatchedDirs(e = isString(e) ? pathSplit(e) : e, r)) if (_queryIndexHostDir(s, i, t, n, l),
40
- l?.isFull) return;
54
+ function $(e, r, i, n, t, l) {
55
+ if (s(n) || c(n)) if (e.isDir) L(e, i, n, t, l); else {
56
+ var f = e.$or;
57
+ if (f) {
58
+ for (var u of f) if ($(u, r, i, n, t, l), l?.isFull) return;
59
+ } else for (var o of F(e = s(e) ? a(e) : e, r)) if (L(o, i, n, t, l), l?.isFull) return;
41
60
  }
42
61
  }
43
62
 
44
- function* _getMatchedDirs(e, r, i = 0) {
45
- i == e.length ? yield r : yield* _getMatchedDirsWithPattern(e, e[i], r, i);
46
- }
47
-
48
- function* _getMatchedDirsWithPattern(e, r, i, t) {
49
- if ("**" == r) {
50
- i.isHiddenFolder || (yield i);
51
- for (var n of i.allSubdirs()) yield n;
52
- } else if ("*" == r) for (var l of i.subdirList) yield* _getMatchedDirs(e, l, t + 1); else if (isFunction(r)) for (var o of i.subdirList) r(o.name) && (yield* _getMatchedDirs(e, o, t + 1)); else if (isArray(r)) for (var a of r) yield* _getMatchedDirsWithPattern(e, a, i, t); else {
53
- var s = r.$or;
54
- if (s) for (var u of s) yield* _getMatchedDirsWithPattern(e, u, i, t); else {
55
- s = i.getSubdir(r);
56
- s && (yield* _getMatchedDirs(e, s, t + 1));
63
+ function* F(e, r, i = 0) {
64
+ i == e.length ? yield r : yield* function* r(i, n, t, l) {
65
+ if (null == n) return;
66
+ if ("**" == n) {
67
+ t.isHiddenFolder || (yield t);
68
+ for (var e of t.allSubdirs()) yield e;
69
+ } else if ("*" == n) for (var f of t.subdirList) yield* F(i, f, l + 1); else if (g(n)) for (var u of t.filterSubdirNames(n)) yield* F(i, u, l + 1); else if (h(n)) for (var o of n) yield* r(i, o, t, l); else {
70
+ let e = n.$or || n.$in;
71
+ if (h(e)) for (var a of e) yield* r(i, a, t, l); else if (j(n)) for (var s of C(t, n)) yield* F(i, s, l + 1); else {
72
+ let e = t.getSubdir(n);
73
+ e && (yield* F(i, e, l + 1));
74
+ }
57
75
  }
58
- }
76
+ }(e, e[i], r, i);
59
77
  }
60
78
 
61
- function _queryIndexHostDir(r, i, t, n, l) {
62
- var o = r.fileCount;
63
- if (!(o <= 0)) {
79
+ function L(r, i, n, t, l) {
80
+ var f = r.fileCount;
81
+ if (!(f <= 0)) {
64
82
  let e = 0;
65
- if (isString(t)) {
66
- var a = r.getFile(t);
67
- a && l.countOne() && (n.push(a), ++e);
83
+ if (s(n)) {
84
+ var u = r.getFile(n);
85
+ u && l.countOne() && (t.push(u), ++e);
68
86
  } else {
69
- var s, a = r.qyCache, i = (0 < i?.length && a.qyDB.createIndex(r, i),
70
- a.getIndexDir(r));
87
+ var o, u = r.qyCache, i = (0 < i?.length && u.qyDB.createIndex(r, i),
88
+ u.getIndexDir(r));
71
89
  if (!i) return;
72
- for (s in _constructQueryNode(i, t).getFileMap(l)) n.push(r.getFile(s)),
73
- ++e;
90
+ for (o of function i(n, e) {
91
+ if (null == e) return N;
92
+ if (d(e)) return new m(n.getSubdir(e));
93
+ if (g(e)) return O(n.filterSubdirNames(e));
94
+ if (j(e)) return O(C(n, e));
95
+ let {
96
+ $link: t,
97
+ $spec: l
98
+ } = e;
99
+ if (null != t) {
100
+ let e = new m(), {
101
+ qyCache: r,
102
+ subdirList: i
103
+ } = n;
104
+ for (var f of i) D(r, t, f.name, l) && e.addDir(f);
105
+ return e;
106
+ }
107
+ let u = new y();
108
+ if (h(e)) for (var r of e) u.addNode(i(n, r)); else for (var o in e) {
109
+ let r = e[o];
110
+ if (o == b) if (h(r)) {
111
+ let e = new m();
112
+ for (var a of r) e.addNode(i(n, a));
113
+ u.addNode(e);
114
+ } else u.addNode(i(n, r)); else if (o == S) if (h(r)) for (var s of r) u.addNode(i(n, s)); else u.addNode(i(n, r)); else {
115
+ let e = n.getSubdir(o);
116
+ if (null == e) return N;
117
+ u.addNode(i(e, r));
118
+ }
119
+ }
120
+ return u;
121
+ }(i, n).getFiles(l)) t.push(r.getFile(o)), ++e;
74
122
  }
75
- logger.info(`Checking ${o} file${getSuffix(o)}, result: ${e} file` + getSuffix(e));
123
+ logger.info(`Checking ${f} file${p(f)}, result: ${e} file` + p(e));
76
124
  }
77
125
  }
78
126
 
79
- function _isValidSimpleValue(e) {
127
+ function u(e) {
80
128
  var r = typeof e;
81
- return "number" == r || "boolean" == r || "string" == r && !(e in SpecialOperators);
129
+ return "number" == r || "boolean" == r || "string" == r && !(e in i);
82
130
  }
83
131
 
84
- function _filterSubdirs(e, r) {
85
- var i, t = new QyUnionNode();
86
- for (i of e.subdirList) r(i.name) && t.addDir(i);
87
- return t;
88
- }
89
-
90
- function _filterSubdirsHtoL(e, r) {
91
- var i = e.sortedSubdirList, t = new QyUnionNode();
92
- for (let e = i.length - 1; 0 <= e; --e) {
93
- var n = i[e], l = n.nameNum;
94
- if (!isNaN(l)) {
95
- if (!r(l)) break;
96
- t.addDir(n);
97
- }
98
- }
99
- return t;
100
- }
101
-
102
- function _filterSubdirsLtoH(e, r) {
103
- var i = e.sortedSubdirList, t = new QyUnionNode();
104
- for (let e = 0; e < i.length; ++e) {
105
- var n = i[e], l = n.nameNum;
106
- if (!isNaN(l)) {
107
- if (!r(l)) break;
108
- t.addDir(n);
109
- }
110
- }
111
- return t;
132
+ function O(e) {
133
+ if (0 == e.length) return N;
134
+ var r, i = new m();
135
+ for (r of e) i.addDir(r);
136
+ return i;
112
137
  }
113
138
 
114
- function _isSimpleQueryObj(e) {
115
- var r, i, t;
116
- return !(null != e && !isSimpleType(e) && !isFunction(e)) || ({
117
- $gt: e,
118
- $lt: r,
119
- $gte: i,
120
- $lte: t
121
- } = e, null != (e ?? r ?? i ?? t));
139
+ function j(e) {
140
+ return null != e && null != (e.$gt ?? e.$lt ?? e.$gte ?? e.$lte);
122
141
  }
123
142
 
124
- function _getIndexPropPaths_rec(e, r, i, t) {
125
- if (_isSimpleQueryObj(e)) 0 < i.length && (r[toSingleName(i)] = 1); else {
126
- var n = e[$or] || e[$and];
127
- if (null != n) if (isArray(n)) for (var l of n) _getIndexPropPaths_rec(l, r, i, t),
128
- i.length = t; else _getIndexPropPaths_rec(n, r, i, t), i.length = t; else for (var o in e) i.push(o),
129
- _getIndexPropPaths_rec(e[o], r, i, t + 1), i.length = t;
130
- }
143
+ function H(e) {
144
+ return null == e || d(e) || g(e) || j(e);
131
145
  }
132
146
 
133
- function _constructComparingNode(e, r, i, t, n) {
134
- if (null != r && null != i && (i <= r ? i = void 0 : r = void 0), null != n && null != t && (n <= t ? t = void 0 : n = void 0),
135
- null != r) if (null != n) {
136
- if (r < n) return _filterSubdirs(e, e => r < e && e < n);
147
+ function C(e, {
148
+ $gt: r,
149
+ $gte: i,
150
+ $lte: n,
151
+ $lt: t
152
+ }) {
153
+ if (null != r && null != i && (i <= r ? i = void 0 : r = void 0), null != t && null != n && (t <= n ? n = void 0 : t = void 0),
154
+ null != r) if (null != t) {
155
+ if (r < t) return e.compareSubdirRangeL2H(e => r < e && e < t);
137
156
  } else {
138
- if (null == t) return _filterSubdirsHtoL(e, e => r < e);
139
- if (r < t) return _filterSubdirs(e, e => r < e && e <= t);
140
- } else if (null != i) if (null != n) {
141
- if (i < n) return _filterSubdirs(e, e => i <= e && e < n);
157
+ if (null == n) return e.compareSubdirRangeH2L(e => r < e);
158
+ if (r < n) return e.compareSubdirRangeL2H(e => r < e && e <= n);
159
+ } else if (null != i) if (null != t) {
160
+ if (i < t) return e.compareSubdirRangeL2H(e => i <= e && e < t);
142
161
  } else {
143
- if (null == t) return _filterSubdirsHtoL(e, e => i <= e);
144
- if (i < t) return _filterSubdirs(e, e => i <= e && e <= t);
145
- if (i == t) return new QyUnionNode(e.getSubdir(i));
162
+ if (null == n) return e.compareSubdirRangeH2L(e => i <= e);
163
+ if (i < n) return e.compareSubdirRangeL2H(e => i <= e && e <= n);
164
+ if (i == n) return [ e.getSubdir(i) ];
146
165
  } else {
147
- if (null != n) return _filterSubdirsLtoH(e, e => e < n);
148
- if (null != t) return _filterSubdirsLtoH(e, e => e <= t);
166
+ if (null != t) return e.compareSubdirRangeL2H(e => e < t);
167
+ if (null != n) return e.compareSubdirRangeL2H(e => e <= n);
149
168
  }
150
- return Empty_Union_Node;
169
+ return l;
151
170
  }
152
171
 
153
- function _matchObj(r, i, t) {
154
- if (null == i) return !1;
155
- if (isSimpleType(t)) return isArray(i) ? i.includes(t) : isNotNullObj(i) ? i[t] : i == t;
156
- if (isFunction(t)) return t(i);
157
- if (isArray(t)) {
158
- if (isArray(i)) {
159
- for (let e = 0; e < t.length; ++e) if (!_matchObj(r, i[e], t[e])) return !1;
160
- return !0;
161
- }
162
- return !1;
163
- }
164
- var e, {
165
- $link: n,
166
- $spec: l
167
- } = t;
168
- if (n) {
169
- if (isSimpleType(i)) return _matchLink(r, n, i, l);
170
- if (isArray(i)) {
171
- for (var o of i) if (_matchLink(r, n, o, l)) return !0;
172
- } else for (var a in i) if (_matchLink(r, n, a, l)) return !0;
173
- return !1;
174
- }
175
- if (isSimpleType(i) || isArray(i)) return !1;
176
- for (e in t) if (!_matchObj(r, i[e], t[e])) return !1;
177
- return !0;
178
- }
179
-
180
- function _matchLink(e, r, i, t) {
172
+ function D(e, r, i, n) {
181
173
  var r = e.getDir(r);
182
- return !!r && !!(r = r.getFile(i)) && (null == t || _matchObj(e, r.fileContent, t));
183
- }
184
-
185
- function _constructQueryNode(e, r) {
186
- if (null == r) return Empty_Union_Node;
187
- if (isSimpleType(r)) return new QyUnionNode(e.getSubdir(r));
188
- if (isFunction(r)) return _filterSubdirs(e, r);
189
- var {
190
- $gt: i,
191
- $lt: t,
192
- $gte: n,
193
- $lte: l
194
- } = r;
195
- if (null != (i ?? t ?? n ?? l)) return _constructComparingNode(e, i, n, l, t);
196
- var {
197
- $link: o,
198
- $spec: a
199
- } = r;
200
- if (null != o) {
201
- var s, u = new QyUnionNode(), {
202
- qyCache: f,
203
- subdirList: i
204
- } = e;
205
- for (s of i) _matchLink(f, o, s.name, a) && u.addDir(s);
206
- return u;
207
- }
208
- var d = new QyIntersectNode();
209
- if (isArray(r)) for (var c of r) d.addNode(_constructQueryNode(e, c)); else for (var y in r) {
210
- var g = r[y];
211
- if (y == $or) if (isArray(g)) {
212
- var _, N = new QyUnionNode();
213
- for (_ of g) N.addNode(_constructQueryNode(e, _));
214
- d.addNode(N);
215
- } else d.addNode(_constructQueryNode(e, g)); else if (y == $and) if (isArray(g)) for (var h of g) d.addNode(_constructQueryNode(e, h)); else d.addNode(_constructQueryNode(e, g)); else {
216
- y = e.getSubdir(y);
217
- if (null == y) return Empty_Union_Node;
218
- d.addNode(_constructQueryNode(y, g));
174
+ return !!r && !!(r = r.getFile(i)) && (null == n || function r(i, n, t) {
175
+ if (null == n) return !1;
176
+ if (d(t)) return h(n) ? n.includes(t) : c(n) ? n[t] : n == t;
177
+ if (g(t)) return t(n);
178
+ if (h(t)) {
179
+ if (h(n)) {
180
+ for (let e = 0; e < t.length; ++e) if (!r(i, n[e], t[e])) return !1;
181
+ return !0;
182
+ }
183
+ return !1;
219
184
  }
220
- }
221
- return d;
222
- }
223
-
224
- function _itemToPropValList(e, r, i = [], t = [], n = 0) {
225
- if (null != e) if (_isValidSimpleValue(e = isNotNullObj(e) && r ? Object.values(e) : e)) t[n] = e,
226
- t.length = n + 1, i.push([ ...t ]); else if (isArray(e)) {
227
- t.length = n + 1;
228
- for (var l of e.filter(e => _isValidSimpleValue(e))) t[n] = l, i.push([ ...t ]);
229
- } else if (isNotNullObj(e)) for (var o in e) t[n] = o, t.length = n + 1, _itemToPropValList(e[o], !1, i, t, n + 1);
185
+ var e, {
186
+ $link: l,
187
+ $spec: f
188
+ } = t;
189
+ if (l) {
190
+ if (d(n)) return D(i, l, n, f);
191
+ if (h(n)) {
192
+ for (var u of n) if (D(i, l, u, f)) return !0;
193
+ } else for (var o in n) if (D(i, l, o, f)) return !0;
194
+ return !1;
195
+ }
196
+ if (d(n) || h(n)) return !1;
197
+ for (e in t) if (!r(i, n[e], t[e])) return !1;
198
+ return !0;
199
+ }(e, r.fileContent, n));
200
+ }
201
+
202
+ function R(e, r, i = [], n = [], t = 0) {
203
+ if (null != e) if (u(e = c(e) && r ? Object.values(e) : e)) n[t] = e, n.length = t + 1,
204
+ i.push([ ...n ]); else if (h(e)) {
205
+ n.length = t + 1;
206
+ for (var l of e.filter(e => u(e))) n[t] = l, i.push([ ...n ]);
207
+ } else if (c(e)) for (var f in e) n[t] = f, n.length = t + 1, R(e[f], !1, i, n, t + 1);
230
208
  return i;
231
209
  }
232
210
 
233
- Object.assign(module.exports, {
234
- calDifferenceList: calDifferenceList,
235
- getIndexPropPaths: getIndexPropPaths,
236
- parseNamePathAndQuery: parseNamePathAndQuery
237
- });
211
+ export {
212
+ n as calDifferenceList,
213
+ e as getIndexPropPaths,
214
+ $ as parseNamePathAndQuery
215
+ };
@@ -1,6 +1,6 @@
1
- let isArray = Array.isArray;
1
+ let t = Array.isArray;
2
2
 
3
- class QyIndexPropNode {
3
+ class i {
4
4
  constructor(e, t) {
5
5
  Object.assign(this, {
6
6
  name: e,
@@ -14,7 +14,7 @@ class QyIndexPropNode {
14
14
  !0);
15
15
  var n = e[t];
16
16
  let h;
17
- return r ? (h = r[n]) || (h = r[n] = new QyIndexPropNode(n, this), ++this.childCount) : (h = new QyIndexPropNode(n, this),
17
+ return r ? (h = r[n]) || (h = r[n] = new i(n, this), ++this.childCount) : (h = new i(n, this),
18
18
  this.children = {
19
19
  [n]: h
20
20
  }, ++this.childCount), h.insert(e, t + 1);
@@ -26,7 +26,14 @@ class QyIndexPropNode {
26
26
  children: i
27
27
  } = this;
28
28
  if (t == e.length) return this.indexPropPath && (r.removed = !0, delete this.indexPropPath),
29
- n && this._isEmpty() && n._removeChild(h), r;
29
+ n && o(this) && function e(t, r) {
30
+ let {
31
+ children: n,
32
+ parent: h,
33
+ name: i
34
+ } = t;
35
+ n[r] && (delete n[r], 0 == --t.childCount && delete t.children, h) && o(t) && e(h, i);
36
+ }(n, h), r;
30
37
  this.indexPropPath && (r.hasPrefix = !0);
31
38
  n = i && i[e[t]];
32
39
  return n ? n.remove(e, t + 1, r) : r;
@@ -38,32 +45,25 @@ class QyIndexPropNode {
38
45
  } = this;
39
46
  if (r) e.push(r); else for (var n in t) t[n].getAllIndexPropPaths(e);
40
47
  }
41
- _removeChild(e) {
42
- var {
43
- children: t,
44
- parent: r,
45
- name: n
46
- } = this;
47
- t[e] && (delete t[e], 0 == --this.childCount && delete this.children, r) && this._isEmpty() && r._removeChild(n);
48
- }
49
- _isEmpty() {
50
- return !this.indexPropPath && 0 == this.childCount;
51
- }
52
48
  }
53
49
 
54
- class QyIndexPropTree {
50
+ function o(e) {
51
+ return !e.indexPropPath && 0 == e.childCount;
52
+ }
53
+
54
+ class n {
55
55
  constructor() {
56
56
  Object.assign(this, {
57
- rootNode: new QyIndexPropNode(),
57
+ rootNode: new i(),
58
58
  changeCount: 0,
59
59
  allIndexPropPaths: []
60
60
  });
61
61
  }
62
62
  insert(e) {
63
- 0 < (e = isArray(e) ? e : [ e ]).length && this.rootNode.insert(e, 0) && ++this.changeCount;
63
+ 0 < (e = t(e) ? e : [ e ]).length && this.rootNode.insert(e, 0) && ++this.changeCount;
64
64
  }
65
65
  remove(e) {
66
- isArray(e) || (e = [ e ]);
66
+ t(e) || (e = [ e ]);
67
67
  e = this.rootNode.remove(e);
68
68
  return e.removed && ++this.changeCount, e;
69
69
  }
@@ -79,14 +79,14 @@ class QyIndexPropTree {
79
79
  }
80
80
  }
81
81
 
82
- function getPrefixPropPaths(e) {
82
+ function e(e) {
83
83
  if (0 == e.length) return [];
84
- var t, r = new QyIndexPropTree();
84
+ var t, r = new n();
85
85
  for (t of e) r.insert(t);
86
86
  return r.getAllIndexPropPaths();
87
87
  }
88
88
 
89
- Object.assign(module.exports, {
90
- QyIndexPropTree: QyIndexPropTree,
91
- getPrefixPropPaths: getPrefixPropPaths
92
- });
89
+ export {
90
+ n as QyIndexPropTree,
91
+ e as getPrefixPropPaths
92
+ };
@@ -1,48 +1,51 @@
1
- let QyQueryNode = require("./QyUnionNode.js").QyQueryNode;
1
+ import {
2
+ QyQueryNode as t
3
+ } from "./QyUnionNode.js";
2
4
 
3
- class QyIntersectNode extends QyQueryNode {
5
+ class i extends t {
4
6
  constructor() {
5
7
  super(), Object.assign(this, {
6
8
  fileCount: void 0
7
9
  });
8
10
  }
9
- containsFile(e) {
11
+ containsFile(t) {
10
12
  var {
11
- nodeList: t,
13
+ nodeList: e,
12
14
  fileCount: n
13
15
  } = this;
14
- if (0 != t.length && 0 != n) return this._ensureSorted(), t[0].containsFile(e) && this._inAllOthers(e);
16
+ if (0 != e.length && 0 != n) return s(this), e[0].containsFile(t) && l(e, t);
15
17
  }
16
- getFileMap(e) {
18
+ *getFiles(t, e = {}) {
17
19
  var {
18
- nodeList: t,
19
- fileCount: n
20
+ nodeList: n,
21
+ fileCount: i
20
22
  } = this;
21
- if (0 == t.length || 0 == n) return {};
22
- this._ensureSorted();
23
- var i, s = {};
24
- for (i in t[0].getFileMap()) if (!s[i] && this._inAllOthers(i) && this.encounterOne(s, i, e)) return s;
25
- return s;
23
+ if (0 != n.length && 0 != i) {
24
+ s(this);
25
+ for (var o of n[0].getFiles()) if (!(o in e) && l(n, o) && this.encounterOne(e, o, t) && (yield o,
26
+ t?.isFull)) return;
27
+ }
26
28
  }
27
- addNode(e) {
28
- var t, n;
29
- e && null != e.fileCount && ({
30
- fileCount: t,
29
+ addNode(t) {
30
+ var e, n;
31
+ t && null != t.fileCount && ({
32
+ fileCount: e,
31
33
  nodeList: n
32
- } = this, 0 < n.length && 0 == t || (e instanceof QyIntersectNode ? (n.push(...e.nodeList),
33
- this.sorted = !1) : n.push(e), (null == t || t > e.fileCount) && (this.fileCount = e.fileCount)));
34
- }
35
- _ensureSorted() {
36
- this.sorted || (this.nodeList.sort((e, t) => e.fileCount - t.fileCount),
37
- this.sorted = !0);
38
- }
39
- _inAllOthers(t) {
40
- var n = this.nodeList;
41
- for (let e = 1; e < n.length; ++e) if (!n[e].containsFile(t)) return !1;
42
- return !0;
34
+ } = this, 0 < n.length && 0 == e || (t instanceof i ? (n.push(...t.nodeList),
35
+ this.sorted = !1) : n.push(t), (null == e || e > t.fileCount) && (this.fileCount = t.fileCount)));
43
36
  }
44
37
  }
45
38
 
46
- Object.assign(module.exports, {
47
- QyIntersectNode: QyIntersectNode
48
- });
39
+ function s(t) {
40
+ t.sorted || (t.nodeList.sort((t, e) => t.fileCount - e.fileCount), t.sorted = !0);
41
+ }
42
+
43
+ function l(e, n) {
44
+ var i = e.length;
45
+ for (let t = 1; t < i; ++t) if (!e[t].containsFile(n)) return !1;
46
+ return !0;
47
+ }
48
+
49
+ export {
50
+ i as QyIntersectNode
51
+ };