esexts 1.4.2 → 1.5.0
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.js +214 -178
- package/dist/esexts.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/esexts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(t, e) {
|
|
2
2
|
return Object.defineProperties(t, Object.fromEntries(Object.keys(e).map((n) => [n, { value: e[n], enumerable: !1, configurable: !0, writable: !0 }])));
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function y() {
|
|
5
5
|
return {
|
|
6
6
|
new: function(...t) {
|
|
7
7
|
return new this(...t);
|
|
@@ -16,68 +16,95 @@ function d(...t) {
|
|
|
16
16
|
};
|
|
17
17
|
return e;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
for (const [
|
|
22
|
-
e
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
e
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
19
|
+
function a(t, e, n, ...r) {
|
|
20
|
+
const i = {};
|
|
21
|
+
for (const [u, s] of r) {
|
|
22
|
+
if (e === null && n === null) {
|
|
23
|
+
i[s] = function(...o) {
|
|
24
|
+
return t[u].apply(this, o);
|
|
25
|
+
};
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (e === null && n === !1) {
|
|
29
|
+
i[s] = function(...o) {
|
|
30
|
+
return t[u].apply(this, o), this;
|
|
31
|
+
};
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (e === null && n === !0) {
|
|
35
|
+
i[s] = function(...o) {
|
|
36
|
+
return t[u].apply(this, o), o;
|
|
37
|
+
};
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (e === null && n > 0) {
|
|
41
|
+
i[s] = function(...o) {
|
|
42
|
+
return t[u].apply(this, o), o[n - 1];
|
|
43
|
+
};
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (e === null && n < 0) {
|
|
47
|
+
i[s] = function(...o) {
|
|
48
|
+
return t[u].apply(this, o), o[o.length + n + 1];
|
|
49
|
+
};
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (e !== null && n === null) {
|
|
53
|
+
i[s] = function(...o) {
|
|
54
|
+
return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o);
|
|
55
|
+
};
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (e !== null && n === !1) {
|
|
59
|
+
i[s] = function(...o) {
|
|
60
|
+
return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), this;
|
|
61
|
+
};
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (e !== null && n === !0) {
|
|
65
|
+
i[s] = function(...o) {
|
|
66
|
+
return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o;
|
|
67
|
+
};
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (e !== null && n > 0) {
|
|
71
|
+
i[s] = function(...o) {
|
|
72
|
+
return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o[n - 1];
|
|
73
|
+
};
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (e !== null && n < 0) {
|
|
77
|
+
i[s] = function(...o) {
|
|
78
|
+
return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o[o.length + n + 1];
|
|
79
|
+
};
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
throw Error("unreachable");
|
|
83
|
+
}
|
|
84
|
+
return i;
|
|
58
85
|
}
|
|
59
|
-
function
|
|
86
|
+
function m(t, ...e) {
|
|
60
87
|
const n = {};
|
|
61
88
|
for (const [r, i] of e)
|
|
62
|
-
n[i] = function(...
|
|
63
|
-
return t[r](this,
|
|
89
|
+
n[i] = function(...u) {
|
|
90
|
+
return [...t[r].apply(this, u)];
|
|
64
91
|
};
|
|
65
92
|
return n;
|
|
66
93
|
}
|
|
67
94
|
function M(t = { array: !1 }) {
|
|
68
95
|
return function(e = {}, ...n) {
|
|
69
|
-
const r = (i,
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
73
|
-
if (
|
|
74
|
-
return t.array ? i.concat(...
|
|
75
|
-
if (
|
|
76
|
-
for (const
|
|
77
|
-
i[
|
|
96
|
+
const r = (i, u) => {
|
|
97
|
+
const s = Object.prototype.toString.call(i), o = Object.prototype.toString.call(u);
|
|
98
|
+
if (s !== o)
|
|
99
|
+
return u;
|
|
100
|
+
if (s === "[object Array]")
|
|
101
|
+
return t.array ? i.concat(...u) : u;
|
|
102
|
+
if (s === "[object Object]") {
|
|
103
|
+
for (const c in u)
|
|
104
|
+
i[c] = r(i[c], u[c]);
|
|
78
105
|
return i;
|
|
79
106
|
} else
|
|
80
|
-
return
|
|
107
|
+
return u;
|
|
81
108
|
};
|
|
82
109
|
for (const i of n)
|
|
83
110
|
e = r(e, i);
|
|
@@ -85,7 +112,7 @@ function M(t = { array: !1 }) {
|
|
|
85
112
|
};
|
|
86
113
|
}
|
|
87
114
|
const D = M({ array: !1 }), F = M({ array: !0 });
|
|
88
|
-
|
|
115
|
+
l(Object, {
|
|
89
116
|
isObject: function(t) {
|
|
90
117
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
91
118
|
},
|
|
@@ -96,14 +123,14 @@ u(Object, {
|
|
|
96
123
|
return F(this, ...t);
|
|
97
124
|
}
|
|
98
125
|
});
|
|
99
|
-
|
|
126
|
+
l(Object.prototype, {
|
|
100
127
|
clone0: function() {
|
|
101
128
|
return JSON.parse(JSON.stringify(this));
|
|
102
129
|
},
|
|
103
130
|
length0: function() {
|
|
104
131
|
return Object.keys(this).length;
|
|
105
132
|
},
|
|
106
|
-
...
|
|
133
|
+
...a(Object, 1, null, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
107
134
|
merge0: function(...t) {
|
|
108
135
|
return D(this, ...t);
|
|
109
136
|
},
|
|
@@ -126,12 +153,17 @@ u(Object.prototype, {
|
|
|
126
153
|
return e;
|
|
127
154
|
},
|
|
128
155
|
attr0: function(t, ...e) {
|
|
129
|
-
return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : this[t];
|
|
156
|
+
return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : e.length > 0 ? ((e[1] === void 0 || e[1] === t in this) && (this[t] = e[0]), this) : this[t];
|
|
130
157
|
},
|
|
131
158
|
toArray0: function() {
|
|
132
159
|
return Array.isArray(this) ? this : [this];
|
|
133
160
|
},
|
|
134
|
-
...
|
|
161
|
+
...a(console, -1, !1, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
|
|
162
|
+
debugger0: function(...t) {
|
|
163
|
+
t.push(this), console.debug(...t);
|
|
164
|
+
debugger;
|
|
165
|
+
return this;
|
|
166
|
+
},
|
|
135
167
|
// ====== Tree ======
|
|
136
168
|
getParents0: function(t = !1, e = -1, n = "parent") {
|
|
137
169
|
const r = t ? [this] : [];
|
|
@@ -141,10 +173,10 @@ u(Object.prototype, {
|
|
|
141
173
|
return r;
|
|
142
174
|
},
|
|
143
175
|
getChildrens0: function(t = !1, e = -1, n = "children") {
|
|
144
|
-
const r = [], i = (s, o
|
|
145
|
-
if (
|
|
146
|
-
for (const
|
|
147
|
-
i(
|
|
176
|
+
const r = [], i = (u, s, o) => {
|
|
177
|
+
if (s && r.push(u), !(o == 0 || !u[n] || u[n].length == 0))
|
|
178
|
+
for (const c of u[n])
|
|
179
|
+
i(c, !0, o - 1);
|
|
148
180
|
};
|
|
149
181
|
return i(this, t, e), r;
|
|
150
182
|
},
|
|
@@ -154,9 +186,9 @@ u(Object.prototype, {
|
|
|
154
186
|
if (n == 0 || !this[r] || this[r].length == 0)
|
|
155
187
|
return null;
|
|
156
188
|
for (const i of this[r]) {
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
189
|
+
const u = i.treeFind0(t, !0, n - 1, r);
|
|
190
|
+
if (u !== null)
|
|
191
|
+
return u;
|
|
160
192
|
}
|
|
161
193
|
return null;
|
|
162
194
|
},
|
|
@@ -168,16 +200,16 @@ u(Object.prototype, {
|
|
|
168
200
|
}
|
|
169
201
|
},
|
|
170
202
|
treeMap0: function(t, e = !0, n = -1, r = "children", i = null) {
|
|
171
|
-
const
|
|
203
|
+
const u = e ? t(this) : this, s = [];
|
|
172
204
|
if (n == 0 || !this[r] || this[r].length == 0)
|
|
173
|
-
return
|
|
174
|
-
for (const
|
|
175
|
-
|
|
176
|
-
return
|
|
205
|
+
return u;
|
|
206
|
+
for (const o of this[r])
|
|
207
|
+
s.push(o.treeMap0(t, !0, n - 1, r, i));
|
|
208
|
+
return u[r] = s, u;
|
|
177
209
|
}
|
|
178
210
|
});
|
|
179
|
-
|
|
180
|
-
...
|
|
211
|
+
l(Number.prototype, {
|
|
212
|
+
...a(Math, 1, null, ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
|
|
181
213
|
baseConvert: function(t = 64) {
|
|
182
214
|
let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
183
215
|
for (; n > 0; )
|
|
@@ -194,12 +226,12 @@ u(Number.prototype, {
|
|
|
194
226
|
return Date.new(this);
|
|
195
227
|
}
|
|
196
228
|
});
|
|
197
|
-
|
|
229
|
+
l(BigInt.prototype, {
|
|
198
230
|
toJSON: function() {
|
|
199
231
|
return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
|
|
200
232
|
}
|
|
201
233
|
});
|
|
202
|
-
|
|
234
|
+
l(String.prototype, {
|
|
203
235
|
...d(["length", "length0"]),
|
|
204
236
|
substring0: function(t = 0, e = this.length) {
|
|
205
237
|
return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
|
|
@@ -227,16 +259,16 @@ u(String.prototype, {
|
|
|
227
259
|
return e;
|
|
228
260
|
},
|
|
229
261
|
subOf: function(t, e, n = 0, r = 0) {
|
|
230
|
-
for (let
|
|
262
|
+
for (let s = 0; s < n && r != -1; s++, r++)
|
|
231
263
|
r = this.indexOf(t, r);
|
|
232
|
-
let i = this.indexOf(t, r),
|
|
233
|
-
return i == -1 ||
|
|
264
|
+
let i = this.indexOf(t, r), u = this.indexOf(e, i);
|
|
265
|
+
return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
|
|
234
266
|
},
|
|
235
267
|
lastSubOf: function(t, e, n = 0, r = 1 / 0) {
|
|
236
|
-
for (let
|
|
268
|
+
for (let s = 0; s < n && r != -1; s++, r--)
|
|
237
269
|
r = this.lastIndexOf(t, r);
|
|
238
|
-
let i = this.lastIndexOf(t, r),
|
|
239
|
-
return i == -1 ||
|
|
270
|
+
let i = this.lastIndexOf(t, r), u = this.indexOf(e, i);
|
|
271
|
+
return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
|
|
240
272
|
},
|
|
241
273
|
camel2under: function() {
|
|
242
274
|
return this.substr(0, 1) + this.substr(1).replace(/([A-Z])/g, (t, e) => "_" + e.toLowerCase());
|
|
@@ -278,15 +310,15 @@ u(String.prototype, {
|
|
|
278
310
|
return Uint8Array.fromBase64(this);
|
|
279
311
|
}
|
|
280
312
|
});
|
|
281
|
-
|
|
282
|
-
...
|
|
313
|
+
l(Array, {
|
|
314
|
+
...y()
|
|
283
315
|
});
|
|
284
|
-
|
|
316
|
+
l(Array.prototype, {
|
|
285
317
|
...d(["length", "length0"]),
|
|
286
|
-
...
|
|
287
|
-
...
|
|
288
|
-
...
|
|
289
|
-
...
|
|
318
|
+
...m(Array.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
319
|
+
...a(Array.prototype, null, !1, ["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
|
|
320
|
+
...a(Array.prototype, null, 1, ["push", "push1"], ["unshift", "unshift1"]),
|
|
321
|
+
...a(Array.prototype, null, !0, ["push", "push3"], ["unshift", "unshift3"]),
|
|
290
322
|
first0: function(t = null) {
|
|
291
323
|
return this.length ? this[0] : t;
|
|
292
324
|
},
|
|
@@ -303,9 +335,17 @@ u(Array.prototype, {
|
|
|
303
335
|
const e = /* @__PURE__ */ new Set();
|
|
304
336
|
return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
|
|
305
337
|
},
|
|
306
|
-
...
|
|
307
|
-
|
|
308
|
-
|
|
338
|
+
...a(Array.prototype, null, !1, ["forEach", "each0"]),
|
|
339
|
+
eachAsync: async function(t) {
|
|
340
|
+
for (let e = 0; e < this.length; e++)
|
|
341
|
+
await t(this[e], e, this);
|
|
342
|
+
return this;
|
|
343
|
+
},
|
|
344
|
+
mapAsync: async function(t) {
|
|
345
|
+
const e = [];
|
|
346
|
+
for (let n = 0; n < this.length; n++)
|
|
347
|
+
e.push(await t(this[n], n, this));
|
|
348
|
+
return e;
|
|
309
349
|
},
|
|
310
350
|
toMap: function(t = (e, n) => [n, e]) {
|
|
311
351
|
return new Map(this.map(t));
|
|
@@ -313,64 +353,49 @@ u(Array.prototype, {
|
|
|
313
353
|
toSet: function(t = (e) => e) {
|
|
314
354
|
return new Set(this.map(t));
|
|
315
355
|
},
|
|
316
|
-
toGroup: function(t = (e) => [e.id, e]) {
|
|
317
|
-
const e = {};
|
|
318
|
-
for (const n of this) {
|
|
319
|
-
const [r, i] = t(n);
|
|
320
|
-
r in e || (e[r] = []), e[r].push(i);
|
|
321
|
-
}
|
|
322
|
-
return e;
|
|
323
|
-
},
|
|
324
|
-
toMerge: function(t = (r) => r.id, e = (r) => ({ ...r, children: [] }), n = (r, i) => r.children.push(i)) {
|
|
325
|
-
const r = [];
|
|
326
|
-
for (const i of this)
|
|
327
|
-
n(r.find((s) => t(s) == t(i)) ?? r.push1(e(i)), i);
|
|
328
|
-
return r;
|
|
329
|
-
},
|
|
330
356
|
bytes2string: function() {
|
|
331
|
-
return
|
|
357
|
+
return this.toUint8Array().bytes2string();
|
|
332
358
|
},
|
|
333
359
|
bytes2hex: function() {
|
|
334
|
-
return
|
|
360
|
+
return this.toUint8Array().toHex();
|
|
335
361
|
},
|
|
336
362
|
base64encode: function() {
|
|
337
|
-
return
|
|
363
|
+
return this.toUint8Array().toBase64();
|
|
338
364
|
},
|
|
339
365
|
toUint8Array: function() {
|
|
340
366
|
return new Uint8Array(this);
|
|
341
367
|
},
|
|
342
368
|
// ====== Relational ======
|
|
343
369
|
assoc: function(t, e, n = {}) {
|
|
344
|
-
const r = this.unique0((
|
|
345
|
-
return this.each0((
|
|
370
|
+
const r = this.unique0((u) => u[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
|
|
371
|
+
return this.each0((u) => u[e] = i[u[t]] ?? null);
|
|
346
372
|
},
|
|
347
373
|
// ====== Tree ======
|
|
348
374
|
toTree: function(t = {}) {
|
|
349
|
-
const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent:
|
|
350
|
-
|
|
375
|
+
const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: s = "children", empty: o = null, hasRoot: c = !0 } = t, b = this.reduce((h, p) => h.attr0(p[e], p), {}), f = this.reduce((h, p) => (h.attr0(p[n], [], !1).attr0(p[n]).push0(p), h), {}), g = this.length && c ? this.find((h) => h[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [s]: f[0] };
|
|
376
|
+
l(g, { [i]: { value: g, enumerable: !1, configurable: !0, writable: !0 } });
|
|
351
377
|
for (const h of this)
|
|
352
|
-
|
|
353
|
-
[i]: { value:
|
|
354
|
-
[
|
|
355
|
-
}), h[
|
|
356
|
-
return
|
|
378
|
+
l(h, {
|
|
379
|
+
[i]: { value: g, enumerable: !1, configurable: !0, writable: !0 },
|
|
380
|
+
[u]: { value: b[h[n]], enumerable: !1, configurable: !0, writable: !0 }
|
|
381
|
+
}), h[s] = f[h[e]] || o;
|
|
382
|
+
return g.treeEach0((h) => h[r] = h[u] ? h[u][r] + 1 : 0, -1, s), g;
|
|
357
383
|
},
|
|
358
384
|
tree2tree: function(t = {}, e = null, n = null) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
[o]: { value:
|
|
365
|
-
|
|
366
|
-
}), c[i] = n[r], c[s] = n[s] + 1, c[f] = c[f] && c[f].length ? c[f] : m, (l = c[f]) == null || l.tree2tree(t, e, c);
|
|
385
|
+
const { id: r = "id", pid: i = "pid", level: u = "level", root: s = "root", parent: o = "parent", children: c = "children", empty: b = null } = t;
|
|
386
|
+
e = e || { [r]: 0, [i]: -1, [u]: 0, [s]: null, [o]: null, [c]: this }, n = n || e;
|
|
387
|
+
for (const f of this)
|
|
388
|
+
l(f, {
|
|
389
|
+
[s]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
390
|
+
[o]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
|
|
391
|
+
}), f[i] = n[r], f[u] = n[u] + 1, f[c] = f[c] && f[c].length ? f[c] : b, f[c]?.tree2tree(t, e, f);
|
|
367
392
|
return e;
|
|
368
393
|
},
|
|
369
394
|
treeFind0: function(t, e = !0, n = -1, r = "children") {
|
|
370
395
|
for (const i of this) {
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
return
|
|
396
|
+
const u = i.treeFind0(t, e, n, r);
|
|
397
|
+
if (u !== null)
|
|
398
|
+
return u;
|
|
374
399
|
}
|
|
375
400
|
return null;
|
|
376
401
|
},
|
|
@@ -380,17 +405,18 @@ u(Array.prototype, {
|
|
|
380
405
|
return this;
|
|
381
406
|
},
|
|
382
407
|
treeMap0: function(t, e = !0, n = -1, r = "children", i = null) {
|
|
383
|
-
return this.map((
|
|
408
|
+
return this.map((u) => u.treeMap0(t, e, n, r, i));
|
|
384
409
|
}
|
|
385
410
|
});
|
|
386
|
-
|
|
387
|
-
...
|
|
411
|
+
l(Map, {
|
|
412
|
+
...y()
|
|
388
413
|
});
|
|
389
|
-
|
|
414
|
+
l(Map.prototype, {
|
|
390
415
|
...d(["size", "length0"]),
|
|
391
|
-
...
|
|
392
|
-
...
|
|
393
|
-
...
|
|
416
|
+
...m(Map.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
417
|
+
...a(Map.prototype, null, !1, ["set", "set0"], ["delete", "delete0"]),
|
|
418
|
+
...a(Map.prototype, null, 1, ["set", "set1"], ["delete", "delete1"]),
|
|
419
|
+
...a(Map.prototype, null, !0, ["set", "set3"], ["delete", "delete3"]),
|
|
394
420
|
get0: function(t, e = null) {
|
|
395
421
|
return this.has(t) ? this.get(t) : e;
|
|
396
422
|
},
|
|
@@ -410,14 +436,15 @@ u(Map.prototype, {
|
|
|
410
436
|
return [...this];
|
|
411
437
|
}
|
|
412
438
|
});
|
|
413
|
-
|
|
414
|
-
...
|
|
439
|
+
l(Set, {
|
|
440
|
+
...y()
|
|
415
441
|
});
|
|
416
|
-
|
|
442
|
+
l(Set.prototype, {
|
|
417
443
|
...d(["size", "length0"]),
|
|
418
|
-
...
|
|
419
|
-
...
|
|
420
|
-
...
|
|
444
|
+
...m(Set.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
445
|
+
...a(Set.prototype, null, !1, ["add", "add0"], ["delete", "delete0"]),
|
|
446
|
+
...a(Set.prototype, null, 1, ["add", "add1"], ["delete", "delete1"]),
|
|
447
|
+
...a(Set.prototype, null, !0, ["add", "add3"], ["delete", "delete3"]),
|
|
421
448
|
toArray: function() {
|
|
422
449
|
return [...this];
|
|
423
450
|
},
|
|
@@ -425,7 +452,7 @@ u(Set.prototype, {
|
|
|
425
452
|
return [...this];
|
|
426
453
|
}
|
|
427
454
|
});
|
|
428
|
-
|
|
455
|
+
l(Date, {
|
|
429
456
|
new: function(...t) {
|
|
430
457
|
return t.length != 1 ? new Date(...t) : Number.isNaN(+t[0]) ? new Date(t[0].includes("T") ? t[0] : t[0].replace(/-/g, "/")) : new Date(t[0] > 25e8 ? t[0] : t[0] * 1e3);
|
|
431
458
|
},
|
|
@@ -461,7 +488,7 @@ u(Date, {
|
|
|
461
488
|
return [n, r];
|
|
462
489
|
}
|
|
463
490
|
});
|
|
464
|
-
|
|
491
|
+
l(Date.prototype, {
|
|
465
492
|
format: function(t = "y-m-d h:i:s") {
|
|
466
493
|
if (this.getTime() === 0)
|
|
467
494
|
return "-";
|
|
@@ -486,9 +513,9 @@ u(Date.prototype, {
|
|
|
486
513
|
getMonthDay: function() {
|
|
487
514
|
return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
|
|
488
515
|
},
|
|
489
|
-
expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s = 0 }) {
|
|
490
|
-
const
|
|
491
|
-
return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(
|
|
516
|
+
expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s: u = 0 }) {
|
|
517
|
+
const s = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
|
|
518
|
+
return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(s.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + u);
|
|
492
519
|
},
|
|
493
520
|
begin: function(t = 3) {
|
|
494
521
|
return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, t), ...[this.getFullYear(), 0, 1, 0, 0, 0].slice(t));
|
|
@@ -506,15 +533,15 @@ u(Date.prototype, {
|
|
|
506
533
|
return this.getTime();
|
|
507
534
|
}
|
|
508
535
|
});
|
|
509
|
-
|
|
510
|
-
...
|
|
536
|
+
l(RegExp, {
|
|
537
|
+
...y()
|
|
511
538
|
});
|
|
512
|
-
|
|
539
|
+
l(RegExp.prototype, {
|
|
513
540
|
toJSON: function() {
|
|
514
541
|
return this.toString();
|
|
515
542
|
}
|
|
516
543
|
});
|
|
517
|
-
|
|
544
|
+
l(Promise, {
|
|
518
545
|
channel: function() {
|
|
519
546
|
let t = null, e = null;
|
|
520
547
|
return [new this((r, i) => {
|
|
@@ -522,12 +549,12 @@ u(Promise, {
|
|
|
522
549
|
}), t, e];
|
|
523
550
|
}
|
|
524
551
|
});
|
|
525
|
-
|
|
552
|
+
l(Promise.prototype, {
|
|
526
553
|
tryCatch: function() {
|
|
527
554
|
return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
|
|
528
555
|
}
|
|
529
556
|
});
|
|
530
|
-
|
|
557
|
+
l(JSON, {
|
|
531
558
|
parse0: function(t, e = null) {
|
|
532
559
|
try {
|
|
533
560
|
if (typeof t != "string")
|
|
@@ -538,17 +565,17 @@ u(JSON, {
|
|
|
538
565
|
}
|
|
539
566
|
}
|
|
540
567
|
});
|
|
541
|
-
typeof Iterator < "u" &&
|
|
568
|
+
typeof Iterator < "u" && l(Iterator.prototype, {
|
|
542
569
|
toArray: function() {
|
|
543
570
|
return Array.from(this);
|
|
544
571
|
}
|
|
545
572
|
});
|
|
546
|
-
|
|
573
|
+
l(ArrayBuffer.prototype, {
|
|
547
574
|
toUint8Array: function() {
|
|
548
575
|
return new Uint8Array(this);
|
|
549
576
|
}
|
|
550
577
|
});
|
|
551
|
-
typeof Uint8Array.fromBase64 > "u" && (
|
|
578
|
+
typeof Uint8Array.fromBase64 > "u" && (l(Uint8Array, {
|
|
552
579
|
fromHex: function(t) {
|
|
553
580
|
const e = [];
|
|
554
581
|
for (let n = 0; n < t.length; n += 2)
|
|
@@ -557,23 +584,23 @@ typeof Uint8Array.fromBase64 > "u" && (u(Uint8Array, {
|
|
|
557
584
|
},
|
|
558
585
|
fromBase64: function(t) {
|
|
559
586
|
const e = [], n = {}, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
560
|
-
for (let
|
|
561
|
-
n[r.charAt(
|
|
587
|
+
for (let u = 0; u < r.length; u++)
|
|
588
|
+
n[r.charAt(u)] = u;
|
|
562
589
|
const i = t.charAt(t.length - 1) != "=" ? t.length : t.charAt(t.length - 2) != "=" ? t.length - 1 : t.length - 2;
|
|
563
|
-
for (let
|
|
564
|
-
const
|
|
565
|
-
e.push((
|
|
590
|
+
for (let u = 3; u < i; u += 4) {
|
|
591
|
+
const s = (n[t.charAt(u - 3)] << 18) + (n[t.charAt(u - 2)] << 12) + (n[t.charAt(u - 1)] << 6) + n[t.charAt(u)];
|
|
592
|
+
e.push((s & 16711680) >> 16, (s & 65280) >> 8, s & 255);
|
|
566
593
|
}
|
|
567
594
|
if (i % 4 == 3) {
|
|
568
|
-
const
|
|
569
|
-
e.push((
|
|
595
|
+
const u = (n[t.charAt(i - 3)] << 18) + (n[t.charAt(i - 2)] << 12) + (n[t.charAt(i - 1)] << 6);
|
|
596
|
+
e.push((u & 16711680) >> 16, (u & 65280) >> 8);
|
|
570
597
|
} else if (i % 4 == 2) {
|
|
571
|
-
const
|
|
572
|
-
e.push((
|
|
598
|
+
const u = (n[t.charAt(i - 2)] << 18) + (n[t.charAt(i - 1)] << 12);
|
|
599
|
+
e.push((u & 16711680) >> 16);
|
|
573
600
|
}
|
|
574
601
|
return new Uint8Array(e);
|
|
575
602
|
}
|
|
576
|
-
}),
|
|
603
|
+
}), l(Uint8Array.prototype, {
|
|
577
604
|
toHex: function() {
|
|
578
605
|
let t = "";
|
|
579
606
|
for (let e = 0; e < this.length; e++)
|
|
@@ -596,24 +623,33 @@ typeof Uint8Array.fromBase64 > "u" && (u(Uint8Array, {
|
|
|
596
623
|
return t;
|
|
597
624
|
}
|
|
598
625
|
}));
|
|
599
|
-
|
|
626
|
+
l(Uint8Array.prototype, {
|
|
627
|
+
bytes2string: function() {
|
|
628
|
+
return new TextDecoder().decode(this);
|
|
629
|
+
},
|
|
630
|
+
bytes2hex: function() {
|
|
631
|
+
return this.toHex();
|
|
632
|
+
},
|
|
633
|
+
base64encode: function() {
|
|
634
|
+
return this.toBase64();
|
|
635
|
+
},
|
|
600
636
|
toArray: function() {
|
|
601
637
|
return new Array(...this);
|
|
602
638
|
}
|
|
603
639
|
});
|
|
604
|
-
let
|
|
605
|
-
|
|
640
|
+
let S = 0, w = 0, A = 0;
|
|
641
|
+
l(Math, {
|
|
606
642
|
randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
|
|
607
643
|
if (t < e)
|
|
608
644
|
throw new Error("randstr: len < slen");
|
|
609
645
|
const i = [];
|
|
610
|
-
for (let
|
|
646
|
+
for (let u = 0; u < t; u++)
|
|
611
647
|
i.push(n.charAt(Math.random() * n.length | 0));
|
|
612
|
-
for (let
|
|
648
|
+
for (let u = /* @__PURE__ */ new Set(), s = 0, o = 0; o < e; o++) {
|
|
613
649
|
do
|
|
614
|
-
|
|
615
|
-
while (
|
|
616
|
-
|
|
650
|
+
s = Math.random() * t | 0;
|
|
651
|
+
while (u.has(s));
|
|
652
|
+
u.set(s, !0), i[s] = r.charAt(Math.random() * r.length | 0);
|
|
617
653
|
}
|
|
618
654
|
return i.join("");
|
|
619
655
|
},
|
|
@@ -621,7 +657,7 @@ u(Math, {
|
|
|
621
657
|
return Math.floor(Math.random() * (e - t) + t);
|
|
622
658
|
},
|
|
623
659
|
incrid: function() {
|
|
624
|
-
return ++
|
|
660
|
+
return ++S;
|
|
625
661
|
},
|
|
626
662
|
incrstr: function() {
|
|
627
663
|
return "" + Math.incrid();
|
|
@@ -637,11 +673,11 @@ u(Math, {
|
|
|
637
673
|
},
|
|
638
674
|
useTemplate: function(t) {
|
|
639
675
|
let e = null;
|
|
640
|
-
const n = { setup(i, { slots:
|
|
641
|
-
return e =
|
|
676
|
+
const n = { setup(i, { slots: u }) {
|
|
677
|
+
return e = u.default, () => {
|
|
642
678
|
};
|
|
643
|
-
}, name: t + "Template" }, r = { setup(i, { attrs:
|
|
644
|
-
return () => e
|
|
679
|
+
}, name: t + "Template" }, r = { setup(i, { attrs: u }) {
|
|
680
|
+
return () => e?.(u);
|
|
645
681
|
}, name: t };
|
|
646
682
|
return { [n.name]: n, [r.name]: r };
|
|
647
683
|
}
|
package/dist/esexts.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u){typeof define=="function"&&define.amd?define(u):u()})((function(){"use strict";function u(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function g(){return{new:function(...t){return new this(...t)}}}function p(...t){const e={};for(const[n,r]of t)e[r]=function(){return this[n]};return e}function m(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return[...this[n](...i)]};return e}function d(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),this};return e}function O(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),i[0]};return e}function b(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),i};return e}function w(t,...e){const n={};for(const[r,i]of e)n[i]=function(...s){return t[r](this,...s)};return n}function S(t,...e){const n={};for(const[r,i]of e)n[i]=function(...s){return t[r](this,...s),this};return n}function A(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),a=Object.prototype.toString.call(s);if(o!==a)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const f in s)i[f]=r(i[f],s[f]);return i}else return s};for(const i of n)e=r(e,i);return e}}const x=A({array:!1}),M=A({array:!0});u(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return x(this,...t)},concat0:function(...t){return M(this,...t)}}),u(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...w(Object,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:function(...t){return x(this,...t)},concat0:function(...t){return M(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...S(console,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,a)=>{if(o&&r.push(s),!(a==0||!s[n]||s[n].length==0))for(const f of s[n])i(f,!0,a-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const s=i.treeFind0(t,!0,n-1,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const s=e?t(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return s;for(const a of this[r])o.push(a.treeMap0(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...w(Math,["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},round:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},toFixed0:function(...t){return+this.toFixed(...t)},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),u(String.prototype,{...p(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let o=0;o<n&&r!=-1;o++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},lastSubOf:function(t,e,n=0,r=1/0){for(let o=0;o<n&&r!=-1;o++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.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(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},string2bytes:function(){return new TextEncoder().encode(this)},hex2bytes:function(){return Uint8Array.fromHex(this)},base64decode:function(){return Uint8Array.fromBase64(this)}}),u(Array,{...g()}),u(Array.prototype,{...p(["length","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...O(["push","push1"],["unshift","unshift1"]),...b(["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...d(["forEach","each0"]),toObject:function(t=(e,n)=>[n,e]){return Object.fromEntries(this.map(t))},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toGroup:function(t=e=>[e.id,e]){const e={};for(const n of this){const[r,i]=t(n);r in e||(e[r]=[]),e[r].push(i)}return e},toMerge:function(t=r=>r.id,e=r=>({...r,children:[]}),n=(r,i)=>r.children.push(i)){const r=[];for(const i of this)n(r.find(s=>t(s)==t(i))??r.push1(e(i)),i);return r},bytes2string:function(){return new TextDecoder().decode(new Uint8Array(this))},bytes2hex:function(){return new Uint8Array(this).toHex()},base64encode:function(){return new Uint8Array(this).toBase64()},toUint8Array:function(){return new Uint8Array(this)},assoc:function(t,e,n={}){const r=this.unique0(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(s=>s[e]=i[s[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:s="parent",children:o="children",empty:a=null,hasRoot:f=!0}=t,y=this.toObject(h=>[h[e],h]),l=this.toGroup(h=>[h[n],h]),c=this.length&&f?this.find(h=>h[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:l[0]};u(c,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)u(h,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0},[s]:{value:y[h[n]],enumerable:!1,configurable:!0,writable:!0}}),h[o]=l[h[e]]||a;return c.treeEach0(h=>h[r]=h[s]?h[s][r]+1:0,-1,o),c},tree2tree:function(t={},e=null,n=null){var l;const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:a="parent",children:f="children",empty:y=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[a]:null,[f]:this},n=n||e;for(const c of this)u(c,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[a]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),c[i]=n[r],c[s]=n[s]+1,c[f]=c[f]&&c[f].length?c[f]:y,(l=c[f])==null||l.tree2tree(t,e,c);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.treeFind0(t,e,n,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.treeMap0(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...p(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["set","set0"],["delete","delete0"]),...b(["set","set3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Set,{...g()}),u(Set.prototype,{...p(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["add","add0"],["delete","delete0"]),...b(["add","add3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),u(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={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 t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="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:t=0,m:e=0,d:n=0,h:r=0,i=0,s=0}){const o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+s)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),u(RegExp,{...g()}),u(RegExp.prototype,{toJSON:function(){return this.toString()}}),u(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),u(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&u(Iterator.prototype,{toArray:function(){return Array.from(this)}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),typeof Uint8Array.fromBase64>"u"&&(u(Uint8Array,{fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<r.length;s++)n[r.charAt(s)]=s;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let s=3;s<i;s+=4){const o=(n[t.charAt(s-3)]<<18)+(n[t.charAt(s-2)]<<12)+(n[t.charAt(s-1)]<<6)+n[t.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return new Uint8Array(e)}}),u(Uint8Array.prototype,{toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t}})),u(Uint8Array.prototype,{toArray:function(){return new Array(...this)}});let j=0,D=0,F=0;u(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let s=0;s<t;s++)i.push(n.charAt(Math.random()*n.length|0));for(let s=new Set,o=0,a=0;a<e;a++){do o=Math.random()*t|0;while(s.has(o));s.set(o,!0),i[o]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++j},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===F?t*2048+ ++D%2048:(F=t)*2048+(D=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:s}){return e=s.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:s}){return()=>e==null?void 0:e(s)},name:t};return{[n.name]:n,[r.name]:r}}})}));
|
|
1
|
+
(function(l){typeof define=="function"&&define.amd?define(l):l()})((function(){"use strict";function l(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function y(){return{new:function(...t){return new this(...t)}}}function d(...t){const e={};for(const[n,r]of t)e[r]=function(){return this[n]};return e}function a(t,e,n,...r){const i={};for(const[u,s]of r){if(e===null&&n===null){i[s]=function(...o){return t[u].apply(this,o)};continue}if(e===null&&n===!1){i[s]=function(...o){return t[u].apply(this,o),this};continue}if(e===null&&n===!0){i[s]=function(...o){return t[u].apply(this,o),o};continue}if(e===null&&n>0){i[s]=function(...o){return t[u].apply(this,o),o[n-1]};continue}if(e===null&&n<0){i[s]=function(...o){return t[u].apply(this,o),o[o.length+n+1]};continue}if(e!==null&&n===null){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o)};continue}if(e!==null&&n===!1){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),this};continue}if(e!==null&&n===!0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o};continue}if(e!==null&&n>0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[n-1]};continue}if(e!==null&&n<0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[o.length+n+1]};continue}throw Error("unreachable")}return i}function b(t,...e){const n={};for(const[r,i]of e)n[i]=function(...u){return[...t[r].apply(this,u)]};return n}function w(t={array:!1}){return function(e={},...n){const r=(i,u)=>{const s=Object.prototype.toString.call(i),o=Object.prototype.toString.call(u);if(s!==o)return u;if(s==="[object Array]")return t.array?i.concat(...u):u;if(s==="[object Object]"){for(const c in u)i[c]=r(i[c],u[c]);return i}else return u};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),M=w({array:!0});l(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)}}),l(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...a(Object,1,null,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):e.length>0?((e[1]===void 0||e[1]===t in this)&&(this[t]=e[0]),this):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...a(console,-1,!1,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),debugger0:function(...t){t.push(this),console.debug(...t);debugger;return this},getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(u,s,o)=>{if(s&&r.push(u),!(o==0||!u[n]||u[n].length==0))for(const c of u[n])i(c,!0,o-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const u=i.treeFind0(t,!0,n-1,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const u=e?t(this):this,s=[];if(n==0||!this[r]||this[r].length==0)return u;for(const o of this[r])s.push(o.treeMap0(t,!0,n-1,r,i));return u[r]=s,u}}),l(Number.prototype,{...a(Math,1,null,["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},round:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},toFixed0:function(...t){return+this.toFixed(...t)},toDate:function(){return Date.new(this)}}),l(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),l(String.prototype,{...d(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let s=0;s<n&&r!=-1;s++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},lastSubOf:function(t,e,n=0,r=1/0){for(let s=0;s<n&&r!=-1;s++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.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(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},string2bytes:function(){return new TextEncoder().encode(this)},hex2bytes:function(){return Uint8Array.fromHex(this)},base64decode:function(){return Uint8Array.fromBase64(this)}}),l(Array,{...y()}),l(Array.prototype,{...d(["length","length0"]),...b(Array.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Array.prototype,null,!1,["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...a(Array.prototype,null,1,["push","push1"],["unshift","unshift1"]),...a(Array.prototype,null,!0,["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...a(Array.prototype,null,!1,["forEach","each0"]),eachAsync:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},mapAsync:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},bytes2string:function(){return this.toUint8Array().bytes2string()},bytes2hex:function(){return this.toUint8Array().toHex()},base64encode:function(){return this.toUint8Array().toBase64()},toUint8Array:function(){return new Uint8Array(this)},assoc:function(t,e,n={}){const r=this.unique0(u=>u[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(u=>u[e]=i[u[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:u="parent",children:s="children",empty:o=null,hasRoot:c=!0}=t,m=this.reduce((h,p)=>h.attr0(p[e],p),{}),f=this.reduce((h,p)=>(h.attr0(p[n],[],!1).attr0(p[n]).push0(p),h),{}),g=this.length&&c?this.find(h=>h[n]===0):{[e]:0,[n]:-1,[i]:null,[u]:null,[s]:f[0]};l(g,{[i]:{value:g,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)l(h,{[i]:{value:g,enumerable:!1,configurable:!0,writable:!0},[u]:{value:m[h[n]],enumerable:!1,configurable:!0,writable:!0}}),h[s]=f[h[e]]||o;return g.treeEach0(h=>h[r]=h[u]?h[u][r]+1:0,-1,s),g},tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:u="level",root:s="root",parent:o="parent",children:c="children",empty:m=null}=t;e=e||{[r]:0,[i]:-1,[u]:0,[s]:null,[o]:null,[c]:this},n=n||e;for(const f of this)l(f,{[s]:{value:e,enumerable:!1,configurable:!0,writable:!0},[o]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),f[i]=n[r],f[u]=n[u]+1,f[c]=f[c]&&f[c].length?f[c]:m,f[c]?.tree2tree(t,e,f);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const u=i.treeFind0(t,e,n,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(u=>u.treeMap0(t,e,n,r,i))}}),l(Map,{...y()}),l(Map.prototype,{...d(["size","length0"]),...b(Map.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Map.prototype,null,!1,["set","set0"],["delete","delete0"]),...a(Map.prototype,null,1,["set","set1"],["delete","delete1"]),...a(Map.prototype,null,!0,["set","set3"],["delete","delete3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),l(Set,{...y()}),l(Set.prototype,{...d(["size","length0"]),...b(Set.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Set.prototype,null,!1,["add","add0"],["delete","delete0"]),...a(Set.prototype,null,1,["add","add1"],["delete","delete1"]),...a(Set.prototype,null,!0,["add","add3"],["delete","delete3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),l(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),l(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={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 t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="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:t=0,m:e=0,d:n=0,h:r=0,i=0,s:u=0}){const s=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(s.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+u)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),l(RegExp,{...y()}),l(RegExp.prototype,{toJSON:function(){return this.toString()}}),l(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),l(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),l(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:function(){return Array.from(this)}}),l(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),typeof Uint8Array.fromBase64>"u"&&(l(Uint8Array,{fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=0;u<r.length;u++)n[r.charAt(u)]=u;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let u=3;u<i;u+=4){const s=(n[t.charAt(u-3)]<<18)+(n[t.charAt(u-2)]<<12)+(n[t.charAt(u-1)]<<6)+n[t.charAt(u)];e.push((s&16711680)>>16,(s&65280)>>8,s&255)}if(i%4==3){const u=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((u&16711680)>>16,(u&65280)>>8)}else if(i%4==2){const u=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((u&16711680)>>16)}return new Uint8Array(e)}}),l(Uint8Array.prototype,{toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t}})),l(Uint8Array.prototype,{bytes2string:function(){return new TextDecoder().decode(this)},bytes2hex:function(){return this.toHex()},base64encode:function(){return this.toBase64()},toArray:function(){return new Array(...this)}});let S=0,D=0,F=0;l(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let u=0;u<t;u++)i.push(n.charAt(Math.random()*n.length|0));for(let u=new Set,s=0,o=0;o<e;o++){do s=Math.random()*t|0;while(u.has(s));u.set(s,!0),i[s]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++S},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===F?t*2048+ ++D%2048:(F=t)*2048+(D=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:u}){return e=u.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:u}){return()=>e?.(u)},name:t};return{[n.name]:n,[r.name]:r}}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esexts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "esexts",
|
|
5
5
|
"author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
|
|
6
6
|
"homepage": "https://github.com/dotcoo/esexts#readme",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"preview": "vite preview"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"vite": "^
|
|
31
|
+
"vite": "^7.1.5"
|
|
32
32
|
}
|
|
33
33
|
}
|