bun-memory 1.1.48 → 1.1.49

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/structs/Memory.ts +62 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-memory",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "author": "Stev Peifer <stev@bell.net>",
5
5
  "repository": {
6
6
  "type": "git",
package/structs/Memory.ts CHANGED
@@ -1592,8 +1592,12 @@ class Memory {
1592
1592
  const dataPtr = this.u64(address);
1593
1593
 
1594
1594
  if (values === undefined) {
1595
- const count = this.u32(address + 0x08n);
1596
- const scratch = new Float32Array(count);
1595
+ const count = this.u32(address + 0x08n),
1596
+ scratch = new Float32Array(count); // prettier-ignore
1597
+
1598
+ if (count === 0) {
1599
+ return scratch;
1600
+ }
1597
1601
 
1598
1602
  void this.read(dataPtr, scratch);
1599
1603
 
@@ -1626,8 +1630,12 @@ class Memory {
1626
1630
  const dataPtr = this.u64(address);
1627
1631
 
1628
1632
  if (values === undefined) {
1629
- const count = this.u32(address + 0x08n);
1630
- const scratch = new Float64Array(count);
1633
+ const count = this.u32(address + 0x08n),
1634
+ scratch = new Float64Array(count); // prettier-ignore
1635
+
1636
+ if (count === 0) {
1637
+ return scratch;
1638
+ }
1631
1639
 
1632
1640
  void this.read(dataPtr, scratch);
1633
1641
 
@@ -1660,8 +1668,12 @@ class Memory {
1660
1668
  const dataPtr = this.u64(address);
1661
1669
 
1662
1670
  if (values === undefined) {
1663
- const count = this.u32(address + 0x08n);
1664
- const scratch = new Int16Array(count);
1671
+ const count = this.u32(address + 0x08n),
1672
+ scratch = new Int16Array(count); // prettier-ignore
1673
+
1674
+ if (count === 0) {
1675
+ return scratch;
1676
+ }
1665
1677
 
1666
1678
  void this.read(dataPtr, scratch);
1667
1679
 
@@ -1694,8 +1706,12 @@ class Memory {
1694
1706
  const dataPtr = this.u64(address);
1695
1707
 
1696
1708
  if (values === undefined) {
1697
- const count = this.u32(address + 0x08n);
1698
- const scratch = new Int32Array(count);
1709
+ const count = this.u32(address + 0x08n),
1710
+ scratch = new Int32Array(count); // prettier-ignore
1711
+
1712
+ if (count === 0) {
1713
+ return scratch;
1714
+ }
1699
1715
 
1700
1716
  void this.read(dataPtr, scratch);
1701
1717
 
@@ -1728,8 +1744,12 @@ class Memory {
1728
1744
  const dataPtr = this.u64(address);
1729
1745
 
1730
1746
  if (values === undefined) {
1731
- const count = this.u32(address + 0x08n);
1732
- const scratch = new BigInt64Array(count);
1747
+ const count = this.u32(address + 0x08n),
1748
+ scratch = new BigInt64Array(count); // prettier-ignore
1749
+
1750
+ if (count === 0) {
1751
+ return scratch;
1752
+ }
1733
1753
 
1734
1754
  void this.read(dataPtr, scratch);
1735
1755
 
@@ -1762,8 +1782,12 @@ class Memory {
1762
1782
  const dataPtr = this.u64(address);
1763
1783
 
1764
1784
  if (values === undefined) {
1765
- const count = this.u32(address + 0x08n);
1766
- const scratch = new Int8Array(count);
1785
+ const count = this.u32(address + 0x08n),
1786
+ scratch = new Int8Array(count); // prettier-ignore
1787
+
1788
+ if (count === 0) {
1789
+ return scratch;
1790
+ }
1767
1791
 
1768
1792
  void this.read(dataPtr, scratch);
1769
1793
 
@@ -1798,8 +1822,8 @@ class Memory {
1798
1822
  const dataPtr = this.u64(address);
1799
1823
 
1800
1824
  if (typeof dataSizeOrValues === 'number') {
1801
- const dataSize = dataSizeOrValues;
1802
- const count = this.u32(address + 0x08n);
1825
+ const count = this.u32(address + 0x08n),
1826
+ dataSize = dataSizeOrValues; // prettier-ignore
1803
1827
 
1804
1828
  if (count === 0) {
1805
1829
  return [];
@@ -1852,8 +1876,12 @@ class Memory {
1852
1876
  const dataPtr = this.u64(address);
1853
1877
 
1854
1878
  if (values === undefined) {
1855
- const count = this.u32(address + 0x08n);
1856
- const scratch = new Uint16Array(count);
1879
+ const count = this.u32(address + 0x08n),
1880
+ scratch = new Uint16Array(count); // prettier-ignore
1881
+
1882
+ if (count === 0) {
1883
+ return scratch;
1884
+ }
1857
1885
 
1858
1886
  void this.read(dataPtr, scratch);
1859
1887
 
@@ -1886,8 +1914,12 @@ class Memory {
1886
1914
  const dataPtr = this.u64(address);
1887
1915
 
1888
1916
  if (values === undefined) {
1889
- const count = this.u32(address + 0x08n);
1890
- const scratch = new Uint32Array(count);
1917
+ const count = this.u32(address + 0x08n),
1918
+ scratch = new Uint32Array(count); // prettier-ignore
1919
+
1920
+ if (count === 0) {
1921
+ return scratch;
1922
+ }
1891
1923
 
1892
1924
  void this.read(dataPtr, scratch);
1893
1925
 
@@ -1920,8 +1952,12 @@ class Memory {
1920
1952
  const dataPtr = this.u64(address);
1921
1953
 
1922
1954
  if (values === undefined) {
1923
- const count = this.u32(address + 0x08n);
1924
- const scratch = new BigUint64Array(count);
1955
+ const count = this.u32(address + 0x08n),
1956
+ scratch = new BigUint64Array(count); // prettier-ignore
1957
+
1958
+ if (count === 0) {
1959
+ return scratch;
1960
+ }
1925
1961
 
1926
1962
  void this.read(dataPtr, scratch);
1927
1963
 
@@ -1954,8 +1990,12 @@ class Memory {
1954
1990
  const dataPtr = this.u64(address);
1955
1991
 
1956
1992
  if (values === undefined) {
1957
- const count = this.u32(address + 0x08n);
1958
- const scratch = new Uint8Array(count);
1993
+ const count = this.u32(address + 0x08n),
1994
+ scratch = new Uint8Array(count); // prettier-ignore
1995
+
1996
+ if (count === 0) {
1997
+ return scratch;
1998
+ }
1959
1999
 
1960
2000
  void this.read(dataPtr, scratch);
1961
2001