esexts 2.2.4 → 2.2.6
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/esexts.d.ts +88 -38
- package/dist/esexts.js +58 -105
- package/dist/polyfill.js +220 -0
- package/dist/util-BwhYR_HP.js +49 -0
- package/package.json +16 -12
- package/dist/esexts.cjs +0 -1
- package/dist/esexts.umd.js +0 -1
package/dist/esexts.d.ts
CHANGED
|
@@ -40,17 +40,32 @@ declare global {
|
|
|
40
40
|
* Object 实例扩展
|
|
41
41
|
*/
|
|
42
42
|
interface Object {
|
|
43
|
+
/**
|
|
44
|
+
* 将值转换为 JSON 字符串
|
|
45
|
+
* @param v 要转换的值
|
|
46
|
+
* @param replacer 替换函数或数组
|
|
47
|
+
* @param space 缩进空格
|
|
48
|
+
* @returns JSON 字符串
|
|
49
|
+
*/
|
|
50
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
51
|
+
|
|
43
52
|
/**
|
|
44
53
|
* 克隆对象
|
|
45
54
|
* @returns 克隆后的新对象
|
|
46
55
|
*/
|
|
47
|
-
$clone():
|
|
56
|
+
$clone(): this;
|
|
48
57
|
|
|
49
58
|
/**
|
|
50
59
|
* 获取对象的长度(属性数量)
|
|
51
60
|
* @returns 对象的属性数量
|
|
52
61
|
*/
|
|
53
62
|
$length(): number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 检查对象是否为空
|
|
66
|
+
* @returns 如果对象为空返回 true,否则返回 false
|
|
67
|
+
*/
|
|
68
|
+
$empty(): boolean;
|
|
54
69
|
|
|
55
70
|
/**
|
|
56
71
|
* 获取对象的键值对迭代器
|
|
@@ -77,15 +92,6 @@ declare global {
|
|
|
77
92
|
*/
|
|
78
93
|
$assign(...sources: any[]): Record<string, any>;
|
|
79
94
|
|
|
80
|
-
/**
|
|
81
|
-
* 将值转换为 JSON 字符串
|
|
82
|
-
* @param v 要转换的值
|
|
83
|
-
* @param replacer 替换函数或数组
|
|
84
|
-
* @param space 缩进空格
|
|
85
|
-
* @returns JSON 字符串
|
|
86
|
-
*/
|
|
87
|
-
$stringify(replacer?: any, space?: string | number): string;
|
|
88
|
-
|
|
89
95
|
/**
|
|
90
96
|
* 合并多个对象到当前对象
|
|
91
97
|
* @param args 要合并的对象列表
|
|
@@ -100,12 +106,6 @@ declare global {
|
|
|
100
106
|
*/
|
|
101
107
|
$concat(...args: Record<string, any>[]): Record<string, any>;
|
|
102
108
|
|
|
103
|
-
/**
|
|
104
|
-
* 检查对象是否为空
|
|
105
|
-
* @returns 如果对象为空返回 true,否则返回 false
|
|
106
|
-
*/
|
|
107
|
-
$empty(): boolean;
|
|
108
|
-
|
|
109
109
|
/**
|
|
110
110
|
* 检查对象是否包含指定键
|
|
111
111
|
* @param key 要检查的键
|
|
@@ -692,11 +692,32 @@ declare global {
|
|
|
692
692
|
* Array 实例扩展
|
|
693
693
|
*/
|
|
694
694
|
interface Array<T> {
|
|
695
|
+
/**
|
|
696
|
+
* 将值转换为 JSON 字符串
|
|
697
|
+
* @param v 要转换的值
|
|
698
|
+
* @param replacer 替换函数或数组
|
|
699
|
+
* @param space 缩进空格
|
|
700
|
+
* @returns JSON 字符串
|
|
701
|
+
*/
|
|
702
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 克隆数组
|
|
706
|
+
* @returns 克隆后的新数组
|
|
707
|
+
*/
|
|
708
|
+
$clone(): this;
|
|
709
|
+
|
|
695
710
|
/**
|
|
696
711
|
* 获取数组长度
|
|
697
712
|
* @returns 数组长度
|
|
698
713
|
*/
|
|
699
714
|
$length(): number;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* 检查数组是否为空
|
|
718
|
+
* @returns 如果数组为空返回 true,否则返回 false
|
|
719
|
+
*/
|
|
720
|
+
$empty(): boolean;
|
|
700
721
|
|
|
701
722
|
/**
|
|
702
723
|
* 获取数组的键值对迭代器
|
|
@@ -715,14 +736,7 @@ declare global {
|
|
|
715
736
|
* @returns 值迭代器
|
|
716
737
|
*/
|
|
717
738
|
$values(): T[];
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* 映射数组元素
|
|
721
|
-
* @param callback 映射函数
|
|
722
|
-
* @returns 映射后的新数组
|
|
723
|
-
*/
|
|
724
|
-
$map<U>(callback: (v: T, i: number, array: T[]) => U): U[];
|
|
725
|
-
|
|
739
|
+
|
|
726
740
|
/**
|
|
727
741
|
* 向数组末尾添加元素, 并返回当前数组
|
|
728
742
|
* @param items 要添加的元素
|
|
@@ -786,12 +800,6 @@ declare global {
|
|
|
786
800
|
*/
|
|
787
801
|
$unshift0(...items: T[]): T;
|
|
788
802
|
|
|
789
|
-
/**
|
|
790
|
-
* 检查数组是否为空
|
|
791
|
-
* @returns 如果数组为空返回 true,否则返回 false
|
|
792
|
-
*/
|
|
793
|
-
$empty(): boolean;
|
|
794
|
-
|
|
795
803
|
/**
|
|
796
804
|
* 获取数组的第一个元素
|
|
797
805
|
* @param defval 默认值
|
|
@@ -951,10 +959,31 @@ declare global {
|
|
|
951
959
|
*/
|
|
952
960
|
interface Map<K, V> {
|
|
953
961
|
/**
|
|
954
|
-
*
|
|
955
|
-
* @
|
|
962
|
+
* 将值转换为 JSON 字符串
|
|
963
|
+
* @param v 要转换的值
|
|
964
|
+
* @param replacer 替换函数或数组
|
|
965
|
+
* @param space 缩进空格
|
|
966
|
+
* @returns JSON 字符串
|
|
967
|
+
*/
|
|
968
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* 克隆 Map
|
|
972
|
+
* @returns 克隆后的新 Map
|
|
973
|
+
*/
|
|
974
|
+
$clone(): this;
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* 获取 Map 长度
|
|
978
|
+
* @returns Map 长度
|
|
956
979
|
*/
|
|
957
980
|
$length(): number;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* 检查 Map 是否为空
|
|
984
|
+
* @returns 如果 Map 为空返回 true,否则返回 false
|
|
985
|
+
*/
|
|
986
|
+
$empty(): boolean;
|
|
958
987
|
|
|
959
988
|
/**
|
|
960
989
|
* 获取 Map 的键值对迭代器
|
|
@@ -1122,28 +1151,49 @@ declare global {
|
|
|
1122
1151
|
*/
|
|
1123
1152
|
interface Set<T> {
|
|
1124
1153
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
* @
|
|
1154
|
+
* 将值转换为 JSON 字符串
|
|
1155
|
+
* @param v 要转换的值
|
|
1156
|
+
* @param replacer 替换函数或数组
|
|
1157
|
+
* @param space 缩进空格
|
|
1158
|
+
* @returns JSON 字符串
|
|
1159
|
+
*/
|
|
1160
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* 克隆 Set
|
|
1164
|
+
* @returns 克隆后的新 Set
|
|
1165
|
+
*/
|
|
1166
|
+
$clone(): this;
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* 获取 Set 长度
|
|
1170
|
+
* @returns Set 长度
|
|
1127
1171
|
*/
|
|
1128
1172
|
$length(): number;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* 检查 Set 是否为空
|
|
1176
|
+
* @returns 如果 Set 为空返回 true,否则返回 false
|
|
1177
|
+
*/
|
|
1178
|
+
$empty(): boolean;
|
|
1129
1179
|
|
|
1130
1180
|
/**
|
|
1131
1181
|
* 获取 Set 的键值对迭代器
|
|
1132
1182
|
* @returns 键值对迭代器
|
|
1133
1183
|
*/
|
|
1134
|
-
$entries():
|
|
1184
|
+
$entries(): [number, T][];
|
|
1135
1185
|
|
|
1136
1186
|
/**
|
|
1137
1187
|
* 获取 Set 的键迭代器
|
|
1138
1188
|
* @returns 键迭代器
|
|
1139
1189
|
*/
|
|
1140
|
-
$keys():
|
|
1190
|
+
$keys(): number[];
|
|
1141
1191
|
|
|
1142
1192
|
/**
|
|
1143
1193
|
* 获取 Set 的值迭代器
|
|
1144
1194
|
* @returns 值迭代器
|
|
1145
1195
|
*/
|
|
1146
|
-
$values():
|
|
1196
|
+
$values(): T[];
|
|
1147
1197
|
|
|
1148
1198
|
/**
|
|
1149
1199
|
* 添加元素, 并返回当前Map
|
|
@@ -1620,7 +1670,7 @@ declare global {
|
|
|
1620
1670
|
* @param callback 异步计算函数
|
|
1621
1671
|
* @returns Promise,解析为值
|
|
1622
1672
|
*/
|
|
1623
|
-
getOrInsertComputedAsync(key: K, callback: (key: K) => Promise<V>): Promise<V>;
|
|
1673
|
+
getOrInsertComputedAsync(key: K, callback: (key: K) => Promise<V | undefined | null>): Promise<V | undefined | null>;
|
|
1624
1674
|
|
|
1625
1675
|
/**
|
|
1626
1676
|
* 设置键值对
|
package/dist/esexts.js
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e, t) {
|
|
3
|
-
return Object.defineProperties(e, Object.fromEntries(Object.keys(t).map((e) => [e, {
|
|
4
|
-
value: t[e],
|
|
5
|
-
enumerable: !1,
|
|
6
|
-
configurable: !0,
|
|
7
|
-
writable: !0
|
|
8
|
-
}])));
|
|
9
|
-
}
|
|
10
|
-
function t() {
|
|
11
|
-
return { new: function(...e) {
|
|
12
|
-
return new this(...e);
|
|
13
|
-
} };
|
|
14
|
-
}
|
|
15
|
-
function n(e, t, n, ...r) {
|
|
16
|
-
let i = {}, a = (e, t, n) => (t !== null && e.splice(t >= 0 ? t : e.length + t + 1, 0, n), e);
|
|
17
|
-
for (let o of r) {
|
|
18
|
-
let [r, s] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replaceAll("-", "_")];
|
|
19
|
-
if (n === "") i[s] = function(...n) {
|
|
20
|
-
return e[r].apply(this, a(n, t, this));
|
|
21
|
-
};
|
|
22
|
-
else if (n === "t") i[s] = function(...n) {
|
|
23
|
-
return e[r].apply(this, a(n, t, this)), this;
|
|
24
|
-
};
|
|
25
|
-
else if (n === "a") i[s] = function(...n) {
|
|
26
|
-
return e[r].apply(this, a(n, t, this)), n;
|
|
27
|
-
};
|
|
28
|
-
else if (n >= 0) i[s] = function(...i) {
|
|
29
|
-
return e[r].apply(this, a(i, t, this)), i[n];
|
|
30
|
-
};
|
|
31
|
-
else if (n < 0) i[s] = function(...i) {
|
|
32
|
-
return e[r].apply(this, a(i, t, this)), i[i.length + n];
|
|
33
|
-
};
|
|
34
|
-
else throw Error("unreachable");
|
|
35
|
-
}
|
|
36
|
-
return i;
|
|
37
|
-
}
|
|
38
|
-
function r(e, ...t) {
|
|
39
|
-
let n = {};
|
|
40
|
-
for (let r of t) {
|
|
41
|
-
let [t, i] = Array.isArray(r) ? r : [r, "$" + r];
|
|
42
|
-
n[i] = function(...n) {
|
|
43
|
-
return [...e[t].apply(this, n)];
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return n;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./util-BwhYR_HP.js";
|
|
49
2
|
//#region lib/Object.js
|
|
50
3
|
function i(e = { array: !1 }) {
|
|
51
4
|
return function(t = {}, ...n) {
|
|
@@ -63,8 +16,8 @@ function i(e = { array: !1 }) {
|
|
|
63
16
|
};
|
|
64
17
|
}
|
|
65
18
|
var a = i({ array: !1 }), o = i({ array: !0 });
|
|
66
|
-
|
|
67
|
-
...
|
|
19
|
+
t(Object, {
|
|
20
|
+
...e(),
|
|
68
21
|
isObject: function(e) {
|
|
69
22
|
return Object.prototype.toString.call(e) === "[object Object]";
|
|
70
23
|
},
|
|
@@ -74,9 +27,9 @@ e(Object, {
|
|
|
74
27
|
concat: function(...e) {
|
|
75
28
|
return o(this, ...e);
|
|
76
29
|
}
|
|
77
|
-
}),
|
|
78
|
-
$stringify: function() {
|
|
79
|
-
return JSON.stringify(this);
|
|
30
|
+
}), t(Object.prototype, {
|
|
31
|
+
$stringify: function(...e) {
|
|
32
|
+
return JSON.stringify(this, ...e);
|
|
80
33
|
},
|
|
81
34
|
$clone: function() {
|
|
82
35
|
return JSON.parse(JSON.stringify(this));
|
|
@@ -87,7 +40,7 @@ e(Object, {
|
|
|
87
40
|
$empty: function() {
|
|
88
41
|
return this.$length() === 0;
|
|
89
42
|
},
|
|
90
|
-
...
|
|
43
|
+
...r(Object, 0, "", "entries", "keys", "values", "assign"),
|
|
91
44
|
$merge: function(...e) {
|
|
92
45
|
return a(this, ...e);
|
|
93
46
|
},
|
|
@@ -127,7 +80,7 @@ e(Object, {
|
|
|
127
80
|
$toArray: function() {
|
|
128
81
|
return Array.isArray(this) ? this : [this];
|
|
129
82
|
},
|
|
130
|
-
...
|
|
83
|
+
...r(console, -1, "t", ["debug", "$debug"], ["log", "$log"], ["info", "$info"], ["warn", "$warn"], ["error", "$error"], ["dir", "$dir"]),
|
|
131
84
|
$debugger: function(...e) {
|
|
132
85
|
return console.debug(this, ...e), this;
|
|
133
86
|
},
|
|
@@ -163,8 +116,8 @@ e(Object, {
|
|
|
163
116
|
for (let t of this[r]) o.push(t.$tree$map(e, !0, n - 1, r, i));
|
|
164
117
|
return a[r] = o, a;
|
|
165
118
|
}
|
|
166
|
-
}),
|
|
167
|
-
...
|
|
119
|
+
}), t(Number.prototype, {
|
|
120
|
+
...r(Math, 0, "", ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
|
|
168
121
|
fixed: function(e = 0) {
|
|
169
122
|
return +this.toFixed(e);
|
|
170
123
|
},
|
|
@@ -207,9 +160,9 @@ e(Object, {
|
|
|
207
160
|
toDate: function() {
|
|
208
161
|
return Date.new(this);
|
|
209
162
|
}
|
|
210
|
-
}),
|
|
163
|
+
}), t(BigInt.prototype, { toJSON: function() {
|
|
211
164
|
return this >= BigInt(-(2 ** 53 - 1)) && this <= BigInt(2 ** 53 - 1) ? Number(this) : this.toString();
|
|
212
|
-
} }),
|
|
165
|
+
} }), t(String, { ...e() }), t(String.prototype, {
|
|
213
166
|
$length: function() {
|
|
214
167
|
return this.length;
|
|
215
168
|
},
|
|
@@ -290,8 +243,8 @@ e(Object, {
|
|
|
290
243
|
base64decode: function() {
|
|
291
244
|
return new TextDecoder().decode(Uint8Array.fromBase64(this));
|
|
292
245
|
}
|
|
293
|
-
}),
|
|
294
|
-
...
|
|
246
|
+
}), t(Array, {
|
|
247
|
+
...e(),
|
|
295
248
|
range: function(...e) {
|
|
296
249
|
let t = [], n = 0, r = 0, i = 1, a = typeof e[e.length - 1] == "boolean" ? e.pop() : !0, o = typeof e[e.length - 1] == "function" ? e.pop() : (e, t, n) => e;
|
|
297
250
|
switch (e.length) {
|
|
@@ -310,14 +263,14 @@ e(Object, {
|
|
|
310
263
|
for (let e = 0, s = 0, c = Math.abs(r - n), l = Math.abs(i), u = n <= r ? 1 : -1; s < c; s += l) t.push(a ? o(n + s * u, e++, t) : o());
|
|
311
264
|
return t;
|
|
312
265
|
}
|
|
313
|
-
}),
|
|
266
|
+
}), t(Array.prototype, {
|
|
314
267
|
$length: function() {
|
|
315
268
|
return this.length;
|
|
316
269
|
},
|
|
317
|
-
...
|
|
318
|
-
...
|
|
319
|
-
...
|
|
320
|
-
...
|
|
270
|
+
...n(Array.prototype, "entries", "keys", "values"),
|
|
271
|
+
...r(Array.prototype, null, "t", ["push", "$push"], ["pop", "$pop"], ["shift", "$shift"], ["unshift", "$unshift"], ["splice", "$splice"]),
|
|
272
|
+
...r(Array.prototype, null, "a", "push", "unshift"),
|
|
273
|
+
...r(Array.prototype, null, 0, "push", "unshift"),
|
|
321
274
|
first: function(e = null) {
|
|
322
275
|
return this.length ? this[0] : e;
|
|
323
276
|
},
|
|
@@ -334,7 +287,7 @@ e(Object, {
|
|
|
334
287
|
let t = /* @__PURE__ */ new Set();
|
|
335
288
|
return this.filter((n) => t.has(e(n)) ? !1 : !!t.add(e(n)));
|
|
336
289
|
},
|
|
337
|
-
...
|
|
290
|
+
...r(Array.prototype, null, "t", ["forEach", "each"]),
|
|
338
291
|
each$async: async function(e) {
|
|
339
292
|
for (let t = 0; t < this.length; t++) await e(this[t], t, this);
|
|
340
293
|
return this;
|
|
@@ -386,23 +339,23 @@ e(Object, {
|
|
|
386
339
|
let r = this.unique$((t) => t[e]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
|
|
387
340
|
return this.each$((n) => n[t] = i[n[e]] ?? null);
|
|
388
341
|
},
|
|
389
|
-
toTree: function(
|
|
390
|
-
let { id: n = "id", pid: r = "pid", level: i = "level", root: a = "root", parent: o = "parent", children: s = "children", empty: c = null, hasRoot: l = !0 } =
|
|
342
|
+
toTree: function(e = {}) {
|
|
343
|
+
let { id: n = "id", pid: r = "pid", level: i = "level", root: a = "root", parent: o = "parent", children: s = "children", empty: c = null, hasRoot: l = !0 } = e, u = this.reduce((e, t) => e.$attr(t[n], t), {}), d = this.reduce((e, t) => (e.$attr(t[r], [], { exists: !1 }).$attr(t[r]).$push(t), e), {}), f = this.length && l ? this.find((e) => e[r] === 0) : {
|
|
391
344
|
[n]: 0,
|
|
392
345
|
[r]: -1,
|
|
393
346
|
[a]: null,
|
|
394
347
|
[o]: null,
|
|
395
348
|
[s]: d[0]
|
|
396
349
|
};
|
|
397
|
-
|
|
398
|
-
for (let
|
|
350
|
+
t(f, { [a]: f });
|
|
351
|
+
for (let e of this) t(e, {
|
|
399
352
|
[a]: f,
|
|
400
|
-
[o]: u[
|
|
401
|
-
}),
|
|
353
|
+
[o]: u[e[r]]
|
|
354
|
+
}), e[s] = d[e[n]] || c;
|
|
402
355
|
return f.$tree$each((e) => e[i] = e[o] ? e[o][i] + 1 : 0, -1, s), f;
|
|
403
356
|
},
|
|
404
|
-
$tree2tree: function(
|
|
405
|
-
let { id: i = "id", pid: a = "pid", level: o = "level", root: s = "root", parent: c = "parent", children: l = "children", empty: u = null } =
|
|
357
|
+
$tree2tree: function(e = {}, n = null, r = null) {
|
|
358
|
+
let { id: i = "id", pid: a = "pid", level: o = "level", root: s = "root", parent: c = "parent", children: l = "children", empty: u = null } = e;
|
|
406
359
|
n ||= {
|
|
407
360
|
[i]: 0,
|
|
408
361
|
[a]: -1,
|
|
@@ -411,10 +364,10 @@ e(Object, {
|
|
|
411
364
|
[c]: null,
|
|
412
365
|
[l]: this
|
|
413
366
|
}, r ||= n;
|
|
414
|
-
for (let d of this)
|
|
367
|
+
for (let d of this) t(d, {
|
|
415
368
|
[s]: n,
|
|
416
369
|
[c]: r
|
|
417
|
-
}), d[a] = r[i], d[o] = r[o] + 1, d[l] = d[l] && d[l].length ? d[l] : u, d[l]?.$tree2tree(
|
|
370
|
+
}), d[a] = r[i], d[o] = r[o] + 1, d[l] = d[l] && d[l].length ? d[l] : u, d[l]?.$tree2tree(e, n, d);
|
|
418
371
|
return n;
|
|
419
372
|
},
|
|
420
373
|
$tree$find: function(e, t = !0, n = -1, r = "children") {
|
|
@@ -431,18 +384,18 @@ e(Object, {
|
|
|
431
384
|
$tree$map: function(e, t = !0, n = -1, r = "children", i = null) {
|
|
432
385
|
return this.map((a) => a.$tree$map(e, t, n, r, i));
|
|
433
386
|
}
|
|
434
|
-
}),
|
|
387
|
+
}), t(Map, { ...e() }), t(Map.prototype, {
|
|
435
388
|
$clone: function() {
|
|
436
389
|
return new Map(JSON.parse(JSON.stringify(this)));
|
|
437
390
|
},
|
|
438
391
|
$length: function() {
|
|
439
392
|
return this.size;
|
|
440
393
|
},
|
|
441
|
-
...
|
|
442
|
-
...
|
|
443
|
-
...
|
|
444
|
-
...
|
|
445
|
-
...
|
|
394
|
+
...n(Map.prototype, "entries", "keys", "values"),
|
|
395
|
+
...r(Map.prototype, null, "t", ["set", "$set"], ["delete", "$delete"]),
|
|
396
|
+
...r(Map.prototype, null, "a", "set", "delete"),
|
|
397
|
+
...r(Map.prototype, null, 0, "set", "delete"),
|
|
398
|
+
...r(Map.prototype, null, 1, "set", "delete"),
|
|
446
399
|
$getOrInsert: function(e, t = null) {
|
|
447
400
|
return this.has(e) ? this.get(e) : this.$set1(e, t);
|
|
448
401
|
},
|
|
@@ -464,20 +417,20 @@ e(Object, {
|
|
|
464
417
|
toJSON: function() {
|
|
465
418
|
return [...this];
|
|
466
419
|
}
|
|
467
|
-
}), Map.prototype.getOrInsert === void 0 && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed),
|
|
420
|
+
}), Map.prototype.getOrInsert === void 0 && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed), t(Set, { ...e() }), t(Set.prototype, {
|
|
468
421
|
$clone: function() {
|
|
469
422
|
return new Set(JSON.parse(JSON.stringify(this)));
|
|
470
423
|
},
|
|
471
424
|
$length: function() {
|
|
472
425
|
return this.size;
|
|
473
426
|
},
|
|
474
|
-
...
|
|
475
|
-
...
|
|
476
|
-
...
|
|
477
|
-
...
|
|
478
|
-
...
|
|
427
|
+
...n(Set.prototype, "entries", "keys", "values"),
|
|
428
|
+
...r(Set.prototype, null, "t", ["add", "$add"], ["delete", "$delete"]),
|
|
429
|
+
...r(Set.prototype, null, "a", "add", "delete"),
|
|
430
|
+
...r(Set.prototype, null, 0, "add", "delete"),
|
|
431
|
+
...r(Set.prototype, null, 1, "add", "delete"),
|
|
479
432
|
$union: function(e) {
|
|
480
|
-
return new Set([...this, ...e]);
|
|
433
|
+
return /* @__PURE__ */ new Set([...this, ...e]);
|
|
481
434
|
},
|
|
482
435
|
$intersection: function(e) {
|
|
483
436
|
return new Set([...this].filter((t) => e.has(t)));
|
|
@@ -486,7 +439,7 @@ e(Object, {
|
|
|
486
439
|
return new Set([...this].filter((t) => !e.has(t)));
|
|
487
440
|
},
|
|
488
441
|
$symmetricDifference: function(e) {
|
|
489
|
-
return new Set([...[...this].filter((t) => !e.has(t)), ...[...e].filter((e) => !this.has(e))]);
|
|
442
|
+
return /* @__PURE__ */ new Set([...[...this].filter((t) => !e.has(t)), ...[...e].filter((e) => !this.has(e))]);
|
|
490
443
|
},
|
|
491
444
|
toArray: function() {
|
|
492
445
|
return [...this];
|
|
@@ -494,7 +447,7 @@ e(Object, {
|
|
|
494
447
|
toJSON: function() {
|
|
495
448
|
return [...this];
|
|
496
449
|
}
|
|
497
|
-
}), Set.prototype.union === void 0 && (Set.prototype.union = Set.prototype.$union, Set.prototype.intersection = Set.prototype.$intersection, Set.prototype.difference = Set.prototype.$difference, Set.prototype.symmetricDifference = Set.prototype.$symmetricDifference),
|
|
450
|
+
}), Set.prototype.union === void 0 && (Set.prototype.union = Set.prototype.$union, Set.prototype.intersection = Set.prototype.$intersection, Set.prototype.difference = Set.prototype.$difference, Set.prototype.symmetricDifference = Set.prototype.$symmetricDifference), t(Date, {
|
|
498
451
|
new: function(...e) {
|
|
499
452
|
return e.length == 1 ? Number.isNaN(+e[0]) ? new Date(e[0].includes("T") ? e[0] : e[0].replace(/-/g, "/")) : new Date(e[0] > 25e8 ? e[0] : e[0] * 1e3) : new Date(...e);
|
|
500
453
|
},
|
|
@@ -528,7 +481,7 @@ e(Object, {
|
|
|
528
481
|
let e = (/* @__PURE__ */ new Date()).getFullYear();
|
|
529
482
|
return [new Date(e, 1, 1).getTime() / 1e3 | 0, new Date(e + 1, 1, 0, 23, 59, 59).getTime() / 1e3 | 0];
|
|
530
483
|
}
|
|
531
|
-
}),
|
|
484
|
+
}), t(Date.prototype, {
|
|
532
485
|
format: function(e = "y-m-d h:i:s") {
|
|
533
486
|
if (this.getTime() === 0) return "-";
|
|
534
487
|
let t = {
|
|
@@ -611,10 +564,10 @@ e(Object, {
|
|
|
611
564
|
toJSON: function() {
|
|
612
565
|
return this.getTime();
|
|
613
566
|
}
|
|
614
|
-
}),
|
|
567
|
+
}), t(RegExp, { ...e() }), t(RegExp.prototype, { toJSON: function() {
|
|
615
568
|
return this.toString();
|
|
616
|
-
} }),
|
|
617
|
-
...
|
|
569
|
+
} }), t(Promise, {
|
|
570
|
+
...e(),
|
|
618
571
|
$channel: function() {
|
|
619
572
|
let e = null, t = null;
|
|
620
573
|
return [
|
|
@@ -635,21 +588,21 @@ e(Object, {
|
|
|
635
588
|
reject: t
|
|
636
589
|
};
|
|
637
590
|
}
|
|
638
|
-
}),
|
|
591
|
+
}), t(Promise.prototype, { tryCatch: function() {
|
|
639
592
|
return new Promise((e) => this.then((t) => e([t, null])).catch((t) => e([null, t])));
|
|
640
|
-
} }), Promise.withResolvers === void 0 && (Promise.withResolvers = Promise.$withResolvers),
|
|
593
|
+
} }), Promise.withResolvers === void 0 && (Promise.withResolvers = Promise.$withResolvers), t(JSON, { $parse: function(e, t = null) {
|
|
641
594
|
try {
|
|
642
595
|
if (typeof e != "string") throw Error("not string");
|
|
643
596
|
return JSON.parse(e);
|
|
644
597
|
} catch {
|
|
645
598
|
return t;
|
|
646
599
|
}
|
|
647
|
-
} }), typeof Iterator < "u" &&
|
|
600
|
+
} }), typeof Iterator < "u" && t(Iterator.prototype, { toArray: function() {
|
|
648
601
|
return [...this];
|
|
649
|
-
} }),
|
|
602
|
+
} }), t(ArrayBuffer.prototype, { toUint8Array: function() {
|
|
650
603
|
return new Uint8Array(this);
|
|
651
|
-
} }),
|
|
652
|
-
...
|
|
604
|
+
} }), t(Uint8Array, {
|
|
605
|
+
...e(),
|
|
653
606
|
fromString: function(e) {
|
|
654
607
|
return new TextEncoder().encode(e);
|
|
655
608
|
},
|
|
@@ -675,7 +628,7 @@ e(Object, {
|
|
|
675
628
|
}
|
|
676
629
|
return new Uint8Array(t);
|
|
677
630
|
}
|
|
678
|
-
}),
|
|
631
|
+
}), t(Uint8Array.prototype, {
|
|
679
632
|
setFromString(e, t = 0) {
|
|
680
633
|
let n = Uint8Array.fromString(e);
|
|
681
634
|
return this.set(n, t), {
|
|
@@ -728,7 +681,7 @@ e(Object, {
|
|
|
728
681
|
//#endregion
|
|
729
682
|
//#region lib/Math.js
|
|
730
683
|
var s = 0, c = 0, l = 0;
|
|
731
|
-
|
|
684
|
+
t(Math, {
|
|
732
685
|
randstr: function(e = 16, t = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
|
|
733
686
|
if (e < t) throw Error("randstr: len < slen");
|
|
734
687
|
let i = [];
|
|
@@ -810,5 +763,5 @@ var u = class extends Map {
|
|
|
810
763
|
return this.set(e, t);
|
|
811
764
|
}
|
|
812
765
|
};
|
|
813
|
-
|
|
766
|
+
globalThis.LRU === void 0 && (globalThis.LRU = u), t(globalThis.LRU, { ...e() });
|
|
814
767
|
//#endregion
|
package/dist/polyfill.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { i as e, n as t } from "./util-BwhYR_HP.js";
|
|
2
|
+
//#region lib/TextDecoder.js
|
|
3
|
+
var n = class {
|
|
4
|
+
decode(e) {
|
|
5
|
+
let t = "";
|
|
6
|
+
for (let n = 0; n < e.length; n++) t += "%" + (e[n] < 16 ? "0" : "") + e[n].toString(16);
|
|
7
|
+
return decodeURIComponent(t);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
globalThis.TextDecoder === void 0 && (globalThis.TextDecoder = n), t(globalThis.TextDecoder, { ...e() });
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region lib/TextEncoder.js
|
|
13
|
+
var r = class {
|
|
14
|
+
encode(e) {
|
|
15
|
+
let t = [], n = encodeURIComponent(e);
|
|
16
|
+
for (let e = 0; e < n.length;) t.push(n.charAt(e) == "%" ? Number.parseInt(n.substring(e + 1, e += 3), 16) : n.codePointAt(e++));
|
|
17
|
+
return new Uint8Array(t);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
globalThis.TextEncoder === void 0 && (globalThis.TextEncoder = r), t(globalThis.TextEncoder, { ...e() });
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region lib/URLSearchParams.js
|
|
23
|
+
var i = class e {
|
|
24
|
+
#e = [];
|
|
25
|
+
constructor(t = void 0) {
|
|
26
|
+
if (t == null) {
|
|
27
|
+
if (t instanceof e) for (let [e, n] of t) this.append(e, n);
|
|
28
|
+
else if (typeof t == "string") this.#t(t);
|
|
29
|
+
else if (typeof t == "object") for (let e of Object.keys(t)) {
|
|
30
|
+
let n = t[e];
|
|
31
|
+
if (Array.isArray(n)) for (let t of n) this.append(e, t);
|
|
32
|
+
else this.append(e, n);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
#t(e) {
|
|
37
|
+
this.#e = [];
|
|
38
|
+
let t = e.indexOf("?"), n = e.indexOf("#");
|
|
39
|
+
if (t != -1 && (e = e.slice(t + 1)), n != -1 && (e = e.slice(0, n)), e) for (let [t, n = ""] of e.split("&").map((e) => e.split("="))) this.append(decodeURIComponent(t), decodeURIComponent(n));
|
|
40
|
+
}
|
|
41
|
+
delete(e) {
|
|
42
|
+
this.#e = this.#e.filter(([t]) => t !== e);
|
|
43
|
+
}
|
|
44
|
+
append(e, t) {
|
|
45
|
+
this.#e.push([e, t]);
|
|
46
|
+
}
|
|
47
|
+
set(e, t) {
|
|
48
|
+
this.delete(e), this.append(e, t);
|
|
49
|
+
}
|
|
50
|
+
get(e) {
|
|
51
|
+
return this.#e.find(([t]) => t === e)?.[1];
|
|
52
|
+
}
|
|
53
|
+
getAll(e) {
|
|
54
|
+
return this.#e.find(([t]) => t === e).map(([e, t]) => t);
|
|
55
|
+
}
|
|
56
|
+
has(e) {
|
|
57
|
+
return this.#e.some(([t]) => t === e);
|
|
58
|
+
}
|
|
59
|
+
sort() {
|
|
60
|
+
this.#e.sort((e, t) => e[0] === t[0] ? 0 : e[0] < t[0] ? -1 : 1);
|
|
61
|
+
}
|
|
62
|
+
get size() {
|
|
63
|
+
return this.#e.length;
|
|
64
|
+
}
|
|
65
|
+
toString() {
|
|
66
|
+
return this.#e.map(([e, t]) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
|
|
67
|
+
}
|
|
68
|
+
*entries() {
|
|
69
|
+
for (let [e, t] of this.#e) yield [e, t];
|
|
70
|
+
}
|
|
71
|
+
*keys() {
|
|
72
|
+
for (let [e] of this.#e) yield e;
|
|
73
|
+
}
|
|
74
|
+
*values() {
|
|
75
|
+
for (let [, e] of this.#e) yield e;
|
|
76
|
+
}
|
|
77
|
+
[Symbol.iterator]() {
|
|
78
|
+
return this.entries();
|
|
79
|
+
}
|
|
80
|
+
forEach(e, t) {
|
|
81
|
+
for (let [n, r] of this.#e) e.call(t, r, n, this);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
globalThis.URLSearchParams === void 0 && (globalThis.URLSearchParams = i), t(globalThis.URLSearchParams, { ...e() });
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region lib/URL.js
|
|
87
|
+
function a(e) {
|
|
88
|
+
let t = e.match(/^([^:\/?#.]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?([^:\/?#]*)(?::(\d*))?)?([^?#]*)(\?[^#]*)?(#.*)?$/);
|
|
89
|
+
if (!t) throw TypeError("Invalid URL");
|
|
90
|
+
let [, n = "", r = "", i = "", a = "", o = "", s = "", c = "", l = ""] = t;
|
|
91
|
+
return {
|
|
92
|
+
protocol: n,
|
|
93
|
+
username: r,
|
|
94
|
+
password: i,
|
|
95
|
+
hostname: a,
|
|
96
|
+
port: o,
|
|
97
|
+
pathname: s || (a ? "/" : ""),
|
|
98
|
+
search: c,
|
|
99
|
+
hash: l
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function o(e, t) {
|
|
103
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)) return e;
|
|
104
|
+
if (e.startsWith("//")) return (t.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:/)?.[0] ?? "http:") + e;
|
|
105
|
+
let n = new s(t);
|
|
106
|
+
if (e.startsWith("/")) return n.protocol + "//" + n.host + e;
|
|
107
|
+
if (e.startsWith("?")) return n.protocol + "//" + n.host + n.pathname + e;
|
|
108
|
+
if (e.startsWith("#")) return n.protocol + "//" + n.host + n.pathname + n.search + e;
|
|
109
|
+
let r = n.pathname;
|
|
110
|
+
r.endsWith("/") || (r += "/");
|
|
111
|
+
let i = (r + e).split("/"), a = [];
|
|
112
|
+
for (let e of i) e === ".." ? a.pop() : e !== "." && a.push(e);
|
|
113
|
+
return n.protocol + "//" + n.host + a.join("/");
|
|
114
|
+
}
|
|
115
|
+
var s = class e {
|
|
116
|
+
static createObjectURL(e) {
|
|
117
|
+
throw Error("Not implemented");
|
|
118
|
+
}
|
|
119
|
+
static revokeObjectURL(e) {}
|
|
120
|
+
static canParse(e) {
|
|
121
|
+
try {
|
|
122
|
+
return a(e), !0;
|
|
123
|
+
} catch {
|
|
124
|
+
return !1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
static parse(t, n = void 0) {
|
|
128
|
+
return new e(t, n);
|
|
129
|
+
}
|
|
130
|
+
#e = "";
|
|
131
|
+
#t = "";
|
|
132
|
+
#n = "";
|
|
133
|
+
#r = "";
|
|
134
|
+
#i = "";
|
|
135
|
+
#a = "";
|
|
136
|
+
#o = "";
|
|
137
|
+
#s = "";
|
|
138
|
+
#c = null;
|
|
139
|
+
constructor(t, n = void 0) {
|
|
140
|
+
this.href = n ? o(n instanceof e ? n.href : baseurl, fullUrl) : t;
|
|
141
|
+
}
|
|
142
|
+
set href(e) {
|
|
143
|
+
let t = a(e);
|
|
144
|
+
this.#e = t.protocol, this.#t = t.username, this.#n = t.password, this.#r = t.hostname, this.#i = t.port, this.#a = t.pathname, this.#o = t.search, this.#s = t.hash, this.#c = new URLSearchParams(this.#o);
|
|
145
|
+
}
|
|
146
|
+
get href() {
|
|
147
|
+
let e = this.#i ? ":" + this.#i : "", t = this.#t || this.#n ? this.#t + (this.#n ? ":" + this.#n : "") + "@" : "", n = this.#a || "/";
|
|
148
|
+
return this.#e + "//" + t + this.#r + e + n + this.#o + this.#s;
|
|
149
|
+
}
|
|
150
|
+
set origin(e) {}
|
|
151
|
+
get origin() {
|
|
152
|
+
if (!this.#r) return "null";
|
|
153
|
+
let e = this.#i && !(this.#e === "http:" && this.#i === "80" || this.#e === "https:" && this.#i === "443") ? ":" + this.#i : "";
|
|
154
|
+
return this.#e + "//" + this.#r + e;
|
|
155
|
+
}
|
|
156
|
+
set protocol(e) {
|
|
157
|
+
this.#e = e.endsWith(":") ? e : e + ":";
|
|
158
|
+
}
|
|
159
|
+
get protocol() {
|
|
160
|
+
return this.#e;
|
|
161
|
+
}
|
|
162
|
+
set username(e) {
|
|
163
|
+
this.#t = e, this._invalidate();
|
|
164
|
+
}
|
|
165
|
+
get username() {
|
|
166
|
+
return this.#t;
|
|
167
|
+
}
|
|
168
|
+
set password(e) {
|
|
169
|
+
this.#n = e, this._invalidate();
|
|
170
|
+
}
|
|
171
|
+
get password() {
|
|
172
|
+
return this.#n;
|
|
173
|
+
}
|
|
174
|
+
set host(e) {}
|
|
175
|
+
get host() {
|
|
176
|
+
return this.#r + (this.port ? ":" + this.port : "");
|
|
177
|
+
}
|
|
178
|
+
set hostname(e) {
|
|
179
|
+
this.#r = e, this._invalidate();
|
|
180
|
+
}
|
|
181
|
+
get hostname() {
|
|
182
|
+
return this.#r;
|
|
183
|
+
}
|
|
184
|
+
set port(e) {
|
|
185
|
+
this.#i = e;
|
|
186
|
+
}
|
|
187
|
+
get port() {
|
|
188
|
+
return this.#i;
|
|
189
|
+
}
|
|
190
|
+
set pathname(e) {
|
|
191
|
+
this.#a = v.startsWith("/") ? e : "/" + e;
|
|
192
|
+
}
|
|
193
|
+
get pathname() {
|
|
194
|
+
return this.#a;
|
|
195
|
+
}
|
|
196
|
+
set search(e) {
|
|
197
|
+
this.#o = e ? e.startsWith("?") ? v : "?" + v : "", this.#c = new URLSearchParams(this.#o);
|
|
198
|
+
}
|
|
199
|
+
get search() {
|
|
200
|
+
return this.#o;
|
|
201
|
+
}
|
|
202
|
+
set hash(e) {
|
|
203
|
+
this.#s = e ? e.startsWith("#") ? v : "#" + v : "";
|
|
204
|
+
}
|
|
205
|
+
get hash() {
|
|
206
|
+
return this.#s;
|
|
207
|
+
}
|
|
208
|
+
set searchParams(e) {}
|
|
209
|
+
get searchParams() {
|
|
210
|
+
return this.#c;
|
|
211
|
+
}
|
|
212
|
+
toString() {
|
|
213
|
+
return this.href;
|
|
214
|
+
}
|
|
215
|
+
toJSON() {
|
|
216
|
+
return this.href;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
globalThis.URL === void 0 && (globalThis.URL = s), t(globalThis.URL, { ...e() });
|
|
220
|
+
//#endregion
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region lib/util.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return Object.defineProperties(e, Object.fromEntries(Object.keys(t).map((e) => [e, {
|
|
4
|
+
value: t[e],
|
|
5
|
+
enumerable: !1,
|
|
6
|
+
configurable: !0,
|
|
7
|
+
writable: !0
|
|
8
|
+
}])));
|
|
9
|
+
}
|
|
10
|
+
function t() {
|
|
11
|
+
return { new: function(...e) {
|
|
12
|
+
return new this(...e);
|
|
13
|
+
} };
|
|
14
|
+
}
|
|
15
|
+
function n(e, t, n, ...r) {
|
|
16
|
+
let i = {}, a = (e, t, n) => (t !== null && e.splice(t >= 0 ? t : e.length + t + 1, 0, n), e);
|
|
17
|
+
for (let o of r) {
|
|
18
|
+
let [r, s] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replace(/-/g, "_")];
|
|
19
|
+
if (n === "") i[s] = function(...n) {
|
|
20
|
+
return e[r].apply(this, a(n, t, this));
|
|
21
|
+
};
|
|
22
|
+
else if (n === "t") i[s] = function(...n) {
|
|
23
|
+
return e[r].apply(this, a(n, t, this)), this;
|
|
24
|
+
};
|
|
25
|
+
else if (n === "a") i[s] = function(...n) {
|
|
26
|
+
return e[r].apply(this, a(n, t, this)), n;
|
|
27
|
+
};
|
|
28
|
+
else if (n >= 0) i[s] = function(...i) {
|
|
29
|
+
return e[r].apply(this, a(i, t, this)), i[n];
|
|
30
|
+
};
|
|
31
|
+
else if (n < 0) i[s] = function(...i) {
|
|
32
|
+
return e[r].apply(this, a(i, t, this)), i[i.length + n];
|
|
33
|
+
};
|
|
34
|
+
else throw Error("unreachable");
|
|
35
|
+
}
|
|
36
|
+
return i;
|
|
37
|
+
}
|
|
38
|
+
function r(e, ...t) {
|
|
39
|
+
let n = {};
|
|
40
|
+
for (let r of t) {
|
|
41
|
+
let [t, i] = Array.isArray(r) ? r : [r, "$" + r];
|
|
42
|
+
n[i] = function(...n) {
|
|
43
|
+
return [...e[t].apply(this, n)];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { t as i, e as n, r, n as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esexts",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "esexts",
|
|
5
5
|
"author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
|
|
6
6
|
"homepage": "https://github.com/dotcoo/esexts#readme",
|
|
@@ -18,21 +18,25 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"main": "./dist/esexts.
|
|
21
|
+
"main": "./dist/esexts.js",
|
|
22
22
|
"exports": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"vite": "^8.0.16",
|
|
31
|
-
"vite-plugin-dts": "^5.0.2"
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/esexts.d.ts",
|
|
25
|
+
"import": "./dist/esexts.js"
|
|
26
|
+
},
|
|
27
|
+
"/polyfill": {
|
|
28
|
+
"import": "./dist/esexts.js"
|
|
29
|
+
}
|
|
32
30
|
},
|
|
33
31
|
"scripts": {
|
|
34
32
|
"dev": "vite",
|
|
35
33
|
"build": "vite build",
|
|
36
34
|
"preview": "vite preview"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"vite": "^8.1.3",
|
|
39
|
+
"vite-plugin-dts": "^5.0.3",
|
|
40
|
+
"vite-plugin-static-copy": "^4.1.1"
|
|
37
41
|
}
|
|
38
|
-
}
|
|
42
|
+
}
|
package/dist/esexts.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(){return JSON.stringify(this)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u);
|
package/dist/esexts.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(){return JSON.stringify(this)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u)});
|