ezh 0.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/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # ezh
2
+ [![ezh npm version](https://img.shields.io/npm/v/ezh.svg?style=popout&color=blue&label=ezh)](https://www.npmjs.com/package/ezh)
3
+
4
+ A frontend framework that using tsx syntax, simple, tiny and fast.
package/lib/RbTree.js ADDED
@@ -0,0 +1,675 @@
1
+ export { a3, U, L, E, W, J, };
2
+ class F {
3
+ a4() {
4
+ return !this.k;
5
+ }
6
+ G(a) {
7
+ while (a.parent?.e) {
8
+ let parent = a.parent;
9
+ let m = parent.parent;
10
+ if (parent === m.c) {
11
+ const x = m.d;
12
+ if (x?.e) {
13
+ parent.e = false;
14
+ x.e = false;
15
+ m.e = true;
16
+ a = m;
17
+ }
18
+ else {
19
+ if (a === parent.d) {
20
+ a = parent;
21
+ this.y(a);
22
+ parent = a.parent;
23
+ m = parent.parent;
24
+ }
25
+ parent.e = false;
26
+ m.e = true;
27
+ this.z(m);
28
+ }
29
+ }
30
+ else {
31
+ const x = m.c;
32
+ if (x?.e === true) {
33
+ parent.e = false;
34
+ x.e = false;
35
+ m.e = true;
36
+ a = m;
37
+ }
38
+ else {
39
+ if (a === parent.c) {
40
+ a = parent;
41
+ this.z(a);
42
+ parent = a.parent;
43
+ m = parent.parent;
44
+ }
45
+ parent.e = false;
46
+ m.e = true;
47
+ this.y(m);
48
+ }
49
+ }
50
+ }
51
+ this.k.e = false;
52
+ }
53
+ v(a) {
54
+ const { c, d, parent } = a;
55
+ if (!c) {
56
+ if (!parent) {
57
+ this.k = d;
58
+ if (d) {
59
+ d.parent = undefined;
60
+ d.e = false;
61
+ }
62
+ return;
63
+ }
64
+ if (parent.c === a) {
65
+ parent.c = d;
66
+ }
67
+ else {
68
+ parent.d = d;
69
+ }
70
+ if (d) {
71
+ d.parent = parent;
72
+ d.e = false;
73
+ return;
74
+ }
75
+ if (!a.e) {
76
+ this.H(parent);
77
+ }
78
+ return;
79
+ }
80
+ if (!d) {
81
+ if (parent) {
82
+ if (parent.c === a) {
83
+ parent.c = c;
84
+ }
85
+ else {
86
+ parent.d = c;
87
+ }
88
+ }
89
+ else {
90
+ this.k = c;
91
+ }
92
+ c.parent = parent;
93
+ c.e = false;
94
+ return;
95
+ }
96
+ let t;
97
+ let replace;
98
+ let target = d;
99
+ if (!target.c) {
100
+ t = target;
101
+ replace = target.d;
102
+ }
103
+ else {
104
+ do {
105
+ target = target.c;
106
+ } while (target.c);
107
+ replace = target.d;
108
+ t = target.parent;
109
+ if (t.c === target) {
110
+ t.c = replace;
111
+ }
112
+ else {
113
+ t.d = replace;
114
+ }
115
+ if (replace) {
116
+ replace.parent = t;
117
+ }
118
+ target.d = d;
119
+ d.parent = target;
120
+ }
121
+ if (parent) {
122
+ if (parent.c === a) {
123
+ parent.c = target;
124
+ }
125
+ else {
126
+ parent.d = target;
127
+ }
128
+ }
129
+ else {
130
+ this.k = target;
131
+ }
132
+ target.parent = parent;
133
+ target.c = c;
134
+ c.parent = target;
135
+ const M = target.e;
136
+ target.e = a.e;
137
+ if (replace) {
138
+ replace.e = false;
139
+ return;
140
+ }
141
+ if (!M) {
142
+ this.H(t);
143
+ }
144
+ }
145
+ H(parent) {
146
+ let a;
147
+ let h;
148
+ for (;;) {
149
+ if (a === parent.c) {
150
+ h = parent.d;
151
+ if (h.e) {
152
+ this.y(parent);
153
+ h.e = false;
154
+ parent.e = true;
155
+ h = parent.d;
156
+ continue;
157
+ }
158
+ if (h.d?.e) {
159
+ this.y(parent);
160
+ h.e = parent.e;
161
+ parent.e = false;
162
+ h.d.e = false;
163
+ return;
164
+ }
165
+ if (h.c?.e) {
166
+ h.c.e = false;
167
+ this.z(h);
168
+ h.e = true;
169
+ h = parent.d;
170
+ continue;
171
+ }
172
+ }
173
+ else {
174
+ h = parent.c;
175
+ if (h.e) {
176
+ this.z(parent);
177
+ h.e = false;
178
+ parent.e = true;
179
+ h = parent.c;
180
+ continue;
181
+ }
182
+ if (h.c?.e) {
183
+ this.z(parent);
184
+ h.e = parent.e;
185
+ parent.e = false;
186
+ h.c.e = false;
187
+ return;
188
+ }
189
+ if (h.d?.e) {
190
+ h.d.e = false;
191
+ this.y(h);
192
+ h.e = true;
193
+ h = parent.c;
194
+ continue;
195
+ }
196
+ }
197
+ if (parent.e) {
198
+ parent.e = false;
199
+ h.e = true;
200
+ return;
201
+ }
202
+ h.e = true;
203
+ a = parent;
204
+ if (!a.parent) {
205
+ return;
206
+ }
207
+ parent = a.parent;
208
+ }
209
+ }
210
+ y(a) {
211
+ const r = a.d;
212
+ a.d = r?.c;
213
+ if (r?.c) {
214
+ r.c.parent = a;
215
+ }
216
+ r.parent = a.parent;
217
+ if (!a.parent) {
218
+ this.k = r;
219
+ }
220
+ else if (a === a.parent.c) {
221
+ a.parent.c = r;
222
+ }
223
+ else {
224
+ a.parent.d = r;
225
+ }
226
+ r.c = a;
227
+ a.parent = r;
228
+ }
229
+ z(a) {
230
+ const s = a.c;
231
+ a.c = s?.d;
232
+ if (s?.d) {
233
+ s.d.parent = a;
234
+ }
235
+ s.parent = a.parent;
236
+ if (!a.parent) {
237
+ this.k = s;
238
+ }
239
+ else if (a === a.parent.d) {
240
+ a.parent.d = s;
241
+ }
242
+ else {
243
+ a.parent.c = s;
244
+ }
245
+ s.d = a;
246
+ a.parent = s;
247
+ }
248
+ k;
249
+ }
250
+ const _ = 1;
251
+ const A = 2;
252
+ const a3 = 0;
253
+ const U = 1;
254
+ const L = 2;
255
+ const E = 3;
256
+ class W extends F {
257
+ search(key) {
258
+ return this.I(key)?.value;
259
+ }
260
+ delete(key) {
261
+ const a = this.I(key);
262
+ if (a) {
263
+ this.v(a);
264
+ return a.value;
265
+ }
266
+ return;
267
+ }
268
+ C(key, value, $) {
269
+ let a = this.k;
270
+ if (a) {
271
+ let i;
272
+ while (key !== a.key) {
273
+ if (key < a.key) {
274
+ if (a.c) {
275
+ a = a.c;
276
+ continue;
277
+ }
278
+ i = { key, value, e: true, parent: a, c: undefined, d: undefined };
279
+ a.c = i;
280
+ }
281
+ else {
282
+ if (a.d) {
283
+ a = a.d;
284
+ continue;
285
+ }
286
+ i = { key, value, e: true, parent: a, c: undefined, d: undefined };
287
+ a.d = i;
288
+ }
289
+ this.G(i);
290
+ return;
291
+ }
292
+ const g = a.value;
293
+ if ($) {
294
+ a.value = value;
295
+ }
296
+ return g;
297
+ }
298
+ this.k = { key, value, e: false, parent: undefined, c: undefined, d: undefined };
299
+ return;
300
+ }
301
+ a5(o, n) {
302
+ let f = 0;
303
+ let a = this.k;
304
+ if (a) {
305
+ const stack = [];
306
+ if (n !== undefined) {
307
+ for (;;) {
308
+ if (n < a.key) {
309
+ if (a.c) {
310
+ stack.push(a);
311
+ a = a.c;
312
+ continue;
313
+ }
314
+ }
315
+ else if (n > a.key) {
316
+ if (a.d) {
317
+ a = a.d;
318
+ continue;
319
+ }
320
+ return f;
321
+ }
322
+ break;
323
+ }
324
+ }
325
+ else {
326
+ while (a.c) {
327
+ stack.push(a);
328
+ a = a.c;
329
+ }
330
+ }
331
+ let j;
332
+ for (;;) {
333
+ const p = o(a.key, a.value);
334
+ f++;
335
+ if (p & A) {
336
+ (j ?? (j = [])).push(a);
337
+ }
338
+ if (p & _) {
339
+ f = -f;
340
+ break;
341
+ }
342
+ if (a.d) {
343
+ a = a.d;
344
+ while (a.c) {
345
+ stack.push(a);
346
+ a = a.c;
347
+ }
348
+ }
349
+ else {
350
+ a = stack.pop();
351
+ if (!a) {
352
+ break;
353
+ }
354
+ }
355
+ }
356
+ if (j) {
357
+ let b = j.length;
358
+ while (b > 0) {
359
+ this.v(j[--b]);
360
+ }
361
+ }
362
+ }
363
+ return f;
364
+ }
365
+ O(o, n) {
366
+ let f = 0;
367
+ let a = this.k;
368
+ if (a) {
369
+ const stack = [];
370
+ if (n !== undefined) {
371
+ for (;;) {
372
+ if (n > a.key) {
373
+ if (a.d) {
374
+ stack.push(a);
375
+ a = a.d;
376
+ continue;
377
+ }
378
+ }
379
+ else if (n < a.key) {
380
+ if (a.c) {
381
+ a = a.c;
382
+ continue;
383
+ }
384
+ return f;
385
+ }
386
+ break;
387
+ }
388
+ }
389
+ else {
390
+ while (a.d) {
391
+ stack.push(a);
392
+ a = a.d;
393
+ }
394
+ }
395
+ let j;
396
+ for (;;) {
397
+ const p = o(a.key, a.value);
398
+ f++;
399
+ if (p & A) {
400
+ (j ?? (j = [])).push(a);
401
+ }
402
+ if (p & _) {
403
+ f = -f;
404
+ break;
405
+ }
406
+ if (a.c) {
407
+ a = a.c;
408
+ while (a.d) {
409
+ stack.push(a);
410
+ a = a.d;
411
+ }
412
+ }
413
+ else {
414
+ a = stack.pop();
415
+ if (!a) {
416
+ break;
417
+ }
418
+ }
419
+ }
420
+ if (j) {
421
+ let b = j.length;
422
+ while (b > 0) {
423
+ this.v(j[--b]);
424
+ }
425
+ }
426
+ }
427
+ return f;
428
+ }
429
+ I(key) {
430
+ let a = this.k;
431
+ if (a) {
432
+ while (key !== a.key) {
433
+ if (key < a.key) {
434
+ if (a.c) {
435
+ a = a.c;
436
+ continue;
437
+ }
438
+ }
439
+ else {
440
+ if (a.d) {
441
+ a = a.d;
442
+ continue;
443
+ }
444
+ }
445
+ return;
446
+ }
447
+ }
448
+ return a;
449
+ }
450
+ }
451
+ class J extends F {
452
+ search(key) {
453
+ let a = this.k;
454
+ if (a) {
455
+ const { w: D } = this;
456
+ let q;
457
+ while ((q = D(key, a)) !== 0) {
458
+ if (q < 0) {
459
+ if (a.c) {
460
+ a = a.c;
461
+ continue;
462
+ }
463
+ }
464
+ else {
465
+ if (a.d) {
466
+ a = a.d;
467
+ continue;
468
+ }
469
+ }
470
+ return;
471
+ }
472
+ }
473
+ return a;
474
+ }
475
+ delete(key) {
476
+ const a = this.search(key);
477
+ if (a) {
478
+ this.v(a);
479
+ a.e = undefined;
480
+ return a;
481
+ }
482
+ return;
483
+ }
484
+ C(i, $) {
485
+ if (i.e !== undefined) {
486
+ throw new Error('Cannot insert a node which is already in an ObjRbTree');
487
+ }
488
+ let a = this.k;
489
+ if (a) {
490
+ const { w: D } = this;
491
+ let q;
492
+ while ((q = D(i, a)) !== 0) {
493
+ if (q < 0) {
494
+ if (a.c) {
495
+ a = a.c;
496
+ continue;
497
+ }
498
+ i.e = true;
499
+ i.parent = a;
500
+ a.c = i;
501
+ }
502
+ else {
503
+ if (a.d) {
504
+ a = a.d;
505
+ continue;
506
+ }
507
+ i.e = true;
508
+ i.parent = a;
509
+ a.d = i;
510
+ }
511
+ this.G(i);
512
+ return;
513
+ }
514
+ if ($) {
515
+ const { parent, c, d, e } = a;
516
+ i.parent = parent;
517
+ i.e = e;
518
+ i.c = c;
519
+ i.d = d;
520
+ if (parent) {
521
+ if (parent.c === a) {
522
+ parent.c = i;
523
+ }
524
+ else {
525
+ parent.d = i;
526
+ }
527
+ }
528
+ if (c) {
529
+ c.parent = i;
530
+ }
531
+ if (d) {
532
+ d.parent = i;
533
+ }
534
+ a.e = undefined;
535
+ }
536
+ return a;
537
+ }
538
+ i.e = false;
539
+ this.k = i;
540
+ return;
541
+ }
542
+ a5(o, n) {
543
+ let f = 0;
544
+ let a = this.k;
545
+ if (a) {
546
+ const stack = [];
547
+ if (n) {
548
+ const { w } = this;
549
+ for (;;) {
550
+ const q = w(n, a);
551
+ if (q < 0) {
552
+ if (a.c) {
553
+ stack.push(a);
554
+ a = a.c;
555
+ continue;
556
+ }
557
+ }
558
+ else if (q > 0) {
559
+ if (a.d) {
560
+ a = a.d;
561
+ continue;
562
+ }
563
+ return f;
564
+ }
565
+ break;
566
+ }
567
+ }
568
+ else {
569
+ while (a.c) {
570
+ stack.push(a);
571
+ a = a.c;
572
+ }
573
+ }
574
+ let j;
575
+ for (;;) {
576
+ const p = o(a);
577
+ f++;
578
+ if (p & A) {
579
+ (j ?? (j = [])).push(a);
580
+ }
581
+ if (p & _) {
582
+ f = -f;
583
+ break;
584
+ }
585
+ if (a.d) {
586
+ a = a.d;
587
+ while (a.c) {
588
+ stack.push(a);
589
+ a = a.c;
590
+ }
591
+ }
592
+ else {
593
+ a = stack.pop();
594
+ if (!a) {
595
+ break;
596
+ }
597
+ }
598
+ }
599
+ if (j) {
600
+ let b = j.length;
601
+ while (b > 0) {
602
+ this.v(j[--b]);
603
+ }
604
+ }
605
+ }
606
+ return f;
607
+ }
608
+ O(o, n) {
609
+ let f = 0;
610
+ let a = this.k;
611
+ if (a) {
612
+ const stack = [];
613
+ if (n) {
614
+ const { w } = this;
615
+ for (;;) {
616
+ const q = w(n, a);
617
+ if (q > 0) {
618
+ if (a.d) {
619
+ stack.push(a);
620
+ a = a.d;
621
+ continue;
622
+ }
623
+ }
624
+ else if (q < 0) {
625
+ if (a.c) {
626
+ a = a.c;
627
+ continue;
628
+ }
629
+ return f;
630
+ }
631
+ break;
632
+ }
633
+ }
634
+ else {
635
+ while (a.d) {
636
+ stack.push(a);
637
+ a = a.d;
638
+ }
639
+ }
640
+ let j;
641
+ for (;;) {
642
+ const p = o(a);
643
+ f++;
644
+ if (p & A) {
645
+ (j ?? (j = [])).push(a);
646
+ }
647
+ if (p & _) {
648
+ f = -f;
649
+ break;
650
+ }
651
+ if (a.c) {
652
+ a = a.c;
653
+ while (a.d) {
654
+ stack.push(a);
655
+ a = a.d;
656
+ }
657
+ }
658
+ else {
659
+ a = stack.pop();
660
+ if (!a) {
661
+ break;
662
+ }
663
+ }
664
+ }
665
+ if (j) {
666
+ let b = j.length;
667
+ while (b > 0) {
668
+ this.v(j[--b]);
669
+ }
670
+ }
671
+ }
672
+ return f;
673
+ }
674
+ }
675
+ //# sourceMappingURL=RbTree.js.map