@aiao/utils 0.0.16 → 0.0.17
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/README.md +24 -1
- package/dist/async/AsyncQueueExecutor.d.ts +7 -2
- package/dist/async/AsyncQueueExecutor.d.ts.map +1 -1
- package/dist/index.js +142 -127
- package/dist/object/cloneDeep.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
# utils
|
|
1
|
+
# @aiao/utils
|
|
2
|
+
|
|
3
|
+
Aiao 项目通用工具库,提供常用的工具函数。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **类型工具**: TypeScript 类型增强
|
|
8
|
+
- **字符串处理**: 字符串常用操作
|
|
9
|
+
- **时间处理**: 日期时间相关工具
|
|
10
|
+
- **RxJS 工具**: RxJS 辅助函数
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @aiao/utils
|
|
16
|
+
# 或
|
|
17
|
+
pnpm add @aiao/utils
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { deepClone, debounce, formatTime } from '@aiao/utils';
|
|
24
|
+
```
|
|
@@ -23,7 +23,8 @@ export declare class AsyncQueueExecutor {
|
|
|
23
23
|
private maxConcurrent;
|
|
24
24
|
private running;
|
|
25
25
|
private queue;
|
|
26
|
-
private
|
|
26
|
+
private queueMap;
|
|
27
|
+
private drainResolvers;
|
|
27
28
|
constructor(maxConcurrent?: number);
|
|
28
29
|
/**
|
|
29
30
|
* 添加任务到执行器
|
|
@@ -59,10 +60,14 @@ export declare class AsyncQueueExecutor {
|
|
|
59
60
|
* 获取队列中等待的任务数
|
|
60
61
|
*/
|
|
61
62
|
getQueuedCount(): number;
|
|
63
|
+
/**
|
|
64
|
+
* drain:当 running 和 queue 均为空时通知所有等待方
|
|
65
|
+
*/
|
|
66
|
+
private _checkDrain;
|
|
62
67
|
/**
|
|
63
68
|
* 执行队列中的下一个任务
|
|
64
69
|
*/
|
|
65
|
-
private
|
|
70
|
+
private _runNext;
|
|
66
71
|
}
|
|
67
72
|
export {};
|
|
68
73
|
//# sourceMappingURL=AsyncQueueExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncQueueExecutor.d.ts","sourceRoot":"","sources":["../../src/async/AsyncQueueExecutor.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,UAAU,cAAc;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"AsyncQueueExecutor.d.ts","sourceRoot":"","sources":["../../src/async/AsyncQueueExecutor.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,UAAU,cAAc;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAiD;IACjE,OAAO,CAAC,cAAc,CAAyB;gBAEnC,aAAa,GAAE,MAAU;IAIrC;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBpE;;;OAGG;IACH,SAAS,IAAI,cAAc;IAQ3B;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQtC;;OAEG;IACH,UAAU,IAAI,IAAI;IASlB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAuBjB"}
|
package/dist/index.js
CHANGED
|
@@ -204,10 +204,10 @@ const wt = (e) => !(!e || !e.then || !d(e.then));
|
|
|
204
204
|
function At(e) {
|
|
205
205
|
return e instanceof RegExp;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function O(e) {
|
|
208
208
|
return typeof e == "string";
|
|
209
209
|
}
|
|
210
|
-
const Et = (e) => b(e) ? e.every(
|
|
210
|
+
const Et = (e) => b(e) ? e.every(O) : !1, M = (e) => e instanceof Uint8Array, St = (e) => Array.isArray(e) ? e : V(e) ? [] : [e], bt = (e, t = [], r = []) => {
|
|
211
211
|
const n = [...e];
|
|
212
212
|
return n.sort((o, c) => {
|
|
213
213
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -221,15 +221,16 @@ const Et = (e) => b(e) ? e.every(C) : !1, $ = (e) => e instanceof Uint8Array, St
|
|
|
221
221
|
}
|
|
222
222
|
return 0;
|
|
223
223
|
}), n;
|
|
224
|
-
},
|
|
224
|
+
}, Ot = (e) => (t, r) => {
|
|
225
225
|
const n = t[e], o = r[e];
|
|
226
226
|
return n == null && o == null ? 0 : n == null ? 1 : o == null ? -1 : n > o ? 1 : n < o ? -1 : 0;
|
|
227
|
-
},
|
|
227
|
+
}, Ct = (e, t) => e.filter(/* @__PURE__ */ ((r) => (n) => r.has(t(n)) ? !1 : r.add(t(n)))(/* @__PURE__ */ new Set()));
|
|
228
228
|
class Tt {
|
|
229
229
|
maxConcurrent;
|
|
230
230
|
running = 0;
|
|
231
231
|
queue = [];
|
|
232
|
-
|
|
232
|
+
queueMap = /* @__PURE__ */ new Map();
|
|
233
|
+
drainResolvers = [];
|
|
233
234
|
constructor(t = 3) {
|
|
234
235
|
this.maxConcurrent = t || 1;
|
|
235
236
|
}
|
|
@@ -240,17 +241,17 @@ class Tt {
|
|
|
240
241
|
* @returns 返回任务执行结果的 Promise
|
|
241
242
|
*/
|
|
242
243
|
addTask(t, r) {
|
|
243
|
-
if (r && this.
|
|
244
|
-
return this.
|
|
244
|
+
if (r && this.queueMap.has(r))
|
|
245
|
+
return this.queueMap.get(r);
|
|
245
246
|
const n = new Promise((o, c) => {
|
|
246
247
|
this.queue.push({
|
|
247
248
|
task: t,
|
|
248
249
|
resolve: o,
|
|
249
250
|
reject: c,
|
|
250
251
|
id: r
|
|
251
|
-
}), this.
|
|
252
|
+
}), this._runNext();
|
|
252
253
|
});
|
|
253
|
-
return r !== void 0 && this.
|
|
254
|
+
return r !== void 0 && this.queueMap.set(r, n), n;
|
|
254
255
|
}
|
|
255
256
|
/**
|
|
256
257
|
* 获取当前状态
|
|
@@ -269,7 +270,7 @@ class Tt {
|
|
|
269
270
|
*/
|
|
270
271
|
setMaxConcurrent(t) {
|
|
271
272
|
for (t = t || 1, this.maxConcurrent = t; this.running < this.maxConcurrent && this.queue.length > 0; )
|
|
272
|
-
this.
|
|
273
|
+
this._runNext();
|
|
273
274
|
}
|
|
274
275
|
/**
|
|
275
276
|
* 清空队列(不影响正在执行的任务)
|
|
@@ -277,18 +278,15 @@ class Tt {
|
|
|
277
278
|
clearQueue() {
|
|
278
279
|
this.queue.forEach(({ reject: t }) => {
|
|
279
280
|
t(new Error("Task cancelled: queue cleared"));
|
|
280
|
-
}), this.queue = [], this.
|
|
281
|
+
}), this.queue = [], this.queueMap.clear(), this._checkDrain();
|
|
281
282
|
}
|
|
282
283
|
/**
|
|
283
284
|
* 等待所有任务完成
|
|
284
285
|
* @returns 当所有任务完成时 resolve
|
|
285
286
|
*/
|
|
286
287
|
waitForAll() {
|
|
287
|
-
return new Promise((t) => {
|
|
288
|
-
|
|
289
|
-
this.running === 0 && this.queue.length === 0 ? t() : setTimeout(r, 50);
|
|
290
|
-
};
|
|
291
|
-
r();
|
|
288
|
+
return this.running === 0 && this.queue.length === 0 ? Promise.resolve() : new Promise((t) => {
|
|
289
|
+
this.drainResolvers.push(t);
|
|
292
290
|
});
|
|
293
291
|
}
|
|
294
292
|
/**
|
|
@@ -303,11 +301,20 @@ class Tt {
|
|
|
303
301
|
getQueuedCount() {
|
|
304
302
|
return this.queue.length;
|
|
305
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* drain:当 running 和 queue 均为空时通知所有等待方
|
|
306
|
+
*/
|
|
307
|
+
_checkDrain() {
|
|
308
|
+
this.running === 0 && this.queue.length === 0 && this.drainResolvers.splice(0).forEach((t) => t());
|
|
309
|
+
}
|
|
306
310
|
/**
|
|
307
311
|
* 执行队列中的下一个任务
|
|
308
312
|
*/
|
|
309
|
-
|
|
310
|
-
if (this.running >= this.maxConcurrent || this.queue.length === 0)
|
|
313
|
+
_runNext() {
|
|
314
|
+
if (this.running >= this.maxConcurrent || this.queue.length === 0) {
|
|
315
|
+
this._checkDrain();
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
311
318
|
const t = this.queue.shift();
|
|
312
319
|
if (!t) return;
|
|
313
320
|
const { task: r, resolve: n, reject: o, id: c } = t;
|
|
@@ -316,11 +323,11 @@ class Tt {
|
|
|
316
323
|
}).catch((s) => {
|
|
317
324
|
o(s);
|
|
318
325
|
}).finally(() => {
|
|
319
|
-
this.running--, c !== void 0 && this.
|
|
326
|
+
this.running--, c !== void 0 && this.queueMap.delete(c), this._runNext();
|
|
320
327
|
});
|
|
321
328
|
}
|
|
322
329
|
}
|
|
323
|
-
const Pt = (e) => setTimeout(() => e(), 0),
|
|
330
|
+
const Pt = (e) => setTimeout(() => e(), 0), D = /* @__PURE__ */ Promise.resolve(), Mt = (e) => e ? D.then(e) : D, $t = (e) => new Promise((t) => setTimeout(t, e)), Ee = new TextDecoder(), Rt = (e) => Ee.decode(e);
|
|
324
331
|
function Se(e, t) {
|
|
325
332
|
for (const r in e)
|
|
326
333
|
Object.prototype.hasOwnProperty.call(e, r) && (t(r, e[r], e), Z(e[r], t));
|
|
@@ -330,7 +337,7 @@ const Z = (e, t) => {
|
|
|
330
337
|
}, T = (e) => new Uint8Array(
|
|
331
338
|
atob(e).split("").map((t) => t.charCodeAt(0))
|
|
332
339
|
);
|
|
333
|
-
async function
|
|
340
|
+
async function It(e, t, r) {
|
|
334
341
|
const n = await crypto.subtle.importKey(
|
|
335
342
|
"raw",
|
|
336
343
|
T(t),
|
|
@@ -351,9 +358,9 @@ async function _t(e, t, r) {
|
|
|
351
358
|
return new TextDecoder().decode(c);
|
|
352
359
|
}
|
|
353
360
|
const S = (e) => {
|
|
354
|
-
if (
|
|
361
|
+
if (O(e))
|
|
355
362
|
return btoa(e);
|
|
356
|
-
if (
|
|
363
|
+
if (M(e) || Array.isArray(e))
|
|
357
364
|
return btoa(String.fromCharCode(...e));
|
|
358
365
|
if (ye(e)) {
|
|
359
366
|
const t = new Uint8Array(e);
|
|
@@ -361,7 +368,7 @@ const S = (e) => {
|
|
|
361
368
|
}
|
|
362
369
|
throw new TypeError(`Unsupported type for base64 encoding: ${typeof e}`);
|
|
363
370
|
}, { subtle: be } = globalThis.crypto;
|
|
364
|
-
async function
|
|
371
|
+
async function Oe() {
|
|
365
372
|
return await be.generateKey(
|
|
366
373
|
{
|
|
367
374
|
name: "AES-GCM",
|
|
@@ -371,12 +378,12 @@ async function Ce() {
|
|
|
371
378
|
["encrypt", "decrypt"]
|
|
372
379
|
);
|
|
373
380
|
}
|
|
374
|
-
async function
|
|
381
|
+
async function Ce(e) {
|
|
375
382
|
const t = await crypto.subtle.exportKey("raw", e);
|
|
376
383
|
return S(t);
|
|
377
384
|
}
|
|
378
|
-
async function
|
|
379
|
-
const t = new TextEncoder(), r = await
|
|
385
|
+
async function xt(e) {
|
|
386
|
+
const t = new TextEncoder(), r = await Oe(), n = crypto.getRandomValues(new Uint8Array(16)), o = await crypto.subtle.encrypt(
|
|
380
387
|
{
|
|
381
388
|
name: "AES-GCM",
|
|
382
389
|
iv: n
|
|
@@ -385,25 +392,25 @@ async function It(e) {
|
|
|
385
392
|
t.encode(e)
|
|
386
393
|
);
|
|
387
394
|
return {
|
|
388
|
-
key: await
|
|
395
|
+
key: await Ce(r),
|
|
389
396
|
iv: S(n),
|
|
390
397
|
cipherText: S(o)
|
|
391
398
|
};
|
|
392
399
|
}
|
|
393
|
-
const Te = (e) => atob(e.replace(/[-]/g, "+").replace(/[_]/g, "/")),
|
|
400
|
+
const Te = (e) => atob(e.replace(/[-]/g, "+").replace(/[_]/g, "/")), Nt = (e) => {
|
|
394
401
|
const t = e.split(".");
|
|
395
402
|
if (t.length !== 3) throw new Error("JWT is not valid: not a JWT structure");
|
|
396
403
|
const r = t[1];
|
|
397
404
|
return JSON.parse(Te(r));
|
|
398
405
|
};
|
|
399
|
-
function
|
|
406
|
+
function I(e) {
|
|
400
407
|
const t = new ArrayBuffer(e.length), r = new Uint8Array(t);
|
|
401
408
|
for (let n = 0, o = e.length; n < o; n++)
|
|
402
409
|
r[n] = e.charCodeAt(n);
|
|
403
410
|
return t;
|
|
404
411
|
}
|
|
405
412
|
function Pe(e) {
|
|
406
|
-
const t = e.replace(/-----.*-----/g, "").trim(), r = atob(t), n =
|
|
413
|
+
const t = e.replace(/-----.*-----/g, "").trim(), r = atob(t), n = I(r);
|
|
407
414
|
return crypto.subtle.importKey(
|
|
408
415
|
"pkcs8",
|
|
409
416
|
n,
|
|
@@ -425,8 +432,8 @@ async function Bt(e, t) {
|
|
|
425
432
|
);
|
|
426
433
|
return new TextDecoder().decode(n);
|
|
427
434
|
}
|
|
428
|
-
function
|
|
429
|
-
const t = e.replace(/-----.*-----/g, "").trim(), r = atob(t), n =
|
|
435
|
+
function Me(e) {
|
|
436
|
+
const t = e.replace(/-----.*-----/g, "").trim(), r = atob(t), n = I(r);
|
|
430
437
|
return crypto.subtle.importKey(
|
|
431
438
|
"spki",
|
|
432
439
|
n,
|
|
@@ -438,22 +445,22 @@ function $e(e) {
|
|
|
438
445
|
["encrypt"]
|
|
439
446
|
);
|
|
440
447
|
}
|
|
441
|
-
async function
|
|
442
|
-
const r = await
|
|
448
|
+
async function Dt(e, t) {
|
|
449
|
+
const r = await Me(t), n = await crypto.subtle.encrypt(
|
|
443
450
|
{
|
|
444
451
|
name: "RSA-OAEP"
|
|
445
452
|
},
|
|
446
453
|
r,
|
|
447
|
-
|
|
454
|
+
I(e)
|
|
448
455
|
);
|
|
449
456
|
return S(n);
|
|
450
457
|
}
|
|
451
|
-
const
|
|
452
|
-
async function
|
|
458
|
+
const L = "PUBLIC KEY", j = "RSA PRIVATE KEY";
|
|
459
|
+
async function _(e, t = "pkcs8") {
|
|
453
460
|
const r = await crypto.subtle.exportKey(t, e);
|
|
454
461
|
return S(r);
|
|
455
462
|
}
|
|
456
|
-
async function
|
|
463
|
+
async function Lt(e = 1024) {
|
|
457
464
|
const { publicKey: t, privateKey: r } = await crypto.subtle.generateKey(
|
|
458
465
|
{
|
|
459
466
|
name: "RSA-OAEP",
|
|
@@ -465,17 +472,17 @@ async function jt(e = 1024) {
|
|
|
465
472
|
},
|
|
466
473
|
!0,
|
|
467
474
|
["encrypt", "decrypt"]
|
|
468
|
-
), n = await
|
|
475
|
+
), n = await _(t, "spki"), o = await _(r, "pkcs8");
|
|
469
476
|
return {
|
|
470
|
-
publicKey: `-----BEGIN ${
|
|
477
|
+
publicKey: `-----BEGIN ${L}-----
|
|
471
478
|
${n}
|
|
472
|
-
-----END ${
|
|
473
|
-
privateKey: `-----BEGIN ${
|
|
479
|
+
-----END ${L}-----`,
|
|
480
|
+
privateKey: `-----BEGIN ${j}-----
|
|
474
481
|
${o}
|
|
475
|
-
-----END ${
|
|
482
|
+
-----END ${j}-----`
|
|
476
483
|
};
|
|
477
484
|
}
|
|
478
|
-
const
|
|
485
|
+
const jt = (e) => p(e) || G(e) ? !0 : V(e) ? !1 : new Date(e).getTime() > 0, $e = (e) => {
|
|
479
486
|
const t = e > 0 ? "+" : "-", r = Math.abs(e), n = `${Math.floor(r / 60)}`.padStart(2, "0"), o = `${r % 60}`.padStart(2, "0");
|
|
480
487
|
return {
|
|
481
488
|
flag: t,
|
|
@@ -484,24 +491,24 @@ const Dt = (e) => p(e) || G(e) ? !0 : V(e) ? !1 : new Date(e).getTime() > 0, Me
|
|
|
484
491
|
minute: o
|
|
485
492
|
};
|
|
486
493
|
}, Re = (e, t, r) => {
|
|
487
|
-
const { flag: n, hour: o, minute: c } =
|
|
494
|
+
const { flag: n, hour: o, minute: c } = $e(r);
|
|
488
495
|
return `${e}T${t}${n}${o}:${c}`;
|
|
489
|
-
},
|
|
496
|
+
}, _t = (e, t, r) => new Date(Re(e, t, r)), H = (e, t) => {
|
|
490
497
|
const r = t.getTime() - e.getTime(), n = Math.floor(r / 864e5), o = Math.floor(n / 30), c = Math.floor(o / 12), s = Math.floor(r / 36e5) % 24, i = Math.floor(r / 6e4) % 60, a = Math.floor(r / 1e3) % 60;
|
|
491
498
|
return { year: c, month: o, day: n, hour: s, minute: i, second: a };
|
|
492
|
-
},
|
|
493
|
-
const n = H(e, t), o =
|
|
494
|
-
return d(r) ? r({ key: o, value: c }) :
|
|
499
|
+
}, J = (e, t, r) => r ? `${t} ${r[e] || e}` : `${t} ${e}`, Q = ["year", "month", "day", "hour", "minute", "second"], kt = (e, t, r) => {
|
|
500
|
+
const n = H(e, t), o = Q.find((s) => n[s] > 0) || "second", c = n[o];
|
|
501
|
+
return d(r) ? r({ key: o, value: c }) : J(o, c, r);
|
|
495
502
|
}, Ut = (e, t, r) => {
|
|
496
503
|
const n = H(e, t);
|
|
497
|
-
return d(r) ? r(n) :
|
|
498
|
-
}, Kt = (e) =>
|
|
504
|
+
return d(r) ? r(n) : Q.filter((o) => o).map((o) => J(o, n[o], r)).join(" ");
|
|
505
|
+
}, Kt = (e) => O(e) && /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|\+[0-2]\d(?:\\:[0-5]\d)?)?/g.test(e);
|
|
499
506
|
function qt(e) {
|
|
500
|
-
return p(e) ? !0 :
|
|
507
|
+
return p(e) ? !0 : O(e) ? !!/^(?<value>-?(?:\d+)?\.?\d+) *(?<type>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
501
508
|
e
|
|
502
509
|
)?.groups : !1;
|
|
503
510
|
}
|
|
504
|
-
const Ft = (e) => ue(e), zt = () => Math.floor(Date.now() / 1e3),
|
|
511
|
+
const Ft = (e) => ue(e), zt = () => Math.floor(Date.now() / 1e3), vt = (e, t = 50) => {
|
|
505
512
|
let r;
|
|
506
513
|
return function(...n) {
|
|
507
514
|
const o = () => {
|
|
@@ -509,7 +516,7 @@ const Ft = (e) => ue(e), zt = () => Math.floor(Date.now() / 1e3), Wt = (e, t = 5
|
|
|
509
516
|
};
|
|
510
517
|
r !== void 0 && clearTimeout(r), r = setTimeout(o, t);
|
|
511
518
|
};
|
|
512
|
-
},
|
|
519
|
+
}, Wt = () => {
|
|
513
520
|
};
|
|
514
521
|
function Gt(e) {
|
|
515
522
|
let t = !1, r;
|
|
@@ -588,7 +595,7 @@ function U(e, t) {
|
|
|
588
595
|
}
|
|
589
596
|
return r + n.join("");
|
|
590
597
|
}
|
|
591
|
-
function
|
|
598
|
+
function Ie(e, t) {
|
|
592
599
|
ee(e);
|
|
593
600
|
const r = e[0], n = e.slice(1).split("");
|
|
594
601
|
let o = !0;
|
|
@@ -615,7 +622,7 @@ function g(e, t, r = Y) {
|
|
|
615
622
|
return a + w("", l, r);
|
|
616
623
|
if (a < t)
|
|
617
624
|
return a;
|
|
618
|
-
const u =
|
|
625
|
+
const u = Ie(a, r);
|
|
619
626
|
if (u == null)
|
|
620
627
|
throw new Error("cannot decrement any more");
|
|
621
628
|
return u;
|
|
@@ -654,29 +661,37 @@ function K(e, t, r, n = Y) {
|
|
|
654
661
|
const o = Math.floor(r / 2), c = g(e, t, n);
|
|
655
662
|
return [...K(e, c, o, n), c, ...K(c, t, r - o - 1, n)];
|
|
656
663
|
}
|
|
657
|
-
const
|
|
664
|
+
const xe = (e) => {
|
|
658
665
|
if (e == null || e === "") return !1;
|
|
659
666
|
const t = parseFloat(e);
|
|
660
667
|
return !(isNaN(t) || !isFinite(t));
|
|
661
|
-
},
|
|
668
|
+
}, Ne = (e, t) => Math.ceil(e / t) * t, Zt = (e, t = 80, r = 1) => Ne(e * r, t), Ht = (e, t = 12) => parseFloat(e.toPrecision(t)), Jt = (e) => {
|
|
662
669
|
const t = Number(e);
|
|
663
670
|
return t < 0 ? Math.ceil(t) : Math.floor(t);
|
|
664
|
-
},
|
|
665
|
-
if (
|
|
671
|
+
}, Qt = (e) => {
|
|
672
|
+
if (xe(e)) {
|
|
666
673
|
const t = Number(e);
|
|
667
674
|
return isNaN(t) || !isFinite(t) ? e : t;
|
|
668
675
|
}
|
|
669
676
|
return e;
|
|
670
|
-
}, Yt = (e) =>
|
|
677
|
+
}, Yt = (e) => {
|
|
678
|
+
if (e == null || typeof e != "object")
|
|
679
|
+
return e;
|
|
680
|
+
try {
|
|
681
|
+
return structuredClone(e);
|
|
682
|
+
} catch {
|
|
683
|
+
return JSON.parse(JSON.stringify(e));
|
|
684
|
+
}
|
|
685
|
+
}, Be = (e) => {
|
|
671
686
|
for (const r of Object.getOwnPropertyNames(e)) {
|
|
672
687
|
const n = e[r];
|
|
673
688
|
!R(n) && !d(n) || n === null || Be(n);
|
|
674
689
|
}
|
|
675
690
|
return Object.isFrozen(e) ? e : Object.freeze(e);
|
|
676
|
-
},
|
|
691
|
+
}, De = (e) => e.replace(/\[/g, ".").replace(/\]/g, "").split(".");
|
|
677
692
|
function te(e, t, r, n) {
|
|
678
693
|
const o = d(n) ? n : void 0;
|
|
679
|
-
return
|
|
694
|
+
return De(t).reduce((s, i, a, l) => {
|
|
680
695
|
if (a === l.length - 1)
|
|
681
696
|
return s[i] = r, s;
|
|
682
697
|
if (i in s)
|
|
@@ -689,19 +704,19 @@ function te(e, t, r, n) {
|
|
|
689
704
|
return s[i] = /^[0-9]{1,}$/.test(l[a + 1]) ? [] : {};
|
|
690
705
|
}, e), e;
|
|
691
706
|
}
|
|
692
|
-
function
|
|
707
|
+
function Le(e, t, r) {
|
|
693
708
|
return te(e, t, r);
|
|
694
709
|
}
|
|
695
|
-
function
|
|
710
|
+
function je(e, t, r, n) {
|
|
696
711
|
const o = d(n) ? n : void 0;
|
|
697
712
|
return te(e, t, r, o);
|
|
698
713
|
}
|
|
699
714
|
const Xt = (e) => {
|
|
700
715
|
const t = {};
|
|
701
716
|
return Object.keys(e).forEach((r) => {
|
|
702
|
-
r.match(/[^\]]*\[\d+\]/) ?
|
|
717
|
+
r.match(/[^\]]*\[\d+\]/) ? Le(t, r, e[r]) : je(t, r, e[r], Object);
|
|
703
718
|
}), t;
|
|
704
|
-
},
|
|
719
|
+
}, _e = (e, t, r) => {
|
|
705
720
|
const n = (c) => String.prototype.split.call(t, c).filter(Boolean).reduce((s, i) => s != null ? s[i] : s, e), o = n(/[,[\]]+?/) || n(/[,[\].]+?/);
|
|
706
721
|
return o === void 0 || o === e ? r : o;
|
|
707
722
|
}, ke = (e, t) => {
|
|
@@ -721,7 +736,7 @@ const q = (e, t) => {
|
|
|
721
736
|
for (n = r; n-- !== 0; ) if (!q(e[n], t[n])) return !1;
|
|
722
737
|
return !0;
|
|
723
738
|
}
|
|
724
|
-
if (
|
|
739
|
+
if (M(e) && M(t)) return Ue(e, t);
|
|
725
740
|
if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
|
|
726
741
|
if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
|
|
727
742
|
if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
|
|
@@ -751,11 +766,11 @@ function nr(e, t) {
|
|
|
751
766
|
function or(e, t) {
|
|
752
767
|
return Object.keys(e).filter((r) => t(e[r], r)).reduce((r, n) => (r[n] = e[n], r), {});
|
|
753
768
|
}
|
|
754
|
-
const
|
|
755
|
-
(n) =>
|
|
769
|
+
const $ = (e, t = "", r = {}) => (b(e) ? e.forEach((n, o) => $(n, `${t}[${o}]`, r)) : Ae(e) ? Object.keys(e).forEach(
|
|
770
|
+
(n) => $(e[n], `${t ? t + "." : ""}${n}`, r)
|
|
756
771
|
) : r[`${t}`] = e, r);
|
|
757
772
|
function sr(e) {
|
|
758
|
-
return
|
|
773
|
+
return $(e);
|
|
759
774
|
}
|
|
760
775
|
const cr = (e) => {
|
|
761
776
|
const t = {};
|
|
@@ -776,18 +791,18 @@ const ar = typeof window == "object", lr = (e) => e[Math.floor(Math.random() * e
|
|
|
776
791
|
function fr(e = Number.MIN_SAFE_INTEGER, t = Number.MAX_SAFE_INTEGER) {
|
|
777
792
|
return Math.floor(Math.random() * (t - e + 1) + e);
|
|
778
793
|
}
|
|
779
|
-
const Ke = "0", re = "123456789", ne = Ke + re, oe = "abcdefghijklmnopqrstuvwxyz", qe = oe.toUpperCase(), Fe = oe + qe, ze = "_-",
|
|
794
|
+
const Ke = "0", re = "123456789", ne = Ke + re, oe = "abcdefghijklmnopqrstuvwxyz", qe = oe.toUpperCase(), Fe = oe + qe, ze = "_-", ve = ne + Fe + ze, F = (e = 16, t = ve) => {
|
|
780
795
|
let r = "";
|
|
781
796
|
const n = crypto.getRandomValues(new Uint8Array(e |= 0)), o = t.length - 1;
|
|
782
797
|
for (; e--; ) r += t[n[e] & o];
|
|
783
798
|
return r;
|
|
784
|
-
},
|
|
799
|
+
}, We = (e = 16) => F(1, re) + F(e - 1, ne), hr = (e = 16) => parseInt(We(e), 10), se = (e) => {
|
|
785
800
|
if (!e) return "";
|
|
786
801
|
const t = e.toLowerCase();
|
|
787
802
|
return Ge(t);
|
|
788
|
-
}, Ge = (e) => e ? e.substring(0, 1).toUpperCase() + e.substring(1, e.length) : "", Ve = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g,
|
|
803
|
+
}, Ge = (e) => e ? e.substring(0, 1).toUpperCase() + e.substring(1, e.length) : "", Ve = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g, x = (e) => Array.from(e.match(Ve) ?? []);
|
|
789
804
|
function pr(e) {
|
|
790
|
-
const t =
|
|
805
|
+
const t = x(e);
|
|
791
806
|
if (t.length === 0)
|
|
792
807
|
return "";
|
|
793
808
|
const [r, ...n] = t;
|
|
@@ -826,9 +841,9 @@ const dr = async (e, t = "deflate") => {
|
|
|
826
841
|
const u = s.readable.getReader(), f = [];
|
|
827
842
|
let A = 0;
|
|
828
843
|
for (; ; ) {
|
|
829
|
-
const { done: h, value:
|
|
844
|
+
const { done: h, value: N } = await u.read();
|
|
830
845
|
if (h) break;
|
|
831
|
-
f.push(
|
|
846
|
+
f.push(N), A += N.length;
|
|
832
847
|
}
|
|
833
848
|
const y = new Uint8Array(A);
|
|
834
849
|
let m = 0;
|
|
@@ -838,7 +853,7 @@ const dr = async (e, t = "deflate") => {
|
|
|
838
853
|
} catch (r) {
|
|
839
854
|
throw console.error("解压过程中出错:", r), r;
|
|
840
855
|
}
|
|
841
|
-
}, Ze = (e) =>
|
|
856
|
+
}, Ze = (e) => x(e).map((r) => r.toLowerCase()).join("-"), He = {
|
|
842
857
|
"〇": 0,
|
|
843
858
|
一: 1,
|
|
844
859
|
二: 2,
|
|
@@ -920,28 +935,28 @@ const gr = (e) => {
|
|
|
920
935
|
Array.isArray(n) ? n.forEach((o) => t.append(r, `${o}`)) : t.set(r, `${n}`);
|
|
921
936
|
}
|
|
922
937
|
return t.sort(), t.toString();
|
|
923
|
-
},
|
|
938
|
+
}, Je = ["角", "分", "厘"], z = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], C = [
|
|
924
939
|
["元", "万", "亿", "兆", "京", "垓"],
|
|
925
940
|
["", "拾", "佰", "仟"]
|
|
926
|
-
],
|
|
941
|
+
], v = Math.pow(10, 22), Ar = (e) => {
|
|
927
942
|
const t = e < 0 ? "欠" : "";
|
|
928
943
|
let r = Math.abs(e);
|
|
929
|
-
if (r >
|
|
930
|
-
throw new Error(`max value is ${
|
|
944
|
+
if (r > v)
|
|
945
|
+
throw new Error(`max value is ${v}`);
|
|
931
946
|
let n = "";
|
|
932
947
|
if (e > Math.floor(e)) {
|
|
933
948
|
const o = +("0." + `${r}`.split(".")[1]);
|
|
934
|
-
n =
|
|
949
|
+
n = Je.reduce(
|
|
935
950
|
(c, s, i) => c + (z[Math.floor(o * 10 * Math.pow(10, i)) % 10] + s).replace(/零./, ""),
|
|
936
951
|
""
|
|
937
952
|
);
|
|
938
953
|
}
|
|
939
954
|
n = n || "整", r = Math.floor(r);
|
|
940
|
-
for (let o = 0; o <
|
|
955
|
+
for (let o = 0; o < C[0].length && r > 0; o++) {
|
|
941
956
|
let c = "";
|
|
942
|
-
for (let s = 0; s <
|
|
943
|
-
c = z[r % 10] +
|
|
944
|
-
n = c.replace(/(零.)*零$/g, "").replace(/^$/, "零") +
|
|
957
|
+
for (let s = 0; s < C[1].length && r > 0; s++)
|
|
958
|
+
c = z[r % 10] + C[1][s] + c, r = Math.floor(r / 10);
|
|
959
|
+
n = c.replace(/(零.)*零$/g, "").replace(/^$/, "零") + C[0][o] + n;
|
|
945
960
|
}
|
|
946
961
|
return `${t}${n.replace(/(零.)*零元/, "元").replace(/(零.)+/g, "零").replace(/^整$/, "零元整")}`;
|
|
947
962
|
};
|
|
@@ -949,18 +964,18 @@ function Er(e, t) {
|
|
|
949
964
|
const r = e || "", n = t || "", o = Math.max(r.length, n.length);
|
|
950
965
|
return o === 0 ? 1 : (o - fe(r, n)) / o;
|
|
951
966
|
}
|
|
952
|
-
const Sr = (e) =>
|
|
967
|
+
const Sr = (e) => x(e).map((r) => r.toLowerCase()).join("_"), br = (e) => Ze(e).split("-").filter((t) => !!t).map((t) => se(t.toLowerCase())).join(" "), Or = (e) => e.trim().replace(/\s+/g, " "), Cr = (e, t) => e.replace(/\${([^}]+)}/g, (r, n) => _e(t, n.trim(), "")), Qe = (e) => e ? e.substring(0, 1).toLowerCase() + e.substring(1, e.length) : "", Tr = (e) => {
|
|
953
968
|
if (!e) return "";
|
|
954
969
|
const t = e.toLowerCase();
|
|
955
|
-
return
|
|
956
|
-
},
|
|
970
|
+
return Qe(t);
|
|
971
|
+
}, W = /^([^/:]+):\/*/, Pr = (...e) => {
|
|
957
972
|
if (e = e.filter((s) => s !== ""), e.length === 0)
|
|
958
973
|
return "";
|
|
959
|
-
if (e.findIndex((s) => !(
|
|
974
|
+
if (e.findIndex((s) => !(O(s) || p(s))) >= 0)
|
|
960
975
|
throw new Error("paths must be a string or number");
|
|
961
976
|
let r = "";
|
|
962
977
|
const n = `${e[0]}`;
|
|
963
|
-
n.startsWith("//") ? r = "//" : n.startsWith("/") ? r = "/" : (n.startsWith("file:") && e.length > 1 && (n + e[1]).match(/^file:\/\/\//) ? r = n.replace(
|
|
978
|
+
n.startsWith("//") ? r = "//" : n.startsWith("/") ? r = "/" : (n.startsWith("file:") && e.length > 1 && (n + e[1]).match(/^file:\/\/\//) ? r = n.replace(W, "$1:///") : r = n.replace(W, "$1://"), e.shift()), r && !r.endsWith("/") && (r += "/");
|
|
964
979
|
let o = e.map(
|
|
965
980
|
(s) => `${s}`.replace(/^\/+/, "").replace(/^\.\/+/, "").replace(/\/+$/, "")
|
|
966
981
|
).filter((s) => s !== "").join("/");
|
|
@@ -975,7 +990,7 @@ const Sr = (e) => I(e).map((r) => r.toLowerCase()).join("_"), br = (e) => Ze(e).
|
|
|
975
990
|
}
|
|
976
991
|
return c.replace(/\/(\?|&|#[^!])/g, "$1");
|
|
977
992
|
};
|
|
978
|
-
class
|
|
993
|
+
class Mr {
|
|
979
994
|
#e = /* @__PURE__ */ new Map();
|
|
980
995
|
/**
|
|
981
996
|
* 添加事件监听器
|
|
@@ -1034,7 +1049,7 @@ class $r {
|
|
|
1034
1049
|
return this.#e.set(t, r), r;
|
|
1035
1050
|
}
|
|
1036
1051
|
}
|
|
1037
|
-
const
|
|
1052
|
+
const $r = "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", Rr = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", Ir = (e, ...t) => {
|
|
1038
1053
|
const r = [];
|
|
1039
1054
|
R(e) ? Object.keys(e).sort().forEach((o) => {
|
|
1040
1055
|
const c = e[o];
|
|
@@ -1046,19 +1061,19 @@ const Mr = "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBAD
|
|
|
1046
1061
|
export {
|
|
1047
1062
|
Tt as AsyncQueueExecutor,
|
|
1048
1063
|
Y as BASE_62_DIGITS,
|
|
1049
|
-
|
|
1050
|
-
|
|
1064
|
+
Mr as EventDispatcher,
|
|
1065
|
+
$r as IMAGE_MIN_BASE64_BLACK,
|
|
1051
1066
|
Rr as IMAGE_MIN_BASE64_TRANSPARENT,
|
|
1052
1067
|
ar as IS_BROWSER,
|
|
1053
1068
|
rt as IdleTimer,
|
|
1054
1069
|
nt as LeaderElection,
|
|
1055
|
-
|
|
1056
|
-
|
|
1070
|
+
It as aesDecrypt,
|
|
1071
|
+
xt as aesEncrypt,
|
|
1057
1072
|
T as base64Decode,
|
|
1058
1073
|
S as base64Encode,
|
|
1059
1074
|
pr as camelCase,
|
|
1060
|
-
|
|
1061
|
-
|
|
1075
|
+
jt as canBeDate,
|
|
1076
|
+
xe as canBeNumber,
|
|
1062
1077
|
se as capitalize,
|
|
1063
1078
|
Ge as capitalizeFirst,
|
|
1064
1079
|
ot as checkOPFSAvailable,
|
|
@@ -1066,14 +1081,14 @@ export {
|
|
|
1066
1081
|
Yt as cloneDeep,
|
|
1067
1082
|
dr as compressToBase64Url,
|
|
1068
1083
|
tt as createBroadcastTopic,
|
|
1069
|
-
|
|
1084
|
+
_t as dateStringToDate,
|
|
1070
1085
|
Re as dateStringWithTimezone,
|
|
1071
|
-
|
|
1072
|
-
|
|
1086
|
+
vt as debounce,
|
|
1087
|
+
Nt as decodeJWTPayload,
|
|
1073
1088
|
mr as decompressFromBase64Url,
|
|
1074
1089
|
Be as deepFreeze,
|
|
1075
1090
|
at as difference,
|
|
1076
|
-
|
|
1091
|
+
Wt as emptyFunction,
|
|
1077
1092
|
lt as flatten,
|
|
1078
1093
|
me as flattenDeep,
|
|
1079
1094
|
Xt as flattenPathObjectToPlainObject,
|
|
@@ -1081,7 +1096,7 @@ export {
|
|
|
1081
1096
|
kt as formatPassTime,
|
|
1082
1097
|
g as generateKeyBetween,
|
|
1083
1098
|
K as generateKeysBetween,
|
|
1084
|
-
|
|
1099
|
+
_e as get,
|
|
1085
1100
|
ke as has,
|
|
1086
1101
|
ut as intersection,
|
|
1087
1102
|
b as isArray,
|
|
@@ -1108,18 +1123,18 @@ export {
|
|
|
1108
1123
|
gt as isPrimitive,
|
|
1109
1124
|
wt as isPromise,
|
|
1110
1125
|
At as isRegExp,
|
|
1111
|
-
|
|
1126
|
+
O as isString,
|
|
1112
1127
|
Et as isStringArray,
|
|
1113
1128
|
ge as isSymbol,
|
|
1114
|
-
|
|
1129
|
+
M as isUint8Array,
|
|
1115
1130
|
Ze as kebabCase,
|
|
1116
|
-
|
|
1131
|
+
Ir as logError,
|
|
1117
1132
|
Ft as msTimeToMilliseconds,
|
|
1118
1133
|
St as needArray,
|
|
1119
1134
|
Pt as nextMacroTask,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1135
|
+
Mt as nextMicroTask,
|
|
1136
|
+
Wt as noop,
|
|
1137
|
+
Ne as numberStep,
|
|
1123
1138
|
Zt as numberStepScreenSize,
|
|
1124
1139
|
Ht as numberStrip,
|
|
1125
1140
|
tr as omit,
|
|
@@ -1140,33 +1155,33 @@ export {
|
|
|
1140
1155
|
fr as randomInt,
|
|
1141
1156
|
F as randomString,
|
|
1142
1157
|
hr as randomUintByLength,
|
|
1143
|
-
|
|
1158
|
+
We as randomUintString,
|
|
1144
1159
|
ct as requestIdleCallbackPolyfill,
|
|
1145
1160
|
Ar as rmbUppercase,
|
|
1146
1161
|
Bt as rsaDecrypt,
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1162
|
+
Dt as rsaEncrypt,
|
|
1163
|
+
Lt as rsaGenerateKey,
|
|
1164
|
+
Le as set,
|
|
1150
1165
|
te as setBase,
|
|
1151
|
-
|
|
1166
|
+
je as setWith,
|
|
1152
1167
|
Er as similarity,
|
|
1153
|
-
|
|
1168
|
+
$t as sleep,
|
|
1154
1169
|
Sr as snakeCase,
|
|
1155
|
-
|
|
1170
|
+
Ot as sortBy,
|
|
1156
1171
|
br as startCase,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1172
|
+
Or as stringSingleline,
|
|
1173
|
+
Cr as stringTemplate,
|
|
1174
|
+
J as stringTime,
|
|
1175
|
+
I as stringToArrayBuffer,
|
|
1161
1176
|
Vt as throttle,
|
|
1162
|
-
|
|
1177
|
+
Jt as toInt,
|
|
1163
1178
|
cr as toPlainObject,
|
|
1164
1179
|
Z as traverseObjectKeys,
|
|
1165
|
-
|
|
1180
|
+
Qt as tryToNumber,
|
|
1166
1181
|
Rt as uint8ArrayToString,
|
|
1167
1182
|
Tr as uncapitalize,
|
|
1168
|
-
|
|
1169
|
-
|
|
1183
|
+
Qe as uncapitalizeFirst,
|
|
1184
|
+
Ct as unionBy,
|
|
1170
1185
|
zt as unixTimestamp,
|
|
1171
1186
|
Pr as urlJoin,
|
|
1172
1187
|
ir as zipObject
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloneDeep.d.ts","sourceRoot":"","sources":["../../src/object/cloneDeep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"cloneDeep.d.ts","sourceRoot":"","sources":["../../src/object/cloneDeep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CASvC,CAAC"}
|