bun-memory 1.1.41 → 1.1.42
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/package.json +1 -1
- package/structs/Memory.ts +12 -10
package/package.json
CHANGED
package/structs/Memory.ts
CHANGED
|
@@ -1796,22 +1796,24 @@ class Memory {
|
|
|
1796
1796
|
/**
|
|
1797
1797
|
* Reads or writes a generic UtlVector as raw bytes (no typing).
|
|
1798
1798
|
* Pass elementSize (bytes per element) so we can set/read the header count.
|
|
1799
|
-
* Optionally provide countOverride to read a specific number of elements regardless of the stored size.
|
|
1800
1799
|
* @example
|
|
1801
1800
|
* ```ts
|
|
1802
|
-
* const bytes = cs2.utlVectorRaw(0x1234n, 0x14
|
|
1803
|
-
* cs2.utlVectorRaw(0x1234n, 0x14); // read size from header
|
|
1801
|
+
* const bytes = cs2.utlVectorRaw(0x1234n, 0x14); // read size*elementSize bytes
|
|
1804
1802
|
* cs2.utlVectorRaw(0x1234n, 0x14, new Uint8Array([...])); // write
|
|
1805
1803
|
* ```
|
|
1806
1804
|
*/
|
|
1807
1805
|
public utlVectorRaw(address: bigint, elementSize: number): Uint8Array;
|
|
1808
|
-
public utlVectorRaw(address: bigint, elementSize: number, count: number): Uint8Array;
|
|
1809
1806
|
public utlVectorRaw(address: bigint, elementSize: number, values: Uint8Array, force?: boolean): this;
|
|
1810
|
-
public utlVectorRaw(address: bigint, elementSize: number,
|
|
1807
|
+
public utlVectorRaw(address: bigint, elementSize: number, values?: Uint8Array, force?: boolean): Uint8Array | this {
|
|
1811
1808
|
const elementsPtr = this.u64(address + 0x08n);
|
|
1812
1809
|
|
|
1813
|
-
if (
|
|
1814
|
-
const count =
|
|
1810
|
+
if (values === undefined) {
|
|
1811
|
+
const count = this.u32(address);
|
|
1812
|
+
|
|
1813
|
+
if (count === 0 || elementsPtr === 0n) {
|
|
1814
|
+
return new Uint8Array(0);
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1815
1817
|
const byteLength = count * elementSize;
|
|
1816
1818
|
const scratch = new Uint8Array(byteLength);
|
|
1817
1819
|
|
|
@@ -1820,15 +1822,15 @@ class Memory {
|
|
|
1820
1822
|
return scratch;
|
|
1821
1823
|
}
|
|
1822
1824
|
|
|
1823
|
-
if (
|
|
1825
|
+
if (values.byteLength % elementSize !== 0) {
|
|
1824
1826
|
throw new RangeError('values length must be a multiple of elementSize');
|
|
1825
1827
|
}
|
|
1826
1828
|
|
|
1827
|
-
const count =
|
|
1829
|
+
const count = values.byteLength / elementSize;
|
|
1828
1830
|
|
|
1829
1831
|
this.u32(address, count, force);
|
|
1830
1832
|
|
|
1831
|
-
void this.write(elementsPtr,
|
|
1833
|
+
void this.write(elementsPtr, values, force);
|
|
1832
1834
|
|
|
1833
1835
|
return this;
|
|
1834
1836
|
}
|