esexts 2.0.5 → 2.1.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/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # esexts
2
- esexts
1
+ # esexts
2
+ esexts
package/dist/esexts.js CHANGED
@@ -1,4 +1,4 @@
1
- function c(t, e) {
1
+ function h(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
4
  function g() {
@@ -19,27 +19,27 @@ function m(...t) {
19
19
  return e;
20
20
  }
21
21
  function f(t, e, n, ...r) {
22
- const i = {}, s = (o, u, h) => (u !== null && o.splice(u >= 0 ? u : o.length + u + 1, 0, h), o);
22
+ const i = {}, s = (o, u, c) => (u !== null && o.splice(u >= 0 ? u : o.length + u + 1, 0, c), o);
23
23
  for (const o of r) {
24
- const [u, h] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replaceAll("-", "_")];
24
+ const [u, c] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replaceAll("-", "_")];
25
25
  if (n === "")
26
- i[h] = function(...a) {
26
+ i[c] = function(...a) {
27
27
  return t[u].apply(this, s(a, e, this));
28
28
  };
29
29
  else if (n === "t")
30
- i[h] = function(...a) {
30
+ i[c] = function(...a) {
31
31
  return t[u].apply(this, s(a, e, this)), this;
32
32
  };
33
33
  else if (n === "a")
34
- i[h] = function(...a) {
34
+ i[c] = function(...a) {
35
35
  return t[u].apply(this, s(a, e, this)), a;
36
36
  };
37
37
  else if (n >= 0)
38
- i[h] = function(...a) {
38
+ i[c] = function(...a) {
39
39
  return t[u].apply(this, s(a, e, this)), a[n];
40
40
  };
41
41
  else if (n < 0)
42
- i[h] = function(...a) {
42
+ i[c] = function(...a) {
43
43
  return t[u].apply(this, s(a, e, this)), a[a.length + n];
44
44
  };
45
45
  else
@@ -66,8 +66,8 @@ function b(t = { array: !1 }) {
66
66
  if (o === "[object Array]")
67
67
  return t.array ? i.concat(...s) : s;
68
68
  if (o === "[object Object]") {
69
- for (const h in s)
70
- i[h] = r(i[h], s[h]);
69
+ for (const c in s)
70
+ i[c] = r(i[c], s[c]);
71
71
  return i;
72
72
  } else
73
73
  return s;
@@ -77,20 +77,20 @@ function b(t = { array: !1 }) {
77
77
  return e;
78
78
  };
79
79
  }
80
- const x = b({ array: !1 }), S = b({ array: !0 });
81
- c(Object, {
80
+ const S = b({ array: !1 }), x = b({ array: !0 });
81
+ h(Object, {
82
82
  ...g(),
83
83
  isObject: function(t) {
84
84
  return Object.prototype.toString.call(t) === "[object Object]";
85
85
  },
86
- merge$: function(...t) {
87
- return x(this, ...t);
86
+ merge: function(...t) {
87
+ return S(this, ...t);
88
88
  },
89
89
  concat: function(...t) {
90
- return S(this, ...t);
90
+ return x(this, ...t);
91
91
  }
92
92
  });
93
- c(Object.prototype, {
93
+ h(Object.prototype, {
94
94
  $clone: function() {
95
95
  return JSON.parse(JSON.stringify(this));
96
96
  },
@@ -100,15 +100,15 @@ c(Object.prototype, {
100
100
  ...f(Object, 0, "", "entries", "keys", "values", "assign"),
101
101
  ...f(JSON, 0, "", "stringify"),
102
102
  $merge: function(...t) {
103
- return x(this, ...t);
103
+ return S(this, ...t);
104
104
  },
105
105
  $concat: function(...t) {
106
- return S(this, ...t);
106
+ return x(this, ...t);
107
107
  },
108
108
  $empty: function() {
109
109
  return Object.keys(this).length == 0;
110
110
  },
111
- $in: function(t) {
111
+ $has: function(t) {
112
112
  return t in this;
113
113
  },
114
114
  $pick: function(...t) {
@@ -155,8 +155,8 @@ c(Object.prototype, {
155
155
  $getChildrens: function(t = !1, e = -1, n = "children") {
156
156
  const r = [], i = (s, o, u) => {
157
157
  if (o && r.push(s), !(u == 0 || !s[n] || s[n].length == 0))
158
- for (const h of s[n])
159
- i(h, !0, u - 1);
158
+ for (const c of s[n])
159
+ i(c, !0, u - 1);
160
160
  };
161
161
  return i(this, t, e), r;
162
162
  },
@@ -188,7 +188,7 @@ c(Object.prototype, {
188
188
  return s[r] = o, s;
189
189
  }
190
190
  });
191
- c(Number.prototype, {
191
+ h(Number.prototype, {
192
192
  ...f(Math, 0, "", ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
193
193
  fixed: function(t = 0) {
194
194
  return +this.toFixed(t);
@@ -237,13 +237,15 @@ c(Number.prototype, {
237
237
  return Date.new(this);
238
238
  }
239
239
  });
240
- c(BigInt.prototype, {
240
+ h(BigInt.prototype, {
241
241
  toJSON: function() {
242
242
  return this >= BigInt(Number.MIN_SAFE_INTEGER) && this <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(this) : this.toString();
243
243
  }
244
244
  });
245
- c(String.prototype, {
246
- ...g(),
245
+ h(String, {
246
+ ...g()
247
+ });
248
+ h(String.prototype, {
247
249
  ...m(["length", "length$"]),
248
250
  $substring: function(t = 0, e = this.length) {
249
251
  return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
@@ -331,11 +333,11 @@ c(String.prototype, {
331
333
  return new TextDecoder().decode(Uint8Array.fromBase64(this));
332
334
  }
333
335
  });
334
- c(Array, {
336
+ h(Array, {
335
337
  ...g(),
336
338
  // ====== from pinojs ======
337
339
  range: function(...t) {
338
- let e = [], n = 0, r = 0, i = 1, s = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, o = typeof t[t.length - 1] == "function" ? t.pop() : (u, h, a) => u;
340
+ let e = [], n = 0, r = 0, i = 1, s = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, o = typeof t[t.length - 1] == "function" ? t.pop() : (u, c, a) => u;
339
341
  switch (t.length) {
340
342
  case 1:
341
343
  [r] = t;
@@ -351,12 +353,12 @@ c(Array, {
351
353
  }
352
354
  if (i == 0)
353
355
  throw new Error("step cannot be 0!");
354
- for (let u = 0, h = 0, a = Math.abs(r - n), p = Math.abs(i), d = n <= r ? 1 : -1; h < a; h += p)
355
- e.push(s ? o(n + h * d, u++, e) : o());
356
+ for (let u = 0, c = 0, a = Math.abs(r - n), p = Math.abs(i), d = n <= r ? 1 : -1; c < a; c += p)
357
+ e.push(s ? o(n + c * d, u++, e) : o());
356
358
  return e;
357
359
  }
358
360
  });
359
- c(Array.prototype, {
361
+ h(Array.prototype, {
360
362
  ...m("length"),
361
363
  ...$(Array.prototype, "entries", "keys", "values"),
362
364
  ...f(Array.prototype, null, "", "map"),
@@ -434,7 +436,7 @@ c(Array.prototype, {
434
436
  },
435
437
  // ====== TextDecoder ======
436
438
  decode: function() {
437
- return this.toUint8Array().decode();
439
+ return this.toUint8Array().toString();
438
440
  },
439
441
  // ====== Relational ======
440
442
  assoc: function(t, e, n = {}) {
@@ -443,17 +445,17 @@ c(Array.prototype, {
443
445
  },
444
446
  // ====== Tree ======
445
447
  toTree: function(t = {}) {
446
- const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: u = null, hasRoot: h = !0 } = t, a = this.reduce((l, y) => l.$attr(y[e], y), {}), p = this.reduce((l, y) => (l.$attr(y[n], [], !1).$attr(y[n]).$push(y), l), {}), d = this.length && h ? this.find((l) => l[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: p[0] };
447
- c(d, { [i]: d });
448
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: u = null, hasRoot: c = !0 } = t, a = this.reduce((l, y) => l.$attr(y[e], y), {}), p = this.reduce((l, y) => (l.$attr(y[n], [], !1).$attr(y[n]).$push(y), l), {}), d = this.length && c ? this.find((l) => l[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: p[0] };
449
+ h(d, { [i]: d });
448
450
  for (const l of this)
449
- c(l, { [i]: d, [s]: a[l[n]] }), l[o] = p[l[e]] || u;
451
+ h(l, { [i]: d, [s]: a[l[n]] }), l[o] = p[l[e]] || u;
450
452
  return d.$tree$each((l) => l[r] = l[s] ? l[s][r] + 1 : 0, -1, o), d;
451
453
  },
452
454
  $tree2tree: function(t = {}, e = null, n = null) {
453
- const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: u = "parent", children: h = "children", empty: a = null } = t;
454
- e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [u]: null, [h]: this }, n = n || e;
455
+ const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: u = "parent", children: c = "children", empty: a = null } = t;
456
+ e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [u]: null, [c]: this }, n = n || e;
455
457
  for (const p of this)
456
- c(p, { [o]: e, [u]: n }), p[i] = n[r], p[s] = n[s] + 1, p[h] = p[h] && p[h].length ? p[h] : a, p[h]?.$tree2tree(t, e, p);
458
+ h(p, { [o]: e, [u]: n }), p[i] = n[r], p[s] = n[s] + 1, p[c] = p[c] && p[c].length ? p[c] : a, p[c]?.$tree2tree(t, e, p);
457
459
  return e;
458
460
  },
459
461
  $tree$find: function(t, e = !0, n = -1, r = "children") {
@@ -473,10 +475,10 @@ c(Array.prototype, {
473
475
  return this.map((s) => s.$tree$map(t, e, n, r, i));
474
476
  }
475
477
  });
476
- c(Map, {
478
+ h(Map, {
477
479
  ...g()
478
480
  });
479
- c(Map.prototype, {
481
+ h(Map.prototype, {
480
482
  ...m(["size", "$length"]),
481
483
  ...$(Map.prototype, "entries", "keys", "values"),
482
484
  ...f(Map.prototype, null, "t", ["set", "$set"], ["delete", "$delete"]),
@@ -506,10 +508,10 @@ c(Map.prototype, {
506
508
  }
507
509
  });
508
510
  typeof Map.prototype.getOrInsert > "u" && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed);
509
- c(Set, {
511
+ h(Set, {
510
512
  ...g()
511
513
  });
512
- c(Set.prototype, {
514
+ h(Set.prototype, {
513
515
  ...m(["size", "$length"]),
514
516
  ...$(Set.prototype, "entries", "keys", "values"),
515
517
  ...f(Set.prototype, null, "t", ["add", "$add"], ["delete", "$delete"]),
@@ -535,7 +537,7 @@ c(Set.prototype, {
535
537
  }
536
538
  });
537
539
  typeof Set.prototype.union > "u" && (Set.prototype.union = Set.prototype.$union, Set.prototype.intersection = Set.prototype.$intersection, Set.prototype.difference = Set.prototype.$difference, Set.prototype.symmetricDifference = Set.prototype.$symmetricDifference);
538
- c(Date, {
540
+ h(Date, {
539
541
  new: function(...t) {
540
542
  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);
541
543
  },
@@ -571,7 +573,7 @@ c(Date, {
571
573
  return [n, r];
572
574
  }
573
575
  });
574
- c(Date.prototype, {
576
+ h(Date.prototype, {
575
577
  format: function(t = "y-m-d h:i:s") {
576
578
  if (this.getTime() === 0)
577
579
  return "-";
@@ -616,17 +618,17 @@ c(Date.prototype, {
616
618
  return this.getTime();
617
619
  }
618
620
  });
619
- c(RegExp, {
621
+ h(RegExp, {
620
622
  ...g()
621
623
  });
622
- c(RegExp.prototype, {
624
+ h(RegExp.prototype, {
623
625
  toJSON: function() {
624
626
  return this.toString();
625
627
  }
626
628
  });
627
- c(Promise, {
629
+ h(Promise, {
628
630
  ...g(),
629
- channel: function() {
631
+ $channel: function() {
630
632
  let t = null, e = null;
631
633
  return [new this((r, i) => {
632
634
  t = r, e = i;
@@ -639,13 +641,13 @@ c(Promise, {
639
641
  }), resolve: t, reject: e };
640
642
  }
641
643
  });
642
- c(Promise.prototype, {
644
+ h(Promise.prototype, {
643
645
  tryCatch: function() {
644
646
  return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
645
647
  }
646
648
  });
647
649
  typeof Promise.withResolvers > "u" && (Promise.withResolvers = Promise.$withResolvers);
648
- c(JSON, {
650
+ h(JSON, {
649
651
  $parse: function(t, e = null) {
650
652
  try {
651
653
  if (typeof t != "string")
@@ -656,17 +658,17 @@ c(JSON, {
656
658
  }
657
659
  }
658
660
  });
659
- typeof Iterator < "u" && c(Iterator.prototype, {
661
+ typeof Iterator < "u" && h(Iterator.prototype, {
660
662
  toArray: function() {
661
663
  return [...this];
662
664
  }
663
665
  });
664
- c(ArrayBuffer.prototype, {
666
+ h(ArrayBuffer.prototype, {
665
667
  toUint8Array: function() {
666
668
  return new Uint8Array(this);
667
669
  }
668
670
  });
669
- c(Uint8Array, {
671
+ h(Uint8Array, {
670
672
  ...g(),
671
673
  fromString: function(t) {
672
674
  return new TextEncoder().encode(t);
@@ -696,7 +698,7 @@ c(Uint8Array, {
696
698
  return new Uint8Array(e);
697
699
  }
698
700
  });
699
- c(Uint8Array.prototype, {
701
+ h(Uint8Array.prototype, {
700
702
  setFromString(t, e = 0) {
701
703
  const n = Uint8Array.fromString(t);
702
704
  return this.set(n, e), { read: n.length, written: n.length };
@@ -740,7 +742,7 @@ c(Uint8Array.prototype, {
740
742
  typeof Uint8Array.fromBase64 > "u" && (Uint8Array.fromHex = Uint8Array.$fromHex, Uint8Array.fromBase64 = Uint8Array.$fromBase64);
741
743
  typeof Uint8Array.prototype.setFromHex > "u" && (Uint8Array.prototype.setFromHex = Uint8Array.prototype.$setFromHex, Uint8Array.prototype.setFromBase64 = Uint8Array.prototype.$setFromBase64, Uint8Array.prototype.toHex = Uint8Array.prototype.$toHex, Uint8Array.prototype.toBase64 = Uint8Array.prototype.$toBase64);
742
744
  let D = 0, w = 0, A = 0;
743
- c(Math, {
745
+ h(Math, {
744
746
  randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
745
747
  if (t < e)
746
748
  throw new Error("randstr: len < slen");
@@ -816,7 +818,7 @@ class M extends Map {
816
818
  return this.set(e, n);
817
819
  }
818
820
  }
819
- c(M, {
821
+ h(M, {
820
822
  ...g()
821
823
  });
822
824
  typeof globalThis.LRU > "u" && (globalThis.LRU = M);
@@ -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 m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,"$"+n];e[i]=function(){return this[r]}}return e}function a(t,e,n,...r){const i={},s=(o,h,c)=>(h!==null&&o.splice(h>=0?h:o.length+h+1,0,c),o);for(const o of r){const[h,c]=Array.isArray(o)?o:[o,"$"+o+n.toString().replaceAll("-","_")];if(n==="")i[c]=function(...f){return t[h].apply(this,s(f,e,this))};else if(n==="t")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),this};else if(n==="a")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f};else if(n>=0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[n]};else if(n<0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[f.length+n]};else throw Error("unreachable")}return i}function $(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,"$"+r];n[s]=function(...o){return[...t[i].apply(this,o)]}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),h=Object.prototype.toString.call(s);if(o!==h)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const c in s)i[c]=r(i[c],s[c]);return i}else return s};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),b=w({array:!0});u(Object,{...g(),isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge$:function(...t){return A(this,...t)},concat:function(...t){return b(this,...t)}}),u(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...a(Object,0,"","entries","keys","values","assign"),...a(JSON,0,"","stringify"),$merge:function(...t){return A(this,...t)},$concat:function(...t){return b(this,...t)},$empty:function(){return Object.keys(this).length==0},$in:function(t){return t in this},$pick:function(...t){const e={};for(const n of t)e[n]=this[n];return e},$omit:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},$attr:function(...t){if(typeof this!="object")return this;const[e,n,r,i]=t;return t.length==1?this[e]:t.length==2?(this[e]=n,this):typeof r=="boolean"?(e in this===r&&(this[e]=n),this):r=="define"||r===null?Object.defineProperty(this,e,{value:n,enumerable:!1,configurable:!0,writable:!0,...i}):r==="+"?(this[e]=(this[e]??i??0)+n,this):r==="-"?(this[e]=(this[e]??i??0)-n,this):r==="*"?(this[e]=(this[e]??i??0)*n,this):r==="/"?(this[e]=(this[e]??i??0)/n,this):this},$pipe:function(t,...e){return t(this,...e)},$tee:function(t,...e){return t(this,...e),this},$toArray:function(){return Array.isArray(this)?this:[this]},...a(console,-1,"t",["debug","$debug"],["log","$log"],["info","$info"],["warn","$warn"],["error","$error"],["dir","$dir"]),$debugger:function(...t){console.debug(this,...t);debugger;return this},$getParents: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},$getChildrens:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,h)=>{if(o&&r.push(s),!(h==0||!s[n]||s[n].length==0))for(const c of s[n])i(c,!0,h-1)};return i(this,t,e),r},$tree$find: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.$tree$find(t,!0,n-1,r);if(s!==null)return s}return null},$tree$each: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.$tree$each(t,!0,n-1,r);return this}},$tree$map: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 h of this[r])o.push(h.$tree$map(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...a(Math,0,"",["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),fixed:function(t=0){return+this.toFixed(t)},round:function(t=0){return Math.round(this*10**t)/10**t},add:function(t,...e){return typeof t=="function"?t(this,...e):this+t},sub:function(t,...e){return typeof t=="function"?t(this,...e):this-t},mul:function(t,...e){return typeof t=="function"?t(this,...e):this*t},div:function(t,...e){return typeof t=="function"?t(this,...e):this/t},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"},unit:function(t,e=0){let n=this,r="";for(const[i,s]of Object.entries(t)){if(r=i,s===0||n<s)break;n=n/s}return e<0?+n.toFixed(0-e)+r:n.toFixed(e)+r},units:function(t,e=!1){let n=this,r=[];for([unit,size]of Object.entries(t))if(size==0||n<size){r.push([n,unit]);break}else r.push([n%size,unit]),n=Math.floor(n/size);return e?r:r.reverse().map(([i,s])=>i+s).join("")},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this>=BigInt(Number.MIN_SAFE_INTEGER)&&this<=BigInt(Number.MAX_SAFE_INTEGER)?Number(this):this.toString()}}),u(String.prototype,{...g(),...m(["length","length$"]),$substring: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)},$substr:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},$split:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.$push(n.splice(e-1).join(t))},$split$number:function(t=","){return this.$split(t).map(e=>+e)},$split$segment: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},fixed:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),u(Array,{...g(),range:function(...t){let e=[],n=0,r=0,i=1,s=typeof t[t.length-1]=="boolean"?t.pop():!0,o=typeof t[t.length-1]=="function"?t.pop():(h,c,f)=>h;switch(t.length){case 1:[r]=t;break;case 2:[n,r]=t;break;case 3:[n,r,i]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(i==0)throw new Error("step cannot be 0!");for(let h=0,c=0,f=Math.abs(r-n),p=Math.abs(i),d=n<=r?1:-1;c<f;c+=p)e.push(s?o(n+c*d,h++,e):o());return e}}),u(Array.prototype,{...m("length"),...$(Array.prototype,"entries","keys","values"),...a(Array.prototype,null,"","map"),...a(Array.prototype,null,"t",["push","$push"],["pop","$pop"],["shift","$shift"],["unshift","$unshift"],["splice","$splice"]),...a(Array.prototype,null,"a","push","unshift"),...a(Array.prototype,null,0,"push","unshift"),$empty:function(){return this.length==0},first:function(t=null){return this.length?this[0]:t},last:function(t=null){return this.length?this[this.length-1]:t},$find:function(t,e=null){return this.find(t)??e},equals:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique: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,"t",["forEach","each"]),each$async:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},map$async:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},shuffle:function(t=!1){let e=this.length;for(;e;){const n=Math.random()*e--|0;[this[n],this[e]]=[this[e],this[n]]}return this},union:function(t){return Set.new(this).union(Set.new(t)).toArray()},intersection:function(t){return Set.new(this).intersection(Set.new(t)).toArray()},difference:function(t){return Set.new(this).difference(Set.new(t)).toArray()},symmetricDifference:function(t){return Set.new(this).symmetricDifference(Set.new(t)).toArray()},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().decode()},assoc:function(t,e,n={}){const r=this.unique$(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each$(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:h=null,hasRoot:c=!0}=t,f=this.reduce((l,y)=>l.$attr(y[e],y),{}),p=this.reduce((l,y)=>(l.$attr(y[n],[],!1).$attr(y[n]).$push(y),l),{}),d=this.length&&c?this.find(l=>l[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:p[0]};u(d,{[i]:d});for(const l of this)u(l,{[i]:d,[s]:f[l[n]]}),l[o]=p[l[e]]||h;return d.$tree$each(l=>l[r]=l[s]?l[s][r]+1:0,-1,o),d},$tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:h="parent",children:c="children",empty:f=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[h]:null,[c]:this},n=n||e;for(const p of this)u(p,{[o]:e,[h]:n}),p[i]=n[r],p[s]=n[s]+1,p[c]=p[c]&&p[c].length?p[c]:f,p[c]?.$tree2tree(t,e,p);return e},$tree$find:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.$tree$find(t,e,n,r);if(s!==null)return s}return null},$tree$each:function(t,e=!0,n=-1,r="children"){for(const i of this)i.$tree$each(t,e,n,r);return this},$tree$map:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.$tree$map(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...m(["size","$length"]),...$(Map.prototype,"entries","keys","values"),...a(Map.prototype,null,"t",["set","$set"],["delete","$delete"]),...a(Map.prototype,null,"a","set","delete"),...a(Map.prototype,null,0,"set","delete"),...a(Map.prototype,null,1,"set","delete"),$getOrInsert:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,e)},$getOrInsertComputed:function(t,e){return this.has(t)?this.get(t):this.$set1(t,e(t))},$get:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?e(t):e)},$get$async:async function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?await e(t):e)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Map.prototype.getOrInsert>"u"&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),u(Set,{...g()}),u(Set.prototype,{...m(["size","$length"]),...$(Set.prototype,"entries","keys","values"),...a(Set.prototype,null,"t",["add","$add"],["delete","$delete"]),...a(Set.prototype,null,"a","add","delete"),...a(Set.prototype,null,0,"add","delete"),$union:function(t){return new Set([...this,...t])},$intersection:function(t){return new Set([...this].filter(e=>t.has(e)))},$difference:function(t){return new Set([...this].filter(e=>!t.has(e)))},$symmetricDifference:function(t){return new Set([...[...this].filter(e=>!t.has(e)),...[...t].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Set.prototype.union>"u"&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),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){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,{...g(),channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},$withResolvers:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),typeof Promise.withResolvers>"u"&&(Promise.withResolvers=Promise.$withResolvers),u(JSON,{$parse: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[...this]}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),u(Uint8Array,{...g(),fromString:function(t){return new TextEncoder().encode(t)},$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,{setFromString(t,e=0){const n=Uint8Array.fromString(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromHex(t,e=0){const n=Uint8Array.fromHex(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromBase64(t,e=0){const n=Uint8Array.fromBase64(t);return this.set(n,e),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$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},toArray:function(){return new Array(...this)}}),typeof Uint8Array.fromBase64>"u"&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),typeof Uint8Array.prototype.setFromHex>"u"&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);let D=0,x=0,S=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,h=0;h<e;h++){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++D},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===S?t*2048+ ++x%2048:(S=t)*2048+(x=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?.(s)},name:t};return{[n.name]:n,[r.name]:r}}});class M extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;const n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsert(e,n){super.has(e)||super.set(e,n);const r=super.get(e);return super.delete(e),super.set(e,r),r}getOrInsertComputed(e,n){super.has(e)||super.set(e,n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}async getOrInsertComputedAsync(e,n){super.has(e)||super.set(e,await n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}set(e,n){super.has(e)&&super.delete(e),super.set(e,n),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,n){return this.set(e,n)}}u(M,{...g()}),typeof globalThis.LRU>"u"&&(globalThis.LRU=M)}));
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 m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,"$"+n];e[i]=function(){return this[r]}}return e}function a(t,e,n,...r){const i={},s=(o,h,c)=>(h!==null&&o.splice(h>=0?h:o.length+h+1,0,c),o);for(const o of r){const[h,c]=Array.isArray(o)?o:[o,"$"+o+n.toString().replaceAll("-","_")];if(n==="")i[c]=function(...f){return t[h].apply(this,s(f,e,this))};else if(n==="t")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),this};else if(n==="a")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f};else if(n>=0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[n]};else if(n<0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[f.length+n]};else throw Error("unreachable")}return i}function $(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,"$"+r];n[s]=function(...o){return[...t[i].apply(this,o)]}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),h=Object.prototype.toString.call(s);if(o!==h)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const c in s)i[c]=r(i[c],s[c]);return i}else return s};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),b=w({array:!0});u(Object,{...g(),isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge:function(...t){return A(this,...t)},concat:function(...t){return b(this,...t)}}),u(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...a(Object,0,"","entries","keys","values","assign"),...a(JSON,0,"","stringify"),$merge:function(...t){return A(this,...t)},$concat:function(...t){return b(this,...t)},$empty:function(){return Object.keys(this).length==0},$has:function(t){return t in this},$pick:function(...t){const e={};for(const n of t)e[n]=this[n];return e},$omit:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},$attr:function(...t){if(typeof this!="object")return this;const[e,n,r,i]=t;return t.length==1?this[e]:t.length==2?(this[e]=n,this):typeof r=="boolean"?(e in this===r&&(this[e]=n),this):r=="define"||r===null?Object.defineProperty(this,e,{value:n,enumerable:!1,configurable:!0,writable:!0,...i}):r==="+"?(this[e]=(this[e]??i??0)+n,this):r==="-"?(this[e]=(this[e]??i??0)-n,this):r==="*"?(this[e]=(this[e]??i??0)*n,this):r==="/"?(this[e]=(this[e]??i??0)/n,this):this},$pipe:function(t,...e){return t(this,...e)},$tee:function(t,...e){return t(this,...e),this},$toArray:function(){return Array.isArray(this)?this:[this]},...a(console,-1,"t",["debug","$debug"],["log","$log"],["info","$info"],["warn","$warn"],["error","$error"],["dir","$dir"]),$debugger:function(...t){console.debug(this,...t);debugger;return this},$getParents: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},$getChildrens:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,h)=>{if(o&&r.push(s),!(h==0||!s[n]||s[n].length==0))for(const c of s[n])i(c,!0,h-1)};return i(this,t,e),r},$tree$find: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.$tree$find(t,!0,n-1,r);if(s!==null)return s}return null},$tree$each: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.$tree$each(t,!0,n-1,r);return this}},$tree$map: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 h of this[r])o.push(h.$tree$map(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...a(Math,0,"",["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),fixed:function(t=0){return+this.toFixed(t)},round:function(t=0){return Math.round(this*10**t)/10**t},add:function(t,...e){return typeof t=="function"?t(this,...e):this+t},sub:function(t,...e){return typeof t=="function"?t(this,...e):this-t},mul:function(t,...e){return typeof t=="function"?t(this,...e):this*t},div:function(t,...e){return typeof t=="function"?t(this,...e):this/t},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"},unit:function(t,e=0){let n=this,r="";for(const[i,s]of Object.entries(t)){if(r=i,s===0||n<s)break;n=n/s}return e<0?+n.toFixed(0-e)+r:n.toFixed(e)+r},units:function(t,e=!1){let n=this,r=[];for([unit,size]of Object.entries(t))if(size==0||n<size){r.push([n,unit]);break}else r.push([n%size,unit]),n=Math.floor(n/size);return e?r:r.reverse().map(([i,s])=>i+s).join("")},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this>=BigInt(Number.MIN_SAFE_INTEGER)&&this<=BigInt(Number.MAX_SAFE_INTEGER)?Number(this):this.toString()}}),u(String,{...g()}),u(String.prototype,{...m(["length","length$"]),$substring: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)},$substr:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},$split:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.$push(n.splice(e-1).join(t))},$split$number:function(t=","){return this.$split(t).map(e=>+e)},$split$segment: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},fixed:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),u(Array,{...g(),range:function(...t){let e=[],n=0,r=0,i=1,s=typeof t[t.length-1]=="boolean"?t.pop():!0,o=typeof t[t.length-1]=="function"?t.pop():(h,c,f)=>h;switch(t.length){case 1:[r]=t;break;case 2:[n,r]=t;break;case 3:[n,r,i]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(i==0)throw new Error("step cannot be 0!");for(let h=0,c=0,f=Math.abs(r-n),p=Math.abs(i),d=n<=r?1:-1;c<f;c+=p)e.push(s?o(n+c*d,h++,e):o());return e}}),u(Array.prototype,{...m("length"),...$(Array.prototype,"entries","keys","values"),...a(Array.prototype,null,"","map"),...a(Array.prototype,null,"t",["push","$push"],["pop","$pop"],["shift","$shift"],["unshift","$unshift"],["splice","$splice"]),...a(Array.prototype,null,"a","push","unshift"),...a(Array.prototype,null,0,"push","unshift"),$empty:function(){return this.length==0},first:function(t=null){return this.length?this[0]:t},last:function(t=null){return this.length?this[this.length-1]:t},$find:function(t,e=null){return this.find(t)??e},equals:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique: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,"t",["forEach","each"]),each$async:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},map$async:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},shuffle:function(t=!1){let e=this.length;for(;e;){const n=Math.random()*e--|0;[this[n],this[e]]=[this[e],this[n]]}return this},union:function(t){return Set.new(this).union(Set.new(t)).toArray()},intersection:function(t){return Set.new(this).intersection(Set.new(t)).toArray()},difference:function(t){return Set.new(this).difference(Set.new(t)).toArray()},symmetricDifference:function(t){return Set.new(this).symmetricDifference(Set.new(t)).toArray()},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(t,e,n={}){const r=this.unique$(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each$(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:h=null,hasRoot:c=!0}=t,f=this.reduce((l,y)=>l.$attr(y[e],y),{}),p=this.reduce((l,y)=>(l.$attr(y[n],[],!1).$attr(y[n]).$push(y),l),{}),d=this.length&&c?this.find(l=>l[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:p[0]};u(d,{[i]:d});for(const l of this)u(l,{[i]:d,[s]:f[l[n]]}),l[o]=p[l[e]]||h;return d.$tree$each(l=>l[r]=l[s]?l[s][r]+1:0,-1,o),d},$tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:h="parent",children:c="children",empty:f=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[h]:null,[c]:this},n=n||e;for(const p of this)u(p,{[o]:e,[h]:n}),p[i]=n[r],p[s]=n[s]+1,p[c]=p[c]&&p[c].length?p[c]:f,p[c]?.$tree2tree(t,e,p);return e},$tree$find:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.$tree$find(t,e,n,r);if(s!==null)return s}return null},$tree$each:function(t,e=!0,n=-1,r="children"){for(const i of this)i.$tree$each(t,e,n,r);return this},$tree$map:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.$tree$map(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...m(["size","$length"]),...$(Map.prototype,"entries","keys","values"),...a(Map.prototype,null,"t",["set","$set"],["delete","$delete"]),...a(Map.prototype,null,"a","set","delete"),...a(Map.prototype,null,0,"set","delete"),...a(Map.prototype,null,1,"set","delete"),$getOrInsert:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,e)},$getOrInsertComputed:function(t,e){return this.has(t)?this.get(t):this.$set1(t,e(t))},$get:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?e(t):e)},$get$async:async function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?await e(t):e)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Map.prototype.getOrInsert>"u"&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),u(Set,{...g()}),u(Set.prototype,{...m(["size","$length"]),...$(Set.prototype,"entries","keys","values"),...a(Set.prototype,null,"t",["add","$add"],["delete","$delete"]),...a(Set.prototype,null,"a","add","delete"),...a(Set.prototype,null,0,"add","delete"),$union:function(t){return new Set([...this,...t])},$intersection:function(t){return new Set([...this].filter(e=>t.has(e)))},$difference:function(t){return new Set([...this].filter(e=>!t.has(e)))},$symmetricDifference:function(t){return new Set([...[...this].filter(e=>!t.has(e)),...[...t].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Set.prototype.union>"u"&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),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){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,{...g(),$channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},$withResolvers:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),typeof Promise.withResolvers>"u"&&(Promise.withResolvers=Promise.$withResolvers),u(JSON,{$parse: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[...this]}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),u(Uint8Array,{...g(),fromString:function(t){return new TextEncoder().encode(t)},$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,{setFromString(t,e=0){const n=Uint8Array.fromString(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromHex(t,e=0){const n=Uint8Array.fromHex(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromBase64(t,e=0){const n=Uint8Array.fromBase64(t);return this.set(n,e),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$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},toArray:function(){return new Array(...this)}}),typeof Uint8Array.fromBase64>"u"&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),typeof Uint8Array.prototype.setFromHex>"u"&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);let D=0,S=0,x=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,h=0;h<e;h++){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++D},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===x?t*2048+ ++S%2048:(x=t)*2048+(S=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?.(s)},name:t};return{[n.name]:n,[r.name]:r}}});class M extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;const n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsert(e,n){super.has(e)||super.set(e,n);const r=super.get(e);return super.delete(e),super.set(e,r),r}getOrInsertComputed(e,n){super.has(e)||super.set(e,n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}async getOrInsertComputedAsync(e,n){super.has(e)||super.set(e,await n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}set(e,n){super.has(e)&&super.delete(e),super.set(e,n),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,n){return this.set(e,n)}}u(M,{...g()}),typeof globalThis.LRU>"u"&&(globalThis.LRU=M)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "2.0.5",
3
+ "version": "2.1.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",
@@ -13,12 +13,15 @@
13
13
  "esexts"
14
14
  ],
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "types.d.ts"
17
18
  ],
18
19
  "type": "module",
20
+ "types": "./types.d.ts",
19
21
  "main": "./dist/esexts.umd.cjs",
20
22
  "module": "./dist/esexts.js",
21
23
  "exports": {
24
+ "types": "./types.d.ts",
22
25
  "require": "./dist/esexts.umd.cjs",
23
26
  "import": "./dist/esexts.js"
24
27
  },
package/types.d.ts ADDED
@@ -0,0 +1,301 @@
1
+ declare global {
2
+ interface ObjectConstructor {
3
+ new(): Object;
4
+ isObject(o: any): boolean;
5
+ merge(...args: Object[]): Object;
6
+ concat(...args: Object[]): Object;
7
+ }
8
+
9
+ interface Object {
10
+ $clone(): Object;
11
+ $length(): number;
12
+ $entries(): IterableIterator<[string, any]>;
13
+ $keys(): IterableIterator<string>;
14
+ $values(): IterableIterator<any>;
15
+ $assign(...args: any[]): Object;
16
+ $stringify(v: any, replacer?: any, space?: string): string;
17
+ $merge(...args: Object[]): Object;
18
+ $concat(...args: Object[]): Object;
19
+ $empty(): boolean;
20
+ $has(key: string): boolean;
21
+ $pick(...keys: string[]): Object;
22
+ $omit(...keys: string[]): Object;
23
+ $attr(key: string): any;
24
+ $attr(key: string, val: any ): any;
25
+ $attr(key: string, val: any, exists?: boolean): any;
26
+ $attr(key: string, val: any, exists?: boolean, define?: boolean|Object): any;
27
+ $attr(key: string, val: any, exists?: boolean, defval?: any): any;
28
+ $pipe(pipe: (v: Object, ...args: any[]) => any, ...args: any[]): any;
29
+ $tee(tee: (v: Object, ...args: any[]) => any, ...args: any[]): any;
30
+ $toArray(): any[];
31
+ $debug(...args: any[]): any;
32
+ $log(...args: any[]): any;
33
+ $info(...args: any[]): any;
34
+ $warn(...args: any[]): any;
35
+ $error(...args: any[]): any;
36
+ $dir(...args: any[]): any;
37
+ $debugger(...args: any[]): any;
38
+ $getParents(self?: boolean, depth?: number, parent?: string): any[];
39
+ $getChildrens(self?: boolean, depth?: number, children?: string): any[];
40
+ $tree$find(cb: (node: any) => boolean, self?: boolean, depth?: number, children?: string): any;
41
+ $tree$each(cb: (node: any) => void, self?: boolean, depth?: number, children?: string): void;
42
+ $tree$map(cb: (node: any) => any, self?: boolean, depth?: number, children?: string, empty?: any): any;
43
+ }
44
+
45
+ interface Number {
46
+ ceil(): number;
47
+ floor(): number;
48
+ trunc(): number;
49
+ abs(): number;
50
+ max(...args: number[]): number;
51
+ min(...args: number[]): number;
52
+ fixed(decimal?: number): number;
53
+ round(precision?: number): number;
54
+ add(v: number): number;
55
+ add(v: ((v:number, ...args: any[]) => number), ...args: any[]): number;
56
+ sub(v: number): number;
57
+ sub(v: ((v:number, ...args: any[]) => number), ...args: any[]): number;
58
+ mul(v: number): number;
59
+ mul(v: ((v:number, ...args: any[]) => number), ...args: any[]): number;
60
+ div(v: number): number;
61
+ div(v: ((v:number, ...args: any[]) => number), ...args: any[]): number;
62
+ baseConvert(base?: number): string;
63
+ unit(units: Record<string, number>, decimal?: number): string;
64
+ units(units: Record<string, number>, array?: boolean): string | [number, string][];
65
+ toDate(): Date;
66
+ }
67
+
68
+ interface BigInt {
69
+ toJSON(): number | string;
70
+ }
71
+
72
+ interface StringConstructor {
73
+ new(): string;
74
+ }
75
+
76
+ interface String {
77
+ $length(): number;
78
+ $substring(s?: number, e?: number): string;
79
+ $substr(s?: number, e?: number): string;
80
+ $split(s?: string, n?: number): string[];
81
+ $split$number(s?: string): number[];
82
+ $split$segment(n?: number): string[];
83
+ sprintf(...args: any[]): string;
84
+ subOf(begin: string, end: string, n?: number, position?: number): string;
85
+ lastSubOf(begin: string, end: string, n?: number, position?: number): string;
86
+ camel2under(): string;
87
+ under2camel(): string;
88
+ camel2pascal(): string;
89
+ pascal2camel(): string;
90
+ under2kebab(): string;
91
+ kebab2under(): string;
92
+ baseConvert(base?: number): string;
93
+ fixed(decimal?: number): string;
94
+ toDate(): Date;
95
+ toUint8Array(): Uint8Array;
96
+ hexencode(): string;
97
+ hexdecode(): string;
98
+ base64encode(): string;
99
+ base64decode(): string;
100
+ }
101
+
102
+ interface ArrayConstructor {
103
+ new(): any[];
104
+ new<T>(): T[];
105
+ new<T>(...items: T[]): T[];
106
+ new<T>(length: number): T[];
107
+ range<T>(end: number, callback?: ((number: number, i: number, a: T[]) => T), input?: boolean): T[];
108
+ range<T>(start: number, end: number, callback?: ((number: number, i: number, a: T[]) => T), input?: boolean): T[];
109
+ range<T>(start: number, end: number, step: number, callback?: ((number: number, i: number, a: T[]) => T), input?: boolean): T[];
110
+ }
111
+
112
+ interface Array<T> {
113
+ $length(): number;
114
+ $entries(): IterableIterator<[number, T]>;
115
+ $keys(): IterableIterator<number>;
116
+ $values(): IterableIterator<T>;
117
+ $map<U>(callback: (v: any, i: number, array: T[]) => U): U[];
118
+ $push(...items: T[]): T[];
119
+ $pop(): T[];
120
+ $shift(): T[];
121
+ $unshift(...items: T[]): T[];
122
+ $splice(start: number, deleteCount?: number, ...items: T[]): T[];
123
+ $pusha(...items: T[]): T[];
124
+ $unshifta(...items: T[]): T[];
125
+ $push0(...items: T[]): T;
126
+ $unshift0(...items: T[]): T;
127
+ $empty(): boolean;
128
+ first(defval?: T): T;
129
+ last(defval?: T): T;
130
+ $find(cb: (value: T, index: number, array: T[]) => boolean, defval?: T): T;
131
+ equals(a: T[]): boolean;
132
+ unique(cb?: (value: T) => any): T[];
133
+ each(cb: (value: T, index: number, array: T[]) => void): T[];
134
+ each$async(cb: (value: T, index: number, array: T[]) => Promise<void>): Promise<T[]>;
135
+ map$async<U>(cb: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]>;
136
+ shuffle(clone?: boolean): T[];
137
+ union(a: T[]): T[];
138
+ intersection(a: T[]): T[];
139
+ difference(a: T[]): T[];
140
+ symmetricDifference(a: T[]): T[];
141
+ toMap(cb?: (value: T, index: number) => [any, any]): Map<any, any>;
142
+ toSet(cb?: (value: T) => any): Set<any>;
143
+ toUint8Array(): Uint8Array;
144
+ toBase64(): string;
145
+ toHex(): string;
146
+ decode(): string;
147
+ // assoc
148
+ // toTree
149
+ // $tree2tree
150
+ // $tree$find
151
+ // $tree$each
152
+ // $tree$map
153
+ }
154
+
155
+ interface MapConstructor {
156
+ new<K, V>(): Map<K, V>;
157
+ new<K, V>(iterator: Iterator<K, V, V>): Map<K, V>;
158
+ }
159
+
160
+ interface Map<K, V> {
161
+ $length(): number;
162
+ $entries(): IterableIterator<[K, V]>;
163
+ $keys(): IterableIterator<K>;
164
+ $values(): IterableIterator<V>;
165
+ $set(key: K, value: V): Map<K, V>;
166
+ $delete(key: K): Map<K, V>;
167
+ $seta(key: K, value: V): [K, V];
168
+ $deletea(key: K): [K];
169
+ $set0(key: K, value: V): K;
170
+ $delete0(key: K): K;
171
+ $set1(key: K, value: V): V;
172
+ $delete1(key: K): V;
173
+ $getOrInsert(key: K, defval?: V): V;
174
+ $getOrInsertComputed(key: K, callback: (key: K) => V): V;
175
+ $get(key: K, defval?: V | ((key: K) => V)): V;
176
+ $get$async(key: K, defval?: V | ((key: K) => Promise<V>)): Promise<V>;
177
+ toObject(): Record<string, V>;
178
+ toArray(): [K, V][];
179
+ toJSON(): [K, V][];
180
+ getOrInsert(key: K, defval?: V): V;
181
+ getOrInsertComputed(key: K, callback: (key: K) => V): V;
182
+ }
183
+
184
+ interface SetConstructor {
185
+ new<T>(): Set<T>;
186
+ new<T>(iterator: Iterator<T, T, T>): Set<T>;
187
+ }
188
+
189
+ interface Set<T> {
190
+ $length(): number;
191
+ $entries(): IterableIterator<[T, T]>;
192
+ $keys(): IterableIterator<T>;
193
+ $values(): IterableIterator<T>;
194
+ $add(value: T): Set<T>;
195
+ $delete(value: T): Set<T>;
196
+ $adda(value: T): [T];
197
+ $deletea(value: T): [T];
198
+ $add0(value: T): T;
199
+ $delete0(value: T): T;
200
+ $union(s: Set<T>): Set<T>;
201
+ $intersection(s: Set<T>): Set<T>;
202
+ $difference(s: Set<T>): Set<T>;
203
+ $symmetricDifference(s: Set<T>): Set<T>;
204
+ toArray(): T[];
205
+ toJSON(): T[];
206
+ }
207
+
208
+ interface DateConstructor {
209
+ new(...args: any[]): Date;
210
+ format(format?: string): string;
211
+ unix(): number;
212
+ fromUnix(time: number): Date;
213
+ expr(opts: { y?: number; m?: number; d?: number; h?: number; i?: number; s?: number }): Date;
214
+ toDayRange(): [number, number];
215
+ toWeekRange(): [number, number];
216
+ toMonthRange(): [number, number];
217
+ toYearRange(): [number, number];
218
+ }
219
+
220
+ interface Date {
221
+ format(format?: string): string;
222
+ unix(): number;
223
+ isLeapYear(): boolean;
224
+ getMonthDay(): number;
225
+ expr(opts?: { y?: number; m?: number; d?: number; h?: number; i?: number; s?: number }): Date;
226
+ begin(n?: number): Date;
227
+ end(n?: number): Date;
228
+ week(n?: number, dir?: number): Date;
229
+ toJSON(): string;
230
+ }
231
+
232
+ interface RegExp {
233
+ toJSON(): string;
234
+ }
235
+
236
+ interface PromiseConstructor {
237
+ $channel(): [Promise<any>, (value: any) => void, (reason: any) => void];
238
+ $withResolvers(): { promise: Promise<any>; resolve: (value: any) => void; reject: (reason: any) => void; };
239
+ }
240
+
241
+ interface Promise<T> {
242
+ tryCatch(): Promise<[T, null] | [null, any]>;
243
+ }
244
+
245
+ interface JSON {
246
+ $parse(v: any, defval?: any): any;
247
+ }
248
+
249
+ interface Iterator<T> {
250
+ toArray(): T[];
251
+ }
252
+
253
+ interface ArrayBuffer {
254
+ toUint8Array(): Uint8Array;
255
+ }
256
+
257
+ interface Uint8ArrayConstructor {
258
+ new(): Uint8Array;
259
+ new(length: number): Uint8Array;
260
+ fromString(str: string): Uint8Array;
261
+ $fromHex(str: string): Uint8Array;
262
+ $fromBase64(str: string): Uint8Array;
263
+ }
264
+
265
+ interface Uint8Array {
266
+ setFromString(str: string, targetOffset?: number): Object;
267
+ $setFromHex(str: string, targetOffset?: number): Object;
268
+ $setFromBase64(str: string, targetOffset?: number): Object;
269
+ toString(): string;
270
+ $toHex(): string;
271
+ $toBase64(): string;
272
+ toArray(): number[];
273
+ }
274
+
275
+ interface Math {
276
+ randstr(len?: number, slen?: number, chars?: string, schars?: string): string;
277
+ randint(min?: number, max?: number): number;
278
+ incrid(): number;
279
+ incrstr(): string;
280
+ uniqid(now?: number): number;
281
+ uniqstr(): string;
282
+ sleep(duration: number): Promise<void>;
283
+ useTemplate(name: string): any;
284
+ }
285
+
286
+ class LRU<K, V> extends Map<K, V> {
287
+ constructor(capacity: number);
288
+ get(key: K): V | undefined;
289
+ getOrInsert(key: K, defval: V): V;
290
+ getOrInsertComputed(key: K, callback: (key: K) => V): V;
291
+ getOrInsertComputedAsync(key: K, callback: (key: K) => Promise<V>): Promise<V>;
292
+ set(key: K, value: V): this;
293
+ put(key: K, value: V): this;
294
+ }
295
+
296
+ interface LRUConstructor {
297
+ new <K, V>(capacity: number): LRU<K, V>;
298
+ }
299
+ }
300
+
301
+ export {};