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