@rsdk/common 5.4.0-next.4 → 5.4.0-next.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.4.0-next.6](https://github.com/R-Vision/rsdk/compare/v5.4.0-next.5...v5.4.0-next.6) (2024-11-28)
7
+
8
+ **Note:** Version bump only for package @rsdk/common
9
+
10
+ ## [5.4.0-next.5](https://github.com/R-Vision/rsdk/compare/v5.4.0-next.4...v5.4.0-next.5) (2024-11-28)
11
+
12
+ **Note:** Version bump only for package @rsdk/common
13
+
6
14
  ## [5.4.0-next.4](https://github.com/R-Vision/rsdk/compare/v5.4.0-next.3...v5.4.0-next.4) (2024-11-27)
7
15
 
8
16
  **Note:** Version bump only for package @rsdk/common
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/common",
3
- "version": "5.4.0-next.4",
3
+ "version": "5.4.0-next.6",
4
4
  "description": "Useful common classes, functions and types",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -16,5 +16,5 @@
16
16
  "dependencies": {
17
17
  "rxjs": "^7.8.1"
18
18
  },
19
- "gitHead": "6f7d6802d4dc34620f3c0e8c8ec73887df36a647"
19
+ "gitHead": "acc1405be758b5ba4d2e8eda8d34b3c4f60a813f"
20
20
  }
@@ -16,30 +16,95 @@ describe('Convert', () => {
16
16
 
17
17
  const tt: Case[] = [
18
18
  // Positive
19
- { name: 'Correct integer (string)', input: '123', success: true, output: 123 },
20
- { name: 'Correct integer (number)', input: 123, success: true, output: 123 },
21
- { name: 'Correct negative integer (number)', input: -123, success: true, output: -123 },
22
- { name: 'Correct negative integer (string)', input: '-123', success: true, output: -123 },
23
- { name: 'Zero', input: 0, success: true, output: 0 },
24
- { name: 'Zero string', input: '0', success: true, output: 0 },
19
+ {
20
+ name: 'Correct integer (string)',
21
+ input: '123',
22
+ success: true,
23
+ output: 123,
24
+ },
25
+ {
26
+ name: 'Correct integer (number)',
27
+ input: 123,
28
+ success: true,
29
+ output: 123,
30
+ },
31
+ {
32
+ name: 'Correct negative integer (number)',
33
+ input: -123,
34
+ success: true,
35
+ output: -123,
36
+ },
37
+ {
38
+ name: 'Correct negative integer (string)',
39
+ input: '-123',
40
+ success: true,
41
+ output: -123,
42
+ },
43
+ { name: 'Zero', input: 0, success: true, output: 0 },
44
+ { name: 'Zero string', input: '0', success: true, output: 0 },
25
45
 
26
46
  // Negative
27
- { name: 'Correct float (string)', input: '123.1', success: false, output: null },
28
- { name: 'Correct float (number)', input: 123.1, success: false, output: null },
29
- { name: 'Correct negative float (number)', input: -123.2, success: false, output: null },
30
- { name: 'Correct negative float (string)', input: '-123.4', success: false, output: null },
31
- { name: 'Incorrect float (string)', input: '123,1', success: false, output: null },
32
- { name: 'Empty string', input: '', success: false, output: null },
33
- { name: 'True (boolean)', input: true, success: false, output: null },
34
- { name: 'True (string lowercase)', input: 'true', success: false, output: null },
35
- { name: 'True (string mixedcase)', input: 'TrUe', success: false, output: null },
36
- { name: 'False (boolean)', input: false, success: false, output: null },
37
- { name: 'False (string lowercase)', input: 'false', success: false, output: null },
38
- { name: 'False (string mixedcase)', input: 'FalSe', success: false, output: null },
39
- { name: 'Trash (string)', input: 'sdfg', success: false, output: null },
40
- { name: 'Trash (object)', input: { a: 1 }, success: false, output: null },
41
- { name: 'null', input: null, success: false, output: null },
42
- { name: 'undefined', input: undefined, success: false, output: null },
47
+ {
48
+ name: 'Correct float (string)',
49
+ input: '123.1',
50
+ success: false,
51
+ output: null,
52
+ },
53
+ {
54
+ name: 'Correct float (number)',
55
+ input: 123.1,
56
+ success: false,
57
+ output: null,
58
+ },
59
+ {
60
+ name: 'Correct negative float (number)',
61
+ input: -123.2,
62
+ success: false,
63
+ output: null,
64
+ },
65
+ {
66
+ name: 'Correct negative float (string)',
67
+ input: '-123.4',
68
+ success: false,
69
+ output: null,
70
+ },
71
+ {
72
+ name: 'Incorrect float (string)',
73
+ input: '123,1',
74
+ success: false,
75
+ output: null,
76
+ },
77
+ { name: 'Empty string', input: '', success: false, output: null },
78
+ { name: 'True (boolean)', input: true, success: false, output: null },
79
+ {
80
+ name: 'True (string lowercase)',
81
+ input: 'true',
82
+ success: false,
83
+ output: null,
84
+ },
85
+ {
86
+ name: 'True (string mixedcase)',
87
+ input: 'TrUe',
88
+ success: false,
89
+ output: null,
90
+ },
91
+ { name: 'False (boolean)', input: false, success: false, output: null },
92
+ {
93
+ name: 'False (string lowercase)',
94
+ input: 'false',
95
+ success: false,
96
+ output: null,
97
+ },
98
+ {
99
+ name: 'False (string mixedcase)',
100
+ input: 'FalSe',
101
+ success: false,
102
+ output: null,
103
+ },
104
+ { name: 'Trash (string)', input: 'sdfg', success: false, output: null },
105
+ { name: 'Trash (object)', input: { a: 1 }, success: false, output: null },
106
+ { name: 'null', input: null, success: false, output: null },
107
+ { name: 'undefined', input: undefined, success: false, output: null },
43
108
  ];
44
109
 
45
110
  for (const { name, input, success, output } of tt) {
@@ -65,61 +130,61 @@ describe('Convert', () => {
65
130
  name: 'Correct integer (string)',
66
131
  input: '123',
67
132
  success: true,
68
- output: 123
133
+ output: 123,
69
134
  },
70
135
  {
71
136
  name: 'Correct integer (number)',
72
137
  input: 123,
73
138
  success: true,
74
- output: 123
139
+ output: 123,
75
140
  },
76
141
  {
77
142
  name: 'Correct negative integer (number)',
78
143
  input: -123,
79
144
  success: true,
80
- output: -123
145
+ output: -123,
81
146
  },
82
147
  {
83
148
  name: 'Correct negative integer (string)',
84
149
  input: '-123',
85
150
  success: true,
86
- output: -123
151
+ output: -123,
87
152
  },
88
153
  {
89
154
  name: 'Correct float (string)',
90
155
  input: '123.1',
91
156
  success: true,
92
- output: 123.1
157
+ output: 123.1,
93
158
  },
94
159
  {
95
160
  name: 'Correct float (number)',
96
161
  input: 123.1,
97
162
  success: true,
98
- output: 123.1
163
+ output: 123.1,
99
164
  },
100
165
  {
101
166
  name: 'Correct negative float (number)',
102
167
  input: -123.4,
103
168
  success: true,
104
- output: -123.4
169
+ output: -123.4,
105
170
  },
106
171
  {
107
172
  name: 'Correct negative float (string)',
108
173
  input: '-123.4',
109
174
  success: true,
110
- output: -123.4
175
+ output: -123.4,
111
176
  },
112
177
  {
113
178
  name: 'Zero',
114
179
  input: 0,
115
180
  success: true,
116
- output: 0
181
+ output: 0,
117
182
  },
118
183
  {
119
184
  name: 'Zero string',
120
185
  input: '0',
121
186
  success: true,
122
- output: 0
187
+ output: 0,
123
188
  },
124
189
 
125
190
  // Negative
@@ -127,79 +192,79 @@ describe('Convert', () => {
127
192
  name: 'Incorrect float (string)',
128
193
  input: '123,1',
129
194
  success: false,
130
- output: null
195
+ output: null,
131
196
  },
132
197
  {
133
198
  name: 'Empty string',
134
199
  input: '',
135
200
  success: false,
136
- output: null
201
+ output: null,
137
202
  },
138
203
  {
139
204
  name: 'True (boolean)',
140
205
  input: true,
141
206
  success: false,
142
- output: null
207
+ output: null,
143
208
  },
144
209
  {
145
210
  name: 'True (string lowercase)',
146
211
  input: 'true',
147
212
  success: false,
148
- output: null
213
+ output: null,
149
214
  },
150
215
  {
151
216
  name: 'True (string mixedcase)',
152
217
  input: 'TrUe',
153
218
  success: false,
154
- output: null
219
+ output: null,
155
220
  },
156
221
  {
157
222
  name: 'False (boolean)',
158
223
  input: false,
159
224
  success: false,
160
- output: null
225
+ output: null,
161
226
  },
162
227
  {
163
228
  name: 'False (string lowercase)',
164
229
  input: 'false',
165
230
  success: false,
166
- output: null
231
+ output: null,
167
232
  },
168
233
  {
169
234
  name: 'False (string mixedcase)',
170
235
  input: 'FalSe',
171
236
  success: false,
172
- output: null
237
+ output: null,
173
238
  },
174
239
  {
175
240
  name: 'Trash (string)',
176
241
  input: 'sdfg',
177
242
  success: false,
178
- output: null
243
+ output: null,
179
244
  },
180
245
  {
181
246
  name: 'Trash (object)',
182
247
  input: { a: 1 },
183
248
  success: false,
184
- output: null
249
+ output: null,
185
250
  },
186
251
  {
187
252
  name: 'Trash (object)',
188
253
  input: { a: 1 },
189
254
  success: false,
190
- output: null
255
+ output: null,
191
256
  },
192
257
  {
193
258
  name: 'null',
194
259
  input: null,
195
260
  success: false,
196
- output: null
261
+ output: null,
197
262
  },
198
263
  {
199
264
  name: 'undefined',
200
265
  input: undefined,
201
266
  success: false,
202
- output: null
267
+ output: null,
203
268
  },
204
269
  ];
205
270
 
@@ -222,26 +287,71 @@ describe('Convert', () => {
222
287
 
223
288
  const tt: Case[] = [
224
289
  // Positive
225
- { name: 'True (boolean)', input: true, success: true, output: true },
226
- { name: 'True (string lowercase)', input: 'true', success: true, output: true },
227
- { name: 'True (string mixedcase)', input: 'TrUe', success: true, output: true },
228
- { name: 'False (boolean)', input: false, success: true, output: false },
229
- { name: 'False (string lowercase)', input: 'false', success: true, output: false },
230
- { name: 'False (string mixedcase)', input: 'FalSe', success: true, output: false },
290
+ { name: 'True (boolean)', input: true, success: true, output: true },
291
+ {
292
+ name: 'True (string lowercase)',
293
+ input: 'true',
294
+ success: true,
295
+ output: true,
296
+ },
297
+ {
298
+ name: 'True (string mixedcase)',
299
+ input: 'TrUe',
300
+ success: true,
301
+ output: true,
302
+ },
303
+ { name: 'False (boolean)', input: false, success: true, output: false },
304
+ {
305
+ name: 'False (string lowercase)',
306
+ input: 'false',
307
+ success: true,
308
+ output: false,
309
+ },
310
+ {
311
+ name: 'False (string mixedcase)',
312
+ input: 'FalSe',
313
+ success: true,
314
+ output: false,
315
+ },
231
316
 
232
317
  // Negative
233
- { name: 'Correct integer (string)', input: '123', success: false, output: null },
234
- { name: 'Correct integer (number)', input: 123, success: false, output: null },
235
- { name: 'Correct float (string)', input: '123.1', success: false, output: null },
236
- { name: 'Correct float (number)', input: 123.1, success: false, output: null },
237
- { name: 'Incorrect float (string)', input: '123,1', success: false, output: null },
238
- { name: 'Empty string', input: '', success: false, output: null },
239
- { name: 'Zero', input: 0, success: false, output: null },
240
- { name: 'Zero string', input: '0', success: false, output: null },
241
- { name: 'Trash (string)', input: 'sdfg', success: false, output: null },
242
- { name: 'Trash (object)', input: { a: 1 }, success: false, output: null },
243
- { name: 'null', input: null, success: false, output: null },
244
- { name: 'undefined', input: undefined, success: false, output: null },
318
+ {
319
+ name: 'Correct integer (string)',
320
+ input: '123',
321
+ success: false,
322
+ output: null,
323
+ },
324
+ {
325
+ name: 'Correct integer (number)',
326
+ input: 123,
327
+ success: false,
328
+ output: null,
329
+ },
330
+ {
331
+ name: 'Correct float (string)',
332
+ input: '123.1',
333
+ success: false,
334
+ output: null,
335
+ },
336
+ {
337
+ name: 'Correct float (number)',
338
+ input: 123.1,
339
+ success: false,
340
+ output: null,
341
+ },
342
+ {
343
+ name: 'Incorrect float (string)',
344
+ input: '123,1',
345
+ success: false,
346
+ output: null,
347
+ },
348
+ { name: 'Empty string', input: '', success: false, output: null },
349
+ { name: 'Zero', input: 0, success: false, output: null },
350
+ { name: 'Zero string', input: '0', success: false, output: null },
351
+ { name: 'Trash (string)', input: 'sdfg', success: false, output: null },
352
+ { name: 'Trash (object)', input: { a: 1 }, success: false, output: null },
353
+ { name: 'null', input: null, success: false, output: null },
354
+ { name: 'undefined', input: undefined, success: false, output: null },
245
355
  ];
246
356
 
247
357
  for (const { name, input, success, output } of tt) {
@@ -293,37 +403,37 @@ describe('Convert', () => {
293
403
  name: 'Random string',
294
404
  input: 'sadfasdf',
295
405
  success: false,
296
- output: null
406
+ output: null,
297
407
  },
298
408
  {
299
409
  name: 'Random number',
300
410
  input: 123,
301
411
  success: false,
302
- output: null
412
+ output: null,
303
413
  },
304
414
  {
305
415
  name: 'Random boolean',
306
416
  input: true,
307
417
  success: false,
308
- output: null
418
+ output: null,
309
419
  },
310
420
  {
311
421
  name: 'Random object',
312
422
  input: { a: 1 },
313
423
  success: false,
314
- output: null
424
+ output: null,
315
425
  },
316
426
  {
317
427
  name: 'null',
318
428
  input: null,
319
429
  success: false,
320
- output: null
430
+ output: null,
321
431
  },
322
432
  {
323
433
  name: 'undefined',
324
434
  input: undefined,
325
435
  success: false,
326
- output: null
436
+ output: null,
327
437
  },
328
438
  ];
329
439
 
@@ -337,37 +447,37 @@ describe('Convert', () => {
337
447
  name: 'Zero (number)',
338
448
  input: 0,
339
449
  success: true,
340
- output: Implicit.KEY_1
450
+ output: Implicit.KEY_1,
341
451
  },
342
452
  {
343
453
  name: 'Zero (string)',
344
454
  input: '0',
345
455
  success: true,
346
- output: Implicit.KEY_1
456
+ output: Implicit.KEY_1,
347
457
  },
348
458
  {
349
459
  name: 'One (number)',
350
460
  input: 1,
351
461
  success: true,
352
- output: Implicit.KEY_2
462
+ output: Implicit.KEY_2,
353
463
  },
354
464
  {
355
465
  name: 'One (number)',
356
466
  input: '1',
357
467
  success: true,
358
- output: Implicit.KEY_2
468
+ output: Implicit.KEY_2,
359
469
  },
360
470
  {
361
471
  name: 'KEY_1',
362
472
  input: 'KEY_1',
363
473
  success: true,
364
- output: Implicit.KEY_1
474
+ output: Implicit.KEY_1,
365
475
  },
366
476
  {
367
477
  name: 'KEY_2',
368
478
  input: 'KEY_2',
369
479
  success: true,
370
- output: Implicit.KEY_2
480
+ output: Implicit.KEY_2,
371
481
  },
372
482
 
373
483
  // Negative
@@ -375,13 +485,13 @@ describe('Convert', () => {
375
485
  name: 'null',
376
486
  input: null,
377
487
  success: false,
378
- output: null
488
+ output: null,
379
489
  },
380
490
  {
381
491
  name: 'undefined',
382
492
  input: undefined,
383
493
  success: false,
384
- output: null
494
+ output: null,
385
495
  },
386
496
  ...common,
387
497
  ],
@@ -395,37 +505,37 @@ describe('Convert', () => {
395
505
  name: 'Zero (number)',
396
506
  input: 0,
397
507
  success: true,
398
- output: Numeric.KEY_1
508
+ output: Numeric.KEY_1,
399
509
  },
400
510
  {
401
511
  name: 'Zero (string)',
402
512
  input: '0',
403
513
  success: true,
404
- output: Numeric.KEY_1
514
+ output: Numeric.KEY_1,
405
515
  },
406
516
  {
407
517
  name: 'One (number)',
408
518
  input: 1,
409
519
  success: true,
410
- output: Numeric.KEY_2
520
+ output: Numeric.KEY_2,
411
521
  },
412
522
  {
413
523
  name: 'One (number)',
414
524
  input: '1',
415
525
  success: true,
416
- output: Numeric.KEY_2
526
+ output: Numeric.KEY_2,
417
527
  },
418
528
  {
419
529
  name: 'KEY_1',
420
530
  input: 'KEY_1',
421
531
  success: true,
422
- output: Numeric.KEY_1
532
+ output: Numeric.KEY_1,
423
533
  },
424
534
  {
425
535
  name: 'KEY_2',
426
536
  input: 'KEY_2',
427
537
  success: true,
428
- output: Numeric.KEY_2
538
+ output: Numeric.KEY_2,
429
539
  },
430
540
 
431
541
  // Negative
@@ -433,16 +543,16 @@ describe('Convert', () => {
433
543
  name: 'null',
434
544
  input: null,
435
545
  success: false,
436
- output: null
546
+ output: null,
437
547
  },
438
548
  {
439
549
  name: 'undefined',
440
550
  input: undefined,
441
551
  success: false,
442
- output: null
552
+ output: null,
443
553
  },
444
554
  ...common,
445
- ]
555
+ ],
446
556
  },
447
557
  {
448
558
  name: 'Strings',
@@ -453,25 +563,25 @@ describe('Convert', () => {
453
563
  name: 'Zero (string)',
454
564
  input: '0',
455
565
  success: true,
456
- output: Strings.KEY_1
566
+ output: Strings.KEY_1,
457
567
  },
458
568
  {
459
569
  name: 'One (number)',
460
570
  input: '1',
461
571
  success: true,
462
- output: Strings.KEY_2
572
+ output: Strings.KEY_2,
463
573
  },
464
574
  {
465
575
  name: 'KEY_1',
466
576
  input: 'KEY_1',
467
577
  success: true,
468
- output: Strings.KEY_1
578
+ output: Strings.KEY_1,
469
579
  },
470
580
  {
471
581
  name: 'KEY_2',
472
582
  input: 'KEY_2',
473
583
  success: true,
474
- output: Strings.KEY_2
584
+ output: Strings.KEY_2,
475
585
  },
476
586
 
477
587
  // Negative
@@ -479,25 +589,25 @@ describe('Convert', () => {
479
589
  name: 'null',
480
590
  input: null,
481
591
  success: false,
482
- output: null
592
+ output: null,
483
593
  },
484
594
  {
485
595
  name: 'undefined',
486
596
  input: undefined,
487
597
  success: false,
488
- output: null
598
+ output: null,
489
599
  },
490
600
  {
491
601
  name: 'Zero (number)',
492
602
  input: 0,
493
603
  success: false,
494
- output: null
604
+ output: null,
495
605
  },
496
606
  {
497
607
  name: 'One (number)',
498
608
  input: 1,
499
609
  success: false,
500
- output: null
610
+ output: null,
501
611
  },
502
612
  ...common,
503
613
  ],
@@ -511,31 +621,31 @@ describe('Convert', () => {
511
621
  name: 'Zero (string)',
512
622
  input: '0',
513
623
  success: true,
514
- output: Mixed.KEY_1
624
+ output: Mixed.KEY_1,
515
625
  },
516
626
  {
517
627
  name: 'One (number)',
518
628
  input: 1,
519
629
  success: true,
520
- output: Mixed.KEY_2
630
+ output: Mixed.KEY_2,
521
631
  },
522
632
  {
523
633
  name: 'One (number)',
524
634
  input: '1',
525
635
  success: true,
526
- output: Mixed.KEY_2
636
+ output: Mixed.KEY_2,
527
637
  },
528
638
  {
529
639
  name: 'KEY_1',
530
640
  input: 'KEY_1',
531
641
  success: true,
532
- output: Mixed.KEY_1
642
+ output: Mixed.KEY_1,
533
643
  },
534
644
  {
535
645
  name: 'KEY_2',
536
646
  input: 'KEY_2',
537
647
  success: true,
538
- output: Mixed.KEY_2
648
+ output: Mixed.KEY_2,
539
649
  },
540
650
 
541
651
  // Negative
@@ -543,19 +653,19 @@ describe('Convert', () => {
543
653
  name: 'null',
544
654
  input: null,
545
655
  success: false,
546
- output: null
656
+ output: null,
547
657
  },
548
658
  {
549
659
  name: 'undefined',
550
660
  input: undefined,
551
661
  success: false,
552
- output: null
662
+ output: null,
553
663
  },
554
664
  {
555
665
  name: 'Zero (number)',
556
666
  input: 0,
557
667
  success: false,
558
- output: null
668
+ output: null,
559
669
  },
560
670
  ...common,
561
671
  ],
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable unicorn/new-for-builtins */
3
3
  /* eslint-disable prettier/prettier */
4
4
 
5
- import type { Equal, Expect, NotEqual } from "../types/test.utils";
5
+ import type { Equal, Expect, NotEqual } from '../types/test.utils';
6
6
 
7
7
  import { isDefined, isRecord, isUndefined } from './misc';
8
8
 
@@ -18,36 +18,108 @@ describe('misc', () => {
18
18
 
19
19
  const tt: Case[] = [
20
20
  // Positive
21
- { name: 'Correct object (literal)', input: {}, success: true, output: true },
22
- { name: 'Correct object (Object())', input: {}, success: true, output: true },
23
- { name: 'Correct object (new Object())', input: {}, success: true, output: true },
24
- { name: 'Correct object (Object.create())', input: Object.create({}), success: true, output: true },
25
- { name: 'Correct object (Object.assign())', input: Object.assign({}, {}), success: true, output: true },
21
+ {
22
+ name: 'Correct object (literal)',
23
+ input: {},
24
+ success: true,
25
+ output: true,
26
+ },
27
+ {
28
+ name: 'Correct object (Object())',
29
+ input: {},
30
+ success: true,
31
+ output: true,
32
+ },
33
+ {
34
+ name: 'Correct object (new Object())',
35
+ input: {},
36
+ success: true,
37
+ output: true,
38
+ },
39
+ {
40
+ name: 'Correct object (Object.create())',
41
+ input: Object.create({}),
42
+ success: true,
43
+ output: true,
44
+ },
45
+ {
46
+ name: 'Correct object (Object.assign())',
47
+ input: Object.assign({}, {}),
48
+ success: true,
49
+ output: true,
50
+ },
26
51
 
27
52
  {
28
- name: 'Function (declarative)', input: function t(): void {}, success: true, output: false
53
+ name: 'Function (declarative)',
54
+ input: function t(): void {},
55
+ success: true,
56
+ output: false,
29
57
  },
30
- { name: 'new Function() instance', input: new Function(), success: true, output: false },
31
58
  {
59
+ name: 'new Function() instance',
60
+ input: new Function(),
61
+ success: true,
62
+ output: false,
63
+ },
64
+ {
65
+ name: 'Function constructor',
32
66
  // @ts-expect-error synthetic for test
33
- name: 'Function constructor', input: new (function t() {})(), success: true, output: false
67
+ input: new (function t() {})(),
68
+ success: true,
69
+ output: false,
34
70
  },
35
71
  {
36
- name: 'Class', input: class T {}, success: true, output: false
72
+ name: 'Class',
73
+ input: class T {},
74
+ success: true,
75
+ output: false,
37
76
  },
38
77
  {
39
- name: 'Class constructor', input: new (class T {})(), success: true, output: false
78
+ name: 'Class constructor',
79
+ input: new (class T {})(),
80
+ success: true,
81
+ output: false,
40
82
  },
41
83
  { name: 'Array (literal)', input: [], success: true, output: false },
42
- { name: 'Array() instance', input: Array(), success: true, output: false },
84
+ {
85
+ name: 'Array() instance',
86
+ input: Array(),
87
+ success: true,
88
+ output: false,
89
+ },
43
90
  { name: 'new Array() instance', input: [], success: true, output: false },
44
- { name: 'The Map (new Map())', input: new Map(), success: true, output: false },
45
- { name: 'The Set (new Set())', input: new Set(), success: true, output: false },
91
+ {
92
+ name: 'The Map (new Map())',
93
+ input: new Map(),
94
+ success: true,
95
+ output: false,
96
+ },
97
+ {
98
+ name: 'The Set (new Set())',
99
+ input: new Set(),
100
+ success: true,
101
+ output: false,
102
+ },
46
103
  { name: 'Date object', input: new Date(), success: true, output: false },
47
- { name: 'String oject', input: String('str'), success: true, output: false },
104
+ {
105
+ name: 'String oject',
106
+ input: String('str'),
107
+ success: true,
108
+ output: false,
109
+ },
48
110
  { name: 'Number object', input: Number(1), success: true, output: false },
49
- { name: 'Boolean object', input: Boolean(true), success: true, output: false },
50
- { name: 'BigInt', input: BigInt(999999999999), success: true, output: false },
111
+ {
112
+ name: 'Boolean object',
113
+ input: Boolean(true),
114
+ success: true,
115
+ output: false,
116
+ },
117
+ {
118
+ name: 'BigInt',
119
+ input: BigInt(999999999999),
120
+ success: true,
121
+ output: false,
122
+ },
51
123
  { name: 'Symbol', input: Symbol(), success: true, output: false },
52
124
  { name: 'null', input: null, success: true, output: false },
53
125
  { name: 'undefined', input: undefined, success: true, output: false },
@@ -56,87 +128,79 @@ describe('misc', () => {
56
128
  { name: 'string', input: 'str', success: true, output: false },
57
129
  ];
58
130
 
59
- for (const {
60
- name,
61
- input,
62
- success,
63
- output
64
- } of tt) {
131
+ for (const { name, input, success, output } of tt) {
65
132
  if (success) {
66
- it(name, () => expect(isRecord(input))
67
- .toBe(output));
133
+ it(name, () => expect(isRecord(input)).toBe(output));
68
134
  } else {
69
- it(name, () => expect(() => isRecord(input))
70
- .toThrow());
135
+ it(name, () => expect(() => isRecord(input)).toThrow());
71
136
  }
72
137
  }
73
138
  });
74
139
 
75
- describe('isUndefined', ()=>{
140
+ describe('isUndefined', () => {
141
+ it('should true', () => {
142
+ const v: undefined | 1 = undefined;
76
143
 
77
- it('should true', ()=>{
78
- const v: undefined | 1 = undefined
79
-
80
- expect(isUndefined(v)).toBe(true)
144
+ expect(isUndefined(v)).toBe(true);
81
145
  if (!isUndefined(v)) {
82
146
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
147
  // @ts-expect-error typecheck
84
- type _ = Expect<Equal<typeof v, 1>>
85
- return
148
+ type _ = Expect<Equal<typeof v, 1>>;
149
+ return;
86
150
  }
87
151
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
88
- type _ = Expect<Equal<typeof v, undefined>>
89
- })
90
- it('should false', ()=>{
91
- const v: "" | undefined = '' as const
152
+ type _ = Expect<Equal<typeof v, undefined>>;
153
+ });
154
+ it('should false', () => {
155
+ const v: '' | undefined = '' as const;
92
156
 
93
- expect(isUndefined(v)).toBe(false)
157
+ expect(isUndefined(v)).toBe(false);
94
158
 
95
159
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
96
160
  // @ts-expect-error typecheck
97
- type _ = Expect<Equal<typeof v, undefined | ''>>
161
+ type _ = Expect<Equal<typeof v, undefined | ''>>;
98
162
  if (isUndefined(v)) {
99
163
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
164
  // @ts-expect-error typecheck
101
- type _ = Expect<Equal<typeof v, undefined>>
165
+ type _ = Expect<Equal<typeof v, undefined>>;
102
166
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
103
- type __ = Expect<NotEqual<typeof v, ''>>
167
+ type __ = Expect<NotEqual<typeof v, ''>>;
104
168
  }
105
169
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
106
- type __ = Expect<Equal<typeof v, ''>>
107
- })
108
- })
109
- describe('isDefined', ()=>{
110
- it('should true', ()=>{
111
- const v = '' as undefined | ''
170
+ type __ = Expect<Equal<typeof v, ''>>;
171
+ });
172
+ });
173
+ describe('isDefined', () => {
174
+ it('should true', () => {
175
+ const v = '' as undefined | '';
112
176
 
113
- expect(isDefined(v)).toBe(true)
177
+ expect(isDefined(v)).toBe(true);
114
178
  if (isDefined(v)) {
115
179
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
180
  type _ = [
117
181
  Expect<Equal<typeof v, ''>>,
118
- Expect<NotEqual<typeof v, undefined>>
119
- ]
120
- return
182
+ Expect<NotEqual<typeof v, undefined>>,
183
+ ];
184
+ return;
121
185
  }
122
- type __ = Expect<Equal<typeof v, undefined>>
123
- })
124
- it('should false', ()=>{
125
- const v = undefined as 1 | undefined
186
+ type __ = Expect<Equal<typeof v, undefined>>;
187
+ });
188
+ it('should false', () => {
189
+ const v = undefined as 1 | undefined;
126
190
 
127
- expect(isDefined(v)).toBe(false)
191
+ expect(isDefined(v)).toBe(false);
128
192
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
129
- type _ = Expect<NotEqual<typeof v, 1>>
193
+ type _ = Expect<NotEqual<typeof v, 1>>;
130
194
  if (isDefined(v)) {
131
195
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
132
196
  type _ = [
133
197
  Expect<Equal<typeof v, 1>>,
134
- Expect<NotEqual<typeof v, undefined>>
135
- ]
136
- return
198
+ Expect<NotEqual<typeof v, undefined>>,
199
+ ];
200
+ return;
137
201
  }
138
202
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
139
- type __ = Expect<Equal<typeof v, undefined>>
140
- })
141
- })
203
+ type __ = Expect<Equal<typeof v, undefined>>;
204
+ });
205
+ });
142
206
  });
@@ -16,20 +16,48 @@ describe('Size', () => {
16
16
 
17
17
  const tt: TestCase[] = [
18
18
  // GB
19
- { name: '1gb', s: new Size(1, 'gb'), gb: 1, mb: 1_024, kb: 1_048_576, b: 1_073_741_824 },
20
- { name: '2gb', s: new Size(2, 'gb'), gb: 2, mb: 2_048, kb: 2_097_152, b: 2_147_483_648 },
19
+ {
20
+ name: '1gb',
21
+ s: new Size(1, 'gb'),
22
+ gb: 1,
23
+ mb: 1_024,
24
+ kb: 1_048_576,
25
+ b: 1_073_741_824,
26
+ },
27
+ {
28
+ name: '2gb',
29
+ s: new Size(2, 'gb'),
30
+ gb: 2,
31
+ mb: 2_048,
32
+ kb: 2_097_152,
33
+ b: 2_147_483_648,
34
+ },
21
35
 
22
36
  // MB
23
- { name: '1mb', s: new Size(1, 'mb'), gb: 0.001, mb: 1, kb: 1_024, b: 1_048_576 },
24
- { name: '2mb', s: new Size(2, 'mb'), gb: 0.002, mb: 2, kb: 2_048, b: 2_097_152 },
37
+ {
38
+ name: '1mb',
39
+ s: new Size(1, 'mb'),
40
+ gb: 0.001,
41
+ mb: 1,
42
+ kb: 1_024,
43
+ b: 1_048_576,
44
+ },
45
+ {
46
+ name: '2mb',
47
+ s: new Size(2, 'mb'),
48
+ gb: 0.002,
49
+ mb: 2,
50
+ kb: 2_048,
51
+ b: 2_097_152,
52
+ },
25
53
 
26
54
  // KB
27
- { name: '1kb', s: new Size(1, 'kb'), gb: 0, mb: 0.001, kb: 1, b: 1_024 },
28
- { name: '2kb', s: new Size(2, 'kb'), gb: 0, mb: 0.002, kb: 2, b: 2_048 },
55
+ { name: '1kb', s: new Size(1, 'kb'), gb: 0, mb: 0.001, kb: 1, b: 1_024 },
56
+ { name: '2kb', s: new Size(2, 'kb'), gb: 0, mb: 0.002, kb: 2, b: 2_048 },
29
57
 
30
58
  // Bytes
31
- { name: '1b', s: new Size(1, 'b'), gb: 0, mb: 0, kb: 0.001, b: 1 },
32
- { name: '2b', s: new Size(2, 'b'), gb: 0, mb: 0, kb: 0.002, b: 2 },
59
+ { name: '1b', s: new Size(1, 'b'), gb: 0, mb: 0, kb: 0.001, b: 1 },
60
+ { name: '2b', s: new Size(2, 'b'), gb: 0, mb: 0, kb: 0.002, b: 2 },
33
61
  ];
34
62
 
35
63
  for (const { name, s, b, kb, mb, gb } of tt) {
@@ -53,11 +81,11 @@ describe('Size', () => {
53
81
  }
54
82
 
55
83
  const tt: TestCase[] = [
56
- { str: '1gb', correct: true, bytes: 1_073_741_824 },
57
- { str: '1mb', correct: true, bytes: 1_048_576 },
58
- { str: '1kb', correct: true, bytes: 1_024 },
59
- { str: '1b', correct: true, bytes: 1 },
60
- { str: '1tb', correct: false, bytes: null },
84
+ { str: '1gb', correct: true, bytes: 1_073_741_824 },
85
+ { str: '1mb', correct: true, bytes: 1_048_576 },
86
+ { str: '1kb', correct: true, bytes: 1_024 },
87
+ { str: '1b', correct: true, bytes: 1 },
88
+ { str: '1tb', correct: false, bytes: null },
61
89
  { str: 'Size', correct: false, bytes: null },
62
90
  ];
63
91
 
@@ -18,24 +18,104 @@ describe('Timespan', () => {
18
18
 
19
19
  const tt: TestCase[] = [
20
20
  // Days
21
- { name: '1d', t: new Timespan(1, 'd'), d: 1, h: 24, m: 1_440, s: 86_400, ms: 86_400_000 },
22
- { name: '2d', t: new Timespan(2, 'd'), d: 2, h: 48, m: 2_880, s: 172_800, ms: 172_800_000 },
21
+ {
22
+ name: '1d',
23
+ t: new Timespan(1, 'd'),
24
+ d: 1,
25
+ h: 24,
26
+ m: 1_440,
27
+ s: 86_400,
28
+ ms: 86_400_000,
29
+ },
30
+ {
31
+ name: '2d',
32
+ t: new Timespan(2, 'd'),
33
+ d: 2,
34
+ h: 48,
35
+ m: 2_880,
36
+ s: 172_800,
37
+ ms: 172_800_000,
38
+ },
23
39
 
24
40
  // Hours
25
- { name: '1h', t: new Timespan(1, 'h'), d: 0.042, h: 1, m: 60, s: 3_600, ms: 3_600_000 },
26
- { name: '2h', t: new Timespan(2, 'h'), d: 0.083, h: 2, m: 120, s: 7_200, ms: 7_200_000 },
41
+ {
42
+ name: '1h',
43
+ t: new Timespan(1, 'h'),
44
+ d: 0.042,
45
+ h: 1,
46
+ m: 60,
47
+ s: 3_600,
48
+ ms: 3_600_000,
49
+ },
50
+ {
51
+ name: '2h',
52
+ t: new Timespan(2, 'h'),
53
+ d: 0.083,
54
+ h: 2,
55
+ m: 120,
56
+ s: 7_200,
57
+ ms: 7_200_000,
58
+ },
27
59
 
28
60
  // Minutes
29
- { name: '1m', t: new Timespan(1, 'm'), d: 0.001, h: 0.017, m: 1, s: 60, ms: 60_000 },
30
- { name: '2m', t: new Timespan(2, 'm'), d: 0.001, h: 0.033, m: 2, s: 120, ms: 120_000 },
61
+ {
62
+ name: '1m',
63
+ t: new Timespan(1, 'm'),
64
+ d: 0.001,
65
+ h: 0.017,
66
+ m: 1,
67
+ s: 60,
68
+ ms: 60_000,
69
+ },
70
+ {
71
+ name: '2m',
72
+ t: new Timespan(2, 'm'),
73
+ d: 0.001,
74
+ h: 0.033,
75
+ m: 2,
76
+ s: 120,
77
+ ms: 120_000,
78
+ },
31
79
 
32
80
  // Seconds
33
- { name: '1s', t: new Timespan(1, 's'), d: 0, h: 0, m: 0.017, s: 1, ms: 1_000 },
34
- { name: '2s', t: new Timespan(2, 's'), d: 0, h: 0.001, m: 0.033, s: 2, ms: 2_000 },
81
+ {
82
+ name: '1s',
83
+ t: new Timespan(1, 's'),
84
+ d: 0,
85
+ h: 0,
86
+ m: 0.017,
87
+ s: 1,
88
+ ms: 1_000,
89
+ },
90
+ {
91
+ name: '2s',
92
+ t: new Timespan(2, 's'),
93
+ d: 0,
94
+ h: 0.001,
95
+ m: 0.033,
96
+ s: 2,
97
+ ms: 2_000,
98
+ },
35
99
 
36
100
  // Milliseconds
37
- { name: '1ms', t: new Timespan(1, 'ms'), d: 0, h: 0, m: 0, s: 0.001, ms: 1 },
38
- { name: '2ms', t: new Timespan(2, 'ms'), d: 0, h: 0, m: 0, s: 0.002, ms: 2 },
101
+ {
102
+ name: '1ms',
103
+ t: new Timespan(1, 'ms'),
104
+ d: 0,
105
+ h: 0,
106
+ m: 0,
107
+ s: 0.001,
108
+ ms: 1,
109
+ },
110
+ {
111
+ name: '2ms',
112
+ t: new Timespan(2, 'ms'),
113
+ d: 0,
114
+ h: 0,
115
+ m: 0,
116
+ s: 0.002,
117
+ ms: 2,
118
+ },
39
119
  ];
40
120
 
41
121
  it.each(tt)('$name', ({ t, d, m, s, ms, h }) => {
@@ -58,14 +138,14 @@ describe('Timespan', () => {
58
138
  }
59
139
 
60
140
  const tt: TestCase[] = [
61
- { str: '1d', correct: true, ms: 86_400_000 },
62
- { str: '1h', correct: true, ms: 3_600_000 },
63
- { str: '1m', correct: true, ms: 60_000 },
64
- { str: '1s', correct: true, ms: 1_000 },
141
+ { str: '1d', correct: true, ms: 86_400_000 },
142
+ { str: '1h', correct: true, ms: 3_600_000 },
143
+ { str: '1m', correct: true, ms: 60_000 },
144
+ { str: '1s', correct: true, ms: 1_000 },
65
145
  { str: '0.1s', correct: true, ms: 100 },
66
- { str: '-1h', correct: true, ms: -3_600_000 },
67
- { str: '1ms', correct: true, ms: 1 },
68
- { str: '1me', correct: false, ms: null },
146
+ { str: '-1h', correct: true, ms: -3_600_000 },
147
+ { str: '1ms', correct: true, ms: 1 },
148
+ { str: '1me', correct: false, ms: null },
69
149
  { str: 'Time', correct: false, ms: null },
70
150
  ];
71
151
 
@@ -86,14 +166,18 @@ describe('Timespan', () => {
86
166
  }
87
167
 
88
168
  const tt: TestCase[] = [
89
- { timespan: new Timespan(1, 'd'), useUnit: undefined, expected: '1d' },
90
- { timespan: new Timespan(1, 'h'), useUnit: undefined, expected: '1h', },
91
- { timespan: new Timespan(1, 'm'), useUnit: undefined, expected: '1m', },
92
- { timespan: new Timespan(1, 's'), useUnit: undefined, expected: '1s', },
93
- { timespan: new Timespan(0.1, 's'), useUnit: undefined, expected: '0.1s', },
94
- { timespan: new Timespan(-1, 'h'), useUnit: undefined, expected: '-1h', },
95
- { timespan: new Timespan(1, 'ms'), useUnit: undefined, expected: '1ms', },
96
- { timespan: new Timespan(10, 'ms'), useUnit: 's', expected: '0.01s' },
169
+ { timespan: new Timespan(1, 'd'), useUnit: undefined, expected: '1d' },
170
+ { timespan: new Timespan(1, 'h'), useUnit: undefined, expected: '1h' },
171
+ { timespan: new Timespan(1, 'm'), useUnit: undefined, expected: '1m' },
172
+ { timespan: new Timespan(1, 's'), useUnit: undefined, expected: '1s' },
173
+ {
174
+ timespan: new Timespan(0.1, 's'),
175
+ useUnit: undefined,
176
+ expected: '0.1s',
177
+ },
178
+ { timespan: new Timespan(-1, 'h'), useUnit: undefined, expected: '-1h' },
179
+ { timespan: new Timespan(1, 'ms'), useUnit: undefined, expected: '1ms' },
180
+ { timespan: new Timespan(10, 'ms'), useUnit: 's', expected: '0.01s' },
97
181
  ];
98
182
 
99
183
  it.each(tt)('$expected', ({ expected, useUnit, timespan }) => {