datafolder 1.0.32 → 1.0.33

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/src/QyUtils.js CHANGED
@@ -7,10 +7,10 @@ import e from "node:process";
7
7
  import o from "node:fs/promises";
8
8
 
9
9
  import i, {
10
- readSync as a
10
+ readSync as u
11
11
  } from "node:fs";
12
12
 
13
- import u from "node:timers/promises";
13
+ import a from "node:timers/promises";
14
14
 
15
15
  import {
16
16
  fileURLToPath as r
@@ -28,16 +28,16 @@ let s = Array.isArray, {
28
28
  isUint8Array: m
29
29
  } = f.types;
30
30
 
31
- var p = t.dirname(r(import.meta.url)), h = Object.fromEntries([ "$link", "$rpl", "$spec", "$raw", "$all", "$clone", "$extend", "$pop", "$or", "$and", "$gt", "$lt", "$gte", "$lte", "$u8" ].map(r => [ r, r ])), y = "%", y = {
32
- HiddenFolderName: y,
33
- TriggerDirPath: [ y, "trigger" ],
34
- RpcDirPath: [ y, "rpc" ],
35
- IndexDirPath: [ y, "index" ],
36
- ExpireDirPath: [ y, "expire" ],
37
- HNSWDirPath: [ y, "hnsw" ],
38
- InfoDirPath: [ y, "info" ],
39
- RecycleDirPath: [ y, "recycle" ],
40
- MetaFilePath: [ y, "meta" ],
31
+ var p = t.dirname(r(import.meta.url)), y = Object.fromEntries([ "$link", "$rpl", "$spec", "$raw", "$all", "$clone", "$extend", "$pop", "$or", "$and", "$gt", "$lt", "$gte", "$lte", "$u8" ].map(r => [ r, r ])), h = "%", h = {
32
+ HiddenFolderName: h,
33
+ TriggerDirPath: [ h, "trigger" ],
34
+ RpcDirPath: [ h, "rpc" ],
35
+ IndexDirPath: [ h, "index" ],
36
+ ExpireDirPath: [ h, "expire" ],
37
+ HNSWDirPath: [ h, "hnsw" ],
38
+ InfoDirPath: [ h, "info" ],
39
+ RecycleDirPath: [ h, "recycle" ],
40
+ MetaFilePath: [ h, "meta" ],
41
41
  IndexPropPathsFileName: "propPaths"
42
42
  };
43
43
 
@@ -95,32 +95,32 @@ function j(r) {
95
95
  return "number" == typeof r;
96
96
  }
97
97
 
98
- function O(r) {
98
+ function N(r) {
99
99
  return "boolean" == typeof r;
100
100
  }
101
101
 
102
- function W(r) {
102
+ function R(r) {
103
103
  return "function" == typeof r;
104
104
  }
105
105
 
106
- function E(r) {
106
+ function H(r) {
107
107
  var t = typeof r;
108
108
  return "string" == t || "number" == t || "boolean" == t || l(r);
109
109
  }
110
110
 
111
- function R(r) {
111
+ function L(r) {
112
112
  let t = r.length;
113
113
  for (;void 0 === r[t - 1] && 0 < t; ) --t;
114
114
  return r.length = t, r;
115
115
  }
116
116
 
117
- function H(n) {
117
+ function O(n) {
118
118
  return void 0 === n.promise && (n.promise = new Promise((r, t) => {
119
119
  n.resolve = r, n.reject = t;
120
120
  })), n;
121
121
  }
122
122
 
123
- function L(r) {
123
+ function W(r) {
124
124
  return Buffer.isBuffer(r) ? r : Buffer.from(r);
125
125
  }
126
126
 
@@ -146,25 +146,25 @@ async function U(r) {
146
146
  }
147
147
  }
148
148
 
149
- async function J(r) {
149
+ async function Q(r) {
150
150
  return !1 !== await U(r);
151
151
  }
152
152
 
153
- function Q(r, t = void 0) {
153
+ function z(r, t = void 0) {
154
154
  r *= 1e3;
155
- return t ? u.setTimeout(r, !0, {
155
+ return t ? a.setTimeout(r, !0, {
156
156
  signal: t
157
- }) : u.setTimeout(r);
157
+ }) : a.setTimeout(r);
158
158
  }
159
159
 
160
160
  let k;
161
161
 
162
- async function z(t) {
162
+ async function K(t) {
163
163
  try {
164
164
  await I(t);
165
165
  var r = new Date().toISOString() + ": " + e.argv.join(" ");
166
166
  function n() {
167
- for (var r of Object.keys(k)) N(r);
167
+ for (var r of Object.keys(k)) A(r);
168
168
  }
169
169
  await o.writeFile(t, r, {
170
170
  flag: "wx",
@@ -178,77 +178,69 @@ async function z(t) {
178
178
  }
179
179
  }
180
180
 
181
- function N(r) {
181
+ function A(r) {
182
182
  try {
183
183
  i.unlinkSync(r), c.info("Unlocked " + r);
184
184
  } catch (r) {}
185
185
  }
186
186
 
187
- function K(r) {
188
- return r.startsWith("[") && r.endsWith("]") ? JSON.parse(r) : r;
189
- }
190
-
191
187
  function X(r) {
192
- return s(r) ? 1 === r.length ? r[0] : JSON.stringify(r) : r;
193
- }
194
-
195
- function q(r) {
196
188
  r = r.split("/");
197
189
  return r[0] || (r[0] = "/"), r;
198
190
  }
199
191
 
200
- function A(r) {
192
+ function E(r) {
201
193
  return r.split(".");
202
194
  }
203
195
 
204
- function C(r) {
205
- return T(r) ? [ A(r) ] : s(r) ? r.map(r => T(r) ? A(r) : r) : void 0;
196
+ function q(r) {
197
+ return T(r) ? [ E(r) ] : s(r) ? r.map(r => T(r) ? E(r) : r) : void 0;
206
198
  }
207
199
 
208
- function V(r) {
200
+ function C(r) {
209
201
  return r.join(".");
210
202
  }
211
203
 
212
- function Y(r, t = 0) {
204
+ function J(r, t = 0) {
213
205
  return Math.floor(Math.random() * (r - t)) + t;
214
206
  }
215
207
 
216
- function Z(r) {
208
+ function V(r) {
217
209
  var t, n = {};
218
210
  for (t of r) n[t] = 1;
219
211
  return n;
220
212
  }
221
213
 
222
- async function _(t, n, e, o) {
214
+ async function Y(t, n, e, o) {
223
215
  var i = Buffer.allocUnsafe(o);
224
216
  for (let r = 0; r < o; ) {
225
- var u = (await n.read(i, r, o - r, e + r)).bytesRead;
226
- if (0 === u) return void c.error(`read ${t} at ${e + r} returning 0 byte`);
227
- r += u;
217
+ var a = (await n.read(i, r, o - r, e + r)).bytesRead;
218
+ if (0 === a) return void c.error(`read ${t} at ${e + r} returning 0 byte`);
219
+ r += a;
228
220
  }
229
221
  return i;
230
222
  }
231
223
 
232
- function rr() {
224
+ function Z() {
233
225
  var r = e.availableMemory();
234
226
  return Math.round(r / (e.memoryUsage.rss() + r) * 100);
235
227
  }
236
228
 
237
- function tr(r = new Date()) {
229
+ function _(r = new Date()) {
238
230
  return r.getTime();
239
231
  }
240
232
 
241
- function nr(r = new Date()) {
233
+ function rr(r = new Date()) {
242
234
  r = r.getTime();
243
235
  return r - r % 1e3;
244
236
  }
245
237
 
246
- function er(t, n, e, o) {
238
+ function tr(t, n, e, o) {
247
239
  var i = Buffer.allocUnsafe(o);
248
240
  for (let r = 0; r < o; ) {
249
- var u = a(t, i, r, o - r, e + r);
250
- if (0 === u) return void c.error(`readSync ${n} at ${e + r} returning 0 byte`);
251
- r += u;
241
+ var a = u(t, i, r, o - r, e + r);
242
+ if (0 === a) return void c.error(`readSync ${n} at ${e + r} returning 0 byte`);
243
+ r += a;
252
244
  }
253
245
  return i;
254
246
  }
@@ -261,8 +253,8 @@ export {
261
253
  d as isFloat32Array,
262
254
  m as isUint8Array,
263
255
  p as __dirname,
264
- h as SpecialOperators,
265
- y as SpecialFilePaths,
256
+ y as SpecialOperators,
257
+ h as SpecialFilePaths,
266
258
  g as isMatchName,
267
259
  v as getMatchParam,
268
260
  $ as getSizeStr,
@@ -276,30 +268,28 @@ export {
276
268
  M as isNotNullObj,
277
269
  T as isString,
278
270
  j as isNumber,
279
- O as isBoolean,
280
- W as isFunction,
281
- E as isSimpleType,
282
- R as trimArrayTail,
283
- H as setPromise,
284
- L as toBuffer,
271
+ N as isBoolean,
272
+ R as isFunction,
273
+ H as isSimpleType,
274
+ L as trimArrayTail,
275
+ O as setPromise,
276
+ W as toBuffer,
285
277
  G as getSuffix,
286
278
  F as ensureDir,
287
279
  I as ensureParentDir,
288
280
  U as getSize,
289
- J as folderOrFileExists,
290
- Q as sleep,
291
- z as lockExclusiveFilePath,
292
- N as unlockExclusiveFilePath,
293
- K as fromSingleName,
294
- X as toSingleName,
295
- q as pathSplit,
296
- C as ensurePropNamePathList,
297
- V as propNameJoin,
298
- Y as randomInt,
299
- Z as listToMap,
300
- _ as readBufferAsync,
301
- rr as memoryPercent,
302
- tr as getNowTime,
303
- nr as getNowRounded,
304
- er as readBufferFromFD
281
+ Q as folderOrFileExists,
282
+ z as sleep,
283
+ K as lockExclusiveFilePath,
284
+ A as unlockExclusiveFilePath,
285
+ X as pathSplit,
286
+ q as ensurePropNamePathList,
287
+ C as propNameJoin,
288
+ J as randomInt,
289
+ V as listToMap,
290
+ Y as readBufferAsync,
291
+ Z as memoryPercent,
292
+ _ as getNowTime,
293
+ rr as getNowRounded,
294
+ tr as readBufferFromFD
305
295
  };