esexts 1.3.1 → 1.3.3
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 +416 -490
- package/dist/esexts.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/esexts.js
CHANGED
|
@@ -1,392 +1,423 @@
|
|
|
1
|
-
const
|
|
2
|
-
function p(
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const l = Object.defineProperties, s = { enumerable: !1, configurable: !0, writable: !0 };
|
|
2
|
+
function p() {
|
|
3
|
+
return {
|
|
4
|
+
new: {
|
|
5
|
+
value: function(...t) {
|
|
6
|
+
return new this(...t);
|
|
7
|
+
},
|
|
8
|
+
...s
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function v(...t) {
|
|
13
|
+
const e = {};
|
|
14
|
+
for (const n of t) {
|
|
15
|
+
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
16
|
+
e[i] = {
|
|
17
|
+
value: function(...u) {
|
|
18
|
+
return this[r](...u), this;
|
|
19
|
+
},
|
|
20
|
+
...s
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
function x(...t) {
|
|
26
|
+
const e = {};
|
|
27
|
+
for (const n of t) {
|
|
28
|
+
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
29
|
+
e[i] = {
|
|
30
|
+
value: function(...u) {
|
|
31
|
+
return this[r](...u), u[0];
|
|
32
|
+
},
|
|
33
|
+
...s
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
function b(...t) {
|
|
39
|
+
const e = {};
|
|
40
|
+
for (const n of t) {
|
|
41
|
+
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
42
|
+
e[i] = {
|
|
43
|
+
value: function(...u) {
|
|
44
|
+
return this[r](...u), u;
|
|
45
|
+
},
|
|
46
|
+
...s
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return e;
|
|
50
|
+
}
|
|
51
|
+
function d(...t) {
|
|
52
|
+
const e = {};
|
|
53
|
+
for (const n of t) {
|
|
54
|
+
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
55
|
+
e[i] = {
|
|
56
|
+
value: function() {
|
|
57
|
+
return this[r];
|
|
58
|
+
},
|
|
59
|
+
...s
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return e;
|
|
63
|
+
}
|
|
64
|
+
function A(...t) {
|
|
65
|
+
const e = {};
|
|
66
|
+
for (const n of t) {
|
|
67
|
+
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
68
|
+
e[i] = {
|
|
69
|
+
value: function(...u) {
|
|
70
|
+
return [...this[r](...u)];
|
|
71
|
+
},
|
|
72
|
+
...s
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
function O(t, ...e) {
|
|
78
|
+
const n = {};
|
|
79
|
+
for (const r of e) {
|
|
80
|
+
const [i, u] = Array.isArray(r) ? r : [r, r];
|
|
81
|
+
n[u] = {
|
|
82
|
+
value: t[i],
|
|
83
|
+
...s
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return n;
|
|
87
|
+
}
|
|
88
|
+
function m(t, ...e) {
|
|
89
|
+
const n = {};
|
|
90
|
+
for (const r of e) {
|
|
91
|
+
const [i, u] = Array.isArray(r) ? r : [r, r];
|
|
92
|
+
n[u] = {
|
|
93
|
+
value: function(...o) {
|
|
94
|
+
return t[i](this, ...o);
|
|
95
|
+
},
|
|
96
|
+
...s
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return n;
|
|
100
|
+
}
|
|
101
|
+
function w(t = { array: !1 }) {
|
|
102
|
+
return function(e = {}, ...n) {
|
|
103
|
+
const r = (i, u) => {
|
|
104
|
+
const o = Object.prototype.toString.call(i), f = Object.prototype.toString.call(u);
|
|
6
105
|
if (o !== f)
|
|
7
|
-
return
|
|
106
|
+
return u;
|
|
8
107
|
if (o === "[object Array]")
|
|
9
|
-
return t.array ? i.concat(...
|
|
108
|
+
return t.array ? i.concat(...u) : u;
|
|
10
109
|
if (o === "[object Object]") {
|
|
11
|
-
for (const c in
|
|
12
|
-
i[c] =
|
|
110
|
+
for (const c in u)
|
|
111
|
+
i[c] = r(i[c], u[c]);
|
|
13
112
|
return i;
|
|
14
113
|
} else
|
|
15
|
-
return
|
|
114
|
+
return u;
|
|
16
115
|
};
|
|
17
|
-
for (const i of
|
|
18
|
-
e =
|
|
116
|
+
for (const i of n)
|
|
117
|
+
e = r(e, i);
|
|
19
118
|
return e;
|
|
20
119
|
};
|
|
21
120
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
121
|
+
const D = w({ array: !1 }), F = w({ array: !0 });
|
|
122
|
+
l(Object, {
|
|
24
123
|
isObject: {
|
|
25
124
|
value: function(t) {
|
|
26
125
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
27
126
|
},
|
|
28
|
-
...
|
|
127
|
+
...s
|
|
29
128
|
},
|
|
30
129
|
merge0: {
|
|
31
130
|
value: function(...t) {
|
|
32
|
-
return
|
|
131
|
+
return D(this, ...t);
|
|
33
132
|
},
|
|
34
|
-
...
|
|
133
|
+
...s
|
|
35
134
|
},
|
|
36
135
|
concat0: {
|
|
37
136
|
value: function(...t) {
|
|
38
|
-
return
|
|
137
|
+
return F(this, ...t);
|
|
39
138
|
},
|
|
40
|
-
...
|
|
139
|
+
...s
|
|
41
140
|
}
|
|
42
141
|
});
|
|
43
|
-
|
|
142
|
+
l(Object.prototype, {
|
|
44
143
|
clone0: {
|
|
45
144
|
value: function() {
|
|
46
145
|
return JSON.parse(JSON.stringify(this));
|
|
47
146
|
},
|
|
48
|
-
...
|
|
147
|
+
...s
|
|
49
148
|
},
|
|
50
149
|
length0: {
|
|
51
150
|
value: function() {
|
|
52
151
|
return Object.keys(this).length;
|
|
53
152
|
},
|
|
54
|
-
...
|
|
55
|
-
},
|
|
56
|
-
entries0: {
|
|
57
|
-
value: function() {
|
|
58
|
-
return Object.entries(this);
|
|
59
|
-
},
|
|
60
|
-
...n
|
|
61
|
-
},
|
|
62
|
-
keys0: {
|
|
63
|
-
value: function() {
|
|
64
|
-
return Object.keys(this);
|
|
65
|
-
},
|
|
66
|
-
...n
|
|
67
|
-
},
|
|
68
|
-
values0: {
|
|
69
|
-
value: function() {
|
|
70
|
-
return Object.values(this);
|
|
71
|
-
},
|
|
72
|
-
...n
|
|
153
|
+
...s
|
|
73
154
|
},
|
|
155
|
+
...m(Object, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
74
156
|
merge0: {
|
|
75
157
|
value: function(...t) {
|
|
76
|
-
return
|
|
158
|
+
return D(this, ...t);
|
|
77
159
|
},
|
|
78
|
-
...
|
|
160
|
+
...s
|
|
79
161
|
},
|
|
80
162
|
concat0: {
|
|
81
163
|
value: function(...t) {
|
|
82
|
-
return
|
|
164
|
+
return F(this, ...t);
|
|
83
165
|
},
|
|
84
|
-
...
|
|
166
|
+
...s
|
|
85
167
|
},
|
|
86
168
|
map0: {
|
|
87
|
-
value: function(t = (
|
|
88
|
-
return Object.entries(this).map(([
|
|
169
|
+
value: function(t = (n, r, i) => [n, r], e = 0) {
|
|
170
|
+
return Object.entries(this).map(([n, r]) => t(n, r, e++));
|
|
89
171
|
},
|
|
90
|
-
...
|
|
172
|
+
...s
|
|
91
173
|
},
|
|
92
174
|
pick0: {
|
|
93
175
|
value: function(...t) {
|
|
94
176
|
const e = {};
|
|
95
|
-
for (const
|
|
96
|
-
e[
|
|
177
|
+
for (const n of t)
|
|
178
|
+
e[n] = this[n];
|
|
97
179
|
return e;
|
|
98
180
|
},
|
|
99
|
-
...
|
|
181
|
+
...s
|
|
100
182
|
},
|
|
101
183
|
omit0: {
|
|
102
184
|
value: function(...t) {
|
|
103
|
-
const e = {},
|
|
104
|
-
for (const
|
|
105
|
-
|
|
185
|
+
const e = {}, n = new Set(t);
|
|
186
|
+
for (const r in this)
|
|
187
|
+
n.has(r) || (e[r] = this[r]);
|
|
106
188
|
return e;
|
|
107
189
|
},
|
|
108
|
-
...
|
|
190
|
+
...s
|
|
109
191
|
},
|
|
110
192
|
attr0: {
|
|
111
193
|
value: function(t, ...e) {
|
|
112
194
|
return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : this[t];
|
|
113
195
|
},
|
|
114
|
-
...
|
|
196
|
+
...s
|
|
115
197
|
},
|
|
116
198
|
toArray0: {
|
|
117
199
|
value: function() {
|
|
118
200
|
return Array.isArray(this) ? this : [this];
|
|
119
201
|
},
|
|
120
|
-
...
|
|
121
|
-
},
|
|
122
|
-
log0: {
|
|
123
|
-
value: function(...t) {
|
|
124
|
-
return console.log(...t, this), this;
|
|
125
|
-
},
|
|
126
|
-
...n
|
|
127
|
-
},
|
|
128
|
-
debug0: {
|
|
129
|
-
value: function(...t) {
|
|
130
|
-
return console.debug(...t, this), this;
|
|
131
|
-
},
|
|
132
|
-
...n
|
|
202
|
+
...s
|
|
133
203
|
},
|
|
204
|
+
...m(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
|
|
134
205
|
// ====== Tree ======
|
|
135
206
|
getParents0: {
|
|
136
|
-
value: function(t = !1, e = -1,
|
|
137
|
-
const
|
|
138
|
-
let i = this[
|
|
207
|
+
value: function(t = !1, e = -1, n = "parent") {
|
|
208
|
+
const r = t ? [this] : [];
|
|
209
|
+
let i = this[n];
|
|
139
210
|
for (; i && e-- != 0; )
|
|
140
|
-
|
|
141
|
-
return
|
|
211
|
+
r.push(i), i = i[n];
|
|
212
|
+
return r;
|
|
142
213
|
},
|
|
143
|
-
...
|
|
214
|
+
...s
|
|
144
215
|
},
|
|
145
216
|
getChildrens0: {
|
|
146
|
-
value: function(t = !1, e = -1,
|
|
147
|
-
const
|
|
148
|
-
if (o &&
|
|
149
|
-
for (const c of
|
|
217
|
+
value: function(t = !1, e = -1, n = "children") {
|
|
218
|
+
const r = [], i = (u, o, f) => {
|
|
219
|
+
if (o && r.push(u), !(f == 0 || !u[n] || u[n].length == 0))
|
|
220
|
+
for (const c of u[n])
|
|
150
221
|
i(c, !0, f - 1);
|
|
151
222
|
};
|
|
152
|
-
return i(this, t, e),
|
|
223
|
+
return i(this, t, e), r;
|
|
153
224
|
},
|
|
154
|
-
...
|
|
225
|
+
...s
|
|
155
226
|
},
|
|
156
227
|
treeFind0: {
|
|
157
|
-
value: function(t, e = !0,
|
|
228
|
+
value: function(t, e = !0, n = -1, r = "children") {
|
|
158
229
|
if (e && t(this))
|
|
159
230
|
return this;
|
|
160
|
-
if (
|
|
231
|
+
if (n == 0 || !this[r] || this[r].length == 0)
|
|
161
232
|
return null;
|
|
162
|
-
for (const i of this[
|
|
163
|
-
const
|
|
164
|
-
if (
|
|
165
|
-
return
|
|
233
|
+
for (const i of this[r]) {
|
|
234
|
+
const u = i.treeFind0(t, !0, n - 1, r);
|
|
235
|
+
if (u !== null)
|
|
236
|
+
return u;
|
|
166
237
|
}
|
|
167
238
|
return null;
|
|
168
239
|
},
|
|
169
|
-
...
|
|
240
|
+
...s
|
|
170
241
|
},
|
|
171
242
|
treeEach0: {
|
|
172
|
-
value: function(t, e = !0,
|
|
173
|
-
if (e && t(this), !(
|
|
174
|
-
for (const i of this[
|
|
175
|
-
i.treeEach0(t, !0,
|
|
243
|
+
value: function(t, e = !0, n = -1, r = "children") {
|
|
244
|
+
if (e && t(this), !(n == 0 || !this[r] || this[r].length == 0)) {
|
|
245
|
+
for (const i of this[r])
|
|
246
|
+
i.treeEach0(t, !0, n - 1, r);
|
|
176
247
|
return this;
|
|
177
248
|
}
|
|
178
249
|
},
|
|
179
|
-
...
|
|
250
|
+
...s
|
|
180
251
|
},
|
|
181
252
|
treeMap0: {
|
|
182
|
-
value: function(t, e = !0,
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
return
|
|
186
|
-
for (const f of this[
|
|
187
|
-
o.push(f.treeMap0(t, !0,
|
|
188
|
-
return
|
|
189
|
-
},
|
|
190
|
-
...
|
|
253
|
+
value: function(t, e = !0, n = -1, r = "children", i = null) {
|
|
254
|
+
const u = e ? t(this) : this, o = [];
|
|
255
|
+
if (n == 0 || !this[r] || this[r].length == 0)
|
|
256
|
+
return u;
|
|
257
|
+
for (const f of this[r])
|
|
258
|
+
o.push(f.treeMap0(t, !0, n - 1, r, i));
|
|
259
|
+
return u[r] = o, u;
|
|
260
|
+
},
|
|
261
|
+
...s
|
|
191
262
|
}
|
|
192
263
|
});
|
|
193
|
-
|
|
194
|
-
ceil
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
value: function() {
|
|
202
|
-
return Math.floor(this);
|
|
264
|
+
l(Number.prototype, {
|
|
265
|
+
...m(Math, "ceil", "floor", "trunc", "abs", "max", "min"),
|
|
266
|
+
baseConvert: {
|
|
267
|
+
value: function(t = 64) {
|
|
268
|
+
let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
269
|
+
for (; n > 0; )
|
|
270
|
+
e = r.at(n % t) + e, n = Math.floor(n / t);
|
|
271
|
+
return e || "0";
|
|
203
272
|
},
|
|
204
|
-
...
|
|
273
|
+
...s
|
|
205
274
|
},
|
|
206
275
|
round: {
|
|
207
276
|
value: function(t = 0) {
|
|
208
277
|
return t == 0 ? Math.round(this) : Math.round(this * 10 ** t) / 10 ** t;
|
|
209
278
|
},
|
|
210
|
-
...
|
|
211
|
-
},
|
|
212
|
-
trunc: {
|
|
213
|
-
value: function() {
|
|
214
|
-
return Math.trunc(this);
|
|
215
|
-
},
|
|
216
|
-
...n
|
|
217
|
-
},
|
|
218
|
-
abs: {
|
|
219
|
-
value: function() {
|
|
220
|
-
return Math.abs(this);
|
|
221
|
-
},
|
|
222
|
-
...n
|
|
223
|
-
},
|
|
224
|
-
max: {
|
|
225
|
-
value: function(...t) {
|
|
226
|
-
return Math.max(this, ...t);
|
|
227
|
-
},
|
|
228
|
-
...n
|
|
229
|
-
},
|
|
230
|
-
min: {
|
|
231
|
-
value: function(...t) {
|
|
232
|
-
return Math.min(this, ...t);
|
|
233
|
-
},
|
|
234
|
-
...n
|
|
235
|
-
},
|
|
236
|
-
baseConvert: {
|
|
237
|
-
value: function(t = 64) {
|
|
238
|
-
let e = "", r = this, u = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
239
|
-
for (; r > 0; )
|
|
240
|
-
e = u.at(r % t) + e, r = Math.floor(r / t);
|
|
241
|
-
return e || "0";
|
|
242
|
-
},
|
|
243
|
-
...n
|
|
279
|
+
...s
|
|
244
280
|
},
|
|
245
281
|
toFixed0: {
|
|
246
282
|
value: function(...t) {
|
|
247
283
|
return +this.toFixed(...t);
|
|
248
284
|
},
|
|
249
|
-
...
|
|
285
|
+
...s
|
|
250
286
|
},
|
|
251
287
|
toDate: {
|
|
252
288
|
value: function() {
|
|
253
289
|
return Date.new(this);
|
|
254
290
|
},
|
|
255
|
-
...
|
|
291
|
+
...s
|
|
256
292
|
}
|
|
257
293
|
});
|
|
258
|
-
|
|
294
|
+
l(BigInt.prototype, {
|
|
259
295
|
toJSON: {
|
|
260
296
|
value: function() {
|
|
261
297
|
return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
|
|
262
298
|
},
|
|
263
|
-
...
|
|
299
|
+
...s
|
|
264
300
|
}
|
|
265
301
|
});
|
|
266
|
-
|
|
267
|
-
length0
|
|
268
|
-
value: function() {
|
|
269
|
-
return this.length;
|
|
270
|
-
},
|
|
271
|
-
...n
|
|
272
|
-
},
|
|
302
|
+
l(String.prototype, {
|
|
303
|
+
...d(["length", "length0"]),
|
|
273
304
|
substring0: {
|
|
274
305
|
value: function(t = 0, e = this.length) {
|
|
275
306
|
return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
|
|
276
307
|
},
|
|
277
|
-
...
|
|
308
|
+
...s
|
|
278
309
|
},
|
|
279
310
|
substr0: {
|
|
280
311
|
value: function(t = 0, e = this.length) {
|
|
281
312
|
return t = t >= 0 ? t : this.length + t, e = t + e, this.substring(t, e);
|
|
282
313
|
},
|
|
283
|
-
...
|
|
314
|
+
...s
|
|
284
315
|
},
|
|
285
316
|
split0: {
|
|
286
317
|
value: function(t = ",", e = -1) {
|
|
287
|
-
const
|
|
288
|
-
return e === -1 ?
|
|
318
|
+
const n = this ? this.split(t) : [];
|
|
319
|
+
return e === -1 ? n : n.push0(n.splice(e - 1).join(t));
|
|
289
320
|
},
|
|
290
|
-
...
|
|
321
|
+
...s
|
|
291
322
|
},
|
|
292
323
|
splitNumber: {
|
|
293
324
|
value: function(t = ",") {
|
|
294
325
|
return this.split0(t).map((e) => +e);
|
|
295
326
|
},
|
|
296
|
-
...
|
|
327
|
+
...s
|
|
297
328
|
},
|
|
298
329
|
splitSegment: {
|
|
299
330
|
value: function(t = 1) {
|
|
300
331
|
const e = [];
|
|
301
|
-
for (let
|
|
302
|
-
e.push(this.substring(
|
|
332
|
+
for (let n = 0; n < this.length; n += t)
|
|
333
|
+
e.push(this.substring(n, n + t));
|
|
303
334
|
return e;
|
|
304
335
|
},
|
|
305
|
-
...
|
|
336
|
+
...s
|
|
306
337
|
},
|
|
307
338
|
sprintf: {
|
|
308
339
|
value: function(...t) {
|
|
309
|
-
let [e, ...
|
|
310
|
-
for (let
|
|
311
|
-
e += t[
|
|
340
|
+
let [e, ...n] = this.split(/%[sd]/);
|
|
341
|
+
for (let r = 0; r < n.length; r++)
|
|
342
|
+
e += t[r] + n[r];
|
|
312
343
|
return e;
|
|
313
344
|
},
|
|
314
|
-
...
|
|
345
|
+
...s
|
|
315
346
|
},
|
|
316
347
|
subOf: {
|
|
317
|
-
value: function(t, e,
|
|
318
|
-
for (let o = 0; o <
|
|
319
|
-
|
|
320
|
-
let i = this.indexOf(t,
|
|
321
|
-
return i == -1 ||
|
|
348
|
+
value: function(t, e, n = 0, r = 0) {
|
|
349
|
+
for (let o = 0; o < n && r != -1; o++, r++)
|
|
350
|
+
r = this.indexOf(t, r);
|
|
351
|
+
let i = this.indexOf(t, r), u = this.indexOf(e, i);
|
|
352
|
+
return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
|
|
322
353
|
},
|
|
323
|
-
...
|
|
354
|
+
...s
|
|
324
355
|
},
|
|
325
356
|
lastSubOf: {
|
|
326
|
-
value: function(t, e,
|
|
327
|
-
for (let o = 0; o <
|
|
328
|
-
|
|
329
|
-
let i = this.lastIndexOf(t,
|
|
330
|
-
return i == -1 ||
|
|
357
|
+
value: function(t, e, n = 0, r = 1 / 0) {
|
|
358
|
+
for (let o = 0; o < n && r != -1; o++, r--)
|
|
359
|
+
r = this.lastIndexOf(t, r);
|
|
360
|
+
let i = this.lastIndexOf(t, r), u = this.indexOf(e, i);
|
|
361
|
+
return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
|
|
331
362
|
},
|
|
332
|
-
...
|
|
363
|
+
...s
|
|
333
364
|
},
|
|
334
365
|
camel2under: {
|
|
335
366
|
value: function() {
|
|
336
|
-
return this.substr(0, 1)
|
|
367
|
+
return this.substr(0, 1) + this.substr(1).replace(/([A-Z])/g, (t, e) => "_" + e.toLowerCase());
|
|
337
368
|
},
|
|
338
|
-
...
|
|
369
|
+
...s
|
|
339
370
|
},
|
|
340
371
|
under2camel: {
|
|
341
372
|
value: function() {
|
|
342
373
|
return this.replace(/_([a-z])/g, (t, e) => e.toUpperCase());
|
|
343
374
|
},
|
|
344
|
-
...
|
|
375
|
+
...s
|
|
345
376
|
},
|
|
346
377
|
camel2pascal: {
|
|
347
378
|
value: function() {
|
|
348
379
|
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
|
349
380
|
},
|
|
350
|
-
...
|
|
381
|
+
...s
|
|
351
382
|
},
|
|
352
383
|
pascal2camel: {
|
|
353
384
|
value: function() {
|
|
354
385
|
return this.substr(0, 1).toLowerCase() + this.substr(1);
|
|
355
386
|
},
|
|
356
|
-
...
|
|
387
|
+
...s
|
|
357
388
|
},
|
|
358
389
|
under2kebab: {
|
|
359
390
|
value: function() {
|
|
360
391
|
return this.replace(/_/g, "-");
|
|
361
392
|
},
|
|
362
|
-
...
|
|
393
|
+
...s
|
|
363
394
|
},
|
|
364
395
|
kebab2under: {
|
|
365
396
|
value: function() {
|
|
366
397
|
return this.replace(/-/g, "_");
|
|
367
398
|
},
|
|
368
|
-
...
|
|
399
|
+
...s
|
|
369
400
|
},
|
|
370
401
|
baseConvert: {
|
|
371
402
|
value: function(t = 64) {
|
|
372
|
-
let e = 0,
|
|
373
|
-
for (let
|
|
374
|
-
e = e * t +
|
|
403
|
+
let e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
404
|
+
for (let r = 0; r < this.length; r++)
|
|
405
|
+
e = e * t + n.indexOf(this.at(r));
|
|
375
406
|
return e;
|
|
376
407
|
},
|
|
377
|
-
...
|
|
408
|
+
...s
|
|
378
409
|
},
|
|
379
410
|
toFixed0: {
|
|
380
411
|
value: function(...t) {
|
|
381
412
|
return +(+this).toFixed(...t);
|
|
382
413
|
},
|
|
383
|
-
...
|
|
414
|
+
...s
|
|
384
415
|
},
|
|
385
416
|
toDate: {
|
|
386
417
|
value: function() {
|
|
387
418
|
return Date.new(this);
|
|
388
419
|
},
|
|
389
|
-
...
|
|
420
|
+
...s
|
|
390
421
|
},
|
|
391
422
|
hex2bytes: {
|
|
392
423
|
value: function() {
|
|
@@ -395,208 +426,127 @@ h(String.prototype, {
|
|
|
395
426
|
t.push(Number.parseInt(this.substring(e, e + 2), 16));
|
|
396
427
|
return t;
|
|
397
428
|
},
|
|
398
|
-
...
|
|
429
|
+
...s
|
|
399
430
|
},
|
|
400
431
|
string2bytes: {
|
|
401
432
|
value: function() {
|
|
402
433
|
if (typeof TextEncoder < "u")
|
|
403
434
|
return Array.from(new TextEncoder().encode(this));
|
|
404
435
|
const t = [], e = encodeURIComponent(this);
|
|
405
|
-
for (let
|
|
406
|
-
t.push(e.charAt(
|
|
436
|
+
for (let n = 0; n < e.length; )
|
|
437
|
+
t.push(e.charAt(n) == "%" ? Number.parseInt(e.substring(n + 1, n += 3), 16) : e.charCodeAt(n++));
|
|
407
438
|
return t;
|
|
408
439
|
},
|
|
409
|
-
...
|
|
440
|
+
...s
|
|
410
441
|
},
|
|
411
442
|
base64decode: {
|
|
412
443
|
value: function(t) {
|
|
413
|
-
const e = [],
|
|
414
|
-
for (let
|
|
415
|
-
r
|
|
444
|
+
const e = [], n = {}, r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
445
|
+
for (let u = 0; u < r.length; u++)
|
|
446
|
+
n[r.charAt(u)] = u;
|
|
416
447
|
const i = this.charAt(this.length - 1) != "=" ? this.length : this.charAt(this.length - 2) != "=" ? this.length - 1 : this.length - 2;
|
|
417
|
-
for (let
|
|
418
|
-
const o = (
|
|
448
|
+
for (let u = 3; u < i; u += 4) {
|
|
449
|
+
const o = (n[this.charAt(u - 3)] << 18) + (n[this.charAt(u - 2)] << 12) + (n[this.charAt(u - 1)] << 6) + n[this.charAt(u)];
|
|
419
450
|
e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
|
|
420
451
|
}
|
|
421
452
|
if (i % 4 == 3) {
|
|
422
|
-
const
|
|
423
|
-
e.push((
|
|
453
|
+
const u = (n[this.charAt(i - 3)] << 18) + (n[this.charAt(i - 2)] << 12) + (n[this.charAt(i - 1)] << 6);
|
|
454
|
+
e.push((u & 16711680) >> 16, (u & 65280) >> 8);
|
|
424
455
|
} else if (i % 4 == 2) {
|
|
425
|
-
const
|
|
426
|
-
e.push((
|
|
456
|
+
const u = (n[this.charAt(i - 2)] << 18) + (n[this.charAt(i - 1)] << 12);
|
|
457
|
+
e.push((u & 16711680) >> 16);
|
|
427
458
|
}
|
|
428
459
|
return e;
|
|
429
460
|
},
|
|
430
|
-
...
|
|
461
|
+
...s
|
|
431
462
|
}
|
|
432
463
|
});
|
|
433
|
-
typeof Iterator < "u" &&
|
|
464
|
+
typeof Iterator < "u" && l(Iterator.prototype, {
|
|
434
465
|
toArray: {
|
|
435
466
|
value: function() {
|
|
436
467
|
return Array.from(this);
|
|
437
468
|
},
|
|
438
|
-
...
|
|
469
|
+
...s
|
|
439
470
|
}
|
|
440
471
|
});
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return this.entries();
|
|
451
|
-
},
|
|
452
|
-
...n
|
|
453
|
-
},
|
|
454
|
-
push0: {
|
|
455
|
-
value: function(...t) {
|
|
456
|
-
return this.push(...t), this;
|
|
457
|
-
},
|
|
458
|
-
...n
|
|
459
|
-
},
|
|
460
|
-
push1: {
|
|
461
|
-
value: function(...t) {
|
|
462
|
-
return this.push(...t), t[0];
|
|
463
|
-
},
|
|
464
|
-
...n
|
|
465
|
-
},
|
|
466
|
-
push3: {
|
|
467
|
-
value: function(...t) {
|
|
468
|
-
return this.push(...t), t;
|
|
469
|
-
},
|
|
470
|
-
...n
|
|
471
|
-
},
|
|
472
|
-
pop0: {
|
|
473
|
-
value: function(...t) {
|
|
474
|
-
return this.pop(...t), this;
|
|
475
|
-
},
|
|
476
|
-
...n
|
|
477
|
-
},
|
|
478
|
-
pop1: {
|
|
479
|
-
value: function(...t) {
|
|
480
|
-
return this.pop(...t), t[0];
|
|
481
|
-
},
|
|
482
|
-
...n
|
|
483
|
-
},
|
|
484
|
-
pop3: {
|
|
485
|
-
value: function(...t) {
|
|
486
|
-
return this.pop(...t), t;
|
|
487
|
-
},
|
|
488
|
-
...n
|
|
489
|
-
},
|
|
490
|
-
unshift0: {
|
|
491
|
-
value: function(...t) {
|
|
492
|
-
return this.unshift(...t), this;
|
|
493
|
-
},
|
|
494
|
-
...n
|
|
495
|
-
},
|
|
496
|
-
unshift1: {
|
|
497
|
-
value: function(...t) {
|
|
498
|
-
return this.unshift(...t), t[0];
|
|
499
|
-
},
|
|
500
|
-
...n
|
|
501
|
-
},
|
|
502
|
-
unshift3: {
|
|
503
|
-
value: function(...t) {
|
|
504
|
-
return this.unshift(...t), t;
|
|
505
|
-
},
|
|
506
|
-
...n
|
|
507
|
-
},
|
|
508
|
-
shift0: {
|
|
509
|
-
value: function(...t) {
|
|
510
|
-
return this.shift(...t), this;
|
|
511
|
-
},
|
|
512
|
-
...n
|
|
513
|
-
},
|
|
514
|
-
shift1: {
|
|
515
|
-
value: function(...t) {
|
|
516
|
-
return this.shift(...t), t[0];
|
|
517
|
-
},
|
|
518
|
-
...n
|
|
519
|
-
},
|
|
520
|
-
shift3: {
|
|
521
|
-
value: function(...t) {
|
|
522
|
-
return this.shift(...t), t;
|
|
523
|
-
},
|
|
524
|
-
...n
|
|
525
|
-
},
|
|
472
|
+
l(Array, {
|
|
473
|
+
...p()
|
|
474
|
+
});
|
|
475
|
+
l(Array.prototype, {
|
|
476
|
+
...d(["length", "length0"]),
|
|
477
|
+
...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
478
|
+
...v(["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
|
|
479
|
+
...x(["push", "push1"], ["unshift", "unshift1"]),
|
|
480
|
+
...b(["push", "push3"], ["unshift", "unshift3"]),
|
|
526
481
|
first0: {
|
|
527
482
|
value: function(t = null) {
|
|
528
483
|
return this.length ? this[0] : t;
|
|
529
484
|
},
|
|
530
|
-
...
|
|
485
|
+
...s
|
|
531
486
|
},
|
|
532
487
|
last0: {
|
|
533
488
|
value: function(t = null) {
|
|
534
489
|
return this.length ? this[this.length - 1] : t;
|
|
535
490
|
},
|
|
536
|
-
...
|
|
491
|
+
...s
|
|
537
492
|
},
|
|
538
493
|
find0: {
|
|
539
494
|
value: function(t, e = null) {
|
|
540
495
|
return this.find(t) ?? e;
|
|
541
496
|
},
|
|
542
|
-
...
|
|
497
|
+
...s
|
|
543
498
|
},
|
|
544
499
|
equals0: {
|
|
545
500
|
value: function(t) {
|
|
546
|
-
return this.length === t.length && (this === t || this.length === 0 || this.every((e,
|
|
501
|
+
return this.length === t.length && (this === t || this.length === 0 || this.every((e, n) => e === t[n]));
|
|
547
502
|
},
|
|
548
|
-
...
|
|
503
|
+
...s
|
|
549
504
|
},
|
|
550
505
|
unique0: {
|
|
551
506
|
value: function(t = (e) => e) {
|
|
552
507
|
const e = /* @__PURE__ */ new Set();
|
|
553
|
-
return this.filter((
|
|
508
|
+
return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
|
|
554
509
|
},
|
|
555
|
-
...
|
|
556
|
-
},
|
|
557
|
-
each0: {
|
|
558
|
-
value: function(t) {
|
|
559
|
-
return this.forEach(t), this;
|
|
560
|
-
},
|
|
561
|
-
...n
|
|
510
|
+
...s
|
|
562
511
|
},
|
|
512
|
+
...v(["forEach", "each0"]),
|
|
563
513
|
toObject: {
|
|
564
|
-
value: function(t = (e,
|
|
514
|
+
value: function(t = (e, n) => [n, e]) {
|
|
565
515
|
return Object.fromEntries(this.map(t));
|
|
566
516
|
},
|
|
567
|
-
...
|
|
517
|
+
...s
|
|
568
518
|
},
|
|
569
519
|
toMap: {
|
|
570
|
-
value: function(t = (e,
|
|
520
|
+
value: function(t = (e, n) => [n, e]) {
|
|
571
521
|
return new Map(this.map(t));
|
|
572
522
|
},
|
|
573
|
-
...
|
|
523
|
+
...s
|
|
574
524
|
},
|
|
575
525
|
toSet: {
|
|
576
|
-
value: function() {
|
|
577
|
-
return new Set(this);
|
|
526
|
+
value: function(t = (e) => e) {
|
|
527
|
+
return new Set(this.map(t));
|
|
578
528
|
},
|
|
579
|
-
...
|
|
529
|
+
...s
|
|
580
530
|
},
|
|
581
531
|
toGroup: {
|
|
582
532
|
value: function(t = (e) => [e.id, e]) {
|
|
583
533
|
const e = {};
|
|
584
|
-
for (const
|
|
585
|
-
const [
|
|
586
|
-
|
|
534
|
+
for (const n of this) {
|
|
535
|
+
const [r, i] = t(n);
|
|
536
|
+
r in e || (e[r] = []), e[r].push(i);
|
|
587
537
|
}
|
|
588
538
|
return e;
|
|
589
539
|
},
|
|
590
|
-
...
|
|
540
|
+
...s
|
|
591
541
|
},
|
|
592
542
|
toMerge: {
|
|
593
|
-
value: function(t = (
|
|
594
|
-
const
|
|
543
|
+
value: function(t = (r) => r.id, e = (r) => ({ ...r, children: [] }), n = (r, i) => r.children.push(i)) {
|
|
544
|
+
const r = [];
|
|
595
545
|
for (const i of this)
|
|
596
|
-
r
|
|
597
|
-
return
|
|
546
|
+
n(r.find((u) => t(u) == t(i)) ?? r.push1(e(i)), i);
|
|
547
|
+
return r;
|
|
598
548
|
},
|
|
599
|
-
...
|
|
549
|
+
...s
|
|
600
550
|
},
|
|
601
551
|
bytes2hex: {
|
|
602
552
|
value: function() {
|
|
@@ -605,7 +555,7 @@ h(Array.prototype, {
|
|
|
605
555
|
t += (this[e] < 16 ? "0" : "") + this[e].toString(16);
|
|
606
556
|
return t;
|
|
607
557
|
},
|
|
608
|
-
...
|
|
558
|
+
...s
|
|
609
559
|
},
|
|
610
560
|
bytes2string: {
|
|
611
561
|
value: function() {
|
|
@@ -616,268 +566,241 @@ h(Array.prototype, {
|
|
|
616
566
|
t += "%" + (this[e] < 16 ? "0" : "") + this[e].toString(16);
|
|
617
567
|
return decodeURIComponent(t);
|
|
618
568
|
},
|
|
619
|
-
...
|
|
569
|
+
...s
|
|
620
570
|
},
|
|
621
571
|
base64encode: {
|
|
622
572
|
value: function(t = !1, e = !0) {
|
|
623
|
-
let
|
|
573
|
+
let n = "", r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
624
574
|
for (let i = 2; i < this.length; i += 3) {
|
|
625
|
-
const
|
|
626
|
-
|
|
575
|
+
const u = (this[i - 2] << 16) + (this[i - 1] << 8) + this[i];
|
|
576
|
+
n += r.charAt((u & 16515072) >> 18) + r.charAt((u & 258048) >> 12) + r.charAt((u & 4032) >> 6) + r.charAt(u & 63);
|
|
627
577
|
}
|
|
628
578
|
if (this.length % 3 == 2) {
|
|
629
579
|
const i = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
|
|
630
|
-
|
|
580
|
+
n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + r.charAt((i & 4032) >> 6) + (e === !1 ? "" : "=");
|
|
631
581
|
} else if (this.length % 3 == 1) {
|
|
632
582
|
const i = this[this.length - 1] << 16;
|
|
633
|
-
|
|
583
|
+
n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + (e === !1 ? "" : "==");
|
|
634
584
|
}
|
|
635
|
-
return
|
|
585
|
+
return n;
|
|
636
586
|
},
|
|
637
|
-
...
|
|
587
|
+
...s
|
|
638
588
|
},
|
|
639
589
|
toUint8Array: {
|
|
640
590
|
value: function() {
|
|
641
591
|
return new Uint8Array(this);
|
|
642
592
|
},
|
|
643
|
-
...
|
|
593
|
+
...s
|
|
644
594
|
},
|
|
645
595
|
// ====== Relational ======
|
|
646
596
|
assoc: {
|
|
647
|
-
value: function(t, e,
|
|
648
|
-
const
|
|
649
|
-
return this.each0((
|
|
597
|
+
value: function(t, e, n = {}) {
|
|
598
|
+
const r = this.unique0((u) => u[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
|
|
599
|
+
return this.each0((u) => u[e] = i[u[t]] ?? null);
|
|
650
600
|
},
|
|
651
|
-
...
|
|
601
|
+
...s
|
|
652
602
|
},
|
|
653
603
|
// ====== Tree ======
|
|
654
604
|
toTree: {
|
|
655
605
|
value: function(t = {}) {
|
|
656
|
-
const { id: e = "id", pid:
|
|
657
|
-
h
|
|
658
|
-
for (const
|
|
659
|
-
|
|
660
|
-
[i]: { value:
|
|
661
|
-
[
|
|
662
|
-
}),
|
|
663
|
-
return
|
|
606
|
+
const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: o = "children", empty: f = null, hasRoot: c = !0 } = t, y = this.toObject((a) => [a[e], a]), g = this.toGroup((a) => [a[n], a]), h = this.length && c ? this.find((a) => a[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [o]: g[0] };
|
|
607
|
+
l(h, { [i]: { value: h, enumerable: !1, configurable: !0, writable: !0 } });
|
|
608
|
+
for (const a of this)
|
|
609
|
+
l(a, {
|
|
610
|
+
[i]: { value: h, enumerable: !1, configurable: !0, writable: !0 },
|
|
611
|
+
[u]: { value: y[a[n]], enumerable: !1, configurable: !0, writable: !0 }
|
|
612
|
+
}), a[o] = g[a[e]] || f;
|
|
613
|
+
return h.treeEach0((a) => a[r] = a[u] ? a[u][r] + 1 : 0, -1, o), h;
|
|
664
614
|
},
|
|
665
|
-
...
|
|
615
|
+
...s
|
|
666
616
|
},
|
|
667
617
|
tree2tree: {
|
|
668
|
-
value: function(t = {}, e = null,
|
|
618
|
+
value: function(t = {}, e = null, n = null) {
|
|
669
619
|
var g;
|
|
670
|
-
const { id:
|
|
671
|
-
e = e || { [
|
|
672
|
-
for (const
|
|
673
|
-
h
|
|
620
|
+
const { id: r = "id", pid: i = "pid", level: u = "level", root: o = "root", parent: f = "parent", children: c = "children", empty: y = null } = t;
|
|
621
|
+
e = e || { [r]: 0, [i]: -1, [u]: 0, [o]: null, [f]: null, [c]: this }, n = n || e;
|
|
622
|
+
for (const h of this)
|
|
623
|
+
l(h, {
|
|
674
624
|
[o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
675
|
-
[f]: { value:
|
|
676
|
-
}),
|
|
625
|
+
[f]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
|
|
626
|
+
}), h[i] = n[r], h[u] = n[u] + 1, h[c] = h[c] && h[c].length ? h[c] : y, (g = h[c]) == null || g.tree2tree(t, e, h);
|
|
677
627
|
return e;
|
|
678
628
|
},
|
|
679
|
-
...
|
|
629
|
+
...s
|
|
680
630
|
},
|
|
681
631
|
treeFind0: {
|
|
682
|
-
value: function(t, e = !0,
|
|
632
|
+
value: function(t, e = !0, n = -1, r = "children") {
|
|
683
633
|
for (const i of this) {
|
|
684
|
-
const
|
|
685
|
-
if (
|
|
686
|
-
return
|
|
634
|
+
const u = i.treeFind0(t, e, n, r);
|
|
635
|
+
if (u !== null)
|
|
636
|
+
return u;
|
|
687
637
|
}
|
|
688
638
|
return null;
|
|
689
639
|
},
|
|
690
|
-
...
|
|
640
|
+
...s
|
|
691
641
|
},
|
|
692
642
|
treeEach0: {
|
|
693
|
-
value: function(t, e = !0,
|
|
643
|
+
value: function(t, e = !0, n = -1, r = "children") {
|
|
694
644
|
for (const i of this)
|
|
695
|
-
i.treeEach0(t, e,
|
|
645
|
+
i.treeEach0(t, e, n, r);
|
|
696
646
|
return this;
|
|
697
647
|
},
|
|
698
|
-
...
|
|
648
|
+
...s
|
|
699
649
|
},
|
|
700
650
|
treeMap0: {
|
|
701
|
-
value: function(t, e = !0,
|
|
702
|
-
return this.map((
|
|
651
|
+
value: function(t, e = !0, n = -1, r = "children", i = null) {
|
|
652
|
+
return this.map((u) => u.treeMap0(t, e, n, r, i));
|
|
703
653
|
},
|
|
704
|
-
...
|
|
654
|
+
...s
|
|
705
655
|
}
|
|
706
656
|
});
|
|
707
|
-
|
|
657
|
+
l(ArrayBuffer.prototype, {
|
|
708
658
|
toUint8Array: {
|
|
709
659
|
value: function() {
|
|
710
660
|
return new Uint8Array(this);
|
|
711
661
|
},
|
|
712
|
-
...
|
|
662
|
+
...s
|
|
713
663
|
}
|
|
714
664
|
});
|
|
715
|
-
|
|
716
|
-
bytes2hex
|
|
717
|
-
value: Array.prototype.bytes2hex,
|
|
718
|
-
...n
|
|
719
|
-
},
|
|
720
|
-
bytes2string: {
|
|
721
|
-
value: Array.prototype.bytes2string,
|
|
722
|
-
...n
|
|
723
|
-
},
|
|
724
|
-
base64encode: {
|
|
725
|
-
value: Array.prototype.base64encode,
|
|
726
|
-
...n
|
|
727
|
-
},
|
|
665
|
+
l(Uint8Array.prototype, {
|
|
666
|
+
...O(Array.prototype, "bytes2hex", "bytes2string", "base64encode"),
|
|
728
667
|
toArray: {
|
|
729
668
|
value: function() {
|
|
730
669
|
return new Array(...this);
|
|
731
670
|
},
|
|
732
|
-
...
|
|
671
|
+
...s
|
|
733
672
|
}
|
|
734
673
|
});
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
674
|
+
l(Map, {
|
|
675
|
+
...p()
|
|
676
|
+
});
|
|
677
|
+
l(Map.prototype, {
|
|
678
|
+
...d(["size", "length0"]),
|
|
679
|
+
...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
680
|
+
...v(["set", "set0"], ["delete", "delete0"]),
|
|
681
|
+
...b(["set", "set3"]),
|
|
682
|
+
get0: {
|
|
683
|
+
value: function(t, e = null) {
|
|
684
|
+
return this.has(t) ? this.get(t) : e;
|
|
739
685
|
},
|
|
740
|
-
...
|
|
686
|
+
...s
|
|
741
687
|
},
|
|
742
|
-
|
|
743
|
-
value: function() {
|
|
744
|
-
return
|
|
688
|
+
get1: {
|
|
689
|
+
value: function(t, e, ...n) {
|
|
690
|
+
return this.has(t) ? this.get(t) : this.set3(t, e(t, ...n))[1];
|
|
745
691
|
},
|
|
746
|
-
...
|
|
692
|
+
...s
|
|
747
693
|
},
|
|
748
|
-
|
|
749
|
-
value: function() {
|
|
750
|
-
return
|
|
694
|
+
getAsync1: {
|
|
695
|
+
value: async function(t, e, ...n) {
|
|
696
|
+
return this.has(t) ? this.get(t) : this.set3(t, await e(t, ...n))[1];
|
|
751
697
|
},
|
|
752
|
-
...
|
|
698
|
+
...s
|
|
753
699
|
},
|
|
754
|
-
|
|
700
|
+
toObject: {
|
|
755
701
|
value: function() {
|
|
756
|
-
return
|
|
757
|
-
},
|
|
758
|
-
...n
|
|
759
|
-
},
|
|
760
|
-
get0: {
|
|
761
|
-
value: function(t, e = null, ...r) {
|
|
762
|
-
if (this.has(t))
|
|
763
|
-
return this.get(t);
|
|
764
|
-
const u = typeof e != "function" ? e : e(t, ...r);
|
|
765
|
-
return this.set(t, u), u;
|
|
766
|
-
},
|
|
767
|
-
...n
|
|
768
|
-
},
|
|
769
|
-
get1: {
|
|
770
|
-
value: async function(t, e = null, ...r) {
|
|
771
|
-
if (this.has(t))
|
|
772
|
-
return this.get(t);
|
|
773
|
-
const u = typeof e != "function" ? e : await e(t, ...r);
|
|
774
|
-
return this.set(t, u), u;
|
|
702
|
+
return Object.fromEntries(this);
|
|
775
703
|
},
|
|
776
|
-
...
|
|
704
|
+
...s
|
|
777
705
|
},
|
|
778
|
-
|
|
706
|
+
toArray: {
|
|
779
707
|
value: function() {
|
|
780
|
-
return
|
|
708
|
+
return [...this];
|
|
781
709
|
},
|
|
782
|
-
...
|
|
710
|
+
...s
|
|
783
711
|
},
|
|
784
712
|
toJSON: {
|
|
785
713
|
value: function() {
|
|
786
714
|
return [...this];
|
|
787
715
|
},
|
|
788
|
-
...
|
|
716
|
+
...s
|
|
789
717
|
}
|
|
790
718
|
});
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
value: function() {
|
|
800
|
-
return this.entries();
|
|
801
|
-
},
|
|
802
|
-
...n
|
|
803
|
-
},
|
|
719
|
+
l(Set, {
|
|
720
|
+
...p()
|
|
721
|
+
});
|
|
722
|
+
l(Set.prototype, {
|
|
723
|
+
...d(["size", "length0"]),
|
|
724
|
+
...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
725
|
+
...v(["add", "add0"], ["delete", "delete0"]),
|
|
726
|
+
...b(["add", "add3"]),
|
|
804
727
|
toArray: {
|
|
805
728
|
value: function() {
|
|
806
729
|
return [...this];
|
|
807
730
|
},
|
|
808
|
-
...
|
|
731
|
+
...s
|
|
809
732
|
},
|
|
810
733
|
toJSON: {
|
|
811
734
|
value: function() {
|
|
812
735
|
return [...this];
|
|
813
736
|
},
|
|
814
|
-
...
|
|
737
|
+
...s
|
|
815
738
|
}
|
|
816
739
|
});
|
|
817
|
-
|
|
740
|
+
l(Date, {
|
|
818
741
|
new: {
|
|
819
742
|
value: function(...t) {
|
|
820
743
|
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);
|
|
821
744
|
},
|
|
822
|
-
...
|
|
745
|
+
...s
|
|
823
746
|
},
|
|
824
747
|
format: {
|
|
825
748
|
value: function(t = "y-m-d h:i:s") {
|
|
826
749
|
return (/* @__PURE__ */ new Date()).format(t);
|
|
827
750
|
},
|
|
828
|
-
...
|
|
751
|
+
...s
|
|
829
752
|
},
|
|
830
753
|
unix: {
|
|
831
754
|
value: function() {
|
|
832
755
|
return this.now() / 1e3 | 0;
|
|
833
756
|
},
|
|
834
|
-
...
|
|
757
|
+
...s
|
|
835
758
|
},
|
|
836
759
|
fromUnix: {
|
|
837
760
|
value: function(t = 0) {
|
|
838
|
-
return
|
|
761
|
+
return new Date((t || 0) * 1e3);
|
|
839
762
|
},
|
|
840
|
-
...
|
|
763
|
+
...s
|
|
841
764
|
},
|
|
842
765
|
expr: {
|
|
843
766
|
value: function(t = {}) {
|
|
844
767
|
return (/* @__PURE__ */ new Date()).expr(t);
|
|
845
768
|
},
|
|
846
|
-
...
|
|
769
|
+
...s
|
|
847
770
|
},
|
|
848
771
|
toDayRange: {
|
|
849
772
|
value: function() {
|
|
850
|
-
const t = /* @__PURE__ */ new Date(), e = t.getFullYear(),
|
|
773
|
+
const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
|
|
851
774
|
return [i, i + 86400 - 1];
|
|
852
775
|
},
|
|
853
|
-
...
|
|
776
|
+
...s
|
|
854
777
|
},
|
|
855
778
|
toWeekRange: {
|
|
856
779
|
value: function() {
|
|
857
780
|
let t = /* @__PURE__ */ new Date();
|
|
858
781
|
for (; t.getDay() != 1; )
|
|
859
782
|
t = new Date(t.getTime() - 86400);
|
|
860
|
-
const e = t.getFullYear(),
|
|
783
|
+
const e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
|
|
861
784
|
return [i, i + 86400 * 7 - 1];
|
|
862
785
|
},
|
|
863
|
-
...
|
|
786
|
+
...s
|
|
864
787
|
},
|
|
865
788
|
toMonthRange: {
|
|
866
789
|
value: function() {
|
|
867
|
-
const t = /* @__PURE__ */ new Date(), e = t.getFullYear(),
|
|
868
|
-
return [
|
|
790
|
+
const t = /* @__PURE__ */ 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;
|
|
791
|
+
return [r, i];
|
|
869
792
|
},
|
|
870
|
-
...
|
|
793
|
+
...s
|
|
871
794
|
},
|
|
872
795
|
toYearRange: {
|
|
873
796
|
value: function() {
|
|
874
|
-
const e = (/* @__PURE__ */ new Date()).getFullYear(),
|
|
875
|
-
return [
|
|
797
|
+
const e = (/* @__PURE__ */ 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;
|
|
798
|
+
return [n, r];
|
|
876
799
|
},
|
|
877
|
-
...
|
|
800
|
+
...s
|
|
878
801
|
}
|
|
879
802
|
});
|
|
880
|
-
|
|
803
|
+
l(Date.prototype, {
|
|
881
804
|
format: {
|
|
882
805
|
value: function(t = "y-m-d h:i:s") {
|
|
883
806
|
if (this.getTime() === 0)
|
|
@@ -892,102 +815,105 @@ h(Date.prototype, {
|
|
|
892
815
|
l: this.getMilliseconds(),
|
|
893
816
|
e: this.getMonthDay()
|
|
894
817
|
};
|
|
895
|
-
return t.replace(/([ymdhisle])/ig, (
|
|
818
|
+
return t.replace(/([ymdhisle])/ig, (n, r) => r >= "A" && r <= "Z" ? e[r.toLowerCase()] : e[r].toString().padStart(r === "l" ? 3 : 2, "0"));
|
|
896
819
|
},
|
|
897
|
-
...
|
|
820
|
+
...s
|
|
898
821
|
},
|
|
899
822
|
unix: {
|
|
900
823
|
value: function() {
|
|
901
824
|
return this.getTime() / 1e3 | 0;
|
|
902
825
|
},
|
|
903
|
-
...
|
|
826
|
+
...s
|
|
904
827
|
},
|
|
905
828
|
isLeapYear: {
|
|
906
829
|
value: function() {
|
|
907
830
|
return this.getFullYear() % 4 === 0 && this.getFullYear() % 400 !== 0;
|
|
908
831
|
},
|
|
909
|
-
...
|
|
832
|
+
...s
|
|
910
833
|
},
|
|
911
834
|
getMonthDay: {
|
|
912
835
|
value: function() {
|
|
913
836
|
return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
|
|
914
837
|
},
|
|
915
|
-
...
|
|
838
|
+
...s
|
|
916
839
|
},
|
|
917
840
|
expr: {
|
|
918
|
-
value: function({ y: t = 0, m: e = 0, d:
|
|
841
|
+
value: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s: u = 0 }) {
|
|
919
842
|
const o = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
|
|
920
|
-
return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(o.getDate(), this.getDate()) +
|
|
843
|
+
return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(o.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + u);
|
|
921
844
|
},
|
|
922
|
-
...
|
|
845
|
+
...s
|
|
923
846
|
},
|
|
924
847
|
begin: {
|
|
925
848
|
value: function(t = 3) {
|
|
926
849
|
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));
|
|
927
850
|
},
|
|
928
|
-
...
|
|
851
|
+
...s
|
|
929
852
|
},
|
|
930
853
|
end: {
|
|
931
854
|
value: function(t = 3) {
|
|
932
855
|
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));
|
|
933
856
|
},
|
|
934
|
-
...
|
|
857
|
+
...s
|
|
935
858
|
},
|
|
936
859
|
week: {
|
|
937
860
|
value: function(t, e = 1) {
|
|
938
|
-
let
|
|
939
|
-
for (;
|
|
940
|
-
|
|
941
|
-
return
|
|
861
|
+
let n = new Date(this.getTime());
|
|
862
|
+
for (; n.getDay() !== t; )
|
|
863
|
+
n = new Date(n.getTime() + 864e5 * e);
|
|
864
|
+
return n;
|
|
942
865
|
},
|
|
943
|
-
...
|
|
866
|
+
...s
|
|
944
867
|
},
|
|
945
868
|
toJSON: {
|
|
946
869
|
value: function() {
|
|
947
870
|
return this.getTime();
|
|
948
871
|
},
|
|
949
|
-
...
|
|
872
|
+
...s
|
|
950
873
|
}
|
|
951
874
|
});
|
|
952
|
-
|
|
875
|
+
l(RegExp, {
|
|
876
|
+
...p()
|
|
877
|
+
});
|
|
878
|
+
l(RegExp.prototype, {
|
|
953
879
|
toJSON: {
|
|
954
880
|
value: function() {
|
|
955
881
|
return this.toString();
|
|
956
882
|
},
|
|
957
|
-
...
|
|
883
|
+
...s
|
|
958
884
|
}
|
|
959
885
|
});
|
|
960
|
-
|
|
961
|
-
tryCatch: {
|
|
962
|
-
value: function() {
|
|
963
|
-
return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
|
|
964
|
-
},
|
|
965
|
-
...n
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
typeof Promise.withResolvers > "u" && h(Promise, {
|
|
886
|
+
typeof Promise.withResolvers > "u" && l(Promise, {
|
|
969
887
|
withResolvers: {
|
|
970
888
|
value: function() {
|
|
971
889
|
let t = null, e = null;
|
|
972
|
-
return { promise: new this((
|
|
973
|
-
t =
|
|
890
|
+
return { promise: new this((r, i) => {
|
|
891
|
+
t = r, e = i;
|
|
974
892
|
}), resolve: t, reject: e };
|
|
975
893
|
},
|
|
976
|
-
...
|
|
894
|
+
...s
|
|
977
895
|
}
|
|
978
896
|
});
|
|
979
|
-
|
|
897
|
+
l(Promise, {
|
|
980
898
|
channel: {
|
|
981
899
|
value: function() {
|
|
982
900
|
let t = null, e = null;
|
|
983
|
-
return [new this((
|
|
984
|
-
t =
|
|
901
|
+
return [new this((r, i) => {
|
|
902
|
+
t = r, e = i;
|
|
985
903
|
}), t, e];
|
|
986
904
|
},
|
|
987
|
-
...
|
|
905
|
+
...s
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
l(Promise.prototype, {
|
|
909
|
+
tryCatch: {
|
|
910
|
+
value: function() {
|
|
911
|
+
return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
|
|
912
|
+
},
|
|
913
|
+
...s
|
|
988
914
|
}
|
|
989
915
|
});
|
|
990
|
-
|
|
916
|
+
l(JSON, {
|
|
991
917
|
parse0: {
|
|
992
918
|
value: function(t, e = null) {
|
|
993
919
|
try {
|
|
@@ -998,6 +924,6 @@ h(JSON, {
|
|
|
998
924
|
return e;
|
|
999
925
|
}
|
|
1000
926
|
},
|
|
1001
|
-
...
|
|
927
|
+
...s
|
|
1002
928
|
}
|
|
1003
929
|
});
|