@nsshunt/stsobservability 1.0.147 → 1.0.149
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/index.cjs +1753 -2172
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1750 -2198
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -10
package/dist/index.mjs
CHANGED
|
@@ -1,2206 +1,1758 @@
|
|
|
1
1
|
import _cloneDeep from "lodash.clonedeep";
|
|
2
2
|
import isNode from "detect-node";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
class
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
function requireTimsort() {
|
|
1707
|
-
if (hasRequiredTimsort) return timsort;
|
|
1708
|
-
hasRequiredTimsort = 1;
|
|
1709
|
-
timsort = requireTimsort$1();
|
|
1710
|
-
return timsort;
|
|
1711
|
-
}
|
|
1712
|
-
var timsortExports = requireTimsort();
|
|
1713
|
-
var lib;
|
|
1714
|
-
var hasRequiredLib;
|
|
1715
|
-
function requireLib() {
|
|
1716
|
-
if (hasRequiredLib) return lib;
|
|
1717
|
-
hasRequiredLib = 1;
|
|
1718
|
-
function lessThanZeroError(p) {
|
|
1719
|
-
return 'Expect percentile to be >= 0 but given "' + p + '" and its type is "' + typeof p + '".';
|
|
1720
|
-
}
|
|
1721
|
-
function greaterThanHundredError(p) {
|
|
1722
|
-
return 'Expect percentile to be <= 100 but given "' + p + '" and its type is "' + typeof p + '".';
|
|
1723
|
-
}
|
|
1724
|
-
function nanError(p) {
|
|
1725
|
-
return 'Expect percentile to be a number but given "' + p + '" and its type is "' + typeof p + '".';
|
|
1726
|
-
}
|
|
1727
|
-
function validateInput(ps) {
|
|
1728
|
-
return ps.reduce(function(errors, p) {
|
|
1729
|
-
if (isNaN(Number(p))) {
|
|
1730
|
-
errors.push(nanError(p));
|
|
1731
|
-
} else if (p < 0) {
|
|
1732
|
-
errors.push(lessThanZeroError(p));
|
|
1733
|
-
} else if (p > 100) {
|
|
1734
|
-
errors.push(greaterThanHundredError(p));
|
|
1735
|
-
}
|
|
1736
|
-
return errors;
|
|
1737
|
-
}, []);
|
|
1738
|
-
}
|
|
1739
|
-
function getPsValue(p, list) {
|
|
1740
|
-
if (p === 0) return list[0];
|
|
1741
|
-
var kIndex = Math.ceil(list.length * (p / 100)) - 1;
|
|
1742
|
-
return list[kIndex];
|
|
1743
|
-
}
|
|
1744
|
-
function percentile2(pOrPs, list, fn) {
|
|
1745
|
-
var ps = Array.isArray(pOrPs) ? pOrPs : [pOrPs];
|
|
1746
|
-
var validationErrors = validateInput(ps);
|
|
1747
|
-
if (validationErrors.length) {
|
|
1748
|
-
throw new Error(validationErrors.join(" "));
|
|
1749
|
-
}
|
|
1750
|
-
list = list.slice().sort(function(a, b) {
|
|
1751
|
-
if (fn) {
|
|
1752
|
-
a = fn(a);
|
|
1753
|
-
b = fn(b);
|
|
1754
|
-
}
|
|
1755
|
-
a = Number.isNaN(a) ? Number.NEGATIVE_INFINITY : a;
|
|
1756
|
-
b = Number.isNaN(b) ? Number.NEGATIVE_INFINITY : b;
|
|
1757
|
-
if (a > b) return 1;
|
|
1758
|
-
if (a < b) return -1;
|
|
1759
|
-
return 0;
|
|
1760
|
-
});
|
|
1761
|
-
if (ps.length === 1) {
|
|
1762
|
-
return getPsValue(ps[0], list);
|
|
1763
|
-
}
|
|
1764
|
-
return ps.map(function(p) {
|
|
1765
|
-
return getPsValue(p, list);
|
|
1766
|
-
});
|
|
1767
|
-
}
|
|
1768
|
-
lib = percentile2;
|
|
1769
|
-
return lib;
|
|
1770
|
-
}
|
|
1771
|
-
var libExports = requireLib();
|
|
1772
|
-
const percentile = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
1773
|
-
class InstrumentGaugeOptions extends InstrumentBaseOptions {
|
|
1774
|
-
interval;
|
|
1775
|
-
sampleSize;
|
|
1776
|
-
fromJSON;
|
|
1777
|
-
initValue;
|
|
1778
|
-
}
|
|
1779
|
-
class InstrumentGaugeTelemetry extends InstrumentBaseTelemetry {
|
|
1780
|
-
val;
|
|
1781
|
-
Inc;
|
|
1782
|
-
Dec;
|
|
1783
|
-
}
|
|
1784
|
-
class InstrumentGauge extends InstrumentBase {
|
|
1785
|
-
#val = 0;
|
|
1786
|
-
#maxval = null;
|
|
1787
|
-
#lastObservedValue = 0;
|
|
1788
|
-
#timeSeriesList = [];
|
|
1789
|
-
#maxSampleSize = 0;
|
|
1790
|
-
#timerInterval = 0;
|
|
1791
|
-
#observer = null;
|
|
1792
|
-
//@@ extras
|
|
1793
|
-
#min = null;
|
|
1794
|
-
#max = 0;
|
|
1795
|
-
#observations = 0;
|
|
1796
|
-
#total = 0;
|
|
1797
|
-
#copy = false;
|
|
1798
|
-
constructor(options = {}) {
|
|
1799
|
-
super(options);
|
|
1800
|
-
if (!options.label) {
|
|
1801
|
-
this.label = "InstrumentGauge";
|
|
1802
|
-
} else {
|
|
1803
|
-
this.label = options.label;
|
|
1804
|
-
}
|
|
1805
|
-
if (typeof options.interval === "undefined") {
|
|
1806
|
-
this.#timerInterval = 0;
|
|
1807
|
-
} else {
|
|
1808
|
-
this.#timerInterval = options.interval;
|
|
1809
|
-
}
|
|
1810
|
-
if (typeof options.sampleSize === "undefined") {
|
|
1811
|
-
this.#maxSampleSize = 600;
|
|
1812
|
-
} else {
|
|
1813
|
-
this.#maxSampleSize = options.sampleSize;
|
|
1814
|
-
}
|
|
1815
|
-
if (typeof options.fromJSON === "undefined") {
|
|
1816
|
-
this.#copy = false;
|
|
1817
|
-
} else {
|
|
1818
|
-
this.#copy = true;
|
|
1819
|
-
}
|
|
1820
|
-
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
1821
|
-
enumerable: true,
|
|
1822
|
-
get: () => GaugeTypes.INSTRUMENT_GAUGE
|
|
1823
|
-
});
|
|
1824
|
-
if (this.#copy) {
|
|
1825
|
-
this.DefineCopyProperties([
|
|
1826
|
-
"val",
|
|
1827
|
-
"min",
|
|
1828
|
-
"max",
|
|
1829
|
-
"avg",
|
|
1830
|
-
"percentile"
|
|
1831
|
-
]);
|
|
1832
|
-
} else {
|
|
1833
|
-
Object.defineProperty(this, "val", {
|
|
1834
|
-
enumerable: true,
|
|
1835
|
-
get: () => this.#GetVal(),
|
|
1836
|
-
set: (value) => {
|
|
1837
|
-
this.#SetVal(value);
|
|
1838
|
-
}
|
|
1839
|
-
});
|
|
1840
|
-
if (this.#timerInterval > 0) {
|
|
1841
|
-
Object.defineProperty(this, "percentile", {
|
|
1842
|
-
enumerable: true,
|
|
1843
|
-
get: () => this.#GetPercentileData()
|
|
1844
|
-
});
|
|
1845
|
-
this._StartTimer();
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
if (typeof options.initValue !== "undefined") {
|
|
1849
|
-
this.val = options.initValue;
|
|
1850
|
-
}
|
|
1851
|
-
if (typeof options.fromJSON !== "undefined") {
|
|
1852
|
-
const result = _cloneDeep(options.fromJSON);
|
|
1853
|
-
this.val = result.val;
|
|
1854
|
-
if (result.percentile) {
|
|
1855
|
-
this.percentile = result.percentile;
|
|
1856
|
-
}
|
|
1857
|
-
if (result.min) {
|
|
1858
|
-
this.min = result.min;
|
|
1859
|
-
}
|
|
1860
|
-
if (result.max) {
|
|
1861
|
-
this.max = result.max;
|
|
1862
|
-
}
|
|
1863
|
-
if (result.avg) {
|
|
1864
|
-
this.avg = result.avg;
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
percentile;
|
|
1869
|
-
min;
|
|
1870
|
-
max;
|
|
1871
|
-
avg;
|
|
1872
|
-
val = 0;
|
|
1873
|
-
WithInitVal(initVal) {
|
|
1874
|
-
this.val = initVal;
|
|
1875
|
-
return this;
|
|
1876
|
-
}
|
|
1877
|
-
WithMin() {
|
|
1878
|
-
Object.defineProperty(this, "min", {
|
|
1879
|
-
enumerable: true,
|
|
1880
|
-
get: () => this.#GetMin()
|
|
1881
|
-
});
|
|
1882
|
-
return this;
|
|
1883
|
-
}
|
|
1884
|
-
WithMax() {
|
|
1885
|
-
Object.defineProperty(this, "max", {
|
|
1886
|
-
enumerable: true,
|
|
1887
|
-
get: () => this.#GetMax()
|
|
1888
|
-
});
|
|
1889
|
-
return this;
|
|
1890
|
-
}
|
|
1891
|
-
WithAverage() {
|
|
1892
|
-
Object.defineProperty(this, "avg", {
|
|
1893
|
-
enumerable: true,
|
|
1894
|
-
get: () => this.#GetAverage()
|
|
1895
|
-
});
|
|
1896
|
-
return this;
|
|
1897
|
-
}
|
|
1898
|
-
_StartTimer() {
|
|
1899
|
-
if (this.#timerInterval > 0) {
|
|
1900
|
-
this.#timeSeriesList = [];
|
|
1901
|
-
this.#observer = setInterval(() => {
|
|
1902
|
-
if (this.#timeSeriesList.length > this.#maxSampleSize) {
|
|
1903
|
-
this.#timeSeriesList.shift();
|
|
1904
|
-
}
|
|
1905
|
-
const maxval = this.#GetAndResetMaxVal();
|
|
1906
|
-
this.#timeSeriesList.push(maxval);
|
|
1907
|
-
}, this.#timerInterval);
|
|
1908
|
-
if (isNode) {
|
|
1909
|
-
this.#observer.unref();
|
|
1910
|
-
}
|
|
1911
|
-
} else {
|
|
1912
|
-
throw new Error(`Unable to StartTimer for this instrument. The interval is set to <= 0.`);
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
StopTimer() {
|
|
1916
|
-
if (this.#observer) {
|
|
1917
|
-
clearTimeout(this.#observer);
|
|
1918
|
-
this.#observer = null;
|
|
1919
|
-
this.#timeSeriesList = [];
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
/**
|
|
1923
|
-
* If the gauge is being monitored as part of a time series, get the most recent recorded value (max value) from within the time interval
|
|
1924
|
-
* otherwise, just return the current instant value.
|
|
1925
|
-
*/
|
|
1926
|
-
#GetVal() {
|
|
1927
|
-
if (this.#timerInterval > 0 && this.#observer !== null) {
|
|
1928
|
-
if (this.#maxval === null) {
|
|
1929
|
-
return this.GetNumber(this.#lastObservedValue);
|
|
1930
|
-
} else {
|
|
1931
|
-
return this.GetNumber(this.#maxval);
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
return this.GetNumber(this.#val);
|
|
1935
|
-
}
|
|
1936
|
-
#SetVal(updatedValue) {
|
|
1937
|
-
this.#val = updatedValue;
|
|
1938
|
-
this.#observations++;
|
|
1939
|
-
this.#total += updatedValue;
|
|
1940
|
-
if (this.#val > this.#max) {
|
|
1941
|
-
this.#max = this.#val;
|
|
1942
|
-
}
|
|
1943
|
-
if (this.#min !== null) {
|
|
1944
|
-
if (this.#val < this.#min) {
|
|
1945
|
-
this.#min = this.#val;
|
|
1946
|
-
}
|
|
1947
|
-
} else {
|
|
1948
|
-
this.#min = this.#val;
|
|
1949
|
-
}
|
|
1950
|
-
if (this.#timerInterval > 0) {
|
|
1951
|
-
this.#lastObservedValue = updatedValue;
|
|
1952
|
-
if (this.#maxval === null) {
|
|
1953
|
-
this.#maxval = this.#val;
|
|
1954
|
-
} else if (this.#val > this.#maxval) {
|
|
1955
|
-
this.#maxval = this.#val;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
#GetMin() {
|
|
1960
|
-
if (this.#min !== null) {
|
|
1961
|
-
return this.#min;
|
|
1962
|
-
}
|
|
1963
|
-
return 0;
|
|
1964
|
-
}
|
|
1965
|
-
#GetMax() {
|
|
1966
|
-
return this.#max;
|
|
1967
|
-
}
|
|
1968
|
-
#GetAverage() {
|
|
1969
|
-
if (this.#observations > 0) {
|
|
1970
|
-
return this.#total / this.#observations;
|
|
1971
|
-
}
|
|
1972
|
-
return 0;
|
|
1973
|
-
}
|
|
1974
|
-
Reset() {
|
|
1975
|
-
this.StopTimer();
|
|
1976
|
-
this.#maxval = 0;
|
|
1977
|
-
this.#lastObservedValue = 0;
|
|
1978
|
-
this.#val = 0;
|
|
1979
|
-
this.#min = null;
|
|
1980
|
-
this.#max = 0;
|
|
1981
|
-
this.#observations = 0;
|
|
1982
|
-
this.#total = 0;
|
|
1983
|
-
if (this.#timerInterval > 0) {
|
|
1984
|
-
this._StartTimer();
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
#GetAndResetMaxVal() {
|
|
1988
|
-
if (this.#maxval === null) {
|
|
1989
|
-
return this.#lastObservedValue;
|
|
1990
|
-
}
|
|
1991
|
-
const retVal = this.#maxval;
|
|
1992
|
-
this.#maxval = null;
|
|
1993
|
-
return retVal;
|
|
1994
|
-
}
|
|
1995
|
-
Inc(incVal = 1) {
|
|
1996
|
-
this.#SetVal(this.#val + incVal);
|
|
1997
|
-
}
|
|
1998
|
-
Dec(decVal = 1) {
|
|
1999
|
-
this.#SetVal(this.#val - decVal);
|
|
2000
|
-
}
|
|
2001
|
-
#NumberCompare(a, b) {
|
|
2002
|
-
return a - b;
|
|
2003
|
-
}
|
|
2004
|
-
#GetPercentileData() {
|
|
2005
|
-
const sortedList = this.#timeSeriesList.slice(0);
|
|
2006
|
-
timsortExports.sort(sortedList, this.#NumberCompare);
|
|
2007
|
-
return percentile([50, 80, 90, 95, 99, 99.95], sortedList);
|
|
2008
|
-
}
|
|
2009
|
-
ProcessTelemetry(telemetry) {
|
|
2010
|
-
if (telemetry.Inc !== void 0) {
|
|
2011
|
-
this.Inc(telemetry.Inc);
|
|
2012
|
-
}
|
|
2013
|
-
if (telemetry.Dec !== void 0) {
|
|
2014
|
-
this.Dec(telemetry.Dec);
|
|
2015
|
-
}
|
|
2016
|
-
if (telemetry.val !== void 0) {
|
|
2017
|
-
this.val = telemetry.val;
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
class InstrumentObjectOptions extends InstrumentBaseOptions {
|
|
2022
|
-
fromJSON;
|
|
2023
|
-
initValue;
|
|
2024
|
-
}
|
|
2025
|
-
class InstrumentObjectTelemetry extends InstrumentBaseTelemetry {
|
|
2026
|
-
val;
|
|
2027
|
-
}
|
|
2028
|
-
class InstrumentObject extends InstrumentBase {
|
|
2029
|
-
#val = {};
|
|
2030
|
-
#copy = false;
|
|
2031
|
-
constructor(options = {}) {
|
|
2032
|
-
super(options);
|
|
2033
|
-
if (typeof options.label === "undefined") {
|
|
2034
|
-
this.label = "InstrumentObject";
|
|
2035
|
-
} else {
|
|
2036
|
-
this.label = options.label;
|
|
2037
|
-
}
|
|
2038
|
-
if (typeof options.fromJSON === "undefined") {
|
|
2039
|
-
this.#copy = false;
|
|
2040
|
-
} else {
|
|
2041
|
-
this.#copy = true;
|
|
2042
|
-
}
|
|
2043
|
-
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
2044
|
-
enumerable: true,
|
|
2045
|
-
get: () => GaugeTypes.INSTRUMENT_OBJECT
|
|
2046
|
-
});
|
|
2047
|
-
if (this.#copy) {
|
|
2048
|
-
this.DefineCopyProperties([
|
|
2049
|
-
"val"
|
|
2050
|
-
]);
|
|
2051
|
-
} else {
|
|
2052
|
-
Object.defineProperty(this, "val", {
|
|
2053
|
-
enumerable: true,
|
|
2054
|
-
get: () => this.#GetVal(),
|
|
2055
|
-
set: (value) => {
|
|
2056
|
-
this.#SetVal(value);
|
|
2057
|
-
}
|
|
2058
|
-
});
|
|
2059
|
-
}
|
|
2060
|
-
if (typeof options.initValue !== "undefined") {
|
|
2061
|
-
this.val = options.initValue;
|
|
2062
|
-
} else {
|
|
2063
|
-
this.val = {};
|
|
2064
|
-
}
|
|
2065
|
-
if (typeof options.fromJSON !== "undefined") {
|
|
2066
|
-
const result = _cloneDeep(options.fromJSON);
|
|
2067
|
-
this.val = result.val;
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
val;
|
|
2071
|
-
WithInitVal(initVal) {
|
|
2072
|
-
this.val = initVal;
|
|
2073
|
-
return this;
|
|
2074
|
-
}
|
|
2075
|
-
#GetVal() {
|
|
2076
|
-
return this.#val;
|
|
2077
|
-
}
|
|
2078
|
-
#SetVal(updatedValue) {
|
|
2079
|
-
this.#val = updatedValue;
|
|
2080
|
-
}
|
|
2081
|
-
ProcessTelemetry(telemetry) {
|
|
2082
|
-
if (telemetry.val !== void 0) {
|
|
2083
|
-
this.val = telemetry.val;
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
+
key = keys[i];
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/instrumentation/instrumentDefs.ts
|
|
27
|
+
var Gauge = /* @__PURE__ */ function(Gauge) {
|
|
28
|
+
Gauge["ACTIVE_REQUEST_GAUGE"] = "a";
|
|
29
|
+
Gauge["AUTHENTICATION_COUNT_GAUGE"] = "b";
|
|
30
|
+
Gauge["AUTHENTICATION_ERROR_COUNT_GAUGE"] = "aa";
|
|
31
|
+
Gauge["AUTHENTICATION_RETRY_COUNT_GAUGE"] = "ab";
|
|
32
|
+
Gauge["CONNECTION_POOL_IDLE_GAUGE"] = "c";
|
|
33
|
+
Gauge["CONNECTION_POOL_TOTAL_GAUGE"] = "d";
|
|
34
|
+
Gauge["CONNECTION_POOL_WAITING_GAUGE"] = "e";
|
|
35
|
+
Gauge["CPU_LOAD_GAUGE"] = "f";
|
|
36
|
+
Gauge["CPU_SYSTEM_LOAD_GAUGE"] = "g";
|
|
37
|
+
Gauge["DURATION_GAUGE"] = "h";
|
|
38
|
+
Gauge["DURATION_HISTOGRAM_GAUGE"] = "i";
|
|
39
|
+
Gauge["ERROR_COUNT_GAUGE"] = "j";
|
|
40
|
+
Gauge["LATENCY_GAUGE"] = "k";
|
|
41
|
+
Gauge["LATENCY_HISTOGRAM_GAUGE"] = "l";
|
|
42
|
+
Gauge["LOGGER"] = "m";
|
|
43
|
+
Gauge["LOGGER_COPY"] = "n";
|
|
44
|
+
Gauge["NETWORK_RX_GAUGE"] = "o";
|
|
45
|
+
Gauge["NETWORK_TX_GAUGE"] = "p";
|
|
46
|
+
Gauge["REQUEST_COUNT_GAUGE"] = "q";
|
|
47
|
+
Gauge["RETRY_COUNT_GAUGE"] = "r";
|
|
48
|
+
Gauge["TIMER_GAUGE"] = "s";
|
|
49
|
+
Gauge["VELOCITY_GAUGE"] = "t";
|
|
50
|
+
Gauge["CONNECTION_COUNT_GAUGE"] = "u";
|
|
51
|
+
Gauge["OBJECT_GAUGE"] = "v";
|
|
52
|
+
Gauge["PAYLOAD_SIZE"] = "w";
|
|
53
|
+
Gauge["CORE_COUNT_GAUGE"] = "x";
|
|
54
|
+
Gauge["CHILD_COUNT"] = "y";
|
|
55
|
+
Gauge["UNKNOWN"] = "z";
|
|
56
|
+
return Gauge;
|
|
57
|
+
}({});
|
|
58
|
+
var GaugeTypes = /* @__PURE__ */ function(GaugeTypes) {
|
|
59
|
+
GaugeTypes["GAUGE_TYPE"] = "_";
|
|
60
|
+
GaugeTypes["INSTRUMENT_GAUGE"] = "a";
|
|
61
|
+
GaugeTypes["INSTRUMENT_VELOCITY"] = "b";
|
|
62
|
+
GaugeTypes["INSTRUMENT_HISTOGRAM"] = "c";
|
|
63
|
+
GaugeTypes["INSTRUMENT_LOG"] = "d";
|
|
64
|
+
GaugeTypes["INSTRUMENT_TIMER"] = "e";
|
|
65
|
+
GaugeTypes["INSTRUMENT_OBJECT"] = "f";
|
|
66
|
+
return GaugeTypes;
|
|
67
|
+
}({});
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/instrumentation/instruments/instrumentBase.ts
|
|
70
|
+
var InstrumentBaseOptions = class {
|
|
71
|
+
fixedSize;
|
|
72
|
+
padLength;
|
|
73
|
+
label;
|
|
74
|
+
};
|
|
75
|
+
var InstrumentBaseTelemetry = class {};
|
|
76
|
+
var InstrumentBase = class {
|
|
77
|
+
#label = "";
|
|
78
|
+
#options = null;
|
|
79
|
+
#data = {};
|
|
80
|
+
constructor(options = {}) {
|
|
81
|
+
if (typeof options === "string" || options instanceof String) throw new Error("Instrument parameter must be an options object.");
|
|
82
|
+
this.#options = options;
|
|
83
|
+
if (options.label) this.#label = options.label;
|
|
84
|
+
else this.#label = "InstrumentGauge";
|
|
85
|
+
}
|
|
86
|
+
[GaugeTypes.GAUGE_TYPE] = GaugeTypes.INSTRUMENT_OBJECT;
|
|
87
|
+
val;
|
|
88
|
+
WithLabel(label) {
|
|
89
|
+
this.label = label;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
DefineCopyProperties(propertyNames) {
|
|
93
|
+
propertyNames.forEach((propertyName) => {
|
|
94
|
+
Object.defineProperty(this, propertyName, {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: () => this.#data[propertyName],
|
|
97
|
+
set: (value) => {
|
|
98
|
+
if (value === void 0) return;
|
|
99
|
+
this.#data[propertyName] = value;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
GetNumber(val) {
|
|
105
|
+
if (Number.isInteger(val)) return val;
|
|
106
|
+
else return Math.round((val + Number.EPSILON) * 100) / 100;
|
|
107
|
+
}
|
|
108
|
+
get options() {
|
|
109
|
+
return this.#options;
|
|
110
|
+
}
|
|
111
|
+
set options(optionsValue) {
|
|
112
|
+
this.#options = optionsValue;
|
|
113
|
+
}
|
|
114
|
+
get label() {
|
|
115
|
+
return this.#label;
|
|
116
|
+
}
|
|
117
|
+
set label(labelValue) {
|
|
118
|
+
this.#label = labelValue;
|
|
119
|
+
}
|
|
120
|
+
StopTimer() {}
|
|
121
|
+
ProcessTelemetry(telemetry) {
|
|
122
|
+
throw new Error(`Must override in extended class: [ProcessTelemetry]: [${telemetry}].`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/instrumentation/instruments/instrumentVelocity.ts
|
|
127
|
+
var InstrumentVelocityOptions = class extends InstrumentBaseOptions {
|
|
128
|
+
interval;
|
|
129
|
+
valStackMaxLength;
|
|
130
|
+
maxAverageValStack;
|
|
131
|
+
maxAverageIterations;
|
|
132
|
+
fromJSON;
|
|
133
|
+
initValue;
|
|
134
|
+
autoComputeVelocity;
|
|
135
|
+
velocityTimeDiff;
|
|
136
|
+
vaTimeDiff;
|
|
137
|
+
autoComputeVelocityTimeout;
|
|
138
|
+
};
|
|
139
|
+
var InstrumentVelocityTelemetry = class extends InstrumentBaseTelemetry {
|
|
140
|
+
val;
|
|
141
|
+
Inc;
|
|
142
|
+
};
|
|
143
|
+
var InstrumentVelocity = class extends InstrumentBase {
|
|
144
|
+
#val = 0;
|
|
145
|
+
#interval = null;
|
|
146
|
+
#timeoutComputeVelocity = null;
|
|
147
|
+
#lastVelocity = 0;
|
|
148
|
+
#delta = 0;
|
|
149
|
+
#maxVelocity = 0;
|
|
150
|
+
#timerInterval = 0;
|
|
151
|
+
#copy = false;
|
|
152
|
+
#velocity = 0;
|
|
153
|
+
#velocityVal = 0;
|
|
154
|
+
#valStack = [];
|
|
155
|
+
#averageValStack = [];
|
|
156
|
+
#maxAverageValStack = 0;
|
|
157
|
+
#maxAverageIterations = 0;
|
|
158
|
+
#valStackMaxLength = 0;
|
|
159
|
+
#valStackAverage = 0;
|
|
160
|
+
#timeStamp = 0;
|
|
161
|
+
#maxTimeDiff = 0;
|
|
162
|
+
#vaTimeDiff = 0;
|
|
163
|
+
#velocityTimeDiff = 0;
|
|
164
|
+
#autoComputeVelocity = false;
|
|
165
|
+
#autoComputeVelocityTimeout = 0;
|
|
166
|
+
#countDiff = 0;
|
|
167
|
+
#timeDiff = 0;
|
|
168
|
+
#deltaCountDiff = 0;
|
|
169
|
+
#deltaTimeDif = 0;
|
|
170
|
+
#minTimeForReporting = 0;
|
|
171
|
+
#averageVelocity = [];
|
|
172
|
+
constructor(options = {}) {
|
|
173
|
+
super(options);
|
|
174
|
+
if (typeof options.label === "undefined") this.label = "InstrumentVelocity";
|
|
175
|
+
else this.label = options.label;
|
|
176
|
+
if (typeof options.interval === "undefined") this.#timerInterval = 1e3;
|
|
177
|
+
else this.#timerInterval = options.interval;
|
|
178
|
+
if (typeof options.valStackMaxLength === "undefined") this.#valStackMaxLength = 100;
|
|
179
|
+
else this.#valStackMaxLength = options.valStackMaxLength;
|
|
180
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
181
|
+
else this.#copy = true;
|
|
182
|
+
if (typeof options.autoComputeVelocity === "undefined") this.#autoComputeVelocity = false;
|
|
183
|
+
else this.#autoComputeVelocity = options.autoComputeVelocity;
|
|
184
|
+
if (typeof options.maxAverageValStack === "undefined") this.#maxAverageValStack = 5;
|
|
185
|
+
else this.#maxAverageValStack = options.maxAverageValStack;
|
|
186
|
+
if (typeof options.maxAverageIterations === "undefined") this.#maxAverageIterations = 3;
|
|
187
|
+
else this.#maxAverageIterations = options.maxAverageIterations;
|
|
188
|
+
if (typeof options.velocityTimeDiff === "undefined") this.#velocityTimeDiff = 5e3;
|
|
189
|
+
else this.#velocityTimeDiff = options.velocityTimeDiff;
|
|
190
|
+
if (typeof options.vaTimeDiff === "undefined") this.#vaTimeDiff = 1e4;
|
|
191
|
+
else this.#vaTimeDiff = options.vaTimeDiff;
|
|
192
|
+
if (typeof options.autoComputeVelocityTimeout === "undefined") this.#autoComputeVelocityTimeout = 50;
|
|
193
|
+
else this.#autoComputeVelocityTimeout = options.autoComputeVelocityTimeout;
|
|
194
|
+
this.#maxTimeDiff = this.#vaTimeDiff * 2;
|
|
195
|
+
this.#minTimeForReporting = this.#vaTimeDiff + 2e3;
|
|
196
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: () => GaugeTypes.INSTRUMENT_VELOCITY
|
|
199
|
+
});
|
|
200
|
+
if (this.#copy) this.DefineCopyProperties([
|
|
201
|
+
"val",
|
|
202
|
+
"maxVelocity",
|
|
203
|
+
"delta",
|
|
204
|
+
"velocity",
|
|
205
|
+
"va",
|
|
206
|
+
"timeStamp",
|
|
207
|
+
"deltaTimeDif",
|
|
208
|
+
"deltaCountDiff",
|
|
209
|
+
"timeDiff",
|
|
210
|
+
"countDiff",
|
|
211
|
+
"averageVelocity"
|
|
212
|
+
]);
|
|
213
|
+
else {
|
|
214
|
+
Object.defineProperty(this, "val", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: () => this.#GetVal(),
|
|
217
|
+
set: (value) => {
|
|
218
|
+
this.#SetVal(value);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(this, "maxVelocity", {
|
|
222
|
+
enumerable: true,
|
|
223
|
+
get: () => this.#GetMaxVelocity()
|
|
224
|
+
});
|
|
225
|
+
Object.defineProperty(this, "delta", {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: () => this.#GetDelta()
|
|
228
|
+
});
|
|
229
|
+
Object.defineProperty(this, "velocity", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: () => this.#GetVelocity()
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(this, "va", {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: () => this.#GetVelocityStackAverage()
|
|
236
|
+
});
|
|
237
|
+
Object.defineProperty(this, "timeStamp", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
get: () => this.#GetTimeStamp()
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(this, "countDiff", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: () => this.#GetCountDiff()
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(this, "timeDiff", {
|
|
246
|
+
enumerable: true,
|
|
247
|
+
get: () => this.#GetTimeDiff()
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(this, "deltaCountDiff", {
|
|
250
|
+
enumerable: true,
|
|
251
|
+
get: () => this.#GetDeltaCountDiff()
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(this, "deltaTimeDif", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: () => this.#GetDeltaTimeDif()
|
|
256
|
+
});
|
|
257
|
+
Object.defineProperty(this, "averageVelocity", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
get: () => this.#GetAverageVelocity()
|
|
260
|
+
});
|
|
261
|
+
if (this.#timerInterval > 0 && this.#autoComputeVelocity === false) this._StartTimer();
|
|
262
|
+
}
|
|
263
|
+
if (typeof options.initValue !== "undefined") this.val = options.initValue;
|
|
264
|
+
if (typeof options.fromJSON !== "undefined") {
|
|
265
|
+
const result = _cloneDeep(options.fromJSON);
|
|
266
|
+
this.val = result.val;
|
|
267
|
+
this.velocity = result.velocity;
|
|
268
|
+
this.maxVelocity = result.maxVelocity;
|
|
269
|
+
this.delta = result.delta;
|
|
270
|
+
this.va = result.va;
|
|
271
|
+
this.timeStamp = result.timeStamp;
|
|
272
|
+
this.countDiff = result.countDiff;
|
|
273
|
+
this.timeDiff = result.timeDiff;
|
|
274
|
+
this.deltaCountDiff = result.deltaCountDiff;
|
|
275
|
+
this.deltaTimeDif = result.deltaTimeDif;
|
|
276
|
+
this.averageVelocity = _cloneDeep(result.averageVelocity);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
maxVelocity = 0;
|
|
280
|
+
delta = 0;
|
|
281
|
+
velocity = 0;
|
|
282
|
+
va = 0;
|
|
283
|
+
timeStamp = 0;
|
|
284
|
+
countDiff = 0;
|
|
285
|
+
timeDiff = 0;
|
|
286
|
+
deltaCountDiff = 0;
|
|
287
|
+
deltaTimeDif = 0;
|
|
288
|
+
averageVelocity = [];
|
|
289
|
+
val = 0;
|
|
290
|
+
WithValStackMaxLength(valStackMaxLength) {
|
|
291
|
+
this.#valStackMaxLength = valStackMaxLength;
|
|
292
|
+
this.#valStack = [];
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
_StartTimer() {
|
|
296
|
+
this.#interval = setInterval(() => {
|
|
297
|
+
this.#ComputeVelocity();
|
|
298
|
+
let pushVal = this.#velocity;
|
|
299
|
+
for (let i = 0; i < this.#maxAverageIterations; i++) {
|
|
300
|
+
if (!this.#averageValStack[i]) this.#averageValStack[i] = [];
|
|
301
|
+
this.#averageValStack[i].push(pushVal);
|
|
302
|
+
if (this.#averageValStack[i].length > this.#maxAverageValStack) this.#averageValStack[i].shift();
|
|
303
|
+
pushVal = this.#averageValStack[i].reduce((prev, current) => prev + current) / this.#averageValStack[i].length;
|
|
304
|
+
this.#averageVelocity[i] = pushVal;
|
|
305
|
+
}
|
|
306
|
+
}, this.#timerInterval);
|
|
307
|
+
if (isNode) this.#interval.unref();
|
|
308
|
+
}
|
|
309
|
+
#ComputeVelocityByTimeDiff(checkTimeDiff, checkDeltaTimeDiff) {
|
|
310
|
+
let val = 0;
|
|
311
|
+
let deltaVal = 0;
|
|
312
|
+
let countDiff = 0;
|
|
313
|
+
let timeDiff = 0;
|
|
314
|
+
let deltaCountDiff = 0;
|
|
315
|
+
let deltaTimeDiff = 0;
|
|
316
|
+
if (this.#valStack.length > 1 && this.#valStack[this.#valStack.length - 1].timeStamp - this.#valStack[0].timeStamp > this.#minTimeForReporting) {
|
|
317
|
+
const dp = this.#valStack[this.#valStack.length - 1];
|
|
318
|
+
let timeDiffPos = -1;
|
|
319
|
+
let deltaDiffPos = -1;
|
|
320
|
+
for (let i = this.#valStack.length - 2; i > -1; i--) {
|
|
321
|
+
if (timeDiffPos === -1 && this.#timeStamp - this.#valStack[i].timeStamp >= checkTimeDiff) {
|
|
322
|
+
timeDiffPos = i;
|
|
323
|
+
if (checkDeltaTimeDiff === 0) break;
|
|
324
|
+
}
|
|
325
|
+
if (deltaDiffPos === -1 && this.#timeStamp - this.#valStack[i].timeStamp >= checkDeltaTimeDiff) deltaDiffPos = i;
|
|
326
|
+
if (timeDiffPos !== -1 && deltaDiffPos !== -1) break;
|
|
327
|
+
}
|
|
328
|
+
if (timeDiffPos > -1) {
|
|
329
|
+
countDiff = dp.count - this.#valStack[timeDiffPos].count;
|
|
330
|
+
if (countDiff > 0) {
|
|
331
|
+
timeDiff = dp.timeStamp - this.#valStack[timeDiffPos].timeStamp;
|
|
332
|
+
if (timeDiff > 0) val = 1e3 / timeDiff * countDiff;
|
|
333
|
+
else val = 0;
|
|
334
|
+
} else val = 0;
|
|
335
|
+
} else val = 0;
|
|
336
|
+
if (deltaDiffPos > -1) {
|
|
337
|
+
deltaCountDiff = this.#valStack[timeDiffPos].count - this.#valStack[deltaDiffPos].count;
|
|
338
|
+
if (deltaCountDiff > 0) {
|
|
339
|
+
deltaTimeDiff = this.#valStack[timeDiffPos].timeStamp - this.#valStack[deltaDiffPos].timeStamp;
|
|
340
|
+
if (deltaTimeDiff > 0) deltaVal = 1e3 / deltaTimeDiff * deltaTimeDiff;
|
|
341
|
+
else deltaVal = 0;
|
|
342
|
+
} else deltaVal = 0;
|
|
343
|
+
} else deltaVal = 0;
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
val,
|
|
347
|
+
countDiff,
|
|
348
|
+
timeDiff,
|
|
349
|
+
deltaVal,
|
|
350
|
+
deltaCountDiff,
|
|
351
|
+
deltaTimeDiff
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
#ComputeVelocity() {
|
|
355
|
+
const dp = {
|
|
356
|
+
timeStamp: performance.now(),
|
|
357
|
+
count: this.#velocityVal
|
|
358
|
+
};
|
|
359
|
+
this.#valStack.push(dp);
|
|
360
|
+
this.#timeStamp = dp.timeStamp;
|
|
361
|
+
while (this.#valStack.length > 0 && this.#timeStamp - this.#valStack[0].timeStamp > this.#maxTimeDiff) this.#valStack.shift();
|
|
362
|
+
this.#valStackAverage = this.#ComputeVelocityByTimeDiff(this.#vaTimeDiff, 0).val;
|
|
363
|
+
const velocityDataPoint = this.#ComputeVelocityByTimeDiff(this.#velocityTimeDiff, this.#velocityTimeDiff * 2);
|
|
364
|
+
this.#velocity = velocityDataPoint.val;
|
|
365
|
+
this.#delta = velocityDataPoint.val - velocityDataPoint.deltaVal;
|
|
366
|
+
this.#countDiff = velocityDataPoint.countDiff;
|
|
367
|
+
this.#timeDiff = velocityDataPoint.timeDiff;
|
|
368
|
+
this.#deltaCountDiff = velocityDataPoint.deltaCountDiff;
|
|
369
|
+
this.#deltaTimeDif = velocityDataPoint.deltaTimeDiff;
|
|
370
|
+
this.#lastVelocity = this.#velocity;
|
|
371
|
+
if (this.#velocity > this.#maxVelocity) this.#maxVelocity = this.#velocity;
|
|
372
|
+
}
|
|
373
|
+
#SetupAutoComputeVelocity() {
|
|
374
|
+
if (this.#timeoutComputeVelocity) clearTimeout(this.#timeoutComputeVelocity);
|
|
375
|
+
this.#timeoutComputeVelocity = setTimeout(() => {
|
|
376
|
+
this.#ComputeVelocity();
|
|
377
|
+
}, this.#autoComputeVelocityTimeout);
|
|
378
|
+
}
|
|
379
|
+
#GetVelocityStackAverage() {
|
|
380
|
+
return this.GetNumber(this.#valStackAverage);
|
|
381
|
+
}
|
|
382
|
+
Inc(incVal = 1) {
|
|
383
|
+
this.#velocityVal += incVal;
|
|
384
|
+
if (this.#autoComputeVelocity) this.#ComputeVelocity();
|
|
385
|
+
else this.#SetupAutoComputeVelocity();
|
|
386
|
+
}
|
|
387
|
+
#GetVal() {
|
|
388
|
+
return this.GetNumber(this.#velocityVal);
|
|
389
|
+
}
|
|
390
|
+
#SetVal(updatedValue) {
|
|
391
|
+
this.#velocityVal = updatedValue;
|
|
392
|
+
if (this.#autoComputeVelocity) this.#ComputeVelocity();
|
|
393
|
+
else this.#SetupAutoComputeVelocity();
|
|
394
|
+
}
|
|
395
|
+
#GetVelocity() {
|
|
396
|
+
return this.GetNumber(this.#velocity);
|
|
397
|
+
}
|
|
398
|
+
#GetMaxVelocity() {
|
|
399
|
+
return this.GetNumber(this.#maxVelocity);
|
|
400
|
+
}
|
|
401
|
+
#GetDelta() {
|
|
402
|
+
return this.GetNumber(this.#delta);
|
|
403
|
+
}
|
|
404
|
+
#GetTimeStamp() {
|
|
405
|
+
return this.GetNumber(this.#timeStamp);
|
|
406
|
+
}
|
|
407
|
+
#GetCountDiff() {
|
|
408
|
+
return this.GetNumber(this.#countDiff);
|
|
409
|
+
}
|
|
410
|
+
#GetTimeDiff() {
|
|
411
|
+
return this.GetNumber(this.#timeDiff);
|
|
412
|
+
}
|
|
413
|
+
#GetDeltaCountDiff() {
|
|
414
|
+
return this.GetNumber(this.#deltaCountDiff);
|
|
415
|
+
}
|
|
416
|
+
#GetDeltaTimeDif() {
|
|
417
|
+
return this.GetNumber(this.#deltaTimeDif);
|
|
418
|
+
}
|
|
419
|
+
#GetAverageVelocity() {
|
|
420
|
+
return this.#averageVelocity;
|
|
421
|
+
}
|
|
422
|
+
StopTimer() {
|
|
423
|
+
if (this.#interval !== null) {
|
|
424
|
+
clearTimeout(this.#interval);
|
|
425
|
+
this.#interval = null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
ProcessTelemetry(telemetry) {
|
|
429
|
+
if (telemetry.Inc !== void 0) this.Inc(telemetry.Inc);
|
|
430
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/instrumentation/instruments/instrumentHistogram.ts
|
|
435
|
+
var HistogramDataElementPos = /* @__PURE__ */ function(HistogramDataElementPos) {
|
|
436
|
+
HistogramDataElementPos[HistogramDataElementPos["val"] = 0] = "val";
|
|
437
|
+
HistogramDataElementPos[HistogramDataElementPos["label"] = 1] = "label";
|
|
438
|
+
HistogramDataElementPos[HistogramDataElementPos["breakPoint"] = 2] = "breakPoint";
|
|
439
|
+
return HistogramDataElementPos;
|
|
440
|
+
}({});
|
|
441
|
+
var InstrumentHistogramOptions = class extends InstrumentBaseOptions {
|
|
442
|
+
histogramData;
|
|
443
|
+
initValue;
|
|
444
|
+
fromJSON;
|
|
445
|
+
};
|
|
446
|
+
var InstrumentHistogramTelemetry = class extends InstrumentBaseTelemetry {
|
|
447
|
+
val;
|
|
448
|
+
};
|
|
449
|
+
var InstrumentHistogram = class extends InstrumentBase {
|
|
450
|
+
#histogramData = [];
|
|
451
|
+
#val = 0;
|
|
452
|
+
#copy = false;
|
|
453
|
+
constructor(options = {}) {
|
|
454
|
+
super(options);
|
|
455
|
+
if (typeof options.label === "undefined") this.label = "InstrumentHistogram";
|
|
456
|
+
else this.label = options.label;
|
|
457
|
+
let histogramData = null;
|
|
458
|
+
if (typeof options.histogramData === "undefined") histogramData = null;
|
|
459
|
+
else histogramData = options.histogramData;
|
|
460
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
461
|
+
else this.#copy = true;
|
|
462
|
+
if (histogramData === null) this.#histogramData = [
|
|
463
|
+
[
|
|
464
|
+
0,
|
|
465
|
+
"10",
|
|
466
|
+
10
|
|
467
|
+
],
|
|
468
|
+
[
|
|
469
|
+
0,
|
|
470
|
+
"20",
|
|
471
|
+
20
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
0,
|
|
475
|
+
"50",
|
|
476
|
+
50
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
0,
|
|
480
|
+
"100",
|
|
481
|
+
100
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
0,
|
|
485
|
+
"1000",
|
|
486
|
+
1e3
|
|
487
|
+
],
|
|
488
|
+
[
|
|
489
|
+
0,
|
|
490
|
+
"5000",
|
|
491
|
+
5e3
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
0,
|
|
495
|
+
"EE",
|
|
496
|
+
0
|
|
497
|
+
]
|
|
498
|
+
];
|
|
499
|
+
else if (Array.isArray(histogramData)) {
|
|
500
|
+
this.#histogramData = [];
|
|
501
|
+
for (let i = 0; i < histogramData.length; i++) this.#histogramData.push([
|
|
502
|
+
0,
|
|
503
|
+
"" + histogramData[i],
|
|
504
|
+
parseFloat(histogramData[i].toString())
|
|
505
|
+
]);
|
|
506
|
+
this.#histogramData.push([
|
|
507
|
+
0,
|
|
508
|
+
"EE",
|
|
509
|
+
0
|
|
510
|
+
]);
|
|
511
|
+
} else throw new Error(`Passed [${histogramData}] must be an array.`);
|
|
512
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
513
|
+
enumerable: true,
|
|
514
|
+
get: () => GaugeTypes.INSTRUMENT_HISTOGRAM
|
|
515
|
+
});
|
|
516
|
+
if (this.#copy) this.DefineCopyProperties(["val", "hist"]);
|
|
517
|
+
else {
|
|
518
|
+
Object.defineProperty(this, "val", {
|
|
519
|
+
enumerable: true,
|
|
520
|
+
get: () => this.#GetVal(),
|
|
521
|
+
set: (value) => {
|
|
522
|
+
this.#SetVal(value);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
Object.defineProperty(this, "hist", {
|
|
526
|
+
enumerable: true,
|
|
527
|
+
get: () => this.#GetHistogramData(),
|
|
528
|
+
set: (value) => {
|
|
529
|
+
this.#SetHistogramData(value);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
if (typeof options.initValue !== "undefined") this.#val = options.initValue;
|
|
534
|
+
if (typeof options.fromJSON !== "undefined") {
|
|
535
|
+
const result = _cloneDeep(options.fromJSON);
|
|
536
|
+
this.#val = result.val;
|
|
537
|
+
this.hist = result.hist;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
hist = [];
|
|
541
|
+
val = 0;
|
|
542
|
+
WithInitVal(initVal) {
|
|
543
|
+
this.#val = initVal;
|
|
544
|
+
return this;
|
|
545
|
+
}
|
|
546
|
+
ResetHistogramData() {
|
|
547
|
+
for (let i = 0; i < this.hist.length; i++) this.hist[i][0] = 0;
|
|
548
|
+
}
|
|
549
|
+
AddObservation(updateValue) {
|
|
550
|
+
if (this.#copy) throw new Error("Cannot add observations from the copy version of this class.");
|
|
551
|
+
let i = 0;
|
|
552
|
+
for (; i < this.#histogramData.length - 1; i++) if (updateValue <= this.#histogramData[i][HistogramDataElementPos.breakPoint]) {
|
|
553
|
+
this.#histogramData[i][HistogramDataElementPos.val]++;
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
this.#histogramData[i][HistogramDataElementPos.val]++;
|
|
557
|
+
}
|
|
558
|
+
#GetVal() {
|
|
559
|
+
return this.GetNumber(this.#val);
|
|
560
|
+
}
|
|
561
|
+
#SetVal(value) {
|
|
562
|
+
this.#val = value;
|
|
563
|
+
this.AddObservation(value);
|
|
564
|
+
}
|
|
565
|
+
get formattedHistogramData() {
|
|
566
|
+
let retVal = "";
|
|
567
|
+
let sep = "";
|
|
568
|
+
for (let i = 0; i < this.hist.length; i++) {
|
|
569
|
+
retVal += sep + "[" + (this.hist[i][HistogramDataElementPos.val] + "/" + this.hist[i][HistogramDataElementPos.label]).padStart(10, " ") + "]";
|
|
570
|
+
sep = " ";
|
|
571
|
+
}
|
|
572
|
+
return retVal;
|
|
573
|
+
}
|
|
574
|
+
#GetHistogramData() {
|
|
575
|
+
return this.#histogramData;
|
|
576
|
+
}
|
|
577
|
+
#SetHistogramData(value) {
|
|
578
|
+
this.#histogramData = value;
|
|
579
|
+
}
|
|
580
|
+
static AddHistogramDataEx(histoA, histoB) {
|
|
581
|
+
if (histoA === null) return _cloneDeep(histoB);
|
|
582
|
+
const result = _cloneDeep(histoA);
|
|
583
|
+
const histogramAData = result.hist;
|
|
584
|
+
const histogramBData = histoB.hist;
|
|
585
|
+
if (histogramAData.length !== histogramBData.length) throw new Error("Invalid HistogramData. HistogramData bucket lengths must be the same.");
|
|
586
|
+
for (let i = 0; i < histogramAData.length; i++) {
|
|
587
|
+
if (histogramAData[i][HistogramDataElementPos.breakPoint] !== histogramBData[i][HistogramDataElementPos.breakPoint]) throw new Error(`Invalid HistogramData. HistogramData bucket break-point at index [${i}] must be the same.`);
|
|
588
|
+
if (histogramAData[i][HistogramDataElementPos.label] !== histogramBData[i][HistogramDataElementPos.label]) throw new Error(`Invalid HistogramData. HistogramData bucket label at index [${i}] must be the same.`);
|
|
589
|
+
histogramAData[i][HistogramDataElementPos.val] += histogramBData[i][HistogramDataElementPos.val];
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Adds a value object (from GetFormatted()) to this instance.
|
|
595
|
+
* @param {*} value
|
|
596
|
+
*/
|
|
597
|
+
AddHistogramData(histogramData) {
|
|
598
|
+
if (histogramData === null) return;
|
|
599
|
+
if (this.hist.length !== histogramData.hist.length) throw new Error("Invalid HistogramData. HistogramData bucket lengths must be the same.");
|
|
600
|
+
for (let i = 0; i < histogramData.hist.length; i++) {
|
|
601
|
+
if (this.hist[i][HistogramDataElementPos.breakPoint] !== histogramData.hist[i][HistogramDataElementPos.breakPoint]) throw new Error(`Invalid HistogramData. HistogramData bucket break-point at index [${i}] must be the same.`);
|
|
602
|
+
if (this.hist[i][HistogramDataElementPos.label] !== histogramData.hist[i][HistogramDataElementPos.label]) throw new Error(`Invalid HistogramData. HistogramData bucket label at index [${i}] must be the same.`);
|
|
603
|
+
this.hist[i][HistogramDataElementPos.val] += histogramData.hist[i][HistogramDataElementPos.val];
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
ProcessTelemetry(telemetry) {
|
|
607
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/instrumentation/instruments/instrumentLog.ts
|
|
612
|
+
var InstrumentLogOptions = class extends InstrumentBaseOptions {
|
|
613
|
+
maxSize;
|
|
614
|
+
useLatestMessages;
|
|
615
|
+
consoleLogging;
|
|
616
|
+
instrumentLogging;
|
|
617
|
+
winstonLogging;
|
|
618
|
+
fromJSON;
|
|
619
|
+
initValue;
|
|
620
|
+
logger;
|
|
621
|
+
};
|
|
622
|
+
var InstrumentLogTelemetry = class extends InstrumentBaseTelemetry {
|
|
623
|
+
Append;
|
|
624
|
+
LogMessage;
|
|
625
|
+
val;
|
|
626
|
+
ResetLog;
|
|
627
|
+
};
|
|
628
|
+
var InstrumentLog = class extends InstrumentBase {
|
|
629
|
+
#messages = [];
|
|
630
|
+
#readPos = 0;
|
|
631
|
+
#maxSize = 200;
|
|
632
|
+
#copy = false;
|
|
633
|
+
#useLatestMessages = false;
|
|
634
|
+
#consoleLogging = false;
|
|
635
|
+
#instrumentLogging = true;
|
|
636
|
+
#winstonLogging = false;
|
|
637
|
+
#stsLogger;
|
|
638
|
+
constructor(options = {}) {
|
|
639
|
+
super(options);
|
|
640
|
+
if (typeof options.label === "undefined") this.label = "InstrumentLog";
|
|
641
|
+
else this.label = options.label;
|
|
642
|
+
if (typeof options.maxSize === "undefined") this.#maxSize = 200;
|
|
643
|
+
else this.#maxSize = options.maxSize;
|
|
644
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
645
|
+
else this.#copy = true;
|
|
646
|
+
if (typeof options.useLatestMessages === "undefined") this.#useLatestMessages = false;
|
|
647
|
+
else this.#useLatestMessages = options.useLatestMessages;
|
|
648
|
+
if (typeof options.consoleLogging === "undefined") this.#consoleLogging = false;
|
|
649
|
+
else this.#consoleLogging = options.consoleLogging;
|
|
650
|
+
if (typeof options.instrumentLogging === "undefined") this.#instrumentLogging = true;
|
|
651
|
+
else this.#instrumentLogging = options.instrumentLogging;
|
|
652
|
+
if (typeof options.winstonLogging === "undefined") this.#winstonLogging = false;
|
|
653
|
+
else this.#winstonLogging = options.winstonLogging;
|
|
654
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
655
|
+
enumerable: true,
|
|
656
|
+
get: () => GaugeTypes.INSTRUMENT_LOG
|
|
657
|
+
});
|
|
658
|
+
if (this.#copy) this.DefineCopyProperties(["val"]);
|
|
659
|
+
else Object.defineProperty(this, "val", {
|
|
660
|
+
enumerable: true,
|
|
661
|
+
get: () => _cloneDeep(this.#GetVal()),
|
|
662
|
+
set: (value) => {
|
|
663
|
+
this.#SetVal(value);
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
if (typeof options.initValue !== "undefined") this.val = options.initValue;
|
|
667
|
+
if (typeof options.fromJSON !== "undefined") this.val = _cloneDeep(options.fromJSON).val;
|
|
668
|
+
}
|
|
669
|
+
val = [];
|
|
670
|
+
WithMaxSize(maxSize) {
|
|
671
|
+
this.#maxSize = maxSize;
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
WithUseLatestMessages(useLatestMessages) {
|
|
675
|
+
this.#useLatestMessages = useLatestMessages;
|
|
676
|
+
return this;
|
|
677
|
+
}
|
|
678
|
+
WithConsoleLogging(consoleLogging) {
|
|
679
|
+
this.#consoleLogging = consoleLogging;
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
682
|
+
WithInstrumentLogging(instrumentLogging) {
|
|
683
|
+
this.#instrumentLogging = instrumentLogging;
|
|
684
|
+
return this;
|
|
685
|
+
}
|
|
686
|
+
get MaxSize() {
|
|
687
|
+
return this.#maxSize;
|
|
688
|
+
}
|
|
689
|
+
set MaxSize(maxSize) {
|
|
690
|
+
this.#maxSize = maxSize;
|
|
691
|
+
}
|
|
692
|
+
#DumpToConsole() {
|
|
693
|
+
const logReport = this.GetMessagesSinceLastRead();
|
|
694
|
+
for (let i = 0; i < logReport.length; i++) console.log(logReport[i]);
|
|
695
|
+
}
|
|
696
|
+
get consoleLogging() {
|
|
697
|
+
return this.#consoleLogging;
|
|
698
|
+
}
|
|
699
|
+
set consoleLogging(value) {
|
|
700
|
+
this.#consoleLogging = value;
|
|
701
|
+
if (value === true) this.#DumpToConsole();
|
|
702
|
+
}
|
|
703
|
+
get instrumentLogging() {
|
|
704
|
+
return this.#instrumentLogging;
|
|
705
|
+
}
|
|
706
|
+
set instrumentLogging(value) {
|
|
707
|
+
this.#instrumentLogging = value;
|
|
708
|
+
}
|
|
709
|
+
Append(messageArray) {
|
|
710
|
+
for (let i = 0; i < messageArray.length; i++) this.LogMessage(messageArray[i]);
|
|
711
|
+
}
|
|
712
|
+
error(message) {
|
|
713
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.error(message);
|
|
714
|
+
}
|
|
715
|
+
warn(message) {
|
|
716
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.warn(message);
|
|
717
|
+
}
|
|
718
|
+
info(message) {
|
|
719
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.info(message);
|
|
720
|
+
}
|
|
721
|
+
http(message) {
|
|
722
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.http(message);
|
|
723
|
+
}
|
|
724
|
+
verbose(message) {
|
|
725
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.verbose(message);
|
|
726
|
+
}
|
|
727
|
+
debug(message) {
|
|
728
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.debug(message);
|
|
729
|
+
}
|
|
730
|
+
silly(message) {
|
|
731
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.silly(message);
|
|
732
|
+
}
|
|
733
|
+
LogMessage(message) {
|
|
734
|
+
if (this.#copy) throw new Error("Cannot add log messages from the copy version of this class.");
|
|
735
|
+
if (this.#consoleLogging === true) console.log(message);
|
|
736
|
+
if (this.#instrumentLogging === false) return;
|
|
737
|
+
this.#messages.push(message);
|
|
738
|
+
if (this.#messages.length > this.#maxSize) {
|
|
739
|
+
this.#messages.shift();
|
|
740
|
+
this.#readPos = this.#readPos > 0 ? this.#readPos - 1 : 0;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
#GetVal() {
|
|
744
|
+
if (this.#useLatestMessages) return this.GetMessagesSinceLastRead();
|
|
745
|
+
else return this.#messages;
|
|
746
|
+
}
|
|
747
|
+
#SetVal(updatedValue) {
|
|
748
|
+
this.#messages = updatedValue;
|
|
749
|
+
this.#readPos = 0;
|
|
750
|
+
}
|
|
751
|
+
GetMessagesNoUpdate() {
|
|
752
|
+
return this.#messages.slice(this.#readPos);
|
|
753
|
+
}
|
|
754
|
+
GetMessagesSinceLastRead() {
|
|
755
|
+
const retVal = this.#messages.slice(this.#readPos);
|
|
756
|
+
this.#readPos = this.#messages.length;
|
|
757
|
+
return retVal;
|
|
758
|
+
}
|
|
759
|
+
ResetLog() {
|
|
760
|
+
this.#messages = [];
|
|
761
|
+
this.#readPos = 0;
|
|
762
|
+
}
|
|
763
|
+
ProcessTelemetry(telemetry) {
|
|
764
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
765
|
+
if (telemetry.Append !== void 0) this.Append(telemetry.Append);
|
|
766
|
+
if (telemetry.LogMessage !== void 0) this.LogMessage(telemetry.LogMessage);
|
|
767
|
+
if (telemetry.ResetLog !== void 0 && telemetry.ResetLog === true) this.ResetLog();
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/instrumentation/instruments/instrumentTimerGauge.ts
|
|
772
|
+
var InstrumentTimerOptions = class extends InstrumentBaseOptions {
|
|
773
|
+
fromJSON;
|
|
774
|
+
initValue;
|
|
775
|
+
};
|
|
776
|
+
var InstrumentTimerTelemetry = class extends InstrumentBaseTelemetry {
|
|
777
|
+
val;
|
|
778
|
+
Pause;
|
|
779
|
+
Resume;
|
|
780
|
+
Reset;
|
|
781
|
+
};
|
|
782
|
+
var InstrumentTimerGauge = class extends InstrumentBase {
|
|
783
|
+
#start = 0;
|
|
784
|
+
#copy = false;
|
|
785
|
+
#pauseVal = 0;
|
|
786
|
+
constructor(options = {}) {
|
|
787
|
+
super(options);
|
|
788
|
+
if (typeof options.label === "undefined") this.label = "InstrumentTimerGauge";
|
|
789
|
+
else this.label = options.label;
|
|
790
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
791
|
+
else this.#copy = true;
|
|
792
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
793
|
+
enumerable: true,
|
|
794
|
+
get: () => GaugeTypes.INSTRUMENT_TIMER
|
|
795
|
+
});
|
|
796
|
+
if (this.#copy) this.DefineCopyProperties(["val"]);
|
|
797
|
+
else Object.defineProperty(this, "val", {
|
|
798
|
+
enumerable: true,
|
|
799
|
+
get: () => this.#GetVal(),
|
|
800
|
+
set: (value) => {
|
|
801
|
+
this.#SetVal(value);
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
if (typeof options.initValue !== "undefined") this.val = options.initValue;
|
|
805
|
+
if (typeof options.fromJSON !== "undefined") this.val = _cloneDeep(options.fromJSON).val;
|
|
806
|
+
this.Reset();
|
|
807
|
+
}
|
|
808
|
+
val = 0;
|
|
809
|
+
Pause() {
|
|
810
|
+
this.#pauseVal = this.val;
|
|
811
|
+
}
|
|
812
|
+
Resume() {
|
|
813
|
+
this.#pauseVal = 0;
|
|
814
|
+
}
|
|
815
|
+
Reset() {
|
|
816
|
+
this.#start = performance.now();
|
|
817
|
+
}
|
|
818
|
+
#GetVal() {
|
|
819
|
+
if (this.#pauseVal !== 0) return this.GetNumber(this.#pauseVal);
|
|
820
|
+
return this.GetNumber(performance.now() - this.#start);
|
|
821
|
+
}
|
|
822
|
+
#SetVal(updatedValue) {
|
|
823
|
+
this.#start = performance.now() - updatedValue;
|
|
824
|
+
}
|
|
825
|
+
get start() {
|
|
826
|
+
return this.#start;
|
|
827
|
+
}
|
|
828
|
+
ProcessTelemetry(telemetry) {
|
|
829
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
830
|
+
if (telemetry.Pause !== void 0 && telemetry.Pause === true) this.Pause();
|
|
831
|
+
if (telemetry.Resume !== void 0 && telemetry.Resume === true) this.Resume();
|
|
832
|
+
if (telemetry.Reset !== void 0 && telemetry.Reset === true) this.Reset();
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region node_modules/timsort/build/timsort.js
|
|
837
|
+
var require_timsort$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
838
|
+
/****
|
|
839
|
+
* The MIT License
|
|
840
|
+
*
|
|
841
|
+
* Copyright (c) 2015 Marco Ziccardi
|
|
842
|
+
*
|
|
843
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
844
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
845
|
+
* in the Software without restriction, including without limitation the rights
|
|
846
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
847
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
848
|
+
* furnished to do so, subject to the following conditions:
|
|
849
|
+
*
|
|
850
|
+
* The above copyright notice and this permission notice shall be included in
|
|
851
|
+
* all copies or substantial portions of the Software.
|
|
852
|
+
*
|
|
853
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
854
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
855
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
856
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
857
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
858
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
859
|
+
* THE SOFTWARE.
|
|
860
|
+
*
|
|
861
|
+
****/
|
|
862
|
+
(function(global, factory) {
|
|
863
|
+
if (typeof define === "function" && define.amd) define("timsort", ["exports"], factory);
|
|
864
|
+
else if (typeof exports !== "undefined") factory(exports);
|
|
865
|
+
else {
|
|
866
|
+
var mod = { exports: {} };
|
|
867
|
+
factory(mod.exports);
|
|
868
|
+
global.timsort = mod.exports;
|
|
869
|
+
}
|
|
870
|
+
})(exports, function(exports$1) {
|
|
871
|
+
"use strict";
|
|
872
|
+
exports$1.__esModule = true;
|
|
873
|
+
exports$1.sort = sort;
|
|
874
|
+
function _classCallCheck(instance, Constructor) {
|
|
875
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
876
|
+
}
|
|
877
|
+
var DEFAULT_MIN_MERGE = 32;
|
|
878
|
+
var DEFAULT_MIN_GALLOPING = 7;
|
|
879
|
+
var DEFAULT_TMP_STORAGE_LENGTH = 256;
|
|
880
|
+
var POWERS_OF_TEN = [
|
|
881
|
+
1,
|
|
882
|
+
10,
|
|
883
|
+
100,
|
|
884
|
+
1e3,
|
|
885
|
+
1e4,
|
|
886
|
+
1e5,
|
|
887
|
+
1e6,
|
|
888
|
+
1e7,
|
|
889
|
+
1e8,
|
|
890
|
+
1e9
|
|
891
|
+
];
|
|
892
|
+
function log10(x) {
|
|
893
|
+
if (x < 1e5) {
|
|
894
|
+
if (x < 100) return x < 10 ? 0 : 1;
|
|
895
|
+
if (x < 1e4) return x < 1e3 ? 2 : 3;
|
|
896
|
+
return 4;
|
|
897
|
+
}
|
|
898
|
+
if (x < 1e7) return x < 1e6 ? 5 : 6;
|
|
899
|
+
if (x < 1e9) return x < 1e8 ? 7 : 8;
|
|
900
|
+
return 9;
|
|
901
|
+
}
|
|
902
|
+
function alphabeticalCompare(a, b) {
|
|
903
|
+
if (a === b) return 0;
|
|
904
|
+
if (~~a === a && ~~b === b) {
|
|
905
|
+
if (a === 0 || b === 0) return a < b ? -1 : 1;
|
|
906
|
+
if (a < 0 || b < 0) {
|
|
907
|
+
if (b >= 0) return -1;
|
|
908
|
+
if (a >= 0) return 1;
|
|
909
|
+
a = -a;
|
|
910
|
+
b = -b;
|
|
911
|
+
}
|
|
912
|
+
var al = log10(a);
|
|
913
|
+
var bl = log10(b);
|
|
914
|
+
var t = 0;
|
|
915
|
+
if (al < bl) {
|
|
916
|
+
a *= POWERS_OF_TEN[bl - al - 1];
|
|
917
|
+
b /= 10;
|
|
918
|
+
t = -1;
|
|
919
|
+
} else if (al > bl) {
|
|
920
|
+
b *= POWERS_OF_TEN[al - bl - 1];
|
|
921
|
+
a /= 10;
|
|
922
|
+
t = 1;
|
|
923
|
+
}
|
|
924
|
+
if (a === b) return t;
|
|
925
|
+
return a < b ? -1 : 1;
|
|
926
|
+
}
|
|
927
|
+
var aStr = String(a);
|
|
928
|
+
var bStr = String(b);
|
|
929
|
+
if (aStr === bStr) return 0;
|
|
930
|
+
return aStr < bStr ? -1 : 1;
|
|
931
|
+
}
|
|
932
|
+
function minRunLength(n) {
|
|
933
|
+
var r = 0;
|
|
934
|
+
while (n >= DEFAULT_MIN_MERGE) {
|
|
935
|
+
r |= n & 1;
|
|
936
|
+
n >>= 1;
|
|
937
|
+
}
|
|
938
|
+
return n + r;
|
|
939
|
+
}
|
|
940
|
+
function makeAscendingRun(array, lo, hi, compare) {
|
|
941
|
+
var runHi = lo + 1;
|
|
942
|
+
if (runHi === hi) return 1;
|
|
943
|
+
if (compare(array[runHi++], array[lo]) < 0) {
|
|
944
|
+
while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) runHi++;
|
|
945
|
+
reverseRun(array, lo, runHi);
|
|
946
|
+
} else while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) runHi++;
|
|
947
|
+
return runHi - lo;
|
|
948
|
+
}
|
|
949
|
+
function reverseRun(array, lo, hi) {
|
|
950
|
+
hi--;
|
|
951
|
+
while (lo < hi) {
|
|
952
|
+
var t = array[lo];
|
|
953
|
+
array[lo++] = array[hi];
|
|
954
|
+
array[hi--] = t;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
function binaryInsertionSort(array, lo, hi, start, compare) {
|
|
958
|
+
if (start === lo) start++;
|
|
959
|
+
for (; start < hi; start++) {
|
|
960
|
+
var pivot = array[start];
|
|
961
|
+
var left = lo;
|
|
962
|
+
var right = start;
|
|
963
|
+
while (left < right) {
|
|
964
|
+
var mid = left + right >>> 1;
|
|
965
|
+
if (compare(pivot, array[mid]) < 0) right = mid;
|
|
966
|
+
else left = mid + 1;
|
|
967
|
+
}
|
|
968
|
+
var n = start - left;
|
|
969
|
+
switch (n) {
|
|
970
|
+
case 3: array[left + 3] = array[left + 2];
|
|
971
|
+
case 2: array[left + 2] = array[left + 1];
|
|
972
|
+
case 1:
|
|
973
|
+
array[left + 1] = array[left];
|
|
974
|
+
break;
|
|
975
|
+
default: while (n > 0) {
|
|
976
|
+
array[left + n] = array[left + n - 1];
|
|
977
|
+
n--;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
array[left] = pivot;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function gallopLeft(value, array, start, length, hint, compare) {
|
|
984
|
+
var lastOffset = 0;
|
|
985
|
+
var maxOffset = 0;
|
|
986
|
+
var offset = 1;
|
|
987
|
+
if (compare(value, array[start + hint]) > 0) {
|
|
988
|
+
maxOffset = length - hint;
|
|
989
|
+
while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
|
|
990
|
+
lastOffset = offset;
|
|
991
|
+
offset = (offset << 1) + 1;
|
|
992
|
+
if (offset <= 0) offset = maxOffset;
|
|
993
|
+
}
|
|
994
|
+
if (offset > maxOffset) offset = maxOffset;
|
|
995
|
+
lastOffset += hint;
|
|
996
|
+
offset += hint;
|
|
997
|
+
} else {
|
|
998
|
+
maxOffset = hint + 1;
|
|
999
|
+
while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
|
|
1000
|
+
lastOffset = offset;
|
|
1001
|
+
offset = (offset << 1) + 1;
|
|
1002
|
+
if (offset <= 0) offset = maxOffset;
|
|
1003
|
+
}
|
|
1004
|
+
if (offset > maxOffset) offset = maxOffset;
|
|
1005
|
+
var tmp = lastOffset;
|
|
1006
|
+
lastOffset = hint - offset;
|
|
1007
|
+
offset = hint - tmp;
|
|
1008
|
+
}
|
|
1009
|
+
lastOffset++;
|
|
1010
|
+
while (lastOffset < offset) {
|
|
1011
|
+
var m = lastOffset + (offset - lastOffset >>> 1);
|
|
1012
|
+
if (compare(value, array[start + m]) > 0) lastOffset = m + 1;
|
|
1013
|
+
else offset = m;
|
|
1014
|
+
}
|
|
1015
|
+
return offset;
|
|
1016
|
+
}
|
|
1017
|
+
function gallopRight(value, array, start, length, hint, compare) {
|
|
1018
|
+
var lastOffset = 0;
|
|
1019
|
+
var maxOffset = 0;
|
|
1020
|
+
var offset = 1;
|
|
1021
|
+
if (compare(value, array[start + hint]) < 0) {
|
|
1022
|
+
maxOffset = hint + 1;
|
|
1023
|
+
while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
|
|
1024
|
+
lastOffset = offset;
|
|
1025
|
+
offset = (offset << 1) + 1;
|
|
1026
|
+
if (offset <= 0) offset = maxOffset;
|
|
1027
|
+
}
|
|
1028
|
+
if (offset > maxOffset) offset = maxOffset;
|
|
1029
|
+
var tmp = lastOffset;
|
|
1030
|
+
lastOffset = hint - offset;
|
|
1031
|
+
offset = hint - tmp;
|
|
1032
|
+
} else {
|
|
1033
|
+
maxOffset = length - hint;
|
|
1034
|
+
while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
|
|
1035
|
+
lastOffset = offset;
|
|
1036
|
+
offset = (offset << 1) + 1;
|
|
1037
|
+
if (offset <= 0) offset = maxOffset;
|
|
1038
|
+
}
|
|
1039
|
+
if (offset > maxOffset) offset = maxOffset;
|
|
1040
|
+
lastOffset += hint;
|
|
1041
|
+
offset += hint;
|
|
1042
|
+
}
|
|
1043
|
+
lastOffset++;
|
|
1044
|
+
while (lastOffset < offset) {
|
|
1045
|
+
var m = lastOffset + (offset - lastOffset >>> 1);
|
|
1046
|
+
if (compare(value, array[start + m]) < 0) offset = m;
|
|
1047
|
+
else lastOffset = m + 1;
|
|
1048
|
+
}
|
|
1049
|
+
return offset;
|
|
1050
|
+
}
|
|
1051
|
+
var TimSort = (function() {
|
|
1052
|
+
function TimSort(array, compare) {
|
|
1053
|
+
_classCallCheck(this, TimSort);
|
|
1054
|
+
this.array = null;
|
|
1055
|
+
this.compare = null;
|
|
1056
|
+
this.minGallop = DEFAULT_MIN_GALLOPING;
|
|
1057
|
+
this.length = 0;
|
|
1058
|
+
this.tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
|
|
1059
|
+
this.stackLength = 0;
|
|
1060
|
+
this.runStart = null;
|
|
1061
|
+
this.runLength = null;
|
|
1062
|
+
this.stackSize = 0;
|
|
1063
|
+
this.array = array;
|
|
1064
|
+
this.compare = compare;
|
|
1065
|
+
this.length = array.length;
|
|
1066
|
+
if (this.length < 2 * DEFAULT_TMP_STORAGE_LENGTH) this.tmpStorageLength = this.length >>> 1;
|
|
1067
|
+
this.tmp = new Array(this.tmpStorageLength);
|
|
1068
|
+
this.stackLength = this.length < 120 ? 5 : this.length < 1542 ? 10 : this.length < 119151 ? 19 : 40;
|
|
1069
|
+
this.runStart = new Array(this.stackLength);
|
|
1070
|
+
this.runLength = new Array(this.stackLength);
|
|
1071
|
+
}
|
|
1072
|
+
TimSort.prototype.pushRun = function pushRun(runStart, runLength) {
|
|
1073
|
+
this.runStart[this.stackSize] = runStart;
|
|
1074
|
+
this.runLength[this.stackSize] = runLength;
|
|
1075
|
+
this.stackSize += 1;
|
|
1076
|
+
};
|
|
1077
|
+
TimSort.prototype.mergeRuns = function mergeRuns() {
|
|
1078
|
+
while (this.stackSize > 1) {
|
|
1079
|
+
var n = this.stackSize - 2;
|
|
1080
|
+
if (n >= 1 && this.runLength[n - 1] <= this.runLength[n] + this.runLength[n + 1] || n >= 2 && this.runLength[n - 2] <= this.runLength[n] + this.runLength[n - 1]) {
|
|
1081
|
+
if (this.runLength[n - 1] < this.runLength[n + 1]) n--;
|
|
1082
|
+
} else if (this.runLength[n] > this.runLength[n + 1]) break;
|
|
1083
|
+
this.mergeAt(n);
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
TimSort.prototype.forceMergeRuns = function forceMergeRuns() {
|
|
1087
|
+
while (this.stackSize > 1) {
|
|
1088
|
+
var n = this.stackSize - 2;
|
|
1089
|
+
if (n > 0 && this.runLength[n - 1] < this.runLength[n + 1]) n--;
|
|
1090
|
+
this.mergeAt(n);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
TimSort.prototype.mergeAt = function mergeAt(i) {
|
|
1094
|
+
var compare = this.compare;
|
|
1095
|
+
var array = this.array;
|
|
1096
|
+
var start1 = this.runStart[i];
|
|
1097
|
+
var length1 = this.runLength[i];
|
|
1098
|
+
var start2 = this.runStart[i + 1];
|
|
1099
|
+
var length2 = this.runLength[i + 1];
|
|
1100
|
+
this.runLength[i] = length1 + length2;
|
|
1101
|
+
if (i === this.stackSize - 3) {
|
|
1102
|
+
this.runStart[i + 1] = this.runStart[i + 2];
|
|
1103
|
+
this.runLength[i + 1] = this.runLength[i + 2];
|
|
1104
|
+
}
|
|
1105
|
+
this.stackSize--;
|
|
1106
|
+
var k = gallopRight(array[start2], array, start1, length1, 0, compare);
|
|
1107
|
+
start1 += k;
|
|
1108
|
+
length1 -= k;
|
|
1109
|
+
if (length1 === 0) return;
|
|
1110
|
+
length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
|
|
1111
|
+
if (length2 === 0) return;
|
|
1112
|
+
if (length1 <= length2) this.mergeLow(start1, length1, start2, length2);
|
|
1113
|
+
else this.mergeHigh(start1, length1, start2, length2);
|
|
1114
|
+
};
|
|
1115
|
+
TimSort.prototype.mergeLow = function mergeLow(start1, length1, start2, length2) {
|
|
1116
|
+
var compare = this.compare;
|
|
1117
|
+
var array = this.array;
|
|
1118
|
+
var tmp = this.tmp;
|
|
1119
|
+
var i = 0;
|
|
1120
|
+
for (i = 0; i < length1; i++) tmp[i] = array[start1 + i];
|
|
1121
|
+
var cursor1 = 0;
|
|
1122
|
+
var cursor2 = start2;
|
|
1123
|
+
var dest = start1;
|
|
1124
|
+
array[dest++] = array[cursor2++];
|
|
1125
|
+
if (--length2 === 0) {
|
|
1126
|
+
for (i = 0; i < length1; i++) array[dest + i] = tmp[cursor1 + i];
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
if (length1 === 1) {
|
|
1130
|
+
for (i = 0; i < length2; i++) array[dest + i] = array[cursor2 + i];
|
|
1131
|
+
array[dest + length2] = tmp[cursor1];
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
var minGallop = this.minGallop;
|
|
1135
|
+
while (true) {
|
|
1136
|
+
var count1 = 0;
|
|
1137
|
+
var count2 = 0;
|
|
1138
|
+
var exit = false;
|
|
1139
|
+
do
|
|
1140
|
+
if (compare(array[cursor2], tmp[cursor1]) < 0) {
|
|
1141
|
+
array[dest++] = array[cursor2++];
|
|
1142
|
+
count2++;
|
|
1143
|
+
count1 = 0;
|
|
1144
|
+
if (--length2 === 0) {
|
|
1145
|
+
exit = true;
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
} else {
|
|
1149
|
+
array[dest++] = tmp[cursor1++];
|
|
1150
|
+
count1++;
|
|
1151
|
+
count2 = 0;
|
|
1152
|
+
if (--length1 === 1) {
|
|
1153
|
+
exit = true;
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
while ((count1 | count2) < minGallop);
|
|
1158
|
+
if (exit) break;
|
|
1159
|
+
do {
|
|
1160
|
+
count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
|
|
1161
|
+
if (count1 !== 0) {
|
|
1162
|
+
for (i = 0; i < count1; i++) array[dest + i] = tmp[cursor1 + i];
|
|
1163
|
+
dest += count1;
|
|
1164
|
+
cursor1 += count1;
|
|
1165
|
+
length1 -= count1;
|
|
1166
|
+
if (length1 <= 1) {
|
|
1167
|
+
exit = true;
|
|
1168
|
+
break;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
array[dest++] = array[cursor2++];
|
|
1172
|
+
if (--length2 === 0) {
|
|
1173
|
+
exit = true;
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1176
|
+
count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
|
|
1177
|
+
if (count2 !== 0) {
|
|
1178
|
+
for (i = 0; i < count2; i++) array[dest + i] = array[cursor2 + i];
|
|
1179
|
+
dest += count2;
|
|
1180
|
+
cursor2 += count2;
|
|
1181
|
+
length2 -= count2;
|
|
1182
|
+
if (length2 === 0) {
|
|
1183
|
+
exit = true;
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
array[dest++] = tmp[cursor1++];
|
|
1188
|
+
if (--length1 === 1) {
|
|
1189
|
+
exit = true;
|
|
1190
|
+
break;
|
|
1191
|
+
}
|
|
1192
|
+
minGallop--;
|
|
1193
|
+
} while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
|
|
1194
|
+
if (exit) break;
|
|
1195
|
+
if (minGallop < 0) minGallop = 0;
|
|
1196
|
+
minGallop += 2;
|
|
1197
|
+
}
|
|
1198
|
+
this.minGallop = minGallop;
|
|
1199
|
+
if (minGallop < 1) this.minGallop = 1;
|
|
1200
|
+
if (length1 === 1) {
|
|
1201
|
+
for (i = 0; i < length2; i++) array[dest + i] = array[cursor2 + i];
|
|
1202
|
+
array[dest + length2] = tmp[cursor1];
|
|
1203
|
+
} else if (length1 === 0) throw new Error("mergeLow preconditions were not respected");
|
|
1204
|
+
else for (i = 0; i < length1; i++) array[dest + i] = tmp[cursor1 + i];
|
|
1205
|
+
};
|
|
1206
|
+
TimSort.prototype.mergeHigh = function mergeHigh(start1, length1, start2, length2) {
|
|
1207
|
+
var compare = this.compare;
|
|
1208
|
+
var array = this.array;
|
|
1209
|
+
var tmp = this.tmp;
|
|
1210
|
+
var i = 0;
|
|
1211
|
+
for (i = 0; i < length2; i++) tmp[i] = array[start2 + i];
|
|
1212
|
+
var cursor1 = start1 + length1 - 1;
|
|
1213
|
+
var cursor2 = length2 - 1;
|
|
1214
|
+
var dest = start2 + length2 - 1;
|
|
1215
|
+
var customCursor = 0;
|
|
1216
|
+
var customDest = 0;
|
|
1217
|
+
array[dest--] = array[cursor1--];
|
|
1218
|
+
if (--length1 === 0) {
|
|
1219
|
+
customCursor = dest - (length2 - 1);
|
|
1220
|
+
for (i = 0; i < length2; i++) array[customCursor + i] = tmp[i];
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
if (length2 === 1) {
|
|
1224
|
+
dest -= length1;
|
|
1225
|
+
cursor1 -= length1;
|
|
1226
|
+
customDest = dest + 1;
|
|
1227
|
+
customCursor = cursor1 + 1;
|
|
1228
|
+
for (i = length1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i];
|
|
1229
|
+
array[dest] = tmp[cursor2];
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
var minGallop = this.minGallop;
|
|
1233
|
+
while (true) {
|
|
1234
|
+
var count1 = 0;
|
|
1235
|
+
var count2 = 0;
|
|
1236
|
+
var exit = false;
|
|
1237
|
+
do
|
|
1238
|
+
if (compare(tmp[cursor2], array[cursor1]) < 0) {
|
|
1239
|
+
array[dest--] = array[cursor1--];
|
|
1240
|
+
count1++;
|
|
1241
|
+
count2 = 0;
|
|
1242
|
+
if (--length1 === 0) {
|
|
1243
|
+
exit = true;
|
|
1244
|
+
break;
|
|
1245
|
+
}
|
|
1246
|
+
} else {
|
|
1247
|
+
array[dest--] = tmp[cursor2--];
|
|
1248
|
+
count2++;
|
|
1249
|
+
count1 = 0;
|
|
1250
|
+
if (--length2 === 1) {
|
|
1251
|
+
exit = true;
|
|
1252
|
+
break;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
while ((count1 | count2) < minGallop);
|
|
1256
|
+
if (exit) break;
|
|
1257
|
+
do {
|
|
1258
|
+
count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
|
|
1259
|
+
if (count1 !== 0) {
|
|
1260
|
+
dest -= count1;
|
|
1261
|
+
cursor1 -= count1;
|
|
1262
|
+
length1 -= count1;
|
|
1263
|
+
customDest = dest + 1;
|
|
1264
|
+
customCursor = cursor1 + 1;
|
|
1265
|
+
for (i = count1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i];
|
|
1266
|
+
if (length1 === 0) {
|
|
1267
|
+
exit = true;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
array[dest--] = tmp[cursor2--];
|
|
1272
|
+
if (--length2 === 1) {
|
|
1273
|
+
exit = true;
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
|
|
1277
|
+
if (count2 !== 0) {
|
|
1278
|
+
dest -= count2;
|
|
1279
|
+
cursor2 -= count2;
|
|
1280
|
+
length2 -= count2;
|
|
1281
|
+
customDest = dest + 1;
|
|
1282
|
+
customCursor = cursor2 + 1;
|
|
1283
|
+
for (i = 0; i < count2; i++) array[customDest + i] = tmp[customCursor + i];
|
|
1284
|
+
if (length2 <= 1) {
|
|
1285
|
+
exit = true;
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
array[dest--] = array[cursor1--];
|
|
1290
|
+
if (--length1 === 0) {
|
|
1291
|
+
exit = true;
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
minGallop--;
|
|
1295
|
+
} while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
|
|
1296
|
+
if (exit) break;
|
|
1297
|
+
if (minGallop < 0) minGallop = 0;
|
|
1298
|
+
minGallop += 2;
|
|
1299
|
+
}
|
|
1300
|
+
this.minGallop = minGallop;
|
|
1301
|
+
if (minGallop < 1) this.minGallop = 1;
|
|
1302
|
+
if (length2 === 1) {
|
|
1303
|
+
dest -= length1;
|
|
1304
|
+
cursor1 -= length1;
|
|
1305
|
+
customDest = dest + 1;
|
|
1306
|
+
customCursor = cursor1 + 1;
|
|
1307
|
+
for (i = length1 - 1; i >= 0; i--) array[customDest + i] = array[customCursor + i];
|
|
1308
|
+
array[dest] = tmp[cursor2];
|
|
1309
|
+
} else if (length2 === 0) throw new Error("mergeHigh preconditions were not respected");
|
|
1310
|
+
else {
|
|
1311
|
+
customCursor = dest - (length2 - 1);
|
|
1312
|
+
for (i = 0; i < length2; i++) array[customCursor + i] = tmp[i];
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
return TimSort;
|
|
1316
|
+
})();
|
|
1317
|
+
function sort(array, compare, lo, hi) {
|
|
1318
|
+
if (!Array.isArray(array)) throw new TypeError("Can only sort arrays");
|
|
1319
|
+
if (!compare) compare = alphabeticalCompare;
|
|
1320
|
+
else if (typeof compare !== "function") {
|
|
1321
|
+
hi = lo;
|
|
1322
|
+
lo = compare;
|
|
1323
|
+
compare = alphabeticalCompare;
|
|
1324
|
+
}
|
|
1325
|
+
if (!lo) lo = 0;
|
|
1326
|
+
if (!hi) hi = array.length;
|
|
1327
|
+
var remaining = hi - lo;
|
|
1328
|
+
if (remaining < 2) return;
|
|
1329
|
+
var runLength = 0;
|
|
1330
|
+
if (remaining < DEFAULT_MIN_MERGE) {
|
|
1331
|
+
runLength = makeAscendingRun(array, lo, hi, compare);
|
|
1332
|
+
binaryInsertionSort(array, lo, hi, lo + runLength, compare);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
var ts = new TimSort(array, compare);
|
|
1336
|
+
var minRun = minRunLength(remaining);
|
|
1337
|
+
do {
|
|
1338
|
+
runLength = makeAscendingRun(array, lo, hi, compare);
|
|
1339
|
+
if (runLength < minRun) {
|
|
1340
|
+
var force = remaining;
|
|
1341
|
+
if (force > minRun) force = minRun;
|
|
1342
|
+
binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
|
|
1343
|
+
runLength = force;
|
|
1344
|
+
}
|
|
1345
|
+
ts.pushRun(lo, runLength);
|
|
1346
|
+
ts.mergeRuns();
|
|
1347
|
+
remaining -= runLength;
|
|
1348
|
+
lo += runLength;
|
|
1349
|
+
} while (remaining !== 0);
|
|
1350
|
+
ts.forceMergeRuns();
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
}));
|
|
1354
|
+
//#endregion
|
|
1355
|
+
//#region node_modules/timsort/index.js
|
|
1356
|
+
var require_timsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1357
|
+
module.exports = require_timsort$1();
|
|
1358
|
+
}));
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region node_modules/percentile/lib/index.js
|
|
1361
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1362
|
+
/**
|
|
1363
|
+
@typedef {(Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array)} TypedArray
|
|
1364
|
+
*/
|
|
1365
|
+
/**
|
|
1366
|
+
* Error message for a case when percentile is less than 0.
|
|
1367
|
+
*
|
|
1368
|
+
* @param {Number} p
|
|
1369
|
+
*
|
|
1370
|
+
* @return {String}
|
|
1371
|
+
*/
|
|
1372
|
+
function lessThanZeroError(p) {
|
|
1373
|
+
return "Expect percentile to be >= 0 but given \"" + p + "\" and its type is \"" + typeof p + "\".";
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Error message for a case when percentile is greater than 100.
|
|
1377
|
+
*
|
|
1378
|
+
* @param {Number} p
|
|
1379
|
+
*
|
|
1380
|
+
* @return {String}
|
|
1381
|
+
*/
|
|
1382
|
+
function greaterThanHundredError(p) {
|
|
1383
|
+
return "Expect percentile to be <= 100 but given \"" + p + "\" and its type is \"" + typeof p + "\".";
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Error message for a case when percentile is not a number (NaN).
|
|
1387
|
+
*
|
|
1388
|
+
* @param {Number} p
|
|
1389
|
+
*
|
|
1390
|
+
* @return {String}
|
|
1391
|
+
*/
|
|
1392
|
+
function nanError(p) {
|
|
1393
|
+
return "Expect percentile to be a number but given \"" + p + "\" and its type is \"" + typeof p + "\".";
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Checks that a list of percentiles are all numbers and they lie in range 0..100.
|
|
1397
|
+
*
|
|
1398
|
+
* @param {Array<Number>} ps - percentiles to calculate
|
|
1399
|
+
*
|
|
1400
|
+
* @return {Array} List of errors
|
|
1401
|
+
*/
|
|
1402
|
+
function validateInput(ps) {
|
|
1403
|
+
return ps.reduce(function(errors, p) {
|
|
1404
|
+
if (isNaN(Number(p))) errors.push(nanError(p));
|
|
1405
|
+
else if (p < 0) errors.push(lessThanZeroError(p));
|
|
1406
|
+
else if (p > 100) errors.push(greaterThanHundredError(p));
|
|
1407
|
+
return errors;
|
|
1408
|
+
}, []);
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Get percentile value from an array.
|
|
1412
|
+
*
|
|
1413
|
+
* @param {Number} p - percentile
|
|
1414
|
+
* @param {Array|TypedArray} list - list of values
|
|
1415
|
+
*
|
|
1416
|
+
* @return {*}
|
|
1417
|
+
*/
|
|
1418
|
+
function getPsValue(p, list) {
|
|
1419
|
+
if (p === 0) return list[0];
|
|
1420
|
+
return list[Math.ceil(list.length * (p / 100)) - 1];
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Calculate percentile for given array of values.
|
|
1424
|
+
*
|
|
1425
|
+
* @template T
|
|
1426
|
+
* @param {Number|Array<Number>} pOrPs - percentile or a list of percentiles
|
|
1427
|
+
* @param {Array<T>|Array<Number>|TypedArray} list - array of values
|
|
1428
|
+
* @param {function(T): Number} [fn] - optional function to extract a value from an array item
|
|
1429
|
+
*
|
|
1430
|
+
* @return {Number|T|Array<Number>|Array<T>}
|
|
1431
|
+
*/
|
|
1432
|
+
function percentile(pOrPs, list, fn) {
|
|
1433
|
+
var ps = Array.isArray(pOrPs) ? pOrPs : [pOrPs];
|
|
1434
|
+
var validationErrors = validateInput(ps);
|
|
1435
|
+
if (validationErrors.length) throw new Error(validationErrors.join(" "));
|
|
1436
|
+
list = list.slice().sort(function(a, b) {
|
|
1437
|
+
if (fn) {
|
|
1438
|
+
a = fn(a);
|
|
1439
|
+
b = fn(b);
|
|
1440
|
+
}
|
|
1441
|
+
a = Number.isNaN(a) ? Number.NEGATIVE_INFINITY : a;
|
|
1442
|
+
b = Number.isNaN(b) ? Number.NEGATIVE_INFINITY : b;
|
|
1443
|
+
if (a > b) return 1;
|
|
1444
|
+
if (a < b) return -1;
|
|
1445
|
+
return 0;
|
|
1446
|
+
});
|
|
1447
|
+
if (ps.length === 1) return getPsValue(ps[0], list);
|
|
1448
|
+
return ps.map(function(p) {
|
|
1449
|
+
return getPsValue(p, list);
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
module.exports = percentile;
|
|
1453
|
+
}));
|
|
1454
|
+
//#endregion
|
|
1455
|
+
//#region src/instrumentation/instruments/instrumentGauge.ts
|
|
1456
|
+
var import_timsort = /* @__PURE__ */ __toESM(require_timsort());
|
|
1457
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib());
|
|
1458
|
+
var InstrumentGaugeOptions = class extends InstrumentBaseOptions {
|
|
1459
|
+
interval;
|
|
1460
|
+
sampleSize;
|
|
1461
|
+
fromJSON;
|
|
1462
|
+
initValue;
|
|
1463
|
+
};
|
|
1464
|
+
var InstrumentGaugeTelemetry = class extends InstrumentBaseTelemetry {
|
|
1465
|
+
val;
|
|
1466
|
+
Inc;
|
|
1467
|
+
Dec;
|
|
1468
|
+
};
|
|
1469
|
+
var InstrumentGauge = class extends InstrumentBase {
|
|
1470
|
+
#val = 0;
|
|
1471
|
+
#maxval = null;
|
|
1472
|
+
#lastObservedValue = 0;
|
|
1473
|
+
#timeSeriesList = [];
|
|
1474
|
+
#maxSampleSize = 0;
|
|
1475
|
+
#timerInterval = 0;
|
|
1476
|
+
#observer = null;
|
|
1477
|
+
#min = null;
|
|
1478
|
+
#max = 0;
|
|
1479
|
+
#observations = 0;
|
|
1480
|
+
#total = 0;
|
|
1481
|
+
#copy = false;
|
|
1482
|
+
constructor(options = {}) {
|
|
1483
|
+
super(options);
|
|
1484
|
+
if (!options.label) this.label = "InstrumentGauge";
|
|
1485
|
+
else this.label = options.label;
|
|
1486
|
+
if (typeof options.interval === "undefined") this.#timerInterval = 0;
|
|
1487
|
+
else this.#timerInterval = options.interval;
|
|
1488
|
+
if (typeof options.sampleSize === "undefined") this.#maxSampleSize = 600;
|
|
1489
|
+
else this.#maxSampleSize = options.sampleSize;
|
|
1490
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
1491
|
+
else this.#copy = true;
|
|
1492
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
1493
|
+
enumerable: true,
|
|
1494
|
+
get: () => GaugeTypes.INSTRUMENT_GAUGE
|
|
1495
|
+
});
|
|
1496
|
+
if (this.#copy) this.DefineCopyProperties([
|
|
1497
|
+
"val",
|
|
1498
|
+
"min",
|
|
1499
|
+
"max",
|
|
1500
|
+
"avg",
|
|
1501
|
+
"percentile"
|
|
1502
|
+
]);
|
|
1503
|
+
else {
|
|
1504
|
+
Object.defineProperty(this, "val", {
|
|
1505
|
+
enumerable: true,
|
|
1506
|
+
get: () => this.#GetVal(),
|
|
1507
|
+
set: (value) => {
|
|
1508
|
+
this.#SetVal(value);
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
if (this.#timerInterval > 0) {
|
|
1512
|
+
Object.defineProperty(this, "percentile", {
|
|
1513
|
+
enumerable: true,
|
|
1514
|
+
get: () => this.#GetPercentileData()
|
|
1515
|
+
});
|
|
1516
|
+
this._StartTimer();
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (typeof options.initValue !== "undefined") this.val = options.initValue;
|
|
1520
|
+
if (typeof options.fromJSON !== "undefined") {
|
|
1521
|
+
const result = _cloneDeep(options.fromJSON);
|
|
1522
|
+
this.val = result.val;
|
|
1523
|
+
if (result.percentile) this.percentile = result.percentile;
|
|
1524
|
+
if (result.min) this.min = result.min;
|
|
1525
|
+
if (result.max) this.max = result.max;
|
|
1526
|
+
if (result.avg) this.avg = result.avg;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
percentile;
|
|
1530
|
+
min;
|
|
1531
|
+
max;
|
|
1532
|
+
avg;
|
|
1533
|
+
val = 0;
|
|
1534
|
+
WithInitVal(initVal) {
|
|
1535
|
+
this.val = initVal;
|
|
1536
|
+
return this;
|
|
1537
|
+
}
|
|
1538
|
+
WithMin() {
|
|
1539
|
+
Object.defineProperty(this, "min", {
|
|
1540
|
+
enumerable: true,
|
|
1541
|
+
get: () => this.#GetMin()
|
|
1542
|
+
});
|
|
1543
|
+
return this;
|
|
1544
|
+
}
|
|
1545
|
+
WithMax() {
|
|
1546
|
+
Object.defineProperty(this, "max", {
|
|
1547
|
+
enumerable: true,
|
|
1548
|
+
get: () => this.#GetMax()
|
|
1549
|
+
});
|
|
1550
|
+
return this;
|
|
1551
|
+
}
|
|
1552
|
+
WithAverage() {
|
|
1553
|
+
Object.defineProperty(this, "avg", {
|
|
1554
|
+
enumerable: true,
|
|
1555
|
+
get: () => this.#GetAverage()
|
|
1556
|
+
});
|
|
1557
|
+
return this;
|
|
1558
|
+
}
|
|
1559
|
+
_StartTimer() {
|
|
1560
|
+
if (this.#timerInterval > 0) {
|
|
1561
|
+
this.#timeSeriesList = [];
|
|
1562
|
+
this.#observer = setInterval(() => {
|
|
1563
|
+
if (this.#timeSeriesList.length > this.#maxSampleSize) this.#timeSeriesList.shift();
|
|
1564
|
+
const maxval = this.#GetAndResetMaxVal();
|
|
1565
|
+
this.#timeSeriesList.push(maxval);
|
|
1566
|
+
}, this.#timerInterval);
|
|
1567
|
+
if (isNode) this.#observer.unref();
|
|
1568
|
+
} else throw new Error(`Unable to StartTimer for this instrument. The interval is set to <= 0.`);
|
|
1569
|
+
}
|
|
1570
|
+
StopTimer() {
|
|
1571
|
+
if (this.#observer) {
|
|
1572
|
+
clearTimeout(this.#observer);
|
|
1573
|
+
this.#observer = null;
|
|
1574
|
+
this.#timeSeriesList = [];
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* If the gauge is being monitored as part of a time series, get the most recent recorded value (max value) from within the time interval
|
|
1579
|
+
* otherwise, just return the current instant value.
|
|
1580
|
+
*/
|
|
1581
|
+
#GetVal() {
|
|
1582
|
+
if (this.#timerInterval > 0 && this.#observer !== null) if (this.#maxval === null) return this.GetNumber(this.#lastObservedValue);
|
|
1583
|
+
else return this.GetNumber(this.#maxval);
|
|
1584
|
+
return this.GetNumber(this.#val);
|
|
1585
|
+
}
|
|
1586
|
+
#SetVal(updatedValue) {
|
|
1587
|
+
this.#val = updatedValue;
|
|
1588
|
+
this.#observations++;
|
|
1589
|
+
this.#total += updatedValue;
|
|
1590
|
+
if (this.#val > this.#max) this.#max = this.#val;
|
|
1591
|
+
if (this.#min !== null) {
|
|
1592
|
+
if (this.#val < this.#min) this.#min = this.#val;
|
|
1593
|
+
} else this.#min = this.#val;
|
|
1594
|
+
if (this.#timerInterval > 0) {
|
|
1595
|
+
this.#lastObservedValue = updatedValue;
|
|
1596
|
+
if (this.#maxval === null) this.#maxval = this.#val;
|
|
1597
|
+
else if (this.#val > this.#maxval) this.#maxval = this.#val;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
#GetMin() {
|
|
1601
|
+
if (this.#min !== null) return this.#min;
|
|
1602
|
+
return 0;
|
|
1603
|
+
}
|
|
1604
|
+
#GetMax() {
|
|
1605
|
+
return this.#max;
|
|
1606
|
+
}
|
|
1607
|
+
#GetAverage() {
|
|
1608
|
+
if (this.#observations > 0) return this.#total / this.#observations;
|
|
1609
|
+
return 0;
|
|
1610
|
+
}
|
|
1611
|
+
Reset() {
|
|
1612
|
+
this.StopTimer();
|
|
1613
|
+
this.#maxval = 0;
|
|
1614
|
+
this.#lastObservedValue = 0;
|
|
1615
|
+
this.#val = 0;
|
|
1616
|
+
this.#min = null;
|
|
1617
|
+
this.#max = 0;
|
|
1618
|
+
this.#observations = 0;
|
|
1619
|
+
this.#total = 0;
|
|
1620
|
+
if (this.#timerInterval > 0) this._StartTimer();
|
|
1621
|
+
}
|
|
1622
|
+
#GetAndResetMaxVal() {
|
|
1623
|
+
if (this.#maxval === null) return this.#lastObservedValue;
|
|
1624
|
+
const retVal = this.#maxval;
|
|
1625
|
+
this.#maxval = null;
|
|
1626
|
+
return retVal;
|
|
1627
|
+
}
|
|
1628
|
+
Inc(incVal = 1) {
|
|
1629
|
+
this.#SetVal(this.#val + incVal);
|
|
1630
|
+
}
|
|
1631
|
+
Dec(decVal = 1) {
|
|
1632
|
+
this.#SetVal(this.#val - decVal);
|
|
1633
|
+
}
|
|
1634
|
+
#NumberCompare(a, b) {
|
|
1635
|
+
return a - b;
|
|
1636
|
+
}
|
|
1637
|
+
#GetPercentileData() {
|
|
1638
|
+
const sortedList = this.#timeSeriesList.slice(0);
|
|
1639
|
+
import_timsort.sort(sortedList, this.#NumberCompare);
|
|
1640
|
+
return (0, import_lib.default)([
|
|
1641
|
+
50,
|
|
1642
|
+
80,
|
|
1643
|
+
90,
|
|
1644
|
+
95,
|
|
1645
|
+
99,
|
|
1646
|
+
99.95
|
|
1647
|
+
], sortedList);
|
|
1648
|
+
}
|
|
1649
|
+
ProcessTelemetry(telemetry) {
|
|
1650
|
+
if (telemetry.Inc !== void 0) this.Inc(telemetry.Inc);
|
|
1651
|
+
if (telemetry.Dec !== void 0) this.Dec(telemetry.Dec);
|
|
1652
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
//#endregion
|
|
1656
|
+
//#region src/instrumentation/instruments/instrumentObject.ts
|
|
1657
|
+
var InstrumentObjectOptions = class extends InstrumentBaseOptions {
|
|
1658
|
+
fromJSON;
|
|
1659
|
+
initValue;
|
|
1660
|
+
};
|
|
1661
|
+
var InstrumentObjectTelemetry = class extends InstrumentBaseTelemetry {
|
|
1662
|
+
val;
|
|
1663
|
+
};
|
|
1664
|
+
var InstrumentObject = class extends InstrumentBase {
|
|
1665
|
+
#val = {};
|
|
1666
|
+
#copy = false;
|
|
1667
|
+
constructor(options = {}) {
|
|
1668
|
+
super(options);
|
|
1669
|
+
if (typeof options.label === "undefined") this.label = "InstrumentObject";
|
|
1670
|
+
else this.label = options.label;
|
|
1671
|
+
if (typeof options.fromJSON === "undefined") this.#copy = false;
|
|
1672
|
+
else this.#copy = true;
|
|
1673
|
+
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
1674
|
+
enumerable: true,
|
|
1675
|
+
get: () => GaugeTypes.INSTRUMENT_OBJECT
|
|
1676
|
+
});
|
|
1677
|
+
if (this.#copy) this.DefineCopyProperties(["val"]);
|
|
1678
|
+
else Object.defineProperty(this, "val", {
|
|
1679
|
+
enumerable: true,
|
|
1680
|
+
get: () => this.#GetVal(),
|
|
1681
|
+
set: (value) => {
|
|
1682
|
+
this.#SetVal(value);
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
if (typeof options.initValue !== "undefined") this.val = options.initValue;
|
|
1686
|
+
else this.val = {};
|
|
1687
|
+
if (typeof options.fromJSON !== "undefined") this.val = _cloneDeep(options.fromJSON).val;
|
|
1688
|
+
}
|
|
1689
|
+
val;
|
|
1690
|
+
WithInitVal(initVal) {
|
|
1691
|
+
this.val = initVal;
|
|
1692
|
+
return this;
|
|
1693
|
+
}
|
|
1694
|
+
#GetVal() {
|
|
1695
|
+
return this.#val;
|
|
1696
|
+
}
|
|
1697
|
+
#SetVal(updatedValue) {
|
|
1698
|
+
this.#val = updatedValue;
|
|
1699
|
+
}
|
|
1700
|
+
ProcessTelemetry(telemetry) {
|
|
1701
|
+
if (telemetry.val !== void 0) this.val = telemetry.val;
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
//#endregion
|
|
1705
|
+
//#region src/instrumentation/instrumentUtils.ts
|
|
2087
1706
|
function CreateInstrument(sourceInstrument) {
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
case GaugeTypes.INSTRUMENT_TIMER:
|
|
2098
|
-
return new InstrumentTimerGauge({ fromJSON: sourceInstrument });
|
|
2099
|
-
case GaugeTypes.INSTRUMENT_OBJECT:
|
|
2100
|
-
return new InstrumentObject({ fromJSON: sourceInstrument });
|
|
2101
|
-
}
|
|
2102
|
-
throw new Error(`Cannot create instrument from type: [${sourceInstrument[GaugeTypes.GAUGE_TYPE]}]`);
|
|
1707
|
+
switch (sourceInstrument[GaugeTypes.GAUGE_TYPE]) {
|
|
1708
|
+
case GaugeTypes.INSTRUMENT_GAUGE: return new InstrumentGauge({ fromJSON: sourceInstrument });
|
|
1709
|
+
case GaugeTypes.INSTRUMENT_VELOCITY: return new InstrumentVelocity({ fromJSON: sourceInstrument });
|
|
1710
|
+
case GaugeTypes.INSTRUMENT_HISTOGRAM: return new InstrumentHistogram({ fromJSON: sourceInstrument });
|
|
1711
|
+
case GaugeTypes.INSTRUMENT_LOG: return new InstrumentLog({ fromJSON: sourceInstrument });
|
|
1712
|
+
case GaugeTypes.INSTRUMENT_TIMER: return new InstrumentTimerGauge({ fromJSON: sourceInstrument });
|
|
1713
|
+
case GaugeTypes.INSTRUMENT_OBJECT: return new InstrumentObject({ fromJSON: sourceInstrument });
|
|
1714
|
+
}
|
|
1715
|
+
throw new Error(`Cannot create instrument from type: [${sourceInstrument[GaugeTypes.GAUGE_TYPE]}]`);
|
|
2103
1716
|
}
|
|
2104
1717
|
function GetInstrumentName(gauge) {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
return "Latency Histogram";
|
|
2134
|
-
case Gauge.LOGGER:
|
|
2135
|
-
return "Logger";
|
|
2136
|
-
case Gauge.LOGGER_COPY:
|
|
2137
|
-
return "_Logger";
|
|
2138
|
-
case Gauge.NETWORK_RX_GAUGE:
|
|
2139
|
-
return "Network Receive";
|
|
2140
|
-
case Gauge.NETWORK_TX_GAUGE:
|
|
2141
|
-
return "Network Transmit";
|
|
2142
|
-
case Gauge.REQUEST_COUNT_GAUGE:
|
|
2143
|
-
return "Requests";
|
|
2144
|
-
case Gauge.RETRY_COUNT_GAUGE:
|
|
2145
|
-
return "Retries";
|
|
2146
|
-
case Gauge.TIMER_GAUGE:
|
|
2147
|
-
return "Timer";
|
|
2148
|
-
case Gauge.VELOCITY_GAUGE:
|
|
2149
|
-
return "Velocity";
|
|
2150
|
-
case Gauge.CONNECTION_COUNT_GAUGE:
|
|
2151
|
-
return "TCP Connection";
|
|
2152
|
-
case Gauge.OBJECT_GAUGE:
|
|
2153
|
-
return "Object";
|
|
2154
|
-
case Gauge.CORE_COUNT_GAUGE:
|
|
2155
|
-
return "Core Count";
|
|
2156
|
-
default:
|
|
2157
|
-
return "Unknown";
|
|
2158
|
-
}
|
|
1718
|
+
switch (gauge) {
|
|
1719
|
+
case Gauge.ACTIVE_REQUEST_GAUGE: return "Active Requests";
|
|
1720
|
+
case Gauge.AUTHENTICATION_COUNT_GAUGE: return "Authentication Count";
|
|
1721
|
+
case Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE: return "Authentication Error Count";
|
|
1722
|
+
case Gauge.AUTHENTICATION_RETRY_COUNT_GAUGE: return "Authentication Retry Count";
|
|
1723
|
+
case Gauge.CONNECTION_POOL_IDLE_GAUGE: return "Connection Pool Idle";
|
|
1724
|
+
case Gauge.CONNECTION_POOL_TOTAL_GAUGE: return "Connection Pool Total";
|
|
1725
|
+
case Gauge.CONNECTION_POOL_WAITING_GAUGE: return "Connection Pool Waiting";
|
|
1726
|
+
case Gauge.CPU_LOAD_GAUGE: return "CPU Load";
|
|
1727
|
+
case Gauge.CPU_SYSTEM_LOAD_GAUGE: return "CPU SYstem Load";
|
|
1728
|
+
case Gauge.DURATION_GAUGE: return "Duration";
|
|
1729
|
+
case Gauge.DURATION_HISTOGRAM_GAUGE: return "Diration Histogram";
|
|
1730
|
+
case Gauge.ERROR_COUNT_GAUGE: return "Errors";
|
|
1731
|
+
case Gauge.LATENCY_GAUGE: return "Latency";
|
|
1732
|
+
case Gauge.LATENCY_HISTOGRAM_GAUGE: return "Latency Histogram";
|
|
1733
|
+
case Gauge.LOGGER: return "Logger";
|
|
1734
|
+
case Gauge.LOGGER_COPY: return "_Logger";
|
|
1735
|
+
case Gauge.NETWORK_RX_GAUGE: return "Network Receive";
|
|
1736
|
+
case Gauge.NETWORK_TX_GAUGE: return "Network Transmit";
|
|
1737
|
+
case Gauge.REQUEST_COUNT_GAUGE: return "Requests";
|
|
1738
|
+
case Gauge.RETRY_COUNT_GAUGE: return "Retries";
|
|
1739
|
+
case Gauge.TIMER_GAUGE: return "Timer";
|
|
1740
|
+
case Gauge.VELOCITY_GAUGE: return "Velocity";
|
|
1741
|
+
case Gauge.CONNECTION_COUNT_GAUGE: return "TCP Connection";
|
|
1742
|
+
case Gauge.OBJECT_GAUGE: return "Object";
|
|
1743
|
+
case Gauge.CORE_COUNT_GAUGE: return "Core Count";
|
|
1744
|
+
default: return "Unknown";
|
|
1745
|
+
}
|
|
2159
1746
|
}
|
|
2160
1747
|
function StopInstruments(instruments) {
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
});
|
|
2168
|
-
} else {
|
|
2169
|
-
for (const [, value] of Object.entries(instruments)) {
|
|
2170
|
-
if (value.StopTimer) {
|
|
2171
|
-
value.StopTimer();
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
1748
|
+
if (instruments) {
|
|
1749
|
+
if (Array.isArray(instruments)) instruments.forEach((instrument) => {
|
|
1750
|
+
if (instrument.StopTimer) instrument.StopTimer();
|
|
1751
|
+
});
|
|
1752
|
+
else for (const [, value] of Object.entries(instruments)) if (value.StopTimer) value.StopTimer();
|
|
1753
|
+
}
|
|
2176
1754
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
GetInstrumentName,
|
|
2182
|
-
HistogramDataElementPos,
|
|
2183
|
-
InstrumentBase,
|
|
2184
|
-
InstrumentBaseOptions,
|
|
2185
|
-
InstrumentBaseTelemetry,
|
|
2186
|
-
InstrumentGauge,
|
|
2187
|
-
InstrumentGaugeOptions,
|
|
2188
|
-
InstrumentGaugeTelemetry,
|
|
2189
|
-
InstrumentHistogram,
|
|
2190
|
-
InstrumentHistogramOptions,
|
|
2191
|
-
InstrumentHistogramTelemetry,
|
|
2192
|
-
InstrumentLog,
|
|
2193
|
-
InstrumentLogOptions,
|
|
2194
|
-
InstrumentLogTelemetry,
|
|
2195
|
-
InstrumentObject,
|
|
2196
|
-
InstrumentObjectOptions,
|
|
2197
|
-
InstrumentObjectTelemetry,
|
|
2198
|
-
InstrumentTimerGauge,
|
|
2199
|
-
InstrumentTimerOptions,
|
|
2200
|
-
InstrumentTimerTelemetry,
|
|
2201
|
-
InstrumentVelocity,
|
|
2202
|
-
InstrumentVelocityOptions,
|
|
2203
|
-
InstrumentVelocityTelemetry,
|
|
2204
|
-
StopInstruments
|
|
2205
|
-
};
|
|
2206
|
-
//# sourceMappingURL=index.mjs.map
|
|
1755
|
+
//#endregion
|
|
1756
|
+
export { CreateInstrument, Gauge, GaugeTypes, GetInstrumentName, HistogramDataElementPos, InstrumentBase, InstrumentBaseOptions, InstrumentBaseTelemetry, InstrumentGauge, InstrumentGaugeOptions, InstrumentGaugeTelemetry, InstrumentHistogram, InstrumentHistogramOptions, InstrumentHistogramTelemetry, InstrumentLog, InstrumentLogOptions, InstrumentLogTelemetry, InstrumentObject, InstrumentObjectOptions, InstrumentObjectTelemetry, InstrumentTimerGauge, InstrumentTimerOptions, InstrumentTimerTelemetry, InstrumentVelocity, InstrumentVelocityOptions, InstrumentVelocityTelemetry, StopInstruments };
|
|
1757
|
+
|
|
1758
|
+
//# sourceMappingURL=index.mjs.map
|