jc-structure 0.1.21 → 0.1.23
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/jc-structure.js +132 -135
- package/dist/jc-structure.umd.cjs +2 -2
- package/index.d.ts +58 -53
- package/package.json +1 -1
package/dist/jc-structure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class D {
|
|
2
2
|
items = {};
|
|
3
3
|
count = 0;
|
|
4
4
|
lowestCount = 0;
|
|
@@ -49,7 +49,7 @@ class H {
|
|
|
49
49
|
return this.isEmpty() ? "" : `Queue(size: ${this.size()}):[${this.items[this.lowestCount]},...rest]`;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
class
|
|
52
|
+
class U {
|
|
53
53
|
items = {};
|
|
54
54
|
count = 0;
|
|
55
55
|
constructor() {
|
|
@@ -100,7 +100,7 @@ class D {
|
|
|
100
100
|
return this.isEmpty() ? "" : `Stack(count: ${this.count}):[${this.items[this.count - 1]},...rest]`;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class q {
|
|
104
104
|
stack = [];
|
|
105
105
|
minStack = [];
|
|
106
106
|
push(t) {
|
|
@@ -129,13 +129,13 @@ class U {
|
|
|
129
129
|
return this.isEmpty() ? "" : `MinStack(count: ${this.size()}):[${this.getMin()},...rest]`;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
132
|
+
function N(o, t) {
|
|
133
|
+
return o === t ? 0 : o < t ? -1 : 1;
|
|
134
134
|
}
|
|
135
135
|
class E {
|
|
136
136
|
heap = [];
|
|
137
137
|
compareFn;
|
|
138
|
-
constructor(t =
|
|
138
|
+
constructor(t = N) {
|
|
139
139
|
this.compareFn = t;
|
|
140
140
|
}
|
|
141
141
|
static getLeftIndex(t) {
|
|
@@ -166,7 +166,7 @@ class E {
|
|
|
166
166
|
return this.heap.toString();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class
|
|
169
|
+
class z extends E {
|
|
170
170
|
insert(t) {
|
|
171
171
|
return t ? !1 : (this.heap.push(t), this.siftUp(this.heap.length - 1), !0);
|
|
172
172
|
}
|
|
@@ -186,15 +186,15 @@ class L extends E {
|
|
|
186
186
|
E.swap(this.heap, e, t), t = e, e = E.getParentIndex(t);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
class
|
|
190
|
-
constructor(t = (e, s) =>
|
|
189
|
+
class F extends z {
|
|
190
|
+
constructor(t = (e, s) => N(s, e)) {
|
|
191
191
|
super(t);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
return { value:
|
|
194
|
+
function $(o) {
|
|
195
|
+
return { value: o };
|
|
196
196
|
}
|
|
197
|
-
class
|
|
197
|
+
class T {
|
|
198
198
|
capacity;
|
|
199
199
|
length = 0;
|
|
200
200
|
head = null;
|
|
@@ -224,14 +224,14 @@ class F {
|
|
|
224
224
|
}
|
|
225
225
|
update(t, e) {
|
|
226
226
|
let s = this.lookup.get(t);
|
|
227
|
-
s ? (this.detach(s), this.prepend(s), s.value = e) : (s =
|
|
227
|
+
s ? (this.detach(s), this.prepend(s), s.value = e) : (s = $(e), this.length++, this.prepend(s), this.trimCache(), this.lookup.set(t, s), this.reverseLookup);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
class
|
|
230
|
+
class R {
|
|
231
231
|
value;
|
|
232
232
|
next = void 0;
|
|
233
233
|
}
|
|
234
|
-
class
|
|
234
|
+
class B {
|
|
235
235
|
count = 0;
|
|
236
236
|
head = void 0;
|
|
237
237
|
constructor() {
|
|
@@ -264,7 +264,7 @@ class T {
|
|
|
264
264
|
return this.getElementAt(t)?.value;
|
|
265
265
|
}
|
|
266
266
|
insert(t, e) {
|
|
267
|
-
let s = new
|
|
267
|
+
let s = new R();
|
|
268
268
|
if (s.value = t, e > this.count || e < 0)
|
|
269
269
|
throw new Error("index error");
|
|
270
270
|
this.count++;
|
|
@@ -276,7 +276,7 @@ class T {
|
|
|
276
276
|
r = this.getElementAt(e - 1), i = r.next, r.next = s, s.next = i;
|
|
277
277
|
}
|
|
278
278
|
push(t) {
|
|
279
|
-
let e = new
|
|
279
|
+
let e = new R();
|
|
280
280
|
if (e.value = t, this.count++, this.isEmpty()) {
|
|
281
281
|
this.head = e;
|
|
282
282
|
return;
|
|
@@ -310,17 +310,17 @@ class T {
|
|
|
310
310
|
return t = t.slice(0, -1), t;
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
class
|
|
313
|
+
class V {
|
|
314
314
|
key;
|
|
315
315
|
value;
|
|
316
316
|
constructor(t, e) {
|
|
317
317
|
this.key = t, this.value = e;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
-
function b(
|
|
321
|
-
return
|
|
320
|
+
function b(o, t = { emptyString: !1, zeroNumber: !1 }) {
|
|
321
|
+
return o == null ? !(t.emptyString && o === "" || t.zeroNumber && o === 0) : !1;
|
|
322
322
|
}
|
|
323
|
-
class
|
|
323
|
+
class H {
|
|
324
324
|
table = [];
|
|
325
325
|
constructor() {
|
|
326
326
|
}
|
|
@@ -339,7 +339,7 @@ class V {
|
|
|
339
339
|
let s = this.getItemIndex(t);
|
|
340
340
|
this.table[s].value = e;
|
|
341
341
|
} else {
|
|
342
|
-
const s = new
|
|
342
|
+
const s = new V(t, e);
|
|
343
343
|
this.table.push(s);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
@@ -390,12 +390,12 @@ class V {
|
|
|
390
390
|
return t = t.slice(0, -1), t;
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
class
|
|
393
|
+
class G {
|
|
394
394
|
isDirected;
|
|
395
395
|
vertices;
|
|
396
396
|
adjList;
|
|
397
397
|
constructor(t = !1) {
|
|
398
|
-
this.isDirected = t, this.vertices = [], this.adjList = new
|
|
398
|
+
this.isDirected = t, this.vertices = [], this.adjList = new H();
|
|
399
399
|
}
|
|
400
400
|
addVertex(t) {
|
|
401
401
|
this.vertices.includes(t) || (this.vertices.push(t), this.adjList.set(t, []));
|
|
@@ -586,12 +586,12 @@ class g {
|
|
|
586
586
|
}
|
|
587
587
|
static getIntersection(t, e, s = g.EPSILON) {
|
|
588
588
|
if (g.isParallel(t, e)) return null;
|
|
589
|
-
const r = t.p1.x, i = t.p1.y, n = t.p2.x, a = t.p2.y,
|
|
589
|
+
const r = t.p1.x, i = t.p1.y, n = t.p2.x, a = t.p2.y, h = e.p1.x, d = e.p1.y, f = e.p2.x, c = e.p2.y, l = (r - n) * (d - c) - (i - a) * (h - f);
|
|
590
590
|
if (Math.abs(l) < s) return null;
|
|
591
|
-
const m = ((r -
|
|
592
|
-
if (m >= 0 && m <= 1 &&
|
|
593
|
-
const
|
|
594
|
-
return new u(
|
|
591
|
+
const m = ((r - h) * (d - c) - (i - d) * (h - f)) / l, v = -((r - n) * (i - d) - (i - a) * (r - h)) / l;
|
|
592
|
+
if (m >= 0 && m <= 1 && v >= 0 && v <= 1) {
|
|
593
|
+
const C = r + m * (n - r), L = i + m * (a - i);
|
|
594
|
+
return new u(C, L);
|
|
595
595
|
}
|
|
596
596
|
return null;
|
|
597
597
|
}
|
|
@@ -599,13 +599,13 @@ class g {
|
|
|
599
599
|
return g.getIntersection(t, e) !== null;
|
|
600
600
|
}
|
|
601
601
|
static distanceToPoint(t, e, s = g.EPSILON) {
|
|
602
|
-
const r = e.x - t.p1.x, i = e.y - t.p1.y, n = t.p2.x - t.p1.x, a = t.p2.y - t.p1.y,
|
|
602
|
+
const r = e.x - t.p1.x, i = e.y - t.p1.y, n = t.p2.x - t.p1.x, a = t.p2.y - t.p1.y, h = r * n + i * a, d = n * n + a * a;
|
|
603
603
|
let f = -1;
|
|
604
|
-
d > s && (f =
|
|
604
|
+
d > s && (f = h / d);
|
|
605
605
|
let c, l;
|
|
606
606
|
f < 0 ? (c = t.p1.x, l = t.p1.y) : f > 1 ? (c = t.p2.x, l = t.p2.y) : (c = t.p1.x + f * n, l = t.p1.y + f * a);
|
|
607
|
-
const m = e.x - c,
|
|
608
|
-
return Math.hypot(m +
|
|
607
|
+
const m = e.x - c, v = e.y - l;
|
|
608
|
+
return Math.hypot(m + v);
|
|
609
609
|
}
|
|
610
610
|
p1;
|
|
611
611
|
p2;
|
|
@@ -640,14 +640,14 @@ class g {
|
|
|
640
640
|
return this.p2;
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
class
|
|
643
|
+
class P {
|
|
644
644
|
static EPSILON = 1e-10;
|
|
645
645
|
name;
|
|
646
646
|
constructor(t) {
|
|
647
647
|
this.name = t;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
class p extends
|
|
650
|
+
class p extends P {
|
|
651
651
|
static isValid(t, e, s) {
|
|
652
652
|
return t <= 0 || e <= 0 || s <= 0 ? !1 : t + e > s && t + s > e && e + s > t;
|
|
653
653
|
}
|
|
@@ -660,7 +660,7 @@ class p extends R {
|
|
|
660
660
|
static getType(t, e, s) {
|
|
661
661
|
if (!p.isValid(t, e, s))
|
|
662
662
|
throw new Error("Invalid triangle sides");
|
|
663
|
-
const r = [t, e, s].sort((
|
|
663
|
+
const r = [t, e, s].sort((h, d) => h - d), [i, n, a] = r;
|
|
664
664
|
return Math.abs(i - n) < p.EPSILON && Math.abs(n - a) < p.EPSILON ? "equilateral" : Math.abs(i - n) < p.EPSILON || Math.abs(n - a) < p.EPSILON ? "isosceles" : "scalene";
|
|
665
665
|
}
|
|
666
666
|
static getAngles(t, e, s) {
|
|
@@ -680,7 +680,7 @@ class p extends R {
|
|
|
680
680
|
areCollinear() {
|
|
681
681
|
return Math.abs(
|
|
682
682
|
(this.p2.x - this.p1.x) * (this.p3.y - this.p1.y) - (this.p3.x - this.p1.x) * (this.p2.y - this.p1.y)
|
|
683
|
-
) <
|
|
683
|
+
) < P.EPSILON;
|
|
684
684
|
}
|
|
685
685
|
get side() {
|
|
686
686
|
return [
|
|
@@ -738,7 +738,7 @@ class p extends R {
|
|
|
738
738
|
return Math.abs(e + s + r - this.area()) < p.EPSILON;
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
class
|
|
741
|
+
class W {
|
|
742
742
|
static sleep(t) {
|
|
743
743
|
return new Promise((e) => setTimeout(e, t));
|
|
744
744
|
}
|
|
@@ -762,7 +762,7 @@ class G {
|
|
|
762
762
|
return t.prototype.constructor = s, s;
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
class
|
|
765
|
+
class X {
|
|
766
766
|
static groupBy(t, e) {
|
|
767
767
|
if (!e)
|
|
768
768
|
throw new Error("generateKey is required");
|
|
@@ -774,8 +774,8 @@ class _ {
|
|
|
774
774
|
console.warn("Invalid key generated for item:", n);
|
|
775
775
|
continue;
|
|
776
776
|
}
|
|
777
|
-
const
|
|
778
|
-
|
|
777
|
+
const h = r.get(a) ?? [];
|
|
778
|
+
h.push(n), r.set(a, h);
|
|
779
779
|
} catch (a) {
|
|
780
780
|
console.error("Error generating key for item:", n, a);
|
|
781
781
|
}
|
|
@@ -808,23 +808,23 @@ class _ {
|
|
|
808
808
|
return e;
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
|
-
function
|
|
812
|
-
return
|
|
811
|
+
function O(o) {
|
|
812
|
+
return o !== null && (typeof o == "object" || typeof o == "function");
|
|
813
813
|
}
|
|
814
|
-
class
|
|
814
|
+
class Q {
|
|
815
815
|
map = /* @__PURE__ */ new Map();
|
|
816
816
|
weakMap = /* @__PURE__ */ new WeakMap();
|
|
817
817
|
set(t, e) {
|
|
818
|
-
|
|
818
|
+
O(t) ? this.weakMap.set(t, e) : this.map.set(t, e);
|
|
819
819
|
}
|
|
820
820
|
get(t) {
|
|
821
|
-
return
|
|
821
|
+
return O(t) ? this.weakMap.get(t) : this.map.get(t);
|
|
822
822
|
}
|
|
823
823
|
has(t) {
|
|
824
|
-
return
|
|
824
|
+
return O(t) ? this.weakMap.has(t) : this.map.has(t);
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
class
|
|
827
|
+
class j {
|
|
828
828
|
static jsonClone(t) {
|
|
829
829
|
try {
|
|
830
830
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -843,8 +843,8 @@ class X {
|
|
|
843
843
|
if (t instanceof Map) {
|
|
844
844
|
const n = /* @__PURE__ */ new Map();
|
|
845
845
|
e.set(t, n);
|
|
846
|
-
for (const [a,
|
|
847
|
-
n.set(this.deepClone(a, e), this.deepClone(
|
|
846
|
+
for (const [a, h] of t)
|
|
847
|
+
n.set(this.deepClone(a, e), this.deepClone(h, e));
|
|
848
848
|
return n;
|
|
849
849
|
}
|
|
850
850
|
if (t instanceof Set) {
|
|
@@ -857,7 +857,7 @@ class X {
|
|
|
857
857
|
if (Array.isArray(t)) {
|
|
858
858
|
const n = new Array(t.length);
|
|
859
859
|
e.set(t, n);
|
|
860
|
-
for (let a = 0,
|
|
860
|
+
for (let a = 0, h = t.length; a < h; a++)
|
|
861
861
|
n[a] = this.deepClone(t[a], e);
|
|
862
862
|
return n;
|
|
863
863
|
}
|
|
@@ -878,8 +878,8 @@ class X {
|
|
|
878
878
|
return new n(t);
|
|
879
879
|
if (typeof t == "function")
|
|
880
880
|
return new Proxy(t, {
|
|
881
|
-
apply(n, a,
|
|
882
|
-
return n.apply(a,
|
|
881
|
+
apply(n, a, h) {
|
|
882
|
+
return n.apply(a, h);
|
|
883
883
|
},
|
|
884
884
|
get(n, a) {
|
|
885
885
|
if (a in n)
|
|
@@ -894,40 +894,40 @@ class X {
|
|
|
894
894
|
return r;
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
const
|
|
897
|
+
const k = {
|
|
898
898
|
date: "yyyy-MM-dd",
|
|
899
899
|
datetime: "yyyy-MM-dd HH:mm:ss",
|
|
900
900
|
time: "HH:mm:ss",
|
|
901
901
|
iso: "yyyy-MM-ddTHH:mm:ss.SSS"
|
|
902
902
|
};
|
|
903
|
-
class
|
|
903
|
+
class M {
|
|
904
904
|
static defaultOptions = {
|
|
905
905
|
paddingZero: !1,
|
|
906
906
|
locale: "en-US"
|
|
907
907
|
};
|
|
908
908
|
static setDefaultOptions(t) {
|
|
909
|
-
|
|
909
|
+
M.defaultOptions = { ...M.defaultOptions, ...t };
|
|
910
910
|
}
|
|
911
911
|
static format(t, e, s = {}) {
|
|
912
|
-
const r = { ...
|
|
913
|
-
return
|
|
912
|
+
const r = { ...M.defaultOptions, ...s }, i = M.getDateInfo(t, r);
|
|
913
|
+
return M.normalizeFormatter(e)(i);
|
|
914
914
|
}
|
|
915
915
|
// 获取日期信息
|
|
916
916
|
static getDateInfo(t, e) {
|
|
917
|
-
const s = (c, l = 2) => e.paddingZero ? c.toString().padStart(l, "0") : c.toString(), r = t.getFullYear(), i = t.getMonth() + 1, n = t.getDate(), a = t.getHours(),
|
|
917
|
+
const s = (c, l = 2) => e.paddingZero ? c.toString().padStart(l, "0") : c.toString(), r = t.getFullYear(), i = t.getMonth() + 1, n = t.getDate(), a = t.getHours(), h = t.getMinutes(), d = t.getSeconds(), f = t.getMilliseconds();
|
|
918
918
|
return {
|
|
919
919
|
year: r,
|
|
920
920
|
month: i,
|
|
921
921
|
day: n,
|
|
922
922
|
hour: a,
|
|
923
|
-
minute:
|
|
923
|
+
minute: h,
|
|
924
924
|
second: d,
|
|
925
925
|
millisecond: f,
|
|
926
926
|
yyyy: s(r, 4),
|
|
927
927
|
MM: s(i),
|
|
928
928
|
dd: s(n),
|
|
929
929
|
HH: s(a),
|
|
930
|
-
mm: s(
|
|
930
|
+
mm: s(h),
|
|
931
931
|
ss: s(d)
|
|
932
932
|
};
|
|
933
933
|
}
|
|
@@ -936,7 +936,7 @@ class S {
|
|
|
936
936
|
return t;
|
|
937
937
|
if (typeof t != "string")
|
|
938
938
|
throw new Error("Formatter must be a string or function");
|
|
939
|
-
t in
|
|
939
|
+
t in k && (t = k[t]);
|
|
940
940
|
const e = {
|
|
941
941
|
yyyy: "yyyy",
|
|
942
942
|
MM: "MM",
|
|
@@ -957,16 +957,16 @@ class S {
|
|
|
957
957
|
};
|
|
958
958
|
}
|
|
959
959
|
static formatRelative(t, e = /* @__PURE__ */ new Date()) {
|
|
960
|
-
const s = t.getTime() - e.getTime(), r = Math.abs(s), i = Math.floor(r / 1e3), n = Math.floor(i / 60), a = Math.floor(n / 60),
|
|
961
|
-
return
|
|
960
|
+
const s = t.getTime() - e.getTime(), r = Math.abs(s), i = Math.floor(r / 1e3), n = Math.floor(i / 60), a = Math.floor(n / 60), h = Math.floor(a / 24);
|
|
961
|
+
return h > 0 ? s > 0 ? `${h}天后` : `${h}天前` : a > 0 ? s > 0 ? `${a}小时后` : `${a}小时前` : n > 0 ? s > 0 ? `${n}分钟后` : `${n}分钟前` : s > 0 ? "刚刚" : "";
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
class
|
|
964
|
+
class J {
|
|
965
965
|
static escape(t) {
|
|
966
966
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
|
-
class
|
|
969
|
+
class _ {
|
|
970
970
|
static ROMAN_MAP = /* @__PURE__ */ new Map([
|
|
971
971
|
["M", 1e3],
|
|
972
972
|
["CM", 900],
|
|
@@ -995,10 +995,10 @@ class j {
|
|
|
995
995
|
if (this.ROMAN_MAP.has(n))
|
|
996
996
|
s += this.ROMAN_MAP.get(n), r += 2;
|
|
997
997
|
else {
|
|
998
|
-
const a = t[r],
|
|
999
|
-
if (!
|
|
998
|
+
const a = t[r], h = this.ROMAN_MAP.get(a);
|
|
999
|
+
if (!h)
|
|
1000
1000
|
throw new Error(`Invalid Roman numeral sequence at position ${r}`);
|
|
1001
|
-
s +=
|
|
1001
|
+
s += h, r += 1;
|
|
1002
1002
|
}
|
|
1003
1003
|
}
|
|
1004
1004
|
if (this.toRoman(s) !== t)
|
|
@@ -1017,7 +1017,7 @@ class j {
|
|
|
1017
1017
|
return e;
|
|
1018
1018
|
}
|
|
1019
1019
|
}
|
|
1020
|
-
class y
|
|
1020
|
+
class y {
|
|
1021
1021
|
static handleNumRange(t, e = !1, s = Number.MIN_SAFE_INTEGER, r = Number.MAX_SAFE_INTEGER) {
|
|
1022
1022
|
if (e && !Number.isInteger(t))
|
|
1023
1023
|
throw new Error("n must be an integer");
|
|
@@ -1083,14 +1083,14 @@ class y extends Number {
|
|
|
1083
1083
|
const s = t.reduce((c, l) => c + l, 0);
|
|
1084
1084
|
if (s === 0)
|
|
1085
1085
|
return t.map(() => "0%");
|
|
1086
|
-
const i = 100 * Math.pow(10, e), n = t.map((c) => c / s * i), a = n.map((c) => Math.floor(c)),
|
|
1086
|
+
const i = 100 * Math.pow(10, e), n = t.map((c) => c / s * i), a = n.map((c) => Math.floor(c)), h = n.map((c, l) => c - a[l]);
|
|
1087
1087
|
let d = a.reduce((c, l) => c + l, 0), f = i - d;
|
|
1088
1088
|
for (; f > 0; ) {
|
|
1089
1089
|
let c = -1, l = -1;
|
|
1090
|
-
for (let m = 0; m <
|
|
1091
|
-
|
|
1090
|
+
for (let m = 0; m < h.length; m++)
|
|
1091
|
+
h[m] > l && (l = h[m], c = m);
|
|
1092
1092
|
if (c === -1) break;
|
|
1093
|
-
a[c]++,
|
|
1093
|
+
a[c]++, h[c] = 0, f--;
|
|
1094
1094
|
}
|
|
1095
1095
|
return a.map((c) => `${(c / i * 100).toFixed(e)}%`);
|
|
1096
1096
|
}
|
|
@@ -1185,7 +1185,7 @@ class y extends Number {
|
|
|
1185
1185
|
return (t - e[0]) * ((s[1] - s[0]) / r) + s[0];
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
-
class
|
|
1188
|
+
class Z {
|
|
1189
1189
|
static READ = 1;
|
|
1190
1190
|
static WRITE = 2;
|
|
1191
1191
|
static SHARE = 4;
|
|
@@ -1204,7 +1204,7 @@ class J {
|
|
|
1204
1204
|
return t ^ e;
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
|
-
class
|
|
1207
|
+
class S {
|
|
1208
1208
|
static frequencyStatistics(t) {
|
|
1209
1209
|
return [...t].reduce(
|
|
1210
1210
|
(e, s) => (e[s] = (e[s] || 0) + 1, e),
|
|
@@ -1264,55 +1264,52 @@ class Z extends String {
|
|
|
1264
1264
|
return !1;
|
|
1265
1265
|
}
|
|
1266
1266
|
}
|
|
1267
|
-
|
|
1268
|
-
super(t);
|
|
1269
|
-
}
|
|
1270
|
-
pointLength() {
|
|
1271
|
-
let t = 0;
|
|
1272
|
-
for (let e = 0, s = this.length; e < s; ) {
|
|
1273
|
-
const r = this.codePointAt(e);
|
|
1274
|
-
e += r > 65535 ? 2 : 1, t++;
|
|
1275
|
-
}
|
|
1276
|
-
return t;
|
|
1277
|
-
}
|
|
1278
|
-
pointAt(t) {
|
|
1279
|
-
if (t >= this.pointLength()) return;
|
|
1267
|
+
static pointLength(t) {
|
|
1280
1268
|
let e = 0;
|
|
1281
|
-
for (let s = 0, r =
|
|
1282
|
-
const i =
|
|
1283
|
-
if (!i) return;
|
|
1284
|
-
if (e === t)
|
|
1285
|
-
return String.fromCodePoint(i);
|
|
1269
|
+
for (let s = 0, r = t.length; s < r; ) {
|
|
1270
|
+
const i = t.codePointAt(s);
|
|
1286
1271
|
s += i > 65535 ? 2 : 1, e++;
|
|
1287
1272
|
}
|
|
1273
|
+
return e;
|
|
1288
1274
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1275
|
+
static pointAt(t, e) {
|
|
1276
|
+
if (e >= S.pointLength(t)) return;
|
|
1277
|
+
let s = 0;
|
|
1278
|
+
for (let r = 0, i = t.length; r < i; ) {
|
|
1279
|
+
const n = t.codePointAt(r);
|
|
1280
|
+
if (!n) return;
|
|
1281
|
+
if (s === e)
|
|
1282
|
+
return String.fromCodePoint(n);
|
|
1283
|
+
r += n > 65535 ? 2 : 1, s++;
|
|
1284
|
+
}
|
|
1294
1285
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1286
|
+
static sliceByPoint(t, e, s = S.pointLength(t)) {
|
|
1287
|
+
let r = "";
|
|
1288
|
+
for (let i = e; i < s; i++)
|
|
1289
|
+
r += S.pointAt(t, i);
|
|
1290
|
+
return r;
|
|
1297
1291
|
}
|
|
1298
|
-
|
|
1299
|
-
return
|
|
1292
|
+
static capitalize(t) {
|
|
1293
|
+
return t.charAt(0).toUpperCase() + t.slice(1).toLowerCase();
|
|
1300
1294
|
}
|
|
1301
|
-
|
|
1302
|
-
return
|
|
1295
|
+
static reverse(t) {
|
|
1296
|
+
return t.split("").reverse().join("");
|
|
1303
1297
|
}
|
|
1304
|
-
|
|
1305
|
-
return this.
|
|
1298
|
+
static truncate(t, e, s = "...") {
|
|
1299
|
+
return t.length <= e ? this : t.slice(0, e - s.length) + s;
|
|
1306
1300
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return (this.match(new RegExp(e, "g")) || []).length;
|
|
1301
|
+
static isPalindrome(t) {
|
|
1302
|
+
return t.toLowerCase().replace(/[^a-z0-9]/g, "") === S.reverse(t);
|
|
1310
1303
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1304
|
+
static count(t, e) {
|
|
1305
|
+
const s = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1306
|
+
return (t.match(new RegExp(s, "g")) || []).length;
|
|
1313
1307
|
}
|
|
1314
|
-
|
|
1315
|
-
return
|
|
1308
|
+
static toCamelCase(t) {
|
|
1309
|
+
return t.replace(/_([a-z])/g, (e, s) => s.toUpperCase());
|
|
1310
|
+
}
|
|
1311
|
+
static toSnakeCase(t) {
|
|
1312
|
+
return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
1316
1313
|
}
|
|
1317
1314
|
}
|
|
1318
1315
|
class Y {
|
|
@@ -1335,7 +1332,7 @@ const x = {
|
|
|
1335
1332
|
UI_HIDE_LOADING: "隐藏加载事件",
|
|
1336
1333
|
UI_SHOW_MESSAGE: "显示消息事件"
|
|
1337
1334
|
};
|
|
1338
|
-
class
|
|
1335
|
+
class A {
|
|
1339
1336
|
static instance = null;
|
|
1340
1337
|
listeners = {};
|
|
1341
1338
|
debugMode;
|
|
@@ -1347,7 +1344,7 @@ class M {
|
|
|
1347
1344
|
);
|
|
1348
1345
|
}
|
|
1349
1346
|
static getInstance(t) {
|
|
1350
|
-
return
|
|
1347
|
+
return A.instance || (A.instance = new A(t)), A.instance;
|
|
1351
1348
|
}
|
|
1352
1349
|
on(t, e) {
|
|
1353
1350
|
this.debugLog(`添加事件监听: ${x[t]}`), this.listeners[t].add(e);
|
|
@@ -1382,30 +1379,30 @@ class M {
|
|
|
1382
1379
|
}
|
|
1383
1380
|
}
|
|
1384
1381
|
export {
|
|
1385
|
-
|
|
1386
|
-
|
|
1382
|
+
X as Arr,
|
|
1383
|
+
Z as BitPerm,
|
|
1387
1384
|
Y as Color,
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1385
|
+
M as DateEx,
|
|
1386
|
+
H as Dictionary,
|
|
1387
|
+
A as Emitter,
|
|
1388
|
+
W as Func,
|
|
1389
|
+
G as Graph,
|
|
1390
|
+
T as LRU,
|
|
1394
1391
|
g as Line,
|
|
1395
|
-
|
|
1392
|
+
B as LinkedList,
|
|
1396
1393
|
I as Matrix,
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1394
|
+
F as MaxHeap,
|
|
1395
|
+
Q as MemoizeMap,
|
|
1396
|
+
z as MinHeap,
|
|
1397
|
+
q as MinStack,
|
|
1401
1398
|
y as Num,
|
|
1402
|
-
|
|
1399
|
+
j as Obj,
|
|
1403
1400
|
u as Point,
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1401
|
+
D as Queue,
|
|
1402
|
+
J as Reg,
|
|
1403
|
+
_ as Roman,
|
|
1404
|
+
U as Stack,
|
|
1405
|
+
S as Str,
|
|
1409
1406
|
p as Triangle,
|
|
1410
1407
|
w as Vector
|
|
1411
1408
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(c,
|
|
2
|
-
`;return t}}class E{_data;static zero(t){return new E(...Array(t).fill(0))}constructor(...t){this._data=t}get dimension(){return this._data.length}get norm(){return Math.hypot(...this._data)}getItem(t){return this._data[t]}normalize(){const t=this.norm;if(t===0)throw new Error("Cannot normalize a zero vector");const e=this._data.map(s=>s/t);return new E(...e)}add(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to add");const e=this._data.map((s,r)=>s+t._data[r]);return new E(...e)}sub(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to subtract");const e=this._data.map((s,r)=>s-t._data[r]);return new E(...e)}mul(t){return new E(...this._data.map(e=>e*t))}dot(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to dot product");return this._data.reduce((e,s,r)=>e+s*t._data[r],0)}pos(){return this.mul(1)}neg(){return this.mul(-1)}}class M{_matrix;static zero(t,e){return new M(Array.from({length:t},()=>Array.from({length:e},()=>0)))}static rotate(t){const e=t.length;for(let s=0;s<(e+1)/2;s++)for(let r=s;r<e/2;r++){const i=t[e-1-r][s];t[e-1-r][s]=t[e-1-s][e-1-r],t[e-1-s][e-1-r]=t[r][e-1-s],t[r][e-1-s]=t[s][r],t[s][r]=i}return t}constructor(t){this._matrix=t}get shape(){return[this._matrix.length,this._matrix[0].length]}get row(){return this.shape[0]}get col(){return this.shape[1]}get size(){return this.row*this.col}rowVector(t){return new E(...this._matrix[t])}colVector(t){return new E(...this._matrix.map(e=>e[t]))}getItem(t){return this._matrix[t[0]][t[1]]}setItem(t,e){return this._matrix[t[0]][t[1]]=e,this}mul(t){return new M(this._matrix.map(e=>e.map(s=>s*t)))}div(t){return this.mul(1/t)}add(t){if(this.row!==t.row||this.col!==t.col)throw new Error("Matrix dimensions do not match");return new M(this._matrix.map((e,s)=>e.map((r,i)=>r+t.getItem([s,i]))))}sub(t){return this.add(t.neg())}pos(){return this.mul(1)}neg(){return this.mul(-1)}mulVector(t){if(this.col!==t.dimension)throw new Error("Matrix dimensions do not match");return new M(this._matrix.map(e=>e.map((s,r)=>s*t.getItem(r))))}mulMatrix(t){if(this.col!==t.row)throw new Error("Matrix dimensions do not match");const e=M.zero(this.row,t.col);for(let s=0;s<this.row;s++){const r=this.rowVector(s);for(let i=0;i<this.col;i++)e.setItem([s,i],r.dot(t.colVector(i)))}return e}}class l{static distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}x;y;constructor(t,e){this.x=t,this.y=e}distanceTo(t){return l.distance(this,t)}}class g{static EPSILON=1e-10;static sloped(t,e=g.EPSILON){const s=t.p2.x-t.p1.x,r=t.p2.y-t.p1.y;return Math.abs(s)<e?Math.abs(r)<e?0:null:r/s}static isParallel(t,e,s=g.EPSILON){const r=g.sloped(t),i=g.sloped(e);return r===null&&i===null?!0:r===null||i===null?!1:Math.abs(r-i)<s}static getIntersection(t,e,s=g.EPSILON){if(g.isParallel(t,e))return null;const r=t.p1.x,i=t.p1.y,n=t.p2.x,a=t.p2.y,o=e.p1.x,f=e.p1.y,m=e.p2.x,u=e.p2.y,p=(r-n)*(f-u)-(i-a)*(o-m);if(Math.abs(p)<s)return null;const y=((r-o)*(f-u)-(i-f)*(o-m))/p,O=-((r-n)*(i-f)-(i-a)*(r-o))/p;if(y>=0&&y<=1&&O>=0&&O<=1){const Y=r+y*(n-r),K=i+y*(a-i);return new l(Y,K)}return null}static isIntersecting(t,e){return g.getIntersection(t,e)!==null}static distanceToPoint(t,e,s=g.EPSILON){const r=e.x-t.p1.x,i=e.y-t.p1.y,n=t.p2.x-t.p1.x,a=t.p2.y-t.p1.y,o=r*n+i*a,f=n*n+a*a;let m=-1;f>s&&(m=o/f);let u,p;m<0?(u=t.p1.x,p=t.p1.y):m>1?(u=t.p2.x,p=t.p2.y):(u=t.p1.x+m*n,p=t.p1.y+m*a);const y=e.x-u,O=e.y-p;return Math.hypot(y+O)}p1;p2;constructor(t,e){this.p1=t,this.p2=e}get length(){const t=this.p2.x-this.p1.x,e=this.p2.y-this.p1.y;return Math.sqrt(t*t+e*e)}get midpoint(){const t=(this.p1.x+this.p2.x)/2,e=(this.p1.y+this.p2.y)/2;return new l(t,e)}get angle(){return Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)}containsPoint(t,e=g.EPSILON){const s=(t.x-this.p1.x)*(this.p2.y-this.p1.y)-(t.y-this.p1.y)*(this.p2.x-this.p1.x);return Math.abs(s)>e?!1:(t.x-this.p1.x)*(t.x-this.p2.x)+(t.y-this.p1.y)*(t.y-this.p2.y)<=e}get direction(){const t=this.length;if(t<g.EPSILON)return new l(0,0);const e=(this.p2.x-this.p1.x)/t,s=(this.p2.y-this.p1.y)/t;return new l(e,s)}get start(){return this.p1}get end(){return this.p2}}class C{static EPSILON=1e-10;name;constructor(t){this.name=t}}class d extends C{static isValid(t,e,s){return t<=0||e<=0||s<=0?!1:t+e>s&&t+s>e&&e+s>t}static area(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle");const r=(t+e+s)/2;return Math.sqrt(r*(r-t)*(r-e)*(r-s))}static getType(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");const r=[t,e,s].sort((o,f)=>o-f),[i,n,a]=r;return Math.abs(i-n)<d.EPSILON&&Math.abs(n-a)<d.EPSILON?"equilateral":Math.abs(i-n)<d.EPSILON||Math.abs(n-a)<d.EPSILON?"isosceles":"scalene"}static getAngles(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");const r=Math.acos((e*e+s*s-t*t)/(2*e*s)),i=Math.acos((t*t+s*s-e*e)/(2*t*s)),n=Math.PI-r-i;return[r,i,n]}p1;p2;p3;constructor(t,e,s,r="triangle"){if(super(r),this.p1=t,this.p2=e,this.p3=s,this.areCollinear())throw new Error("Points are collinear, cannot form a triangle")}areCollinear(){return Math.abs((this.p2.x-this.p1.x)*(this.p3.y-this.p1.y)-(this.p3.x-this.p1.x)*(this.p2.y-this.p1.y))<C.EPSILON}get side(){return[l.distance(this.p1,this.p2),l.distance(this.p2,this.p3),l.distance(this.p3,this.p1)]}perimeter(){return d.isValid(this.side[0],this.side[1],this.side[2]),this.side.reduce((t,e)=>t+e,0)}area(){const[t,e,s]=this.side;return d.area(t,e,s)}get type(){const[t,e,s]=this.side;return d.getType(t,e,s)}get angles(){const[t,e,s]=this.side;return d.getAngles(t,e,s)}get centroid(){return new l((this.p1.x+this.p2.x+this.p3.x)/3,(this.p1.y+this.p2.y+this.p3.y)/3)}get incenter(){const[t,e,s]=this.side,r=this.perimeter()/2,i=(t*this.p1.x+e*this.p2.x+s*this.p3.x)/r,n=(t*this.p1.y+e*this.p2.y+s*this.p3.y)/r;return new l(i,n)}get circumcenter(){const t=2*(this.p1.x*(this.p2.y-this.p3.y)+this.p2.x*(this.p3.y-this.p1.y)+this.p3.x*(this.p1.y-this.p2.y));if(Math.abs(t)<d.EPSILON)throw new Error("Cannot calculate circumcenter for collinear points");const e=((this.p1.x*this.p1.x+this.p1.y*this.p1.y)*(this.p2.y-this.p3.y)+(this.p2.x*this.p2.x+this.p2.y*this.p2.y)*(this.p3.y-this.p1.y)+(this.p3.x*this.p3.x+this.p3.y*this.p3.y)*(this.p1.y-this.p2.y))/t,s=((this.p1.x*this.p1.x+this.p1.y*this.p1.y)*(this.p3.x-this.p2.x)+(this.p2.x*this.p2.x+this.p2.y*this.p2.y)*(this.p1.x-this.p3.x)+(this.p3.x*this.p3.x+this.p3.y*this.p3.y)*(this.p2.x-this.p1.x))/t;return new l(e,s)}containsPoint(t){const e=d.area(l.distance(t,this.p1),l.distance(t,this.p2),l.distance(this.p1,this.p2)),s=d.area(l.distance(t,this.p2),l.distance(t,this.p3),l.distance(this.p2,this.p3)),r=d.area(l.distance(t,this.p3),l.distance(t,this.p1),l.distance(this.p3,this.p1));return Math.abs(e+s+r-this.area())<d.EPSILON}}class B{static sleep(t){return new Promise(e=>setTimeout(e,t))}static binarySearchTemplate(t,e,s){let r=-1,i=t.length,n;for(;i-r>1;)n=i-(i-r)>>1,s(t[n],e)?i=n:r=n;return i}static singleton(t){let e;const s=new Proxy(t,{construct(r,i,n){return e||(e=Reflect.construct(r,i,n)),e}});return t.prototype.constructor=s,s}}class G{static groupBy(t,e){if(!e)throw new Error("generateKey is required");const s=typeof e=="string"?i=>i[e]:e,r=new Map;for(const[i,n]of t.entries())try{const a=s(n,i,t);if(a==null){console.warn("Invalid key generated for item:",n);continue}const o=r.get(a)??[];o.push(n),r.set(a,o)}catch(a){console.error("Error generating key for item:",n,a)}return Object.fromEntries(r)}static LIS(t){if(!t.length)return[];const e=[[t[0]]];for(let r=1,i=t.length;r<i;r++){const n=t[r];s(n)}function s(r){for(let i=e.length-1;i>=0;i--){const n=e[i],a=n[e[i].length-1];if(a<r){e[i+1]=[...n,r];break}else a>r&&i===0&&(e[i]=[r])}}return e[e.length-1]}static LCP(t){if(!t.length)return"";let e=t[0];for(let s=1;s<t.length;s++)for(;!t[s].startsWith(e);)if(e=e.slice(0,-1),e==="")return"";return e}}function b(h){return h!==null&&(typeof h=="object"||typeof h=="function")}class j{map=new Map;weakMap=new WeakMap;set(t,e){b(t)?this.weakMap.set(t,e):this.map.set(t,e)}get(t){return b(t)?this.weakMap.get(t):this.map.get(t)}has(t){return b(t)?this.weakMap.has(t):this.map.has(t)}}class _{static jsonClone(t){try{return JSON.parse(JSON.stringify(t))}catch{throw new Error("Object is not JSON cloneable")}}static structureClone(t){return structuredClone(t)}static deepClone(t,e=new WeakMap){if(t==null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof Map){const n=new Map;e.set(t,n);for(const[a,o]of t)n.set(this.deepClone(a,e),this.deepClone(o,e));return n}if(t instanceof Set){const n=new Set;e.set(t,n);for(const a of t)n.add(this.deepClone(a,e));return n}if(Array.isArray(t)){const n=new Array(t.length);e.set(t,n);for(let a=0,o=t.length;a<o;a++)n[a]=this.deepClone(t[a],e);return n}if(t instanceof ArrayBuffer)return t.slice(0);const s=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];for(const n of s)if(t instanceof n)return new n(t);if(typeof t=="function")return new Proxy(t,{apply(n,a,o){return n.apply(a,o)},get(n,a){if(a in n)return n[a]}});const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);const i=Object.getOwnPropertyDescriptors(t);for(const[n,a]of Object.entries(i))a.value!==void 0&&(a.value=this.deepClone(a.value,e)),Object.defineProperty(r,n,a);return r}}const z={date:"yyyy-MM-dd",datetime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",iso:"yyyy-MM-ddTHH:mm:ss.SSS"};class S{static defaultOptions={paddingZero:!1,locale:"en-US"};static setDefaultOptions(t){S.defaultOptions={...S.defaultOptions,...t}}static format(t,e,s={}){const r={...S.defaultOptions,...s},i=S.getDateInfo(t,r);return S.normalizeFormatter(e)(i)}static getDateInfo(t,e){const s=(u,p=2)=>e.paddingZero?u.toString().padStart(p,"0"):u.toString(),r=t.getFullYear(),i=t.getMonth()+1,n=t.getDate(),a=t.getHours(),o=t.getMinutes(),f=t.getSeconds(),m=t.getMilliseconds();return{year:r,month:i,day:n,hour:a,minute:o,second:f,millisecond:m,yyyy:s(r,4),MM:s(i),dd:s(n),HH:s(a),mm:s(o),ss:s(f)}}static normalizeFormatter(t){if(typeof t=="function")return t;if(typeof t!="string")throw new Error("Formatter must be a string or function");t in z&&(t=z[t]);const e={yyyy:"yyyy",MM:"MM",dd:"dd",HH:"HH",mm:"mm",ss:"ss",SSS:"SSS"};return s=>{let r=t;for(const[i,n]of Object.entries(e))r=r.replace(new RegExp(i,"g"),String(s[n]||""));return r}}static formatRelative(t,e=new Date){const s=t.getTime()-e.getTime(),r=Math.abs(s),i=Math.floor(r/1e3),n=Math.floor(i/60),a=Math.floor(n/60),o=Math.floor(a/24);return o>0?s>0?`${o}天后`:`${o}天前`:a>0?s>0?`${a}小时后`:`${a}小时前`:n>0?s>0?`${n}分钟后`:`${n}分钟前`:s>0?"刚刚":""}}class W{static escape(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class X{static ROMAN_MAP=new Map([["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toInteger(t){if(t.length===0)throw new Error("Input cannot be empty");const e=new Set(["I","V","X","L","C","D","M"]);for(const n of t)if(!e.has(n))throw new Error(`Invalid Roman numeral character: ${n}`);let s=0,r=0;for(;r<t.length;){const n=t.slice(r,r+2);if(this.ROMAN_MAP.has(n))s+=this.ROMAN_MAP.get(n),r+=2;else{const a=t[r],o=this.ROMAN_MAP.get(a);if(!o)throw new Error(`Invalid Roman numeral sequence at position ${r}`);s+=o,r+=1}}if(this.toRoman(s)!==t)throw new Error("Invalid Roman numeral sequence");return s}static toRoman(t){if(t<=0||t>=4e3)throw new Error("Number must be between 1 and 3999");if(!Number.isInteger(t))throw new Error("Number must be an integer");let e="";for(const[s,r]of this.ROMAN_MAP)for(;t>=r;)e+=s,t-=r;return e}}class w extends Number{static handleNumRange(t,e=!1,s=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){if(e&&!Number.isInteger(t))throw new Error("n must be an integer");if(t<s||t>=r)throw new RangeError(`n must be in the range of ${s} to ${r}`)}static consecutiveSum(t){return w.handleNumRange(t,!0,0,1e8),t*(t+1)/2}static consecutiveSquaresSum(t){return w.handleNumRange(t,!0,0,1e6),t*(t+1)*(2*t+1)/6}static consecutivecubesSum(t){return w.handleNumRange(t,!0,0,1e4),t*(t+1)*(2*t+1)*(3*t*t+3*t-1)/30}static clamp(t,e,s){return s==null?Math.min(t,e):Math.min(Math.max(t,e),s)}static factorial(t){if(w.handleNumRange(t,!0,0,1e3),t<2)return 1;let e=1;for(let s=2;s<=t;s++)e*=s;return e}static fibonacci(t,e=1,s=1){return w.handleNumRange(t,!0,0,1e3),t<2?s:this.fibonacci(t-1,s,s+e)}static fibonacciIterative(t){if(w.handleNumRange(t,!0,0,1e3),t<2)return t;let e=0,s=1;for(let r=2;r<=t;r++)[e,s]=[s,(e+s)%1000000007];return s}static floatEqual(t,e,s=1e-6){return Math.abs(t-e)<s}static fastPower(t,e){if(w.handleNumRange(e,!0,0,10),w.handleNumRange(t,!1,0,1e3),t===0)return 0;if(e===0)return 1;const s=this.fastPower(t,e>>1);return e%2===0?s*s:s*s*t}static fastSqrt(t){if(w.handleNumRange(t,!1,0,1e8),typeof BigInt>"u")return Math.sqrt(t);const e=.5*t,s=new ArrayBuffer(8);new Float64Array(s)[0]=t;let r=new BigInt64Array(s)[0];r=0x1ff7a3bea91d9b1bn+(r>>1n);const i=new ArrayBuffer(8);new BigInt64Array(i)[0]=r;let n=new Float64Array(i)[0];return n=n*.5+e/n,n=n*.5+e/n,n=n*.5+e/n,n}static getPercentWithPrecision(t,e=2){if(!Array.isArray(t)||t.length===0)return[];if(e<0||!Number.isInteger(e))throw new Error("Precision must be a non-negative integer");const s=t.reduce((u,p)=>u+p,0);if(s===0)return t.map(()=>"0%");const i=100*Math.pow(10,e),n=t.map(u=>u/s*i),a=n.map(u=>Math.floor(u)),o=n.map((u,p)=>u-a[p]);let f=a.reduce((u,p)=>u+p,0),m=i-f;for(;m>0;){let u=-1,p=-1;for(let y=0;y<o.length;y++)o[y]>p&&(p=o[y],u=y);if(u===-1)break;a[u]++,o[u]=0,m--}return a.map(u=>`${(u/i*100).toFixed(e)}%`)}static gcd(t,e){return e===0?t:this.gcd(e,t%e)}static isValidPositiveInteger(t){return Number.isInteger(t)&&t>0&&t<=Number.MAX_SAFE_INTEGER}static isPowerOfTwo(t){return t>0&&(t&t-1)===0}static isOdd(t){return t%2===1||t%2===-1}static isPrime(t){if(t<=1)return!1;for(let e=2;e<=Math.sqrt(t);e++)if(t%e===0)return!1;return!0}static isPalindrome(t){if(t<0||t%10===0&&t!==0)return!1;let e=0,s=t;for(;t>0;){const r=t%10;e=e*10+r,t=Math.floor(t/10)}return s===e}static isArmstrong(t){const e=t.toString(),s=e.length;let r=0;for(let i=0;i<s;i++)r+=Math.pow(parseInt(e[i]),s);return r===t}static isHappy(t){const e=new Set;for(;t!==1;){if(e.has(t))return!1;e.add(t),t=(t+"").split("").reduce((s,r)=>s+Number(r)*Number(r),0)}return!0}static isPerfect(t){let e=0;for(let s=1;s<t;s++)t%s===0&&(e+=s);return e===t}static isSameSign(t,e){return t>=0&&e>=0||t<=0&&e<=0}static isRange(t,e,s){if(s==null&&(s=e,e=0),e>=s)throw new Error("The maximum value must be greater than the minimum value");return e<=t&&t<s}static lcm(t,e){return t*e/this.gcd(t,e)}static middle(t,e){return e-(e-t>>1)}static random(t,e){if(e==null&&(e=t,t=0),t>=e)throw new Error("The maximum value must be greater than the minimum value");return Math.random()*(e-t)+t}static randomInt(t,e){return Math.floor(this.random(t,e))}static round(t,e=0){if(!Number.isInteger(e))throw new Error("precision must be an integer");const s=Math.pow(10,e);return Math.round(t*s)/s}static scale(t,e,s){if(e[0]>=e[1]||s[0]>=s[1])throw new Error("Invalid range");t=this.clamp(t,e[0],e[1]);const r=e[1]-e[0];return(t-e[0])*((s[1]-s[0])/r)+s[0]}}class Q{static READ=1;static WRITE=2;static SHARE=4;static DELETE=8;static CREATE=16;static include(t,e){return(t&e)===e}static add(t,e){return t|e}static remove(t,e){return t&~e}static toggle(t,e){return t^e}}class J extends String{static frequencyStatistics(t){return[...t].reduce((e,s)=>(e[s]=(e[s]||0)+1,e),{})}static isValidBracket(t){const e=[],s={"(":")","[":"]","{":"}"},r=new Set(Object.values(s));for(const i of t)if(i in s)e.push(s[i]);else if(r.has(i)&&i!==e.pop())return!1;return e.length===0}static random(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let r=0;r<t;r++)s+=e.charAt(Math.floor(Math.random()*e.length));return s}static template(t,e){return t.replace(/\${(\w+)}/g,(s,r)=>e[r]||"")}static escapeHtml(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"," ":" ","±":"±","×":"×","÷":"÷","≠":"≠","≤":"≤","≥":"≥"},s=new RegExp(`[${Object.keys(e).join("")}]`,"g");return t.replace(s,r=>e[r])}static isEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}static isUrl(t){try{return new URL(t),!0}catch{return!1}}constructor(t){super(t)}pointLength(){let t=0;for(let e=0,s=this.length;e<s;){const r=this.codePointAt(e);e+=r>65535?2:1,t++}return t}pointAt(t){if(t>=this.pointLength())return;let e=0;for(let s=0,r=this.length;s<r;){const i=this.codePointAt(s);if(!i)return;if(e===t)return String.fromCodePoint(i);s+=i>65535?2:1,e++}}sliceByPoint(t,e=this.pointLength()){let s="";for(let r=t;r<e;r++)s+=this.pointAt(r);return s}capitalize(){return this.charAt(0).toUpperCase()+this.slice(1).toLowerCase()}reverse(){return this.split("").reverse().join("")}truncate(t,e="..."){return this.length<=t?this:this.slice(0,t-e.length)+e}isPalindrome(){return this.toLowerCase().replace(/[^a-z0-9]/g,"")===this.reverse()}count(t){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return(this.match(new RegExp(e,"g"))||[]).length}toCamelCase(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())}toSnakeCase(){return this.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}}class Z{static isValidHex(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}static isValidRGB(t){return/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t)}}const x={AUTH_UNAUTHORIZED:"未授权事件",AUTH_LOGIN_SUCCESS:"登录成功事件",AUTH_LOGOUT:"注销事件",AUTH_TOKEN_EXPIRED:"令牌过期事件",REQUEST_ERROR:"请求错误事件",REQUEST_TIMEOUT:"请求超时事件",REQUEST_NETWORK_ERROR:"网络错误事件",UI_SHOW_LOADING:"显示加载事件",UI_HIDE_LOADING:"隐藏加载事件",UI_SHOW_MESSAGE:"显示消息事件"};class A{static instance=null;listeners={};debugMode;constructor(t=!1){this.debugMode=t,Object.keys(x).forEach(e=>{this.listeners[e]=new Set})}static getInstance(t){return A.instance||(A.instance=new A(t)),A.instance}on(t,e){this.debugLog(`添加事件监听: ${x[t]}`),this.listeners[t].add(e)}emit(t,e){this.debugLog(`触发事件: ${x[t]}`,e),this.listeners[t].forEach(s=>{try{s(e)}catch(r){console.error(`事件 ${x[t]} 处理出错:`,r)}})}off(t,e){this.debugLog(`移除事件监听: ${x[t]}`),this.listeners[t].delete(e)}once(t,e){this.debugLog(`添加一次性事件监听: ${x[t]}`);const s=r=>{e(r),this.off(t,s)};this.on(t,s)}clear(){this.debugLog("清除所有事件监听器"),Object.values(this.listeners).forEach(t=>t.clear())}getListenerCount(t){return this.listeners[t].size}debugLog(t,e){this.debugMode&&console.log(`[EventEmitter] ${t}`,e||"")}}c.Arr=G,c.BitPerm=Q,c.Color=Z,c.DateEx=S,c.Dictionary=L,c.Emitter=A,c.Func=B,c.Graph=F,c.LRU=U,c.Line=g,c.LinkedList=q,c.Matrix=M,c.MaxHeap=V,c.MemoizeMap=j,c.MinHeap=P,c.MinStack=H,c.Num=w,c.Obj=_,c.Point=l,c.Queue=v,c.Reg=W,c.Roman=X,c.Stack=$,c.Str=J,c.Triangle=d,c.Vector=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(c,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(c=typeof globalThis<"u"?globalThis:c||self,O(c["jc-structure"]={}))})(this,(function(c){"use strict";class O{items={};count=0;lowestCount=0;constructor(){}dequeue(){if(this.isEmpty())return;const t=this.items[this.lowestCount];return delete this.items[this.lowestCount],this.lowestCount++,t}enqueue(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e)}for(const e of t)Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e);return this}batchEnqueue(t){return t.filter(s=>this.isValidItem(s)).forEach(s=>{this.isValidItem(s)&&(this.items[this.count]=s,this.count++)}),this}enqueueItem(t){if(!this.isValidItem(t))throw new Error("Invalid item");return this.items[this.count]=t,this.count++,this}isValidItem(t){return t!=null}front(){return this.isEmpty()?void 0:this.items[this.lowestCount]}isEmpty(){return this.size()===0}size(){return this.count-this.lowestCount}clear(){this.items={},this.count=0,this.lowestCount=0}toString(){return this.isEmpty()?"":`Queue(size: ${this.size()}):[${this.items[this.lowestCount]},...rest]`}}class H{items={};count=0;constructor(){}pop(){if(this.isEmpty())return;this.count--;const t=this.items[this.count];return delete this.items[this.count],t}push(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.addItems(e):this.addItem(e)}for(const e of t)Array.isArray(e)?this.addItems(e):this.addItem(e);return this}addItem(t){if(!this.isValidItem(t))throw new Error("Invalid item: item cannot be null or undefined");return this.items[this.count]=t,this.count++,this}addItems(t){return t.filter(s=>this.isValidItem(s)).forEach(s=>{this.items[this.count]=s,this.count++}),this}isValidItem(t){return t!=null}peek(){return this.isEmpty()?void 0:this.items[this.count-1]}isEmpty(){return this.count===0}size(){return this.count}clear(){this.items={},this.count=0}toString(){return this.isEmpty()?"":`Stack(count: ${this.count}):[${this.items[this.count-1]},...rest]`}}class V{stack=[];minStack=[];push(t){this.stack.push(t),(this.minStack.length===0||t<=this.minStack[this.minStack.length-1])&&this.minStack.push(t)}pop(){const t=this.stack.pop();return t===this.minStack[this.minStack.length-1]&&this.minStack.pop(),t}peek(){return this.stack[this.stack.length-1]}getMin(){return this.minStack[this.minStack.length-1]}isEmpty(){return this.size()===0}size(){return this.stack.length}clear(){this.stack=[],this.minStack=[]}toString(){return this.isEmpty()?"":`MinStack(count: ${this.size()}):[${this.getMin()},...rest]`}}function P(h,t){return h===t?0:h<t?-1:1}class I{heap=[];compareFn;constructor(t=P){this.compareFn=t}static getLeftIndex(t){return 2*t+1}static getRightIndex(t){return 2*t+2}static getParentIndex(t){return t===0?void 0:Math.floor((t-1)/2)}static swap(t,e,s){[t[e],t[s]]=[t[s],t[e]]}find(){return this.isEmpty()?void 0:this.heap[0]}size(){return this.heap.length}isEmpty(){return this.size()===0}clear(){this.heap=[]}toString(){return this.heap.toString()}}class k extends I{insert(t){return t?!1:(this.heap.push(t),this.siftUp(this.heap.length-1),!0)}extract(){if(this.isEmpty())return;if(this.heap.length===1)return this.heap.shift();const t=this.heap[0];return this.heap[0]=this.heap.pop(),this.siftDown(0),t}siftUp(t){let e=t,s=I.getLeftIndex(e),r=I.getRightIndex(e),i=this.size();s<i&&this.compareFn(this.heap[e],this.heap[s])===-1&&(e=s),r<i&&this.compareFn(this.heap[e],this.heap[r])===1&&(e=r),e!==t&&(I.swap(this.heap,t,e),this.siftUp(e))}siftDown(t){let e=I.getParentIndex(t);for(;t>0&&e&&this.compareFn(this.heap[e],this.heap[t])===1;)I.swap(this.heap,e,t),t=e,e=I.getParentIndex(t)}}class D extends k{constructor(t=(e,s)=>P(s,e)){super(t)}}function U(h){return{value:h}}class q{capacity;length=0;head=null;tail=null;lookup=new Map;reverseLookup=new Map;constructor(t=10){this.capacity=t}prepend(t){this.head?(t.next=this.head,this.head.prev=t,this.head=t):this.head=this.tail=t}detach(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),this.head===t&&(this.head=this.head.next||null),this.tail===t&&(this.tail=this.tail.prev||null),t.next=void 0,t.prev=void 0}trimCache(){if(this.length<=this.capacity)return;const t=this.tail;this.detach(t);const e=this.reverseLookup.get(t);this.lookup.delete(e),this.reverseLookup.delete(t),this.length--}get(t){const e=this.lookup.get(t);if(e)return this.detach(e),this.prepend(e),e.value}update(t,e){let s=this.lookup.get(t);s?(this.detach(s),this.prepend(s),s.value=e):(s=U(e),this.length++,this.prepend(s),this.trimCache(),this.lookup.set(t,s),this.reverseLookup)}}class N{value;next=void 0}class T{count=0;head=void 0;constructor(){}indexOf(t){let e=this.head,s=0,r=!1;for(;e;){if(this.equals(e.value,t)){r=!0;break}s++,e=e.next}return r?s:-1}equals(t,e){return t===e?!0:t==null||e==null?!1:typeof t=="object"&&typeof e=="object"?JSON.stringify(t)===JSON.stringify(e):!1}getElementAt(t){if(t<0||t>=this.count)return;if(t===0)return this.head;let e=this.head;for(let s=0;s<t;s++)e=e?.next;return e}getValueAt(t){return this.getElementAt(t)?.value}insert(t,e){let s=new N;if(s.value=t,e>this.count||e<0)throw new Error("index error");this.count++;let r,i;if(e===0){s.next=this.head,this.head=s;return}r=this.getElementAt(e-1),i=r.next,r.next=s,s.next=i}push(t){let e=new N;if(e.value=t,this.count++,this.isEmpty()){this.head=e;return}let s=this.getElementAt(this.count-1);s.next=e}remove(t){const e=this.indexOf(t);return e===-1?void 0:this.removeAt(e)}removeAt(t){if(this.isEmpty()||t<0||t>=this.count)return;let e=this.getElementAt(t),s=this.getElementAt(t-1),r=e?.next;return t===0&&(this.head=r),s&&(s.next=r),this.count--,e?.value}isEmpty(){return this.count===0}size(){return this.count}clear(){this.count=0,this.head=void 0}toString(){let t="",e=this.head;for(;e;)t+=e.value,t+=",",e=e.next;return t=t.slice(0,-1),t}}class F{key;value;constructor(t,e){this.key=t,this.value=e}}function L(h,t={emptyString:!1,zeroNumber:!1}){return h==null?!(t.emptyString&&h===""||t.zeroNumber&&h===0):!1}class C{table=[];constructor(){}getItemIndex(t){for(let e=0,s=this.table.length;e<s;e++)if(this.table[e].key===t)return e;return-1}set(t,e){if(L(t))throw new Error("key is required");if(L(e))throw new Error("value is required");if(this.has(t)){let s=this.getItemIndex(t);this.table[s].value=e}else{const s=new F(t,e);this.table.push(s)}}remove(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table.splice(e,1)[0]}}has(t){return this.getItemIndex(t)!==-1}get(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table[e]}}keys(){return this.table.map(t=>t.key)}values(){return this.table.map(t=>t.value)}keyValues(){return this.table.map(t=>[t.key,t.value])}forEach(t){for(let e=0,s=this.size();e<s;e++){let r=this.table[e];if(!t(r.key,r.value))break}}isEmpty(){return!this.size()}size(){return this.table.length}clear(){this.table=[]}toString(){let t="";for(let e=0,s=this.table.length;e<s;e++)t+=this.table[e].toString(),t+=",";return t=t.slice(0,-1),t}}class B{isDirected;vertices;adjList;constructor(t=!1){this.isDirected=t,this.vertices=[],this.adjList=new C}addVertex(t){this.vertices.includes(t)||(this.vertices.push(t),this.adjList.set(t,[]))}addEdge(t,e){this.adjList.get(t)||this.addVertex(t),this.adjList.get(e)||this.addVertex(e),this.adjList.get(t)?.value.indexOf(e)===-1&&this.adjList.get(t)?.value.push(e),this.isDirected||this.adjList.get(e)?.value.indexOf(t)===-1&&this.adjList.get(e)?.value.push(t)}getVertices(){return this.vertices}getAdjacencyList(){return this.adjList}toString(){let t="";for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e]+"-->",t+=this.adjList.get(this.vertices[e])?.toString()||"",t+=`
|
|
2
|
+
`;return t}}class E{_data;static zero(t){return new E(...Array(t).fill(0))}constructor(...t){this._data=t}get dimension(){return this._data.length}get norm(){return Math.hypot(...this._data)}getItem(t){return this._data[t]}normalize(){const t=this.norm;if(t===0)throw new Error("Cannot normalize a zero vector");const e=this._data.map(s=>s/t);return new E(...e)}add(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to add");const e=this._data.map((s,r)=>s+t._data[r]);return new E(...e)}sub(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to subtract");const e=this._data.map((s,r)=>s-t._data[r]);return new E(...e)}mul(t){return new E(...this._data.map(e=>e*t))}dot(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to dot product");return this._data.reduce((e,s,r)=>e+s*t._data[r],0)}pos(){return this.mul(1)}neg(){return this.mul(-1)}}class M{_matrix;static zero(t,e){return new M(Array.from({length:t},()=>Array.from({length:e},()=>0)))}static rotate(t){const e=t.length;for(let s=0;s<(e+1)/2;s++)for(let r=s;r<e/2;r++){const i=t[e-1-r][s];t[e-1-r][s]=t[e-1-s][e-1-r],t[e-1-s][e-1-r]=t[r][e-1-s],t[r][e-1-s]=t[s][r],t[s][r]=i}return t}constructor(t){this._matrix=t}get shape(){return[this._matrix.length,this._matrix[0].length]}get row(){return this.shape[0]}get col(){return this.shape[1]}get size(){return this.row*this.col}rowVector(t){return new E(...this._matrix[t])}colVector(t){return new E(...this._matrix.map(e=>e[t]))}getItem(t){return this._matrix[t[0]][t[1]]}setItem(t,e){return this._matrix[t[0]][t[1]]=e,this}mul(t){return new M(this._matrix.map(e=>e.map(s=>s*t)))}div(t){return this.mul(1/t)}add(t){if(this.row!==t.row||this.col!==t.col)throw new Error("Matrix dimensions do not match");return new M(this._matrix.map((e,s)=>e.map((r,i)=>r+t.getItem([s,i]))))}sub(t){return this.add(t.neg())}pos(){return this.mul(1)}neg(){return this.mul(-1)}mulVector(t){if(this.col!==t.dimension)throw new Error("Matrix dimensions do not match");return new M(this._matrix.map(e=>e.map((s,r)=>s*t.getItem(r))))}mulMatrix(t){if(this.col!==t.row)throw new Error("Matrix dimensions do not match");const e=M.zero(this.row,t.col);for(let s=0;s<this.row;s++){const r=this.rowVector(s);for(let i=0;i<this.col;i++)e.setItem([s,i],r.dot(t.colVector(i)))}return e}}class l{static distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}x;y;constructor(t,e){this.x=t,this.y=e}distanceTo(t){return l.distance(this,t)}}class g{static EPSILON=1e-10;static sloped(t,e=g.EPSILON){const s=t.p2.x-t.p1.x,r=t.p2.y-t.p1.y;return Math.abs(s)<e?Math.abs(r)<e?0:null:r/s}static isParallel(t,e,s=g.EPSILON){const r=g.sloped(t),i=g.sloped(e);return r===null&&i===null?!0:r===null||i===null?!1:Math.abs(r-i)<s}static getIntersection(t,e,s=g.EPSILON){if(g.isParallel(t,e))return null;const r=t.p1.x,i=t.p1.y,n=t.p2.x,a=t.p2.y,o=e.p1.x,f=e.p1.y,m=e.p2.x,u=e.p2.y,p=(r-n)*(f-u)-(i-a)*(o-m);if(Math.abs(p)<s)return null;const y=((r-o)*(f-u)-(i-f)*(o-m))/p,b=-((r-n)*(i-f)-(i-a)*(r-o))/p;if(y>=0&&y<=1&&b>=0&&b<=1){const Y=r+y*(n-r),K=i+y*(a-i);return new l(Y,K)}return null}static isIntersecting(t,e){return g.getIntersection(t,e)!==null}static distanceToPoint(t,e,s=g.EPSILON){const r=e.x-t.p1.x,i=e.y-t.p1.y,n=t.p2.x-t.p1.x,a=t.p2.y-t.p1.y,o=r*n+i*a,f=n*n+a*a;let m=-1;f>s&&(m=o/f);let u,p;m<0?(u=t.p1.x,p=t.p1.y):m>1?(u=t.p2.x,p=t.p2.y):(u=t.p1.x+m*n,p=t.p1.y+m*a);const y=e.x-u,b=e.y-p;return Math.hypot(y+b)}p1;p2;constructor(t,e){this.p1=t,this.p2=e}get length(){const t=this.p2.x-this.p1.x,e=this.p2.y-this.p1.y;return Math.sqrt(t*t+e*e)}get midpoint(){const t=(this.p1.x+this.p2.x)/2,e=(this.p1.y+this.p2.y)/2;return new l(t,e)}get angle(){return Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)}containsPoint(t,e=g.EPSILON){const s=(t.x-this.p1.x)*(this.p2.y-this.p1.y)-(t.y-this.p1.y)*(this.p2.x-this.p1.x);return Math.abs(s)>e?!1:(t.x-this.p1.x)*(t.x-this.p2.x)+(t.y-this.p1.y)*(t.y-this.p2.y)<=e}get direction(){const t=this.length;if(t<g.EPSILON)return new l(0,0);const e=(this.p2.x-this.p1.x)/t,s=(this.p2.y-this.p1.y)/t;return new l(e,s)}get start(){return this.p1}get end(){return this.p2}}class z{static EPSILON=1e-10;name;constructor(t){this.name=t}}class d extends z{static isValid(t,e,s){return t<=0||e<=0||s<=0?!1:t+e>s&&t+s>e&&e+s>t}static area(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle");const r=(t+e+s)/2;return Math.sqrt(r*(r-t)*(r-e)*(r-s))}static getType(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");const r=[t,e,s].sort((o,f)=>o-f),[i,n,a]=r;return Math.abs(i-n)<d.EPSILON&&Math.abs(n-a)<d.EPSILON?"equilateral":Math.abs(i-n)<d.EPSILON||Math.abs(n-a)<d.EPSILON?"isosceles":"scalene"}static getAngles(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");const r=Math.acos((e*e+s*s-t*t)/(2*e*s)),i=Math.acos((t*t+s*s-e*e)/(2*t*s)),n=Math.PI-r-i;return[r,i,n]}p1;p2;p3;constructor(t,e,s,r="triangle"){if(super(r),this.p1=t,this.p2=e,this.p3=s,this.areCollinear())throw new Error("Points are collinear, cannot form a triangle")}areCollinear(){return Math.abs((this.p2.x-this.p1.x)*(this.p3.y-this.p1.y)-(this.p3.x-this.p1.x)*(this.p2.y-this.p1.y))<z.EPSILON}get side(){return[l.distance(this.p1,this.p2),l.distance(this.p2,this.p3),l.distance(this.p3,this.p1)]}perimeter(){return d.isValid(this.side[0],this.side[1],this.side[2]),this.side.reduce((t,e)=>t+e,0)}area(){const[t,e,s]=this.side;return d.area(t,e,s)}get type(){const[t,e,s]=this.side;return d.getType(t,e,s)}get angles(){const[t,e,s]=this.side;return d.getAngles(t,e,s)}get centroid(){return new l((this.p1.x+this.p2.x+this.p3.x)/3,(this.p1.y+this.p2.y+this.p3.y)/3)}get incenter(){const[t,e,s]=this.side,r=this.perimeter()/2,i=(t*this.p1.x+e*this.p2.x+s*this.p3.x)/r,n=(t*this.p1.y+e*this.p2.y+s*this.p3.y)/r;return new l(i,n)}get circumcenter(){const t=2*(this.p1.x*(this.p2.y-this.p3.y)+this.p2.x*(this.p3.y-this.p1.y)+this.p3.x*(this.p1.y-this.p2.y));if(Math.abs(t)<d.EPSILON)throw new Error("Cannot calculate circumcenter for collinear points");const e=((this.p1.x*this.p1.x+this.p1.y*this.p1.y)*(this.p2.y-this.p3.y)+(this.p2.x*this.p2.x+this.p2.y*this.p2.y)*(this.p3.y-this.p1.y)+(this.p3.x*this.p3.x+this.p3.y*this.p3.y)*(this.p1.y-this.p2.y))/t,s=((this.p1.x*this.p1.x+this.p1.y*this.p1.y)*(this.p3.x-this.p2.x)+(this.p2.x*this.p2.x+this.p2.y*this.p2.y)*(this.p1.x-this.p3.x)+(this.p3.x*this.p3.x+this.p3.y*this.p3.y)*(this.p2.x-this.p1.x))/t;return new l(e,s)}containsPoint(t){const e=d.area(l.distance(t,this.p1),l.distance(t,this.p2),l.distance(this.p1,this.p2)),s=d.area(l.distance(t,this.p2),l.distance(t,this.p3),l.distance(this.p2,this.p3)),r=d.area(l.distance(t,this.p3),l.distance(t,this.p1),l.distance(this.p3,this.p1));return Math.abs(e+s+r-this.area())<d.EPSILON}}class G{static sleep(t){return new Promise(e=>setTimeout(e,t))}static binarySearchTemplate(t,e,s){let r=-1,i=t.length,n;for(;i-r>1;)n=i-(i-r)>>1,s(t[n],e)?i=n:r=n;return i}static singleton(t){let e;const s=new Proxy(t,{construct(r,i,n){return e||(e=Reflect.construct(r,i,n)),e}});return t.prototype.constructor=s,s}}class j{static groupBy(t,e){if(!e)throw new Error("generateKey is required");const s=typeof e=="string"?i=>i[e]:e,r=new Map;for(const[i,n]of t.entries())try{const a=s(n,i,t);if(a==null){console.warn("Invalid key generated for item:",n);continue}const o=r.get(a)??[];o.push(n),r.set(a,o)}catch(a){console.error("Error generating key for item:",n,a)}return Object.fromEntries(r)}static LIS(t){if(!t.length)return[];const e=[[t[0]]];for(let r=1,i=t.length;r<i;r++){const n=t[r];s(n)}function s(r){for(let i=e.length-1;i>=0;i--){const n=e[i],a=n[e[i].length-1];if(a<r){e[i+1]=[...n,r];break}else a>r&&i===0&&(e[i]=[r])}}return e[e.length-1]}static LCP(t){if(!t.length)return"";let e=t[0];for(let s=1;s<t.length;s++)for(;!t[s].startsWith(e);)if(e=e.slice(0,-1),e==="")return"";return e}}function R(h){return h!==null&&(typeof h=="object"||typeof h=="function")}class W{map=new Map;weakMap=new WeakMap;set(t,e){R(t)?this.weakMap.set(t,e):this.map.set(t,e)}get(t){return R(t)?this.weakMap.get(t):this.map.get(t)}has(t){return R(t)?this.weakMap.has(t):this.map.has(t)}}class X{static jsonClone(t){try{return JSON.parse(JSON.stringify(t))}catch{throw new Error("Object is not JSON cloneable")}}static structureClone(t){return structuredClone(t)}static deepClone(t,e=new WeakMap){if(t==null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof Map){const n=new Map;e.set(t,n);for(const[a,o]of t)n.set(this.deepClone(a,e),this.deepClone(o,e));return n}if(t instanceof Set){const n=new Set;e.set(t,n);for(const a of t)n.add(this.deepClone(a,e));return n}if(Array.isArray(t)){const n=new Array(t.length);e.set(t,n);for(let a=0,o=t.length;a<o;a++)n[a]=this.deepClone(t[a],e);return n}if(t instanceof ArrayBuffer)return t.slice(0);const s=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];for(const n of s)if(t instanceof n)return new n(t);if(typeof t=="function")return new Proxy(t,{apply(n,a,o){return n.apply(a,o)},get(n,a){if(a in n)return n[a]}});const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);const i=Object.getOwnPropertyDescriptors(t);for(const[n,a]of Object.entries(i))a.value!==void 0&&(a.value=this.deepClone(a.value,e)),Object.defineProperty(r,n,a);return r}}const $={date:"yyyy-MM-dd",datetime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",iso:"yyyy-MM-ddTHH:mm:ss.SSS"};class S{static defaultOptions={paddingZero:!1,locale:"en-US"};static setDefaultOptions(t){S.defaultOptions={...S.defaultOptions,...t}}static format(t,e,s={}){const r={...S.defaultOptions,...s},i=S.getDateInfo(t,r);return S.normalizeFormatter(e)(i)}static getDateInfo(t,e){const s=(u,p=2)=>e.paddingZero?u.toString().padStart(p,"0"):u.toString(),r=t.getFullYear(),i=t.getMonth()+1,n=t.getDate(),a=t.getHours(),o=t.getMinutes(),f=t.getSeconds(),m=t.getMilliseconds();return{year:r,month:i,day:n,hour:a,minute:o,second:f,millisecond:m,yyyy:s(r,4),MM:s(i),dd:s(n),HH:s(a),mm:s(o),ss:s(f)}}static normalizeFormatter(t){if(typeof t=="function")return t;if(typeof t!="string")throw new Error("Formatter must be a string or function");t in $&&(t=$[t]);const e={yyyy:"yyyy",MM:"MM",dd:"dd",HH:"HH",mm:"mm",ss:"ss",SSS:"SSS"};return s=>{let r=t;for(const[i,n]of Object.entries(e))r=r.replace(new RegExp(i,"g"),String(s[n]||""));return r}}static formatRelative(t,e=new Date){const s=t.getTime()-e.getTime(),r=Math.abs(s),i=Math.floor(r/1e3),n=Math.floor(i/60),a=Math.floor(n/60),o=Math.floor(a/24);return o>0?s>0?`${o}天后`:`${o}天前`:a>0?s>0?`${a}小时后`:`${a}小时前`:n>0?s>0?`${n}分钟后`:`${n}分钟前`:s>0?"刚刚":""}}class Q{static escape(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class J{static ROMAN_MAP=new Map([["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toInteger(t){if(t.length===0)throw new Error("Input cannot be empty");const e=new Set(["I","V","X","L","C","D","M"]);for(const n of t)if(!e.has(n))throw new Error(`Invalid Roman numeral character: ${n}`);let s=0,r=0;for(;r<t.length;){const n=t.slice(r,r+2);if(this.ROMAN_MAP.has(n))s+=this.ROMAN_MAP.get(n),r+=2;else{const a=t[r],o=this.ROMAN_MAP.get(a);if(!o)throw new Error(`Invalid Roman numeral sequence at position ${r}`);s+=o,r+=1}}if(this.toRoman(s)!==t)throw new Error("Invalid Roman numeral sequence");return s}static toRoman(t){if(t<=0||t>=4e3)throw new Error("Number must be between 1 and 3999");if(!Number.isInteger(t))throw new Error("Number must be an integer");let e="";for(const[s,r]of this.ROMAN_MAP)for(;t>=r;)e+=s,t-=r;return e}}class w{static handleNumRange(t,e=!1,s=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){if(e&&!Number.isInteger(t))throw new Error("n must be an integer");if(t<s||t>=r)throw new RangeError(`n must be in the range of ${s} to ${r}`)}static consecutiveSum(t){return w.handleNumRange(t,!0,0,1e8),t*(t+1)/2}static consecutiveSquaresSum(t){return w.handleNumRange(t,!0,0,1e6),t*(t+1)*(2*t+1)/6}static consecutivecubesSum(t){return w.handleNumRange(t,!0,0,1e4),t*(t+1)*(2*t+1)*(3*t*t+3*t-1)/30}static clamp(t,e,s){return s==null?Math.min(t,e):Math.min(Math.max(t,e),s)}static factorial(t){if(w.handleNumRange(t,!0,0,1e3),t<2)return 1;let e=1;for(let s=2;s<=t;s++)e*=s;return e}static fibonacci(t,e=1,s=1){return w.handleNumRange(t,!0,0,1e3),t<2?s:this.fibonacci(t-1,s,s+e)}static fibonacciIterative(t){if(w.handleNumRange(t,!0,0,1e3),t<2)return t;let e=0,s=1;for(let r=2;r<=t;r++)[e,s]=[s,(e+s)%1000000007];return s}static floatEqual(t,e,s=1e-6){return Math.abs(t-e)<s}static fastPower(t,e){if(w.handleNumRange(e,!0,0,10),w.handleNumRange(t,!1,0,1e3),t===0)return 0;if(e===0)return 1;const s=this.fastPower(t,e>>1);return e%2===0?s*s:s*s*t}static fastSqrt(t){if(w.handleNumRange(t,!1,0,1e8),typeof BigInt>"u")return Math.sqrt(t);const e=.5*t,s=new ArrayBuffer(8);new Float64Array(s)[0]=t;let r=new BigInt64Array(s)[0];r=0x1ff7a3bea91d9b1bn+(r>>1n);const i=new ArrayBuffer(8);new BigInt64Array(i)[0]=r;let n=new Float64Array(i)[0];return n=n*.5+e/n,n=n*.5+e/n,n=n*.5+e/n,n}static getPercentWithPrecision(t,e=2){if(!Array.isArray(t)||t.length===0)return[];if(e<0||!Number.isInteger(e))throw new Error("Precision must be a non-negative integer");const s=t.reduce((u,p)=>u+p,0);if(s===0)return t.map(()=>"0%");const i=100*Math.pow(10,e),n=t.map(u=>u/s*i),a=n.map(u=>Math.floor(u)),o=n.map((u,p)=>u-a[p]);let f=a.reduce((u,p)=>u+p,0),m=i-f;for(;m>0;){let u=-1,p=-1;for(let y=0;y<o.length;y++)o[y]>p&&(p=o[y],u=y);if(u===-1)break;a[u]++,o[u]=0,m--}return a.map(u=>`${(u/i*100).toFixed(e)}%`)}static gcd(t,e){return e===0?t:this.gcd(e,t%e)}static isValidPositiveInteger(t){return Number.isInteger(t)&&t>0&&t<=Number.MAX_SAFE_INTEGER}static isPowerOfTwo(t){return t>0&&(t&t-1)===0}static isOdd(t){return t%2===1||t%2===-1}static isPrime(t){if(t<=1)return!1;for(let e=2;e<=Math.sqrt(t);e++)if(t%e===0)return!1;return!0}static isPalindrome(t){if(t<0||t%10===0&&t!==0)return!1;let e=0,s=t;for(;t>0;){const r=t%10;e=e*10+r,t=Math.floor(t/10)}return s===e}static isArmstrong(t){const e=t.toString(),s=e.length;let r=0;for(let i=0;i<s;i++)r+=Math.pow(parseInt(e[i]),s);return r===t}static isHappy(t){const e=new Set;for(;t!==1;){if(e.has(t))return!1;e.add(t),t=(t+"").split("").reduce((s,r)=>s+Number(r)*Number(r),0)}return!0}static isPerfect(t){let e=0;for(let s=1;s<t;s++)t%s===0&&(e+=s);return e===t}static isSameSign(t,e){return t>=0&&e>=0||t<=0&&e<=0}static isRange(t,e,s){if(s==null&&(s=e,e=0),e>=s)throw new Error("The maximum value must be greater than the minimum value");return e<=t&&t<s}static lcm(t,e){return t*e/this.gcd(t,e)}static middle(t,e){return e-(e-t>>1)}static random(t,e){if(e==null&&(e=t,t=0),t>=e)throw new Error("The maximum value must be greater than the minimum value");return Math.random()*(e-t)+t}static randomInt(t,e){return Math.floor(this.random(t,e))}static round(t,e=0){if(!Number.isInteger(e))throw new Error("precision must be an integer");const s=Math.pow(10,e);return Math.round(t*s)/s}static scale(t,e,s){if(e[0]>=e[1]||s[0]>=s[1])throw new Error("Invalid range");t=this.clamp(t,e[0],e[1]);const r=e[1]-e[0];return(t-e[0])*((s[1]-s[0])/r)+s[0]}}class _{static READ=1;static WRITE=2;static SHARE=4;static DELETE=8;static CREATE=16;static include(t,e){return(t&e)===e}static add(t,e){return t|e}static remove(t,e){return t&~e}static toggle(t,e){return t^e}}class x{static frequencyStatistics(t){return[...t].reduce((e,s)=>(e[s]=(e[s]||0)+1,e),{})}static isValidBracket(t){const e=[],s={"(":")","[":"]","{":"}"},r=new Set(Object.values(s));for(const i of t)if(i in s)e.push(s[i]);else if(r.has(i)&&i!==e.pop())return!1;return e.length===0}static random(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let r=0;r<t;r++)s+=e.charAt(Math.floor(Math.random()*e.length));return s}static template(t,e){return t.replace(/\${(\w+)}/g,(s,r)=>e[r]||"")}static escapeHtml(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"," ":" ","±":"±","×":"×","÷":"÷","≠":"≠","≤":"≤","≥":"≥"},s=new RegExp(`[${Object.keys(e).join("")}]`,"g");return t.replace(s,r=>e[r])}static isEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}static isUrl(t){try{return new URL(t),!0}catch{return!1}}static pointLength(t){let e=0;for(let s=0,r=t.length;s<r;){const i=t.codePointAt(s);s+=i>65535?2:1,e++}return e}static pointAt(t,e){if(e>=x.pointLength(t))return;let s=0;for(let r=0,i=t.length;r<i;){const n=t.codePointAt(r);if(!n)return;if(s===e)return String.fromCodePoint(n);r+=n>65535?2:1,s++}}static sliceByPoint(t,e,s=x.pointLength(t)){let r="";for(let i=e;i<s;i++)r+=x.pointAt(t,i);return r}static capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}static reverse(t){return t.split("").reverse().join("")}static truncate(t,e,s="..."){return t.length<=e?this:t.slice(0,e-s.length)+s}static isPalindrome(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")===x.reverse(t)}static count(t,e){const s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return(t.match(new RegExp(s,"g"))||[]).length}static toCamelCase(t){return t.replace(/_([a-z])/g,(e,s)=>s.toUpperCase())}static toSnakeCase(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}}class Z{static isValidHex(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}static isValidRGB(t){return/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t)}}const A={AUTH_UNAUTHORIZED:"未授权事件",AUTH_LOGIN_SUCCESS:"登录成功事件",AUTH_LOGOUT:"注销事件",AUTH_TOKEN_EXPIRED:"令牌过期事件",REQUEST_ERROR:"请求错误事件",REQUEST_TIMEOUT:"请求超时事件",REQUEST_NETWORK_ERROR:"网络错误事件",UI_SHOW_LOADING:"显示加载事件",UI_HIDE_LOADING:"隐藏加载事件",UI_SHOW_MESSAGE:"显示消息事件"};class v{static instance=null;listeners={};debugMode;constructor(t=!1){this.debugMode=t,Object.keys(A).forEach(e=>{this.listeners[e]=new Set})}static getInstance(t){return v.instance||(v.instance=new v(t)),v.instance}on(t,e){this.debugLog(`添加事件监听: ${A[t]}`),this.listeners[t].add(e)}emit(t,e){this.debugLog(`触发事件: ${A[t]}`,e),this.listeners[t].forEach(s=>{try{s(e)}catch(r){console.error(`事件 ${A[t]} 处理出错:`,r)}})}off(t,e){this.debugLog(`移除事件监听: ${A[t]}`),this.listeners[t].delete(e)}once(t,e){this.debugLog(`添加一次性事件监听: ${A[t]}`);const s=r=>{e(r),this.off(t,s)};this.on(t,s)}clear(){this.debugLog("清除所有事件监听器"),Object.values(this.listeners).forEach(t=>t.clear())}getListenerCount(t){return this.listeners[t].size}debugLog(t,e){this.debugMode&&console.log(`[EventEmitter] ${t}`,e||"")}}c.Arr=j,c.BitPerm=_,c.Color=Z,c.DateEx=S,c.Dictionary=C,c.Emitter=v,c.Func=G,c.Graph=B,c.LRU=q,c.Line=g,c.LinkedList=T,c.Matrix=M,c.MaxHeap=D,c.MemoizeMap=W,c.MinHeap=k,c.MinStack=V,c.Num=w,c.Obj=X,c.Point=l,c.Queue=O,c.Reg=Q,c.Roman=J,c.Stack=H,c.Str=x,c.Triangle=d,c.Vector=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="./types/string.extensions.d.ts"/>
|
|
2
|
-
|
|
3
1
|
declare module "jc-structure" {
|
|
4
2
|
//#region data structure
|
|
5
3
|
/**
|
|
@@ -575,9 +573,9 @@ declare module "jc-structure" {
|
|
|
575
573
|
}
|
|
576
574
|
|
|
577
575
|
/**
|
|
578
|
-
* ###
|
|
576
|
+
* ### 数字类
|
|
579
577
|
*/
|
|
580
|
-
interface NumConstructor
|
|
578
|
+
interface NumConstructor {
|
|
581
579
|
/**
|
|
582
580
|
* #### 判断是否是有效的正整数
|
|
583
581
|
* @param n A numeric value
|
|
@@ -818,7 +816,43 @@ declare module "jc-structure" {
|
|
|
818
816
|
}
|
|
819
817
|
declare var BitPer: BitPerConstructor;
|
|
820
818
|
|
|
821
|
-
interface
|
|
819
|
+
interface StrConstructor {
|
|
820
|
+
/**
|
|
821
|
+
* #### 根据字符串频率统计
|
|
822
|
+
* @param s
|
|
823
|
+
*/
|
|
824
|
+
frequencyStatistics(s: string): { [key: string]: number };
|
|
825
|
+
/**
|
|
826
|
+
* #### 是否是成对的括号
|
|
827
|
+
* @param str
|
|
828
|
+
*/
|
|
829
|
+
isValidBracket(str: string): boolean;
|
|
830
|
+
/**
|
|
831
|
+
* #### 根据长度获取随机字符串
|
|
832
|
+
* @param length 长度 默认为:8
|
|
833
|
+
*/
|
|
834
|
+
random(length?: number): string;
|
|
835
|
+
/**
|
|
836
|
+
* #### 生成模板字符串
|
|
837
|
+
* @param template 模板字符串
|
|
838
|
+
* @param values
|
|
839
|
+
*/
|
|
840
|
+
template(template: string, values: Record<string, any>): string;
|
|
841
|
+
/**
|
|
842
|
+
* #### 转义HTML标签
|
|
843
|
+
* @param str 字符串
|
|
844
|
+
*/
|
|
845
|
+
escapeHtml(str: string): string;
|
|
846
|
+
/**
|
|
847
|
+
* #### 判断是否是邮箱号码
|
|
848
|
+
* @param str
|
|
849
|
+
*/
|
|
850
|
+
isEmail(str: string): boolean;
|
|
851
|
+
/**
|
|
852
|
+
* #### 判断是否是URL
|
|
853
|
+
* @param str
|
|
854
|
+
*/
|
|
855
|
+
isUrl(str: string): boolean;
|
|
822
856
|
/**
|
|
823
857
|
* #### 获取字符串码点长度
|
|
824
858
|
*/
|
|
@@ -833,7 +867,7 @@ declare module "jc-structure" {
|
|
|
833
867
|
* @param start 开始索引
|
|
834
868
|
* @param end 结束索引
|
|
835
869
|
*/
|
|
836
|
-
sliceByPoint(start: number, end
|
|
870
|
+
sliceByPoint(start: number, end?: number): string;
|
|
837
871
|
/**
|
|
838
872
|
* #### 首字母大写
|
|
839
873
|
*/
|
|
@@ -847,7 +881,7 @@ declare module "jc-structure" {
|
|
|
847
881
|
* @param length 长度,包含‘...’
|
|
848
882
|
* @param suffix 后缀符号,默认‘...’
|
|
849
883
|
*/
|
|
850
|
-
truncate(length: number, suffix
|
|
884
|
+
truncate(length: number, suffix?: string): string;
|
|
851
885
|
/**
|
|
852
886
|
* #### 是否是回文字符串
|
|
853
887
|
*/
|
|
@@ -866,46 +900,6 @@ declare module "jc-structure" {
|
|
|
866
900
|
*/
|
|
867
901
|
toSnakeCase(): string;
|
|
868
902
|
}
|
|
869
|
-
interface StrConstructor extends StringConstructor {
|
|
870
|
-
new (value?: any): Str;
|
|
871
|
-
readonly prototype: Str;
|
|
872
|
-
/**
|
|
873
|
-
* #### 根据字符串频率统计
|
|
874
|
-
* @param s
|
|
875
|
-
*/
|
|
876
|
-
frequencyStatistics(s: string): { [key: string]: number };
|
|
877
|
-
/**
|
|
878
|
-
* #### 是否是成对的括号
|
|
879
|
-
* @param str
|
|
880
|
-
*/
|
|
881
|
-
isValidBracket(str: string): boolean;
|
|
882
|
-
/**
|
|
883
|
-
* #### 根据长度获取随机字符串
|
|
884
|
-
* @param length
|
|
885
|
-
*/
|
|
886
|
-
random(length: number = 8): string;
|
|
887
|
-
/**
|
|
888
|
-
* #### 生成模板字符串
|
|
889
|
-
* @param template 模板字符串
|
|
890
|
-
* @param values
|
|
891
|
-
*/
|
|
892
|
-
template(template: string, values: Record<string, any>): string;
|
|
893
|
-
/**
|
|
894
|
-
* #### 转义HTML标签
|
|
895
|
-
* @param str 字符串
|
|
896
|
-
*/
|
|
897
|
-
escapeHtml(str: string): string;
|
|
898
|
-
/**
|
|
899
|
-
* #### 判断是否是邮箱号码
|
|
900
|
-
* @param str
|
|
901
|
-
*/
|
|
902
|
-
isEmail(str: string): boolean;
|
|
903
|
-
/**
|
|
904
|
-
* #### 判断是否是URL
|
|
905
|
-
* @param str
|
|
906
|
-
*/
|
|
907
|
-
isUrl(str: string): boolean;
|
|
908
|
-
}
|
|
909
903
|
declare var Str: StrConstructor;
|
|
910
904
|
|
|
911
905
|
interface RegConstructor {
|
|
@@ -926,6 +920,21 @@ declare module "jc-structure" {
|
|
|
926
920
|
}
|
|
927
921
|
declare var Reg: RegConstructor;
|
|
928
922
|
|
|
923
|
+
interface DateInfo {
|
|
924
|
+
year: number;
|
|
925
|
+
month: number;
|
|
926
|
+
day: number;
|
|
927
|
+
hour: number;
|
|
928
|
+
minute: number;
|
|
929
|
+
second: number;
|
|
930
|
+
millisecond: number;
|
|
931
|
+
yyyy?: string;
|
|
932
|
+
MM?: string;
|
|
933
|
+
dd?: string;
|
|
934
|
+
HH?: string;
|
|
935
|
+
mm?: string;
|
|
936
|
+
ss?: string;
|
|
937
|
+
}
|
|
929
938
|
interface FormatOptions {
|
|
930
939
|
/**
|
|
931
940
|
* #### 是否补零
|
|
@@ -949,11 +958,7 @@ declare module "jc-structure" {
|
|
|
949
958
|
* @param formatter 格式化器
|
|
950
959
|
* @param options
|
|
951
960
|
*/
|
|
952
|
-
format(
|
|
953
|
-
date: Date,
|
|
954
|
-
formatter: Formatter,
|
|
955
|
-
options: FormatOptions = {}
|
|
956
|
-
): string;
|
|
961
|
+
format(date: Date, formatter: Formatter, options?: FormatOptions): string;
|
|
957
962
|
}
|
|
958
963
|
declare var DateEx: DateExConstructor;
|
|
959
964
|
|
|
@@ -1046,7 +1051,7 @@ declare module "jc-structure" {
|
|
|
1046
1051
|
* @param visited
|
|
1047
1052
|
* @returns
|
|
1048
1053
|
*/
|
|
1049
|
-
deepClone(obj: unknown, visited
|
|
1054
|
+
deepClone(obj: unknown, visited?: WeakMap): unknown;
|
|
1050
1055
|
}
|
|
1051
1056
|
declare var Obj: ObjConstructor;
|
|
1052
1057
|
|