@sswroom/sswr 1.6.12 → 1.6.14

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/data.js CHANGED
@@ -10,16 +10,26 @@ export const Weekday = {
10
10
  Saturday: 6
11
11
  }
12
12
 
13
+ /**
14
+ * @param {any} o
15
+ */
13
16
  export function isArray(o)
14
17
  {
15
18
  return o != null && o.constructor === Array;
16
19
  }
17
20
 
21
+ /**
22
+ * @param {any} o
23
+ */
18
24
  export function isObject(o)
19
25
  {
20
26
  return o != null && (typeof o) == "object";
21
27
  }
22
28
 
29
+ /**
30
+ * @param {string} o
31
+ * @param {number} lev
32
+ */
23
33
  export function toObjectString(o, lev)
24
34
  {
25
35
  if (lev && lev > 8)
@@ -42,6 +52,7 @@ export function toObjectString(o, lev)
42
52
  {
43
53
  out = new Array();
44
54
  out.push("[");
55
+ // @ts-ignore
45
56
  for (name in o)
46
57
  {
47
58
  out.push(toObjectString(o[name], nextLev));
@@ -55,6 +66,7 @@ export function toObjectString(o, lev)
55
66
  {
56
67
  out = new Array();
57
68
  out.push("{");
69
+ // @ts-ignore
58
70
  for (name in o)
59
71
  {
60
72
  out.push(text.toJSText(name));
@@ -85,11 +97,18 @@ export function toObjectString(o, lev)
85
97
  }
86
98
  }
87
99
 
100
+ /**
101
+ * @param {Iterable<number>} buff
102
+ */
88
103
  export function arrayBuffer2Base64(buff)
89
104
  {
90
105
  return btoa(String.fromCharCode.apply(null, new Uint8Array(buff)));
91
106
  }
92
107
 
108
+ /**
109
+ * @param {Iterable<number>} buff1
110
+ * @param {Iterable<number>} buff2
111
+ */
93
112
  export function arrayBufferEquals(buff1, buff2)
94
113
  {
95
114
  let arr1 = new Uint8Array(buff1);
@@ -107,6 +126,10 @@ export function arrayBufferEquals(buff1, buff2)
107
126
  return true;
108
127
  }
109
128
 
129
+ /**
130
+ * @param {string | number | null} a
131
+ * @param {string | number | null} b
132
+ */
110
133
  export function compare(a, b)
111
134
  {
112
135
  if (a == b)
@@ -115,12 +138,11 @@ export function compare(a, b)
115
138
  return -1;
116
139
  if (b == null)
117
140
  return 1;
118
- let ta = typeof a;
119
- if (ta == "string")
141
+ if (typeof a == "string" && typeof b == "string")
120
142
  {
121
143
  return a.localeCompare(b);
122
144
  }
123
- else if (ta == "number")
145
+ else if (typeof a == "number" && typeof b == "number")
124
146
  {
125
147
  if (a > b)
126
148
  return 1;
@@ -129,12 +151,15 @@ export function compare(a, b)
129
151
  else
130
152
  return 0;
131
153
  }
132
- else if (ta == "object")
154
+ else if (typeof a == "object" && typeof b == "object")
133
155
  {
156
+ // @ts-ignore
134
157
  if (a.compareTo)
135
158
  {
159
+ // @ts-ignore
136
160
  return a.compareTo(b);
137
161
  }
162
+ // @ts-ignore
138
163
  return a.toString().localeCompare(b.toString());
139
164
  }
140
165
  else
@@ -143,6 +168,12 @@ export function compare(a, b)
143
168
  }
144
169
  }
145
170
 
171
+ /**
172
+ * @param {any[]} arr
173
+ * @param {((a: any, b: any) => number) | null} compareFunc
174
+ * @param {number | null} firstIndex
175
+ * @param {number | null} lastIndex
176
+ */
146
177
  export function sort(arr, compareFunc, firstIndex, lastIndex)
147
178
  {
148
179
  let levi = new Array();
@@ -264,6 +295,10 @@ export function sort(arr, compareFunc, firstIndex, lastIndex)
264
295
  }
265
296
  }
266
297
 
298
+ /**
299
+ * @param {{ [x: string]: any; } | null} options
300
+ * @param {{ [x: string]: any; }} defOptions
301
+ */
267
302
  export function mergeOptions(options, defOptions)
268
303
  {
269
304
  if (options == null)
@@ -277,21 +312,37 @@ export function mergeOptions(options, defOptions)
277
312
  return options;
278
313
  }
279
314
 
315
+ /**
316
+ * @param {Uint8Array} arr
317
+ * @param {number} index
318
+ */
280
319
  export function readUInt16(arr, index)
281
320
  {
282
321
  return arr[index] | (arr[index + 1] << 8);
283
322
  }
284
323
 
324
+ /**
325
+ * @param {Uint8Array} arr
326
+ * @param {number} index
327
+ */
285
328
  export function readMUInt16(arr, index)
286
329
  {
287
330
  return arr[index + 1] | (arr[index + 0] << 8);
288
331
  }
289
332
 
333
+ /**
334
+ * @param {Uint8Array} arr
335
+ * @param {number} index
336
+ */
290
337
  export function readUInt24(arr, index)
291
338
  {
292
339
  return arr[index] | (arr[index + 1] << 8) | (arr[index + 2] << 16);
293
340
  }
294
341
 
342
+ /**
343
+ * @param {Uint8Array} arr
344
+ * @param {number} index
345
+ */
295
346
  export function readMUInt24(arr, index)
296
347
  {
297
348
  return arr[index + 2] | (arr[index + 1] << 8) | (arr[index + 0] << 16);
@@ -337,6 +388,10 @@ export function readMUInt64(arr, index)
337
388
  return (BigInt(readUInt32(arr, index)) << 32n) + BigInt(readUInt32(arr, index + 4));
338
389
  }
339
390
 
391
+ /**
392
+ * @param {number} v
393
+ * @param {number} n
394
+ */
340
395
  export function rol32(v, n)
341
396
  {
342
397
  if (n == 0)
@@ -344,6 +399,10 @@ export function rol32(v, n)
344
399
  return ((v << n) | ((v >> 1) & 0x7fffffff) >> (31 - n));
345
400
  }
346
401
 
402
+ /**
403
+ * @param {number} v
404
+ * @param {number} n
405
+ */
347
406
  export function ror32(v, n)
348
407
  {
349
408
  if (n == 0)
@@ -351,16 +410,28 @@ export function ror32(v, n)
351
410
  return ((v << (32 - n)) | ((v >> 1) & 0x7fffffff) >> (n - 1));
352
411
  }
353
412
 
413
+ /**
414
+ * @param {number} v
415
+ * @param {number} n
416
+ */
354
417
  export function shl32(v, n)
355
418
  {
356
419
  return v << n;
357
420
  }
358
421
 
422
+ /**
423
+ * @param {number} v
424
+ * @param {number} n
425
+ */
359
426
  export function sar32(v, n)
360
427
  {
361
428
  return v >> n;
362
429
  }
363
430
 
431
+ /**
432
+ * @param {number} v
433
+ * @param {number} n
434
+ */
364
435
  export function shr32(v, n)
365
436
  {
366
437
  if (n == 0)
@@ -368,6 +439,10 @@ export function shr32(v, n)
368
439
  return ((v >> 1) & 0x7fffffff) >> (n - 1);
369
440
  }
370
441
 
442
+ /**
443
+ * @param {{ [x: string]: any; }} o
444
+ * @param {{ [x: string]: string; }} items
445
+ */
371
446
  export function objectParseTS(o, items)
372
447
  {
373
448
  let item;
@@ -375,7 +450,7 @@ export function objectParseTS(o, items)
375
450
  {
376
451
  if (o[items[item]] && typeof o[items[item]] == "string")
377
452
  {
378
- o[items[item]] = Timestamp.fromStr(o[items[item]]);
453
+ o[items[item]] = Timestamp.fromStr(o[items[item]], null);
379
454
  }
380
455
  }
381
456
  }
@@ -407,11 +482,15 @@ export class DateTimeUtil
407
482
  {
408
483
  static monString = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
409
484
  static monthString = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
485
+ /**
486
+ * @param {TimeValue} t
487
+ * @param {string[]} dateStrs
488
+ */
410
489
  static dateValueSetDate(t, dateStrs)
411
490
  {
412
- let vals0 = dateStrs[0] - 0;
413
- let vals1 = dateStrs[1] - 0;
414
- let vals2 = dateStrs[2] - 0;
491
+ let vals0 = Number(dateStrs[0]);
492
+ let vals1 = Number(dateStrs[1]);
493
+ let vals2 = Number(dateStrs[2]);
415
494
  if (vals0 > 100)
416
495
  {
417
496
  t.year = vals0;
@@ -446,57 +525,66 @@ export class DateTimeUtil
446
525
  }
447
526
  }
448
527
 
528
+ /**
529
+ * @param {TimeValue} t
530
+ * @param {string[]} timeStrs
531
+ */
449
532
  static timeValueSetTime(t, timeStrs)
450
533
  {
451
534
  let strs;
452
535
 
453
- t.hour = timeStrs[0] - 0;
454
- t.minute = timeStrs[1] - 0;
536
+ t.hour = Number(timeStrs[0]);
537
+ t.minute = Number(timeStrs[1]);
455
538
  strs = timeStrs[2].split('.');
456
539
  if (strs.length == 1)
457
540
  {
458
- t.second = strs[0] - 0;
541
+ t.second = Number(strs[0]);
459
542
  t.nanosec = 0;
460
543
  }
461
544
  else
462
545
  {
463
- t.second = strs[0] - 0;
546
+ t.second = Number(strs[0]);
464
547
  switch (strs[1].length)
465
548
  {
466
549
  case 0:
467
550
  t.nanosec = 0;
468
551
  break;
469
552
  case 1:
470
- t.nanosec = (strs[1] - 0) * 100000000;
553
+ t.nanosec = Number(strs[1]) * 100000000;
471
554
  break;
472
555
  case 2:
473
- t.nanosec = (strs[1] - 0) * 10000000;
556
+ t.nanosec = Number(strs[1]) * 10000000;
474
557
  break;
475
558
  case 3:
476
- t.nanosec = (strs[1] - 0) * 1000000;
559
+ t.nanosec = Number(strs[1]) * 1000000;
477
560
  break;
478
561
  case 4:
479
- t.nanosec = (strs[1] - 0) * 100000;
562
+ t.nanosec = Number(strs[1]) * 100000;
480
563
  break;
481
564
  case 5:
482
- t.nanosec = (strs[1] - 0) * 10000;
565
+ t.nanosec = Number(strs[1]) * 10000;
483
566
  break;
484
567
  case 6:
485
- t.nanosec = (strs[1] - 0) * 1000;
568
+ t.nanosec = Number(strs[1]) * 1000;
486
569
  break;
487
570
  case 7:
488
- t.nanosec = (strs[1] - 0) * 100;
571
+ t.nanosec = Number(strs[1]) * 100;
489
572
  break;
490
573
  case 8:
491
- t.nanosec = (strs[1] - 0) * 10;
574
+ t.nanosec = Number(strs[1]) * 10;
492
575
  break;
493
576
  default:
494
- t.nanosec = strs[1].substr(0, 9) - 0;
577
+ t.nanosec = Number(strs[1].substring(0, 9));
495
578
  break;
496
579
  }
497
580
  }
498
581
  }
499
582
 
583
+ /**
584
+ * @param {number} year
585
+ * @param {number} month
586
+ * @param {number} day
587
+ */
500
588
  static date2TotalDays(year, month, day)
501
589
  {
502
590
  let totalDays;
@@ -567,31 +655,53 @@ export class DateTimeUtil
567
655
  return totalDays;
568
656
  }
569
657
 
658
+ /**
659
+ * @param {DateValue} d
660
+ */
570
661
  static dateValue2TotalDays(d)
571
662
  {
572
663
  return DateTimeUtil.date2TotalDays(d.year, d.month, d.day);
573
664
  }
574
665
 
666
+ /**
667
+ * @param {TimeValue} tval
668
+ */
575
669
  static timeValue2Secs(tval)
576
670
  {
577
671
  return BigInt(DateTimeUtil.dateValue2TotalDays(tval)) * 86400n + BigInt(tval.second + tval.minute * 60 + tval.hour * 3600 - tval.tzQhr * 900);
578
672
  }
579
673
 
674
+ /**
675
+ * @param {TimeValue} t
676
+ */
580
677
  static timeValue2Ticks(t)
581
678
  {
679
+ // @ts-ignore
582
680
  return DateTimeUtil.timeValue2Secs(t) * 1000n + BigInt(Math.floor(t.nanosec / 1000000));
583
681
  }
584
682
 
683
+ /**
684
+ * @param {number} ticks
685
+ * @param {number} tzQhr
686
+ */
585
687
  static ticks2TimeValue(ticks, tzQhr)
586
688
  {
587
689
  return DateTimeUtil.instant2TimeValue(ticks / 1000, (ticks % 1000) * 1000000, tzQhr);
588
690
  }
589
691
 
692
+ /**
693
+ * @param {any} secs
694
+ * @param {number} tzQhr
695
+ */
590
696
  static secs2TimeValue(secs, tzQhr)
591
697
  {
592
698
  return DateTimeUtil.instant2TimeValue(secs, 0, tzQhr);
593
699
  }
594
700
 
701
+ /**
702
+ * @param {number | bigint} totalDays
703
+ * @param {DateValue} t
704
+ */
595
705
  static totalDays2DateValue(totalDays, t)
596
706
  {
597
707
  totalDays = BigInt(totalDays);
@@ -831,6 +941,11 @@ export class DateTimeUtil
831
941
  }
832
942
  }
833
943
 
944
+ /**
945
+ * @param {string | number | bigint | boolean} secs
946
+ * @param {number} nanosec
947
+ * @param {number | null} tzQhr
948
+ */
834
949
  static instant2TimeValue(secs, nanosec, tzQhr)
835
950
  {
836
951
  if (tzQhr == null)
@@ -864,6 +979,10 @@ export class DateTimeUtil
864
979
  return t;
865
980
  }
866
981
 
982
+ /**
983
+ * @param {number} ticks
984
+ * @param {number} tzQhr
985
+ */
867
986
  static ticks2Weekday(ticks, tzQhr)
868
987
  {
869
988
  let days = ((ticks + tzQhr * 900000) / 86400000 + 4);
@@ -877,6 +996,10 @@ export class DateTimeUtil
877
996
  }
878
997
  }
879
998
 
999
+ /**
1000
+ * @param {TimeValue} tval
1001
+ * @param {string} pattern
1002
+ */
880
1003
  static toString(tval, pattern)
881
1004
  {
882
1005
  let output = new Array();
@@ -1236,6 +1359,10 @@ export class DateTimeUtil
1236
1359
  return output.join("");
1237
1360
  }
1238
1361
 
1362
+ /**
1363
+ * @param {string} dateStr
1364
+ * @param {number | null|undefined} tzQhr
1365
+ */
1239
1366
  static string2TimeValue(dateStr, tzQhr)
1240
1367
  {
1241
1368
  if (dateStr.length < 4)
@@ -1286,19 +1413,19 @@ export class DateTimeUtil
1286
1413
  if (i != -1)
1287
1414
  {
1288
1415
  let c = strs2[1].charAt(i);
1289
- let tz = strs2[1].substr(i + 1);
1416
+ let tz = strs2[1].substring(i + 1);
1290
1417
  if (tz.length == 5)
1291
1418
  {
1292
- let min = strs2[1].substr(i + 4) - 0;
1419
+ let min = Number(strs2[1].substring(i + 4));
1293
1420
  if (tz.charAt(2) == ':')
1294
1421
  {
1295
- tz = tz.substr(0, 2);
1422
+ tz = tz.substring(0, 2);
1296
1423
  }
1297
1424
  else
1298
1425
  {
1299
- tz = tz.substr(0, 3);
1426
+ tz = tz.substring(0, 3);
1300
1427
  }
1301
- min = min + (tz - 0) * 60;
1428
+ min = min + Number(tz) * 60;
1302
1429
  if (c == '-')
1303
1430
  {
1304
1431
  tval.tzQhr = -min / 15;
@@ -1312,21 +1439,21 @@ export class DateTimeUtil
1312
1439
  {
1313
1440
  if (c == '-')
1314
1441
  {
1315
- tval.tzQhr = -(tz - 0) * 4;
1442
+ tval.tzQhr = -Number(tz) * 4;
1316
1443
  }
1317
1444
  else
1318
1445
  {
1319
- tval.tzQhr = (tz - 0) * 4;
1446
+ tval.tzQhr = Number(tz) * 4;
1320
1447
  }
1321
1448
  }
1322
- strs2[1] = strs2.substr(0, i);
1449
+ strs2[1] = strs2[1].substring(0, i);
1323
1450
  }
1324
1451
  if ((strs = strs2[1].split(':')).length == 3)
1325
1452
  {
1326
1453
  if (strs[2].endsWith('Z'))
1327
1454
  {
1328
1455
  tval.tzQhr = 0;
1329
- strs[2] = strs[2].substr(0, strs[2].length - 1);
1456
+ strs[2] = strs[2].substring(0, strs[2].length - 1);
1330
1457
  }
1331
1458
  DateTimeUtil.timeValueSetTime(tval, strs);
1332
1459
  }
@@ -1381,19 +1508,19 @@ export class DateTimeUtil
1381
1508
  {
1382
1509
  tval.year = DateTimeUtil.parseYearStr(strs2[2]);
1383
1510
  tval.month = DateTimeUtil.parseMonthStr(strs2[0]);
1384
- tval.day = strs2[1] - 0;
1511
+ tval.day = Number(strs2[1]);
1385
1512
  }
1386
1513
  else if (len1 <= 2 && len2 == 3 && len3 == 4)
1387
1514
  {
1388
1515
  tval.year = DateTimeUtil.parseYearStr(strs2[2]);
1389
1516
  tval.month = DateTimeUtil.parseMonthStr(strs2[1]);
1390
- tval.day = strs2[0] - 0;
1517
+ tval.day = Number(strs2[0]);
1391
1518
  }
1392
1519
  else if (len1 == 3 && len2 <= 2 && len4 == 4)
1393
1520
  {
1394
1521
  tval.year = DateTimeUtil.parseYearStr(strs2[3]);
1395
1522
  tval.month = DateTimeUtil.parseMonthStr(strs2[0]);
1396
- tval.day = strs2[1] - 0;
1523
+ tval.day = Number(strs2[1]);
1397
1524
  timeStr = strs2[2];
1398
1525
  }
1399
1526
  else
@@ -1417,16 +1544,16 @@ export class DateTimeUtil
1417
1544
  }
1418
1545
  else if (strs2[4].length == 5)
1419
1546
  {
1420
- let min = strs2[4].substr(3) - 0;
1547
+ let min = Number(strs2[4].substring(3));
1421
1548
  if (strs2[4].charAt(2) == ':')
1422
1549
  {
1423
- strs2[4] = strs2[4].substr(0, 2);
1550
+ strs2[4] = strs2[4].substring(0, 2);
1424
1551
  }
1425
1552
  else
1426
1553
  {
1427
- strs2[4] = strs2[4].substr(0, 3);
1554
+ strs2[4] = strs2[4].substring(0, 3);
1428
1555
  }
1429
- min = min + (strs2[4].substr(1) - 0) * 60;
1556
+ min = min + Number(strs2[4].substring(1)) * 60;
1430
1557
  if (strs2[4].charAt(0) == '-')
1431
1558
  {
1432
1559
  tval.tzQhr = (-min / 15);
@@ -1461,26 +1588,26 @@ export class DateTimeUtil
1461
1588
  {
1462
1589
  if ((strs = strs2[j].split(':')).length == 2)
1463
1590
  {
1464
- tval.tzQhr = -(((strs[0].substr(1) - 0) * 4) + (strs[1] - 0) / 15);
1591
+ tval.tzQhr = -((Number(strs[0].substring(1)) * 4) + Number(strs[1]) / 15);
1465
1592
  }
1466
- else if (strs2[j].leng == 5)
1593
+ else if (strs2[j].length == 5)
1467
1594
  {
1468
- tval.tzQhr = (strs2[j].substr(3) - 0) / 15;
1469
- strs2[j] = strs2[j].substr(0, 3);
1470
- tval.tzQhr = -(tval.tzQhr + (strs2[j].substr(1) - 0) * 4);
1595
+ tval.tzQhr = Number(strs2[j].substring(3)) / 15;
1596
+ strs2[j] = strs2[j].substring(0, 3);
1597
+ tval.tzQhr = -(tval.tzQhr + Number(strs2[j].substring(1)) * 4);
1471
1598
  }
1472
1599
  }
1473
1600
  else if (strs2[j].charAt(0) == '+')
1474
1601
  {
1475
1602
  if ((strs = strs2[j].split(':')).length == 2)
1476
1603
  {
1477
- tval.tzQhr = ((strs[0].substr(1) - 0) * 4) + (strs[1] - 0) / 15;
1604
+ tval.tzQhr = (Number(strs[0].substring(1)) * 4) + Number(strs[1]) / 15;
1478
1605
  }
1479
- else if (strs2[j].leng == 5)
1606
+ else if (strs2[j].length == 5)
1480
1607
  {
1481
- tval.tzQhr = (strs2[j].substr(3) - 0) / 15;
1482
- strs2[j] = strs2[j].substr(0, 3);
1483
- tval.tzQhr = (tval.tzQhr + (strs2[j].substr(1) - 0) * 4);
1608
+ tval.tzQhr = Number(strs2[j].substring(3)) / 15;
1609
+ strs2[j] = strs2[j].substring(0, 3);
1610
+ tval.tzQhr = (tval.tzQhr + Number(strs2[j].substring(1)) * 4);
1484
1611
  }
1485
1612
  }
1486
1613
  else
@@ -1503,7 +1630,7 @@ export class DateTimeUtil
1503
1630
  }
1504
1631
  else
1505
1632
  {
1506
- i = strs2[j] - 0;
1633
+ i = Number(strs2[j]);
1507
1634
  if (isNaN(i))
1508
1635
  {
1509
1636
  i = DateTimeUtil.parseMonthStr(strs2[j]);
@@ -1529,6 +1656,9 @@ export class DateTimeUtil
1529
1656
  return tval;
1530
1657
  }
1531
1658
 
1659
+ /**
1660
+ * @param {string | number | bigint | boolean} prmymdhms
1661
+ */
1532
1662
  static timeValueFromYMDHMS(prmymdhms)
1533
1663
  {
1534
1664
  let ymdhms = BigInt(prmymdhms);
@@ -1563,19 +1693,28 @@ export class DateTimeUtil
1563
1693
  return tval;
1564
1694
  }
1565
1695
 
1696
+ /**
1697
+ * @param {number} year
1698
+ */
1566
1699
  static isYearLeap(year)
1567
1700
  {
1568
1701
  return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0);
1569
1702
  }
1570
1703
 
1704
+ /**
1705
+ * @param {string} year
1706
+ */
1571
1707
  static parseYearStr(year)
1572
1708
  {
1573
- let y = year - 0;
1709
+ let y = Number(year);
1574
1710
  if (y > 0)
1575
1711
  return y;
1576
1712
  return y + 1;
1577
1713
  }
1578
1714
 
1715
+ /**
1716
+ * @param {string} month
1717
+ */
1579
1718
  static parseMonthStr(month)
1580
1719
  {
1581
1720
  if (month.length < 3)
@@ -1632,6 +1771,10 @@ export class DateTimeUtil
1632
1771
  return 0;
1633
1772
  }
1634
1773
 
1774
+ /**
1775
+ * @param {number} year
1776
+ * @param {number} month
1777
+ */
1635
1778
  static dayInMonth(year, month)
1636
1779
  {
1637
1780
  while (month < 1)
@@ -1682,16 +1825,33 @@ export class DateTimeUtil
1682
1825
  {
1683
1826
  return new Date().getTimezoneOffset() / -15;
1684
1827
  }
1828
+
1829
+ /**
1830
+ * @param {bigint} secs
1831
+ * @param {number} nanosec
1832
+ */
1833
+ static secs2FILETIME(secs, nanosec)
1834
+ {
1835
+ secs = secs * 10000000n + BigInt(Math.round(nanosec / 100));
1836
+ return secs + 116444736000000000n;
1837
+ }
1685
1838
  }
1686
1839
 
1687
1840
  export class Duration
1688
1841
  {
1842
+ /**
1843
+ * @param {string | number | bigint | boolean} seconds
1844
+ * @param {number} nanosec
1845
+ */
1689
1846
  constructor(seconds, nanosec)
1690
1847
  {
1691
1848
  this.seconds = BigInt(seconds);
1692
1849
  this.nanosec = nanosec;
1693
1850
  }
1694
1851
 
1852
+ /**
1853
+ * @param {number | bigint} ticks
1854
+ */
1695
1855
  static fromTicks(ticks)
1696
1856
  {
1697
1857
  if (ticks < 0)
@@ -1711,6 +1871,9 @@ export class Duration
1711
1871
  }
1712
1872
  }
1713
1873
 
1874
+ /**
1875
+ * @param {number | bigint} us
1876
+ */
1714
1877
  static fromUs(us)
1715
1878
  {
1716
1879
  if (us < 0)
@@ -1807,6 +1970,11 @@ export class LocalDate
1807
1970
  {
1808
1971
  static DATE_NULL = -1234567;
1809
1972
 
1973
+ /**
1974
+ * @param {string | number | null | DateValue} year
1975
+ * @param {number | null | undefined} [month]
1976
+ * @param {number | null | undefined} [day]
1977
+ */
1810
1978
  constructor(year, month, day)
1811
1979
  {
1812
1980
  if (year == null)
@@ -1815,8 +1983,7 @@ export class LocalDate
1815
1983
  }
1816
1984
  else
1817
1985
  {
1818
- let t = typeof year;
1819
- if (t == "number")
1986
+ if (typeof year == "number")
1820
1987
  {
1821
1988
  if (month != null && day != null)
1822
1989
  {
@@ -1827,15 +1994,15 @@ export class LocalDate
1827
1994
  this.dateVal = year;
1828
1995
  }
1829
1996
  }
1830
- else if (t == "string" && text.isInteger(year))
1997
+ else if (typeof year == "string" && text.isInteger(year))
1831
1998
  {
1832
1999
  if (month != null && day != null)
1833
2000
  {
1834
- this.dateVal = DateTimeUtil.date2TotalDays(year - 0, month - 0, day - 0);
2001
+ this.dateVal = DateTimeUtil.date2TotalDays(Number(year), Number(month), Number(day));
1835
2002
  }
1836
2003
  else
1837
2004
  {
1838
- this.dateVal = year;
2005
+ this.dateVal = Number(year);
1839
2006
  }
1840
2007
  }
1841
2008
  else if (year instanceof DateValue)
@@ -1857,6 +2024,11 @@ export class LocalDate
1857
2024
  }
1858
2025
  }
1859
2026
 
2027
+ /**
2028
+ * @param {number} year
2029
+ * @param {number} month
2030
+ * @param {number} day
2031
+ */
1860
2032
  setValue(year, month, day)
1861
2033
  {
1862
2034
  this.dateVal = DateTimeUtil.date2TotalDays(year, month, day);
@@ -1874,6 +2046,9 @@ export class LocalDate
1874
2046
  return this.dateVal;
1875
2047
  }
1876
2048
 
2049
+ /**
2050
+ * @param {number} year
2051
+ */
1877
2052
  setYear(year)
1878
2053
  {
1879
2054
  let d = new DateValue();
@@ -1881,6 +2056,9 @@ export class LocalDate
1881
2056
  this.dateVal = DateTimeUtil.date2TotalDays(year, d.month, d.day);
1882
2057
  }
1883
2058
 
2059
+ /**
2060
+ * @param {number} month
2061
+ */
1884
2062
  setMonth(month)
1885
2063
  {
1886
2064
  let d = new DateValue();
@@ -1888,6 +2066,9 @@ export class LocalDate
1888
2066
  this.dateVal = DateTimeUtil.date2TotalDays(d.year, month, d.day);
1889
2067
  }
1890
2068
 
2069
+ /**
2070
+ * @param {number} day
2071
+ */
1891
2072
  setDay(day)
1892
2073
  {
1893
2074
  let d = new DateValue();
@@ -1907,6 +2088,9 @@ export class LocalDate
1907
2088
  return this.dateVal * 86400000;
1908
2089
  }
1909
2090
 
2091
+ /**
2092
+ * @param {string | null} pattern
2093
+ */
1910
2094
  toString(pattern)
1911
2095
  {
1912
2096
  if (pattern == null)
@@ -1916,14 +2100,17 @@ export class LocalDate
1916
2100
  return DateTimeUtil.toString(t, pattern);
1917
2101
  }
1918
2102
 
2103
+ /**
2104
+ * @param {LocalDate} obj
2105
+ */
1919
2106
  compareTo(obj)
1920
2107
  {
1921
2108
  if (this.dateVal > obj.dateVal)
1922
- return 1;
1923
- else if (this.dateVal < obj.dateVal)
1924
- return -1;
1925
- else
1926
- return 0;
2109
+ return 1;
2110
+ else if (this.dateVal < obj.dateVal)
2111
+ return -1;
2112
+ else
2113
+ return 0;
1927
2114
  }
1928
2115
 
1929
2116
  isNull()
@@ -1942,6 +2129,9 @@ export class LocalDate
1942
2129
  return new LocalDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
1943
2130
  }
1944
2131
 
2132
+ /**
2133
+ * @param {any} s
2134
+ */
1945
2135
  static fromStr(s)
1946
2136
  {
1947
2137
  let timeVal = DateTimeUtil.string2TimeValue(s, 0);
@@ -1955,6 +2145,10 @@ export class LocalDate
1955
2145
 
1956
2146
  export class TimeInstant
1957
2147
  {
2148
+ /**
2149
+ * @param {string | number | bigint | boolean} sec
2150
+ * @param {number} nanosec
2151
+ */
1958
2152
  constructor(sec, nanosec)
1959
2153
  {
1960
2154
  this.sec = BigInt(sec)
@@ -1979,6 +2173,9 @@ export class TimeInstant
1979
2173
  }
1980
2174
  }
1981
2175
 
2176
+ /**
2177
+ * @param {number} variTime
2178
+ */
1982
2179
  static fromVariTime(variTime)
1983
2180
  {
1984
2181
  let days = Math.floor(variTime);
@@ -1987,39 +2184,57 @@ export class TimeInstant
1987
2184
  return new TimeInstant(BigInt(days - 25569) * 86400000n + BigInt(Math.floor(ds * 86400000)), ((ds * 86400 - s) * 1000000000));
1988
2185
  }
1989
2186
 
2187
+ /**
2188
+ * @param {bigint|number} ticks
2189
+ */
1990
2190
  static fromTicks(ticks)
1991
2191
  {
1992
- let ms = (ticks % 1000);
2192
+ let ms = Number(BigInt(ticks) % 1000n);
1993
2193
  if (ms < 0)
1994
2194
  {
1995
- return new TimeInstant(Math.floor(ticks / 1000) - 1, (ms + 1000) * 1000000);
2195
+ return new TimeInstant(Math.floor(Number(ticks) / 1000) - 1, (ms + 1000) * 1000000);
1996
2196
  }
1997
2197
  else
1998
2198
  {
1999
- return new TimeInstant(Math.floor(ticks / 1000), ms * 1000000);
2199
+ return new TimeInstant(Math.floor(Number(ticks) / 1000), ms * 1000000);
2000
2200
  }
2001
2201
  }
2002
2202
 
2203
+ /**
2204
+ * @param {number} val
2205
+ */
2003
2206
  addDay(val)
2004
2207
  {
2005
- return new TimeInstant(this.sec + val * 86400n, this.nanosec);
2208
+ return new TimeInstant(this.sec + BigInt(val) * 86400n, this.nanosec);
2006
2209
  }
2007
2210
 
2211
+ /**
2212
+ * @param {number} val
2213
+ */
2008
2214
  addHour(val)
2009
2215
  {
2010
- return new TimeInstant(this.sec + val * 3600n, this.nanosec);
2216
+ return new TimeInstant(this.sec + BigInt(val) * 3600n, this.nanosec);
2011
2217
  }
2012
2218
 
2219
+ /**
2220
+ * @param {number} val
2221
+ */
2013
2222
  addMinute(val)
2014
2223
  {
2015
- return new TimeInstant(this.sec + val * 60n, this.nanosec);
2224
+ return new TimeInstant(this.sec + BigInt(val) * 60n, this.nanosec);
2016
2225
  }
2017
2226
 
2227
+ /**
2228
+ * @param {number} val
2229
+ */
2018
2230
  addSecond(val)
2019
2231
  {
2020
- return new TimeInstant(this.sec + val, this.nanosec);
2232
+ return new TimeInstant(this.sec + BigInt(val), this.nanosec);
2021
2233
  }
2022
2234
 
2235
+ /**
2236
+ * @param {number} val
2237
+ */
2023
2238
  addMS(val)
2024
2239
  {
2025
2240
  let newSec = this.sec + BigInt(Math.floor(val / 1000));
@@ -2032,6 +2247,9 @@ export class TimeInstant
2032
2247
  return new TimeInstant(newSec, val);
2033
2248
  }
2034
2249
 
2250
+ /**
2251
+ * @param {number} val
2252
+ */
2035
2253
  addNS(val)
2036
2254
  {
2037
2255
  let newSec = this.sec + BigInt(Math.floor(val / 1000000000));
@@ -2071,21 +2289,33 @@ export class TimeInstant
2071
2289
  return Number(this.sec % 86400n) * 1000 + Math.floor(this.nanosec / 1000000);
2072
2290
  }
2073
2291
 
2292
+ /**
2293
+ * @param {TimeInstant} ts
2294
+ */
2074
2295
  diffMS(ts)
2075
2296
  {
2076
2297
  return Number(this.sec - ts.sec) * 1000 + Math.floor((this.nanosec / 1000000) - (ts.nanosec / 1000000));
2077
2298
  }
2078
2299
 
2300
+ /**
2301
+ * @param {TimeInstant} ts
2302
+ */
2079
2303
  diffSec(ts)
2080
2304
  {
2081
2305
  return Number(this.sec - ts.sec);
2082
2306
  }
2083
2307
 
2308
+ /**
2309
+ * @param {TimeInstant} ts
2310
+ */
2084
2311
  diffSecDbl(ts)
2085
2312
  {
2086
2313
  return Number(this.sec - ts.sec) + (this.nanosec - ts.nanosec) / 1000000000.0;
2087
2314
  }
2088
2315
 
2316
+ /**
2317
+ * @param {TimeInstant} ts
2318
+ */
2089
2319
  diff(ts)
2090
2320
  {
2091
2321
  let secs = this.sec - ts.sec;
@@ -2127,6 +2357,14 @@ export class TimeInstant
2127
2357
  return this.sec * 1000000000n + BigInt(this.nanosec);
2128
2358
  }
2129
2359
 
2360
+ toFILETIME()
2361
+ {
2362
+ return DateTimeUtil.secs2FILETIME(this.sec, this.nanosec);
2363
+ }
2364
+
2365
+ /**
2366
+ * @param {number | bigint} ticks
2367
+ */
2130
2368
  static fromDotNetTicks(ticks)
2131
2369
  {
2132
2370
  ticks = BigInt(ticks) - 621355968000000000n;
@@ -2145,6 +2383,10 @@ export class TimeInstant
2145
2383
 
2146
2384
  export class Timestamp
2147
2385
  {
2386
+ /**
2387
+ * @param {TimeInstant} inst
2388
+ * @param {number|null|undefined} tzQhr
2389
+ */
2148
2390
  constructor(inst, tzQhr)
2149
2391
  {
2150
2392
  this.inst = inst;
@@ -2153,11 +2395,19 @@ export class Timestamp
2153
2395
  this.tzQhr = DateTimeUtil.getLocalTzQhr();
2154
2396
  }
2155
2397
 
2398
+ /**
2399
+ * @param {number|bigint} ticks
2400
+ * @param {number|undefined} tzQhr
2401
+ */
2156
2402
  static fromTicks(ticks, tzQhr)
2157
2403
  {
2158
2404
  return new Timestamp(TimeInstant.fromTicks(ticks), tzQhr);
2159
2405
  }
2160
2406
 
2407
+ /**
2408
+ * @param {string} str
2409
+ * @param {number|null|undefined} defTzQhr
2410
+ */
2161
2411
  static fromStr(str, defTzQhr)
2162
2412
  {
2163
2413
  let tval = DateTimeUtil.string2TimeValue(str, defTzQhr);
@@ -2181,60 +2431,95 @@ export class Timestamp
2181
2431
  return new Timestamp(TimeInstant.now(), 0);
2182
2432
  }
2183
2433
 
2434
+ /**
2435
+ * @param {number} variTime
2436
+ */
2184
2437
  static fromVariTime(variTime)
2185
2438
  {
2186
2439
  return new Timestamp(TimeInstant.fromVariTime(variTime), DateTimeUtil.getLocalTzQhr());
2187
2440
  }
2188
2441
 
2442
+ /**
2443
+ * @param {number} unixTS
2444
+ * @param {number} nanosec
2445
+ * @param {number} tzQhr
2446
+ */
2189
2447
  static fromSecNS(unixTS, nanosec, tzQhr)
2190
2448
  {
2191
2449
  return new Timestamp(new TimeInstant(unixTS, nanosec), tzQhr);
2192
2450
  }
2193
2451
 
2452
+ /**
2453
+ * @param {number} ticks
2454
+ * @param {number} tzQhr
2455
+ */
2194
2456
  static fromDotNetTicks(ticks, tzQhr)
2195
2457
  {
2196
2458
  return new Timestamp(TimeInstant.fromDotNetTicks(ticks), tzQhr);
2197
2459
  }
2198
2460
 
2461
+ /**
2462
+ * @param {number|bigint} epochSec
2463
+ * @param {number|undefined} tzQhr
2464
+ */
2199
2465
  static fromEpochSec(epochSec, tzQhr)
2200
2466
  {
2201
2467
  return new Timestamp(new TimeInstant(epochSec, 0), tzQhr);
2202
2468
  }
2203
2469
 
2470
+ /**
2471
+ * @param {number|bigint} epochMS
2472
+ * @param {number|undefined} tzQhr
2473
+ */
2204
2474
  static fromEpochMS(epochMS, tzQhr)
2205
2475
  {
2206
2476
  return Timestamp.fromTicks(epochMS, tzQhr);
2207
2477
  }
2208
2478
 
2479
+ /**
2480
+ * @param {number|bigint} epochUS
2481
+ * @param {number|undefined} tzQhr
2482
+ */
2209
2483
  static fromEpochUS(epochUS, tzQhr)
2210
2484
  {
2211
2485
  if (epochUS < 0)
2212
2486
  {
2213
- return new Timestamp(new TimeInstant(epochUS / 1000000n - 1n, Number(epochUS % 1000000n + 1000000n) * 1000), tzQhr);
2487
+ return new Timestamp(new TimeInstant(BigInt(epochUS) / 1000000n - 1n, Number(BigInt(epochUS) % 1000000n + 1000000n) * 1000), tzQhr);
2214
2488
  }
2215
2489
  else
2216
2490
  {
2217
- return new Timestamp(new TimeInstant(epochUS / 1000000n, Number(epochUS % 1000000n) * 1000), tzQhr);
2491
+ return new Timestamp(new TimeInstant(BigInt(epochUS) / 1000000n, Number(BigInt(epochUS) % 1000000n) * 1000), tzQhr);
2218
2492
  }
2219
2493
  }
2220
2494
 
2495
+ /**
2496
+ * @param {number|bigint} epochNS
2497
+ * @param {number|undefined} tzQhr
2498
+ */
2221
2499
  static fromEpochNS(epochNS, tzQhr)
2222
2500
  {
2223
2501
  if (epochNS < 0)
2224
2502
  {
2225
- return new Timestamp(new TimeInstant(epochNS / 1000000000n - 1n, Number(epochNS % 1000000000n + 1000000000n)), tzQhr);
2503
+ return new Timestamp(new TimeInstant(BigInt(epochNS) / 1000000000n - 1n, Number(BigInt(epochNS) % 1000000000n + 1000000000n)), tzQhr);
2226
2504
  }
2227
2505
  else
2228
2506
  {
2229
- return new Timestamp(new TimeInstant(epochNS / 1000000000n, Number(epochNS % 1000000000n)), tzQhr);
2507
+ return new Timestamp(new TimeInstant(BigInt(epochNS) / 1000000000n, Number(BigInt(epochNS) % 1000000000n)), tzQhr);
2230
2508
  }
2231
2509
  }
2232
2510
 
2511
+ /**
2512
+ * @param {TimeValue} tval
2513
+ */
2233
2514
  static fromTimeValue(tval)
2234
2515
  {
2235
2516
  return new Timestamp(new TimeInstant(DateTimeUtil.timeValue2Secs(tval), tval.nanosec), tval.tzQhr);
2236
2517
  }
2237
2518
 
2519
+ /**
2520
+ * @param {any} ymdhms
2521
+ * @param {number} tzQhr
2522
+ */
2238
2523
  static fromYMDHMS(ymdhms, tzQhr)
2239
2524
  {
2240
2525
  let tval = DateTimeUtil.timeValueFromYMDHMS(ymdhms);
@@ -2248,6 +2533,9 @@ export class Timestamp
2248
2533
  }
2249
2534
  }
2250
2535
 
2536
+ /**
2537
+ * @param {number} val
2538
+ */
2251
2539
  addMonth(val)
2252
2540
  {
2253
2541
  let tval = this.toTimeValue();
@@ -2266,6 +2554,9 @@ export class Timestamp
2266
2554
  return new Timestamp(new TimeInstant(DateTimeUtil.timeValue2Secs(tval), this.inst.nanosec), this.tzQhr);
2267
2555
  }
2268
2556
 
2557
+ /**
2558
+ * @param {number} val
2559
+ */
2269
2560
  addYear(val)
2270
2561
  {
2271
2562
  let tval = this.toTimeValue();
@@ -2273,21 +2564,33 @@ export class Timestamp
2273
2564
  return new Timestamp(new TimeInstant(DateTimeUtil.timeValue2Secs(tval), this.inst.nanosec), this.tzQhr);
2274
2565
  }
2275
2566
 
2567
+ /**
2568
+ * @param {any} val
2569
+ */
2276
2570
  addDay(val)
2277
2571
  {
2278
2572
  return new Timestamp(this.inst.addDay(val), this.tzQhr);
2279
2573
  }
2280
2574
 
2575
+ /**
2576
+ * @param {any} val
2577
+ */
2281
2578
  addHour(val)
2282
2579
  {
2283
2580
  return new Timestamp(this.inst.addHour(val), this.tzQhr);
2284
2581
  }
2285
2582
 
2583
+ /**
2584
+ * @param {any} val
2585
+ */
2286
2586
  addMinute(val)
2287
2587
  {
2288
2588
  return new Timestamp(this.inst.addMinute(val), this.tzQhr);
2289
2589
  }
2290
2590
 
2591
+ /**
2592
+ * @param {number} val
2593
+ */
2291
2594
  addSecond(val)
2292
2595
  {
2293
2596
  let sec = Math.floor(val);
@@ -2295,11 +2598,17 @@ export class Timestamp
2295
2598
  return new Timestamp(this.inst.addSecond(sec).addNS(ns), this.tzQhr);
2296
2599
  }
2297
2600
 
2601
+ /**
2602
+ * @param {any} val
2603
+ */
2298
2604
  addMS(val)
2299
2605
  {
2300
2606
  return new Timestamp(this.inst.addMS(val), this.tzQhr);
2301
2607
  }
2302
2608
 
2609
+ /**
2610
+ * @param {any} val
2611
+ */
2303
2612
  addNS(val)
2304
2613
  {
2305
2614
  return new Timestamp(this.inst.addNS(val), this.tzQhr);
@@ -2307,7 +2616,7 @@ export class Timestamp
2307
2616
 
2308
2617
  getMS()
2309
2618
  {
2310
- return this.inst.GetMS();
2619
+ return this.inst.getMS();
2311
2620
  }
2312
2621
 
2313
2622
  clearTimeUTC()
@@ -2353,21 +2662,33 @@ export class Timestamp
2353
2662
  return this.inst.addSecond(this.tzQhr * 900).getMSPassedDate();
2354
2663
  }
2355
2664
 
2665
+ /**
2666
+ * @param {{ inst: any; }} ts
2667
+ */
2356
2668
  diffSec(ts)
2357
2669
  {
2358
2670
  return this.inst.diffSec(ts.inst);
2359
2671
  }
2360
2672
 
2673
+ /**
2674
+ * @param {{ inst: any; }} ts
2675
+ */
2361
2676
  diffMS(ts)
2362
2677
  {
2363
2678
  return this.inst.diffMS(ts.inst);
2364
2679
  }
2365
2680
 
2681
+ /**
2682
+ * @param {{ inst: any; }} ts
2683
+ */
2366
2684
  diffSecDbl(ts)
2367
2685
  {
2368
2686
  return this.inst.diffSecDbl(ts.inst);
2369
2687
  }
2370
2688
 
2689
+ /**
2690
+ * @param {{ inst: any; }} ts
2691
+ */
2371
2692
  diff(ts)
2372
2693
  {
2373
2694
  return this.inst.diff(ts.inst);
@@ -2408,6 +2729,26 @@ export class Timestamp
2408
2729
  return this.inst.toEpochNS();
2409
2730
  }
2410
2731
 
2732
+ toMSDOSDate()
2733
+ {
2734
+ let tval = this.toTimeValue();
2735
+ return ((((tval.year - 1980) & 0x7f) << 9) | (tval.month << 5) | tval.day);
2736
+ }
2737
+
2738
+ toMSDOSTime()
2739
+ {
2740
+ let tval = this.toTimeValue();
2741
+ return ((tval.hour << 11) | (tval.minute << 5) | (tval.second >> 1));
2742
+ }
2743
+
2744
+ toFILETIME()
2745
+ {
2746
+ return this.inst.toFILETIME();
2747
+ }
2748
+
2749
+ /**
2750
+ * @param {string | null} pattern
2751
+ */
2411
2752
  toString(pattern)
2412
2753
  {
2413
2754
  if (pattern == null)
@@ -2490,11 +2831,17 @@ export class Timestamp
2490
2831
  return new Timestamp(this.inst, DateTimeUtil.getLocalTzQhr());
2491
2832
  }
2492
2833
 
2834
+ /**
2835
+ * @param {number} tzQhr
2836
+ */
2493
2837
  convertTimeZoneQHR(tzQhr)
2494
2838
  {
2495
2839
  return new Timestamp(this.inst, tzQhr);
2496
2840
  }
2497
2841
 
2842
+ /**
2843
+ * @param {number} tzQhr
2844
+ */
2498
2845
  setTimeZoneQHR(tzQhr)
2499
2846
  {
2500
2847
  if (this.tzQhr != tzQhr)
@@ -2512,9 +2859,17 @@ export class Timestamp
2512
2859
  return this.tzQhr;
2513
2860
  }
2514
2861
 
2862
+ getLocalSecs()
2863
+ {
2864
+ return this.inst.sec + BigInt(this.tzQhr * 900);
2865
+ }
2866
+
2867
+ /**
2868
+ * @param {Timestamp} ts
2869
+ */
2515
2870
  sameDate(ts)
2516
2871
  {
2517
- return this.inst.sameDate(ts.inst);
2872
+ return (this.getLocalSecs() / 86400n) == (ts.getLocalSecs() / 86400n);
2518
2873
  }
2519
2874
 
2520
2875
  toTimeValue()
@@ -2530,6 +2885,9 @@ export class Timestamp
2530
2885
 
2531
2886
  export class ByteReader
2532
2887
  {
2888
+ /**
2889
+ * @param {ArrayBufferLike & { BYTES_PER_ELEMENT?: undefined; }} arr
2890
+ */
2533
2891
  constructor(arr)
2534
2892
  {
2535
2893
  this.view = new DataView(arr);
@@ -2540,6 +2898,10 @@ export class ByteReader
2540
2898
  return this.view.byteLength;
2541
2899
  }
2542
2900
 
2901
+ /**
2902
+ * @param {number | null} ofst
2903
+ * @param {number | null} size
2904
+ */
2543
2905
  getArrayBuffer(ofst, size)
2544
2906
  {
2545
2907
  if (ofst == null)
@@ -2549,6 +2911,10 @@ export class ByteReader
2549
2911
  return this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + ofst + size);
2550
2912
  }
2551
2913
 
2914
+ /**
2915
+ * @param {any} ofst
2916
+ * @param {any} size
2917
+ */
2552
2918
  getU8Arr(ofst, size)
2553
2919
  {
2554
2920
  return new Uint8Array(this.getArrayBuffer(ofst, size));
@@ -2648,17 +3014,29 @@ export class ByteReader
2648
3014
  return this.view.getBigInt64(ofst, lsb);
2649
3015
  }
2650
3016
 
3017
+ /**
3018
+ * @param {number} ofst
3019
+ * @param {boolean | undefined} lsb
3020
+ */
2651
3021
  readFloat64(ofst, lsb)
2652
3022
  {
2653
3023
  return this.view.getFloat64(ofst, lsb);
2654
3024
  }
2655
3025
 
3026
+ /**
3027
+ * @param {any} ofst
3028
+ * @param {any} len
3029
+ */
2656
3030
  readUTF8(ofst, len)
2657
3031
  {
2658
3032
  let dec = new TextDecoder();
2659
3033
  return dec.decode(this.getArrayBuffer(ofst, len));
2660
3034
  }
2661
3035
 
3036
+ /**
3037
+ * @param {number} ofst
3038
+ * @param {any} maxSize
3039
+ */
2662
3040
  readUTF8Z(ofst, maxSize)
2663
3041
  {
2664
3042
  let end = ofst;
@@ -2679,6 +3057,11 @@ export class ByteReader
2679
3057
  return dec.decode(this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + end));
2680
3058
  }
2681
3059
 
3060
+ /**
3061
+ * @param {number} ofst
3062
+ * @param {number} nChar
3063
+ * @param {boolean | undefined} lsb
3064
+ */
2682
3065
  readUTF16(ofst, nChar, lsb)
2683
3066
  {
2684
3067
  let ret = [];
@@ -2690,6 +3073,10 @@ export class ByteReader
2690
3073
  return ret.join("");
2691
3074
  }
2692
3075
 
3076
+ /**
3077
+ * @param {number} ofst
3078
+ * @param {number} cnt
3079
+ */
2693
3080
  readUInt8Arr(ofst, cnt)
2694
3081
  {
2695
3082
  let ret = [];
@@ -2701,6 +3088,11 @@ export class ByteReader
2701
3088
  return ret;
2702
3089
  }
2703
3090
 
3091
+ /**
3092
+ * @param {number} ofst
3093
+ * @param {boolean | undefined} lsb
3094
+ * @param {number} cnt
3095
+ */
2704
3096
  readUInt16Arr(ofst, lsb, cnt)
2705
3097
  {
2706
3098
  let ret = [];
@@ -2712,6 +3104,11 @@ export class ByteReader
2712
3104
  return ret;
2713
3105
  }
2714
3106
 
3107
+ /**
3108
+ * @param {number} ofst
3109
+ * @param {boolean | undefined} lsb
3110
+ * @param {number} cnt
3111
+ */
2715
3112
  readUInt32Arr(ofst, lsb, cnt)
2716
3113
  {
2717
3114
  let ret = [];
@@ -2723,6 +3120,10 @@ export class ByteReader
2723
3120
  return ret;
2724
3121
  }
2725
3122
 
3123
+ /**
3124
+ * @param {number} ofst
3125
+ * @param {number} cnt
3126
+ */
2726
3127
  readInt8Arr(ofst, cnt)
2727
3128
  {
2728
3129
  let ret = [];
@@ -2734,6 +3135,11 @@ export class ByteReader
2734
3135
  return ret;
2735
3136
  }
2736
3137
 
3138
+ /**
3139
+ * @param {number} ofst
3140
+ * @param {boolean | undefined} lsb
3141
+ * @param {number} cnt
3142
+ */
2737
3143
  readInt16Arr(ofst, lsb, cnt)
2738
3144
  {
2739
3145
  let ret = [];
@@ -2745,6 +3151,11 @@ export class ByteReader
2745
3151
  return ret;
2746
3152
  }
2747
3153
 
3154
+ /**
3155
+ * @param {number} ofst
3156
+ * @param {boolean | undefined} lsb
3157
+ * @param {number} cnt
3158
+ */
2748
3159
  readInt32Arr(ofst, lsb, cnt)
2749
3160
  {
2750
3161
  let ret = [];
@@ -2756,6 +3167,11 @@ export class ByteReader
2756
3167
  return ret;
2757
3168
  }
2758
3169
 
3170
+ /**
3171
+ * @param {number} ofst
3172
+ * @param {any} lsb
3173
+ * @param {number} cnt
3174
+ */
2759
3175
  readFloat64Arr(ofst, lsb, cnt)
2760
3176
  {
2761
3177
  let ret = [];
@@ -2767,6 +3183,10 @@ export class ByteReader
2767
3183
  return ret;
2768
3184
  }
2769
3185
 
3186
+ /**
3187
+ * @param {number} ofst
3188
+ * @param {number} len
3189
+ */
2770
3190
  isASCIIText(ofst, len)
2771
3191
  {
2772
3192
  while (len-- > 0)
@@ -2786,6 +3206,187 @@ export class ByteReader
2786
3206
  }
2787
3207
  }
2788
3208
 
3209
+ export class ByteBuilder
3210
+ {
3211
+ constructor()
3212
+ {
3213
+ this.tmpBuff = new Uint8Array(8);
3214
+ this.view = new DataView(this.tmpBuff.buffer);
3215
+ /** @type {number[]} */
3216
+ this.buff = [];
3217
+ }
3218
+
3219
+ /**
3220
+ * @param {number} ofst
3221
+ * @param {number} value
3222
+ */
3223
+ writeInt8(ofst, value)
3224
+ {
3225
+ this.allocBuff(ofst, 1);
3226
+ this.buff[ofst] = (value & 0xff);
3227
+ }
3228
+
3229
+ /**
3230
+ * @param {number} ofst
3231
+ * @param {number} value
3232
+ * @param {boolean} lsb
3233
+ */
3234
+ writeInt16(ofst, value, lsb)
3235
+ {
3236
+ this.allocBuff(ofst, 2);
3237
+ this.view.setInt16(0, value, lsb);
3238
+ this.buff[ofst] = this.tmpBuff[0];
3239
+ this.buff[ofst + 1] = this.tmpBuff[1];
3240
+ }
3241
+
3242
+ /**
3243
+ * @param {number} ofst
3244
+ * @param {number} value
3245
+ * @param {boolean} lsb
3246
+ */
3247
+ writeInt24(ofst, value, lsb)
3248
+ {
3249
+ this.allocBuff(ofst, 3);
3250
+ this.view.setInt32(0, value, lsb);
3251
+ if (lsb)
3252
+ {
3253
+ this.buff[ofst] = this.tmpBuff[0];
3254
+ this.buff[ofst + 1] = this.tmpBuff[1];
3255
+ this.buff[ofst + 2] = this.tmpBuff[2];
3256
+ }
3257
+ else
3258
+ {
3259
+ this.buff[ofst] = this.tmpBuff[1];
3260
+ this.buff[ofst + 1] = this.tmpBuff[2];
3261
+ this.buff[ofst + 2] = this.tmpBuff[3];
3262
+ }
3263
+ }
3264
+
3265
+ /**
3266
+ * @param {number} ofst
3267
+ * @param {number} value
3268
+ * @param {boolean} lsb
3269
+ */
3270
+ writeInt32(ofst, value, lsb)
3271
+ {
3272
+ this.allocBuff(ofst, 4);
3273
+ this.view.setInt32(0, value, lsb);
3274
+ this.buff[ofst] = this.tmpBuff[0];
3275
+ this.buff[ofst + 1] = this.tmpBuff[1];
3276
+ this.buff[ofst + 2] = this.tmpBuff[2];
3277
+ this.buff[ofst + 3] = this.tmpBuff[3];
3278
+ }
3279
+
3280
+ /**
3281
+ * @param {number} ofst
3282
+ * @param {bigint} value
3283
+ * @param {boolean} lsb
3284
+ */
3285
+ writeInt64(ofst, value, lsb)
3286
+ {
3287
+ this.allocBuff(ofst, 8);
3288
+ this.view.setBigInt64(0, value, lsb);
3289
+ this.buff[ofst] = this.tmpBuff[0];
3290
+ this.buff[ofst + 1] = this.tmpBuff[1];
3291
+ this.buff[ofst + 2] = this.tmpBuff[2];
3292
+ this.buff[ofst + 3] = this.tmpBuff[3];
3293
+ this.buff[ofst + 4] = this.tmpBuff[4];
3294
+ this.buff[ofst + 5] = this.tmpBuff[5];
3295
+ this.buff[ofst + 6] = this.tmpBuff[6];
3296
+ this.buff[ofst + 7] = this.tmpBuff[7];
3297
+ }
3298
+
3299
+
3300
+ /**
3301
+ * @param {number} ofst
3302
+ * @param {number} value
3303
+ * @param {boolean} lsb
3304
+ */
3305
+ writeFloat64(ofst, value, lsb)
3306
+ {
3307
+ this.allocBuff(ofst, 8);
3308
+ this.view.setFloat64(0, value, lsb);
3309
+ this.buff[ofst] = this.tmpBuff[0];
3310
+ this.buff[ofst + 1] = this.tmpBuff[1];
3311
+ this.buff[ofst + 2] = this.tmpBuff[2];
3312
+ this.buff[ofst + 3] = this.tmpBuff[3];
3313
+ this.buff[ofst + 4] = this.tmpBuff[4];
3314
+ this.buff[ofst + 5] = this.tmpBuff[5];
3315
+ this.buff[ofst + 6] = this.tmpBuff[6];
3316
+ this.buff[ofst + 7] = this.tmpBuff[7];
3317
+ }
3318
+
3319
+ /**
3320
+ * @param {number} ofst
3321
+ * @param {string} value
3322
+ */
3323
+ writeUTF8(ofst, value)
3324
+ {
3325
+ let sbuff = new TextEncoder().encode(value);
3326
+ this.allocBuff(ofst, sbuff.length);
3327
+ let i = 0;
3328
+ while (i < sbuff.length)
3329
+ {
3330
+ this.buff[ofst + i] = sbuff[i];
3331
+ i++;
3332
+ }
3333
+ return sbuff.length;
3334
+ }
3335
+
3336
+ /**
3337
+ * @param {number} ofst
3338
+ * @param {string} value
3339
+ * @param {boolean} lsb
3340
+ */
3341
+ writeUTF16(ofst, value, lsb)
3342
+ {
3343
+ this.allocBuff(ofst, value.length);
3344
+ let i = 0;
3345
+ while (i < value.length)
3346
+ {
3347
+ this.view.setInt16(0, value.charCodeAt(i), lsb);
3348
+ this.buff[ofst + i * 2] = this.tmpBuff[0];
3349
+ this.buff[ofst + i * 2 + 1] = this.tmpBuff[1];
3350
+ i++;
3351
+ }
3352
+ return value.length * 2;
3353
+ }
3354
+
3355
+ /**
3356
+ * @param {number} ofst
3357
+ * @param {Uint8Array} buff
3358
+ */
3359
+ writeUInt8Array(ofst, buff)
3360
+ {
3361
+ this.allocBuff(ofst, buff.length);
3362
+ let i = 0;
3363
+ let j = buff.length;
3364
+ while (i < j)
3365
+ {
3366
+ this.buff[ofst + i] = buff[i];
3367
+ i++;
3368
+ }
3369
+ }
3370
+
3371
+ build()
3372
+ {
3373
+ return new Uint8Array(this.buff);
3374
+ }
3375
+
3376
+ /**
3377
+ * @param {number} ofst
3378
+ * @param {number} len
3379
+ */
3380
+ allocBuff(ofst, len)
3381
+ {
3382
+ ofst += len;
3383
+ while (this.buff.length < ofst)
3384
+ {
3385
+ this.buff.push(0);
3386
+ }
3387
+ }
3388
+ }
3389
+
2789
3390
  export class ParsedObject
2790
3391
  {
2791
3392
  /**