bun-memory 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -58,12 +58,16 @@ const myView = new BigUint64Array(myScratch.buffer, myScratch.byteOffset, 0xf000
58
58
 
59
59
  while (true) {
60
60
  memory.readInto(myAddress, myScratch); // Updates myView with no new allocations…
61
+
62
+ // …or…
63
+
64
+ memory.readBuffer(myAddress, 0xf000, myScratch); // Also updates myView with no new allocations…
61
65
  }
62
66
  ```
63
67
 
64
68
  ```ts
65
- const myScratch = Buffer.allocUnsafe(0x256);
66
- const myValue = memory.readString(myAddress, myScratch);
69
+ const myScratch = Buffer.allocUnsafe(0x100);
70
+ const myValue = memory.readString(myAddress, 0x100, myScratch);
67
71
  ```
68
72
 
69
73
  ### Notes
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "url": "git://github.com/obscuritysrl/bun-memory.git"
23
23
  },
24
24
  "type": "module",
25
- "version": "1.0.1",
25
+ "version": "1.0.3",
26
26
  "main": "./index.ts",
27
27
  "keywords": [
28
28
  "bun",
package/structs/Memory.ts CHANGED
@@ -1296,6 +1296,33 @@ class Memory {
1296
1296
 
1297
1297
  return this;
1298
1298
  }
1299
+
1300
+ /**
1301
+ * Write a {@link Vector3} as three consecutive 32-bit little-endian floats at the target address.
1302
+ *
1303
+ * Layout:
1304
+ * - +0x00 = x (float32)
1305
+ * - +0x04 = y (float32)
1306
+ * - +0x08 = z (float32)
1307
+ *
1308
+ * Uses `Memory.Scratch12` to avoid allocations and delegates to {@link writeBuffer}.
1309
+ *
1310
+ * @param address Destination address.
1311
+ * @param value Vector with `x`, `y`, and `z` components to write.
1312
+ * @param force When true, temporarily enables `PAGE_EXECUTE_READWRITE` to bypass protection.
1313
+ * @returns `this` for chaining.
1314
+ * @throws {Win32Error} If the underlying write or protection change fails.
1315
+ */
1316
+
1317
+ public writeVector3(address: bigint | number, value: Vector3, force = false): this {
1318
+ Memory.Scratch12.writeFloatLE(value.x);
1319
+ Memory.Scratch12.writeFloatLE(value.y, 0x04);
1320
+ Memory.Scratch12.writeFloatLE(value.z, 0x08);
1321
+
1322
+ this.writeBuffer(address, Memory.Scratch12, force);
1323
+
1324
+ return this;
1325
+ }
1299
1326
  }
1300
1327
 
1301
1328
  export default Memory;