@sswroom/sswr 1.5.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/data.js CHANGED
@@ -80,6 +80,23 @@ export function arrayBuffer2Base64(buff)
80
80
  return btoa(String.fromCharCode.apply(null, new Uint8Array(buff)));
81
81
  }
82
82
 
83
+ export function arrayBufferEquals(buff1, buff2)
84
+ {
85
+ let arr1 = new Uint8Array(buff1);
86
+ let arr2 = new Uint8Array(buff2);
87
+ if (arr1.byteLength != arr2.byteLength)
88
+ return false;
89
+ let i = 0;
90
+ let j = arr1.length;
91
+ while (i < j)
92
+ {
93
+ if (arr1[i] != arr2[i])
94
+ return false;
95
+ i++;
96
+ }
97
+ return true;
98
+ }
99
+
83
100
  export function compare(a, b)
84
101
  {
85
102
  if (a == b)
@@ -280,6 +297,37 @@ export function readMUInt32(arr, index)
280
297
  return arr[index + 3] | (arr[index + 2] << 8) | (arr[index + 1] << 16) | (arr[index + 0] << 24);
281
298
  }
282
299
 
300
+ export function rol32(v, n)
301
+ {
302
+ if (n == 0)
303
+ return v;
304
+ return ((v << n) | ((v >> 1) & 0x7fffffff) >> (31 - n));
305
+ }
306
+
307
+ export function ror32(v, n)
308
+ {
309
+ if (n == 0)
310
+ return v;
311
+ return ((v << (32 - n)) | ((v >> 1) & 0x7fffffff) >> (n - 1));
312
+ }
313
+
314
+ export function shl32(v, n)
315
+ {
316
+ return v << n;
317
+ }
318
+
319
+ export function sar32(v, n)
320
+ {
321
+ return v >> n;
322
+ }
323
+
324
+ export function shr32(v, n)
325
+ {
326
+ if (n == 0)
327
+ return v;
328
+ return ((v >> 1) & 0x7fffffff) >> (n - 1);
329
+ }
330
+
283
331
  export class DateValue
284
332
  {
285
333
  constructor()
@@ -474,12 +522,12 @@ export class DateTimeUtil
474
522
 
475
523
  static timeValue2Secs(tval)
476
524
  {
477
- return DateTimeUtil.dateValue2TotalDays(tval) * 86400 + (tval.second + tval.minute * 60 + tval.hour * 3600 - tval.tzQhr * 900);
525
+ return BigInt(DateTimeUtil.dateValue2TotalDays(tval)) * 86400n + BigInt(tval.second + tval.minute * 60 + tval.hour * 3600 - tval.tzQhr * 900);
478
526
  }
479
527
 
480
528
  static timeValue2Ticks(t)
481
529
  {
482
- return DateTimeUtil.timeValue2Secs(t) * 1000 + Math.floor(t.nanosec / 1000000);
530
+ return DateTimeUtil.timeValue2Secs(t) * 1000n + Math.floor(t.nanosec / 1000000);
483
531
  }
484
532
 
485
533
  static ticks2TimeValue(ticks, tzQhr)
@@ -543,14 +591,14 @@ export class DateTimeUtil
543
591
  }
544
592
  else
545
593
  {
546
- totalDays -= 10957;
547
- t.year = (2000 + (Math.floor(totalDays / 1461) * 4));
548
- totalDays = totalDays % 1461;
549
- if (totalDays >= 366)
594
+ totalDays -= 10957n;
595
+ t.year = (2000 + (Math.floor(Number(totalDays) / 1461) * 4));
596
+ totalDays = totalDays % 1461n;
597
+ if (totalDays >= 366n)
550
598
  {
551
599
  totalDays--;
552
- t.year = (t.year + Math.floor(totalDays / 365));
553
- totalDays = totalDays % 365;
600
+ t.year = (t.year + Math.floor(Number(totalDays) / 365));
601
+ totalDays = totalDays % 365n;
554
602
  }
555
603
  }
556
604
 
@@ -563,24 +611,24 @@ export class DateTimeUtil
563
611
  if (totalDays < 31)
564
612
  {
565
613
  t.month = 1;
566
- t.day = (totalDays + 1);
614
+ t.day = (Number(totalDays) + 1);
567
615
  }
568
616
  else
569
617
  {
570
618
  t.month = 2;
571
- t.day = (totalDays - 31 + 1);
619
+ t.day = (Number(totalDays) - 31 + 1);
572
620
  }
573
621
  }
574
622
  else
575
623
  if (totalDays < 91)
576
624
  {
577
625
  t.month = 3;
578
- t.day = (totalDays - 60 + 1);
626
+ t.day = (Number(totalDays) - 60 + 1);
579
627
  }
580
628
  else
581
629
  {
582
630
  t.month = 4;
583
- t.day = (totalDays - 91 + 1);
631
+ t.day = (Number(totalDays) - 91 + 1);
584
632
  }
585
633
  }
586
634
  else
@@ -592,24 +640,24 @@ export class DateTimeUtil
592
640
  if (totalDays < 152)
593
641
  {
594
642
  t.month = 5;
595
- t.day = (totalDays - 121 + 1);
643
+ t.day = (Number(totalDays) - 121 + 1);
596
644
  }
597
645
  else
598
646
  {
599
647
  t.month = 6;
600
- t.day = (totalDays - 152 + 1);
648
+ t.day = (Number(totalDays) - 152 + 1);
601
649
  }
602
650
  }
603
651
  else
604
652
  if (totalDays < 213)
605
653
  {
606
654
  t.month = 7;
607
- t.day = (totalDays - 182 + 1);
655
+ t.day = (Number(totalDays) - 182 + 1);
608
656
  }
609
657
  else
610
658
  {
611
659
  t.month = 8;
612
- t.day = (totalDays - 213 + 1);
660
+ t.day = (Number(totalDays) - 213 + 1);
613
661
  }
614
662
  }
615
663
  else
@@ -619,24 +667,24 @@ export class DateTimeUtil
619
667
  if (totalDays < 274)
620
668
  {
621
669
  t.month = 9;
622
- t.day = (totalDays - 244 + 1);
670
+ t.day = (Number(totalDays) - 244 + 1);
623
671
  }
624
672
  else
625
673
  {
626
674
  t.month = 10;
627
- t.day = (totalDays - 274 + 1);
675
+ t.day = (Number(totalDays) - 274 + 1);
628
676
  }
629
677
  }
630
678
  else
631
679
  if (totalDays < 335)
632
680
  {
633
681
  t.month = 11;
634
- t.day = (totalDays - 305 + 1);
682
+ t.day = (Number(totalDays) - 305 + 1);
635
683
  }
636
684
  else
637
685
  {
638
686
  t.month = 12;
639
- t.day = (totalDays - 335 + 1);
687
+ t.day = (Number(totalDays) - 335 + 1);
640
688
  }
641
689
  }
642
690
  }
@@ -650,24 +698,24 @@ export class DateTimeUtil
650
698
  if (totalDays < 31)
651
699
  {
652
700
  t.month = 1;
653
- t.day = (totalDays + 1);
701
+ t.day = (Number(totalDays) + 1);
654
702
  }
655
703
  else
656
704
  {
657
705
  t.month = 2;
658
- t.day = (totalDays - 31 + 1);
706
+ t.day = (Number(totalDays) - 31 + 1);
659
707
  }
660
708
  }
661
709
  else
662
710
  if (totalDays < 90)
663
711
  {
664
712
  t.month = 3;
665
- t.day = (totalDays - 59 + 1);
713
+ t.day = (Number(totalDays) - 59 + 1);
666
714
  }
667
715
  else
668
716
  {
669
717
  t.month = 4;
670
- t.day = (totalDays - 90 + 1);
718
+ t.day = (Number(totalDays) - 90 + 1);
671
719
  }
672
720
  }
673
721
  else
@@ -679,24 +727,24 @@ export class DateTimeUtil
679
727
  if (totalDays < 151)
680
728
  {
681
729
  t.month = 5;
682
- t.day = (totalDays - 120 + 1);
730
+ t.day = (Number(totalDays) - 120 + 1);
683
731
  }
684
732
  else
685
733
  {
686
734
  t.month = 6;
687
- t.day = (totalDays - 151 + 1);
735
+ t.day = (Number(totalDays) - 151 + 1);
688
736
  }
689
737
  }
690
738
  else
691
739
  if (totalDays < 212)
692
740
  {
693
741
  t.month = 7;
694
- t.day = (totalDays - 181 + 1);
742
+ t.day = (Number(totalDays) - 181 + 1);
695
743
  }
696
744
  else
697
745
  {
698
746
  t.month = 8;
699
- t.day = (totalDays - 212 + 1);
747
+ t.day = (Number(totalDays) - 212 + 1);
700
748
  }
701
749
  }
702
750
  else
@@ -706,24 +754,24 @@ export class DateTimeUtil
706
754
  if (totalDays < 273)
707
755
  {
708
756
  t.month = 9;
709
- t.day = (totalDays - 243 + 1);
757
+ t.day = (Number(totalDays) - 243 + 1);
710
758
  }
711
759
  else
712
760
  {
713
761
  t.month = 10;
714
- t.day = (totalDays - 273 + 1);
762
+ t.day = (Number(totalDays) - 273 + 1);
715
763
  }
716
764
  }
717
765
  else
718
766
  if (totalDays < 334)
719
767
  {
720
768
  t.month = 11;
721
- t.day = (totalDays - 304 + 1);
769
+ t.day = (Number(totalDays) - 304 + 1);
722
770
  }
723
771
  else
724
772
  {
725
773
  t.month = 12;
726
- t.day = (totalDays - 334 + 1);
774
+ t.day = (Number(totalDays) - 334 + 1);
727
775
  }
728
776
  }
729
777
  }
@@ -734,22 +782,22 @@ export class DateTimeUtil
734
782
  {
735
783
  if (tzQhr == null)
736
784
  tzQhr = DateTimeUtil.getLocalTzQhr();
737
- secs = secs + tzQhr * 900;
738
- let totalDays = Math.floor(secs / 86400);
785
+ secs = BigInt(secs) + BigInt(tzQhr * 900);
786
+ let totalDays = secs / 86400n;
739
787
  let minutes;
740
788
  if (secs < 0)
741
789
  {
742
- secs -= totalDays * 86400;
790
+ secs -= totalDays * 86400n;
743
791
  while (secs < 0)
744
792
  {
745
793
  totalDays -= 1;
746
- secs += 86400;
794
+ secs += 86400n;
747
795
  }
748
- minutes = (secs % 86400);
796
+ minutes = Number(secs % 86400n);
749
797
  }
750
798
  else
751
799
  {
752
- minutes = (secs % 86400);
800
+ minutes = Number(secs % 86400n);
753
801
  }
754
802
 
755
803
  let t = new TimeValue();
@@ -1494,7 +1542,7 @@ export class Duration
1494
1542
  {
1495
1543
  constructor(seconds, nanosec)
1496
1544
  {
1497
- this.seconds = seconds;
1545
+ this.seconds = BigInt(seconds);
1498
1546
  this.nanosec = nanosec;
1499
1547
  }
1500
1548
 
@@ -1502,8 +1550,8 @@ export class Duration
1502
1550
  {
1503
1551
  if (ticks < 0)
1504
1552
  {
1505
- let ns = ticks % 1000;
1506
- let seconds = Math.floor(ticks / 1000);
1553
+ let ns = Number(BigInt(ticks) % 1000n);
1554
+ let seconds = BigInt(ticks) / 1000n;
1507
1555
  if (ns != 0)
1508
1556
  {
1509
1557
  ns = (-ns) * 1000000;
@@ -1513,7 +1561,7 @@ export class Duration
1513
1561
  }
1514
1562
  else
1515
1563
  {
1516
- return new Duration(Math.floor(ticks / 1000), (ticks % 1000) * 1000000);
1564
+ return new Duration(BigInt(ticks) / 1000n, Number(BigInt(ticks) % 1000n) * 1000000);
1517
1565
  }
1518
1566
  }
1519
1567
 
@@ -1521,16 +1569,16 @@ export class Duration
1521
1569
  {
1522
1570
  if (us < 0)
1523
1571
  {
1524
- let ns = us % 1000000;
1525
- let seconds = Math.floor(us / 1000000);
1526
- if (ns != 0)
1572
+ let ns = Number(BigInt(us) % 1000000n);
1573
+ let seconds = BigInt(us) / 1000000n;
1574
+ if (ns == 0)
1527
1575
  return new Duration(seconds, 0);
1528
1576
  else
1529
- return new Duration(seconds - 1, (-ns) * 1000);
1577
+ return new Duration(seconds - 1n, (-ns) * 1000);
1530
1578
  }
1531
1579
  else
1532
1580
  {
1533
- return new Duration(Math.floor(us / 1000000), (us % 1000000) * 1000);
1581
+ return new Duration(BigInt(us) / 1000000n, Number(BigInt(us) % 1000000n) * 1000);
1534
1582
  }
1535
1583
  }
1536
1584
 
@@ -1546,12 +1594,12 @@ export class Duration
1546
1594
 
1547
1595
  getTotalMS()
1548
1596
  {
1549
- return this.seconds * 1000 + Math.floor(this.ns / 1000000);
1597
+ return Number(this.seconds) * 1000 + this.ns / 1000000n;
1550
1598
  }
1551
1599
 
1552
1600
  getTotalSec()
1553
1601
  {
1554
- return this.seconds + (this.ns * 0.000000001);
1602
+ return Number(this.seconds) + (this.ns * 0.000000001);
1555
1603
  }
1556
1604
 
1557
1605
  notZero()
@@ -1574,7 +1622,7 @@ export class Duration
1574
1622
  txt.push('-');
1575
1623
  if (ns > 0)
1576
1624
  {
1577
- secs = -secs - 1;
1625
+ secs = -secs - 1n;
1578
1626
  ns = 1000000000 - ns;
1579
1627
  }
1580
1628
  else
@@ -1582,21 +1630,21 @@ export class Duration
1582
1630
  secs = -secs;
1583
1631
  }
1584
1632
  }
1585
- txt.push(Math.floor(secs / 3600));
1586
- secs = secs % 3600;
1633
+ txt.push((secs / 3600n).toString());
1634
+ secs = secs % 3600n;
1587
1635
  txt.push(':');
1588
1636
  if (secs < 600)
1589
1637
  {
1590
1638
  txt.push('0');
1591
1639
  }
1592
- txt.push(Math.floor(secs / 60));
1593
- secs = secs % 60;
1640
+ txt.push((secs / 60n).toString());
1641
+ secs = secs % 60n;
1594
1642
  txt.push(':');
1595
1643
  if (secs < 10)
1596
1644
  {
1597
1645
  txt.push('0');
1598
1646
  }
1599
- txt.push(secs);
1647
+ txt.push(secs.toString());
1600
1648
  if (ns != 0)
1601
1649
  {
1602
1650
  txt.push('.');
@@ -1742,7 +1790,7 @@ export class TimeInstant
1742
1790
  {
1743
1791
  constructor(sec, nanosec)
1744
1792
  {
1745
- this.sec = sec;
1793
+ this.sec = BigInt(sec)
1746
1794
  this.nanosec = nanosec;
1747
1795
  }
1748
1796
 
@@ -1769,7 +1817,7 @@ export class TimeInstant
1769
1817
  let days = Math.floor(variTime);
1770
1818
  let ds = (variTime - days);
1771
1819
  let s = Math.floor(ds * 86400);
1772
- return new TimeInstant((days - 25569) * 86400000 + Math.floor(ds * 86400000), ((ds * 86400 - s) * 1000000000));
1820
+ return new TimeInstant((days - 25569n) * 86400000n + Math.floor(ds * 86400000n), ((ds * 86400n - s) * 1000000000n));
1773
1821
  }
1774
1822
 
1775
1823
  static fromTicks(ticks)
@@ -1787,17 +1835,17 @@ export class TimeInstant
1787
1835
 
1788
1836
  addDay(val)
1789
1837
  {
1790
- return new TimeInstant(this.sec + val * 86400, this.nanosec);
1838
+ return new TimeInstant(this.sec + val * 86400n, this.nanosec);
1791
1839
  }
1792
1840
 
1793
1841
  addHour(val)
1794
1842
  {
1795
- return new TimeInstant(this.sec + val * 3600, this.nanosec);
1843
+ return new TimeInstant(this.sec + val * 3600n, this.nanosec);
1796
1844
  }
1797
1845
 
1798
1846
  addMinute(val)
1799
1847
  {
1800
- return new TimeInstant(this.sec + val * 60, this.nanosec);
1848
+ return new TimeInstant(this.sec + val * 60n, this.nanosec);
1801
1849
  }
1802
1850
 
1803
1851
  addSecond(val)
@@ -1853,22 +1901,22 @@ export class TimeInstant
1853
1901
 
1854
1902
  getMSPassedDate()
1855
1903
  {
1856
- return (this.sec % 86400) * 1000 + Math.floor(this.nanosec / 1000000);
1904
+ return Number(this.sec % 86400) * 1000 + Math.floor(this.nanosec / 1000000);
1857
1905
  }
1858
1906
 
1859
1907
  diffMS(ts)
1860
1908
  {
1861
- return (this.sec - ts.sec) * 1000 + Math.floor((this.nanosec / 1000000) - (ts.nanosec / 1000000));
1909
+ return Number(this.sec - ts.sec) * 1000 + Math.floor((this.nanosec / 1000000) - (ts.nanosec / 1000000));
1862
1910
  }
1863
1911
 
1864
1912
  diffSec(ts)
1865
1913
  {
1866
- return this.sec - ts.sec;
1914
+ return Number(this.sec - ts.sec);
1867
1915
  }
1868
1916
 
1869
1917
  diffSecDbl(ts)
1870
1918
  {
1871
- return (this.sec - ts.sec) + (this.nanosec - ts.nanosec) / 1000000000.0;
1919
+ return Number(this.sec - ts.sec) + (this.nanosec - ts.nanosec) / 1000000000.0;
1872
1920
  }
1873
1921
 
1874
1922
  diff(ts)
@@ -1879,22 +1927,22 @@ export class TimeInstant
1879
1927
  if (ns1 >= ns2)
1880
1928
  return new Duration(secs, ns1 - ns2);
1881
1929
  else
1882
- return new Duration(secs - 1, 1000000000 + ns1 - ns2);
1930
+ return new Duration(secs - 1n, 1000000000 + ns1 - ns2);
1883
1931
  }
1884
1932
 
1885
1933
  toTicks()
1886
1934
  {
1887
- return this.sec * 1000 + Math.floor(this.nanosec / 1000000);
1935
+ return Number(this.sec) * 1000 + Math.floor(this.nanosec / 1000000);
1888
1936
  }
1889
1937
 
1890
1938
  toDotNetTicks()
1891
1939
  {
1892
- return this.sec * 10000000 + 621355968000000000 + Math.floor(this.nanosec / 100);
1940
+ return this.sec * 10000000n + 621355968000000000n + BigInt(Math.floor(this.nanosec / 100));
1893
1941
  }
1894
1942
 
1895
1943
  toUnixTimestamp()
1896
1944
  {
1897
- return this.sec;
1945
+ return Number(this.sec);
1898
1946
  }
1899
1947
 
1900
1948
  toEpochSec()
@@ -1904,12 +1952,12 @@ export class TimeInstant
1904
1952
 
1905
1953
  toEpochMS()
1906
1954
  {
1907
- return this.sec * 1000 + Math.floor(this.nanosec / 1000000);
1955
+ return this.sec * 1000 + BigInt(Math.floor(this.nanosec / 1000000));
1908
1956
  }
1909
1957
 
1910
1958
  toEpochNS()
1911
1959
  {
1912
- return this.sec * 1000000000 + this.nanosec;
1960
+ return this.sec * 1000000000 + BigInt(this.nanosec);
1913
1961
  }
1914
1962
  }
1915
1963
 
@@ -1980,11 +2028,11 @@ export class Timestamp
1980
2028
  {
1981
2029
  if (epochUS < 0)
1982
2030
  {
1983
- return new Timestamp(new TimeInstant(Math.floor(epochUS / 1000000) - 1, (epochUS % 1000000 + 1000000) * 1000), tzQhr);
2031
+ return new Timestamp(new TimeInstant(epochUS / 1000000n - 1, Number(epochUS % 1000000 + 1000000) * 1000), tzQhr);
1984
2032
  }
1985
2033
  else
1986
2034
  {
1987
- return new Timestamp(new TimeInstant(Math.floor(epochUS / 1000000), (epochUS % 1000000) * 1000), tzQhr);
2035
+ return new Timestamp(new TimeInstant(epochUS / 1000000n, Number(epochUS % 1000000) * 1000), tzQhr);
1988
2036
  }
1989
2037
  }
1990
2038
 
@@ -1992,11 +2040,11 @@ export class Timestamp
1992
2040
  {
1993
2041
  if (epochNS < 0)
1994
2042
  {
1995
- return new Timestamp(new TimeInstant(Math.floor(epochNS / 1000000000) - 1, (epochNS % 1000000000 + 1000000000)), tzQhr);
2043
+ return new Timestamp(new TimeInstant(epochNS / 1000000000n - 1, Number(epochNS % 1000000000 + 1000000000)), tzQhr);
1996
2044
  }
1997
2045
  else
1998
2046
  {
1999
- return new Timestamp(new TimeInstant(Math.floor(epochNS / 1000000000), (epochNS % 1000000000)), tzQhr);
2047
+ return new Timestamp(new TimeInstant(epochNS / 1000000000n, Number(epochNS % 1000000000)), tzQhr);
2000
2048
  }
2001
2049
  }
2002
2050
 
@@ -2222,7 +2270,7 @@ export class Timestamp
2222
2270
  {
2223
2271
  if (this.inst.nanosec == 0)
2224
2272
  {
2225
- if (((this.inst.sec + this.tzQhr * 900) % 86400) == 0)
2273
+ if (((this.inst.sec + BigInt(this.tzQhr * 900)) % 86400n) == 0)
2226
2274
  {
2227
2275
  return this.toString("yyyy-MM-dd");
2228
2276
  }
@@ -2292,3 +2340,222 @@ export class Timestamp
2292
2340
  return new Timestamp(this.inst.roundToS(), this.tzQhr);
2293
2341
  }
2294
2342
  }
2343
+
2344
+ export class ByteReader
2345
+ {
2346
+ constructor(arr)
2347
+ {
2348
+ this.view = new DataView(arr);
2349
+ }
2350
+
2351
+ getLength()
2352
+ {
2353
+ return this.view.byteLength;
2354
+ }
2355
+
2356
+ getArrayBuffer(ofst, size)
2357
+ {
2358
+ if (ofst == null)
2359
+ ofst = 0;
2360
+ if (size == null)
2361
+ size = this.view.byteLength - ofst;
2362
+ return this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + ofst + size);
2363
+ }
2364
+
2365
+ getU8Arr(ofst, size)
2366
+ {
2367
+ return new Uint8Array(this.getArrayBuffer(ofst, size));
2368
+ }
2369
+
2370
+ readUInt8(ofst)
2371
+ {
2372
+ return this.view.getUint8(ofst);
2373
+ }
2374
+
2375
+ readUInt16(ofst, lsb)
2376
+ {
2377
+ return this.view.getUint16(ofst, lsb);
2378
+ }
2379
+
2380
+ readUInt24(ofst, lsb)
2381
+ {
2382
+ if (lsb)
2383
+ return this.view.getUint8(ofst) + (this.view.getUint16(ofst + 1, true) << 8);
2384
+ else
2385
+ return (this.view.getUint16(ofst, false) << 8) | this.view.getUint8(ofst + 2);
2386
+ }
2387
+
2388
+ readUInt32(ofst, lsb)
2389
+ {
2390
+ return this.view.getUint32(ofst, lsb);
2391
+ }
2392
+
2393
+ readInt8(ofst)
2394
+ {
2395
+ return this.view.getInt8(ofst);
2396
+ }
2397
+
2398
+ readInt16(ofst, lsb)
2399
+ {
2400
+ return this.view.getInt16(ofst, lsb);
2401
+ }
2402
+
2403
+ readInt24(ofst, lsb)
2404
+ {
2405
+ if (lsb)
2406
+ return this.view.getUint8(ofst) + (this.view.getInt16(ofst + 1, true) << 8);
2407
+ else
2408
+ return (this.view.getInt16(ofst, false) << 8) | this.view.getUint8(ofst + 2);
2409
+ }
2410
+
2411
+ readInt32(ofst, lsb)
2412
+ {
2413
+ return this.view.getInt32(ofst, lsb);
2414
+ }
2415
+
2416
+ readFloat64(ofst, lsb)
2417
+ {
2418
+ return this.view.getFloat64(ofst, lsb);
2419
+ }
2420
+
2421
+ readUTF8(ofst, len)
2422
+ {
2423
+ let dec = new TextDecoder();
2424
+ return dec.decode(this.getArrayBuffer(ofst, len));
2425
+ }
2426
+
2427
+ readUTF8Z(ofst, maxSize)
2428
+ {
2429
+ let end = ofst;
2430
+ let maxEnd;
2431
+ if (maxSize)
2432
+ {
2433
+ maxEnd = ofst + maxSize;
2434
+ if (maxEnd > this.view.byteLength)
2435
+ maxEnd = this.view.byteLength;
2436
+ }
2437
+ else
2438
+ {
2439
+ maxEnd = this.view.byteLength;
2440
+ }
2441
+ while (end < maxEnd && this.view.getUint8(end) != 0)
2442
+ end++;
2443
+ let dec = new TextDecoder();
2444
+ return dec.decode(this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + end));
2445
+ }
2446
+
2447
+ readUTF16(ofst, nChar, lsb)
2448
+ {
2449
+ let ret = [];
2450
+ while (nChar-- > 0)
2451
+ {
2452
+ ret.push(String.fromCharCode(this.readUInt16(ofst, lsb)));
2453
+ ofst += 2;
2454
+ }
2455
+ return ret.join("");
2456
+ }
2457
+
2458
+ readUInt8Arr(ofst, cnt)
2459
+ {
2460
+ let ret = [];
2461
+ while (cnt-- > 0)
2462
+ {
2463
+ ret.push(this.readUInt8(ofst));
2464
+ ofst++;
2465
+ }
2466
+ return ret;
2467
+ }
2468
+
2469
+ readUInt16Arr(ofst, lsb, cnt)
2470
+ {
2471
+ let ret = [];
2472
+ while (cnt-- > 0)
2473
+ {
2474
+ ret.push(this.readUInt16(ofst, lsb));
2475
+ ofst += 2;
2476
+ }
2477
+ return ret;
2478
+ }
2479
+
2480
+ readUInt32Arr(ofst, lsb, cnt)
2481
+ {
2482
+ let ret = [];
2483
+ while (cnt-- > 0)
2484
+ {
2485
+ ret.push(this.readUInt32(ofst, lsb));
2486
+ ofst += 4;
2487
+ }
2488
+ return ret;
2489
+ }
2490
+
2491
+ readInt8Arr(ofst, cnt)
2492
+ {
2493
+ let ret = [];
2494
+ while (cnt-- > 0)
2495
+ {
2496
+ ret.push(this.readInt8(ofst));
2497
+ ofst++;
2498
+ }
2499
+ return ret;
2500
+ }
2501
+
2502
+ readInt16Arr(ofst, lsb, cnt)
2503
+ {
2504
+ let ret = [];
2505
+ while (cnt-- > 0)
2506
+ {
2507
+ ret.push(this.readInt16(ofst, lsb));
2508
+ ofst += 2;
2509
+ }
2510
+ return ret;
2511
+ }
2512
+
2513
+ readInt32Arr(ofst, lsb, cnt)
2514
+ {
2515
+ let ret = [];
2516
+ while (cnt-- > 0)
2517
+ {
2518
+ ret.push(this.readInt32(ofst, lsb));
2519
+ ofst += 4;
2520
+ }
2521
+ return ret;
2522
+ }
2523
+
2524
+ readFloat64Arr(ofst, lsb, cnt)
2525
+ {
2526
+ let ret = [];
2527
+ while (cnt-- > 0)
2528
+ {
2529
+ ret.push(this.readFloat64(ofst, lsb));
2530
+ ofst += 8;
2531
+ }
2532
+ return ret;
2533
+ }
2534
+
2535
+ isASCIIText(ofst, len)
2536
+ {
2537
+ while (len-- > 0)
2538
+ {
2539
+ let b = this.readUInt8(ofst);
2540
+ if ((b >= 0x20 && b < 0x7F) || b == 13 || b == 10)
2541
+ {
2542
+
2543
+ }
2544
+ else
2545
+ {
2546
+ return false;
2547
+ }
2548
+ ofst++;
2549
+ }
2550
+ return true;
2551
+ }
2552
+ }
2553
+
2554
+ export class ParsedObject
2555
+ {
2556
+ constructor(sourceName, objType)
2557
+ {
2558
+ this.sourceName = sourceName;
2559
+ this.objType = objType;
2560
+ }
2561
+ }