bun-memory 1.1.11 → 1.1.12

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.
@@ -9,6 +9,8 @@ import Memory from '../index.ts';
9
9
  import ClientDLLJSON from './offsets/client_dll.json';
10
10
  import OffsetsJSON from './offsets/offsets.json';
11
11
 
12
+ const { random } = Math;
13
+
12
14
  // !
13
15
  const buffer = Buffer.from('Hello world!');
14
16
  const bufferPtr = ptr(buffer);
@@ -20,8 +22,6 @@ console.log(cString.byteLength, cString.byteOffset); // undefined undefined
20
22
 
21
23
  const Delay = 2.5;
22
24
 
23
- const { random } = Math;
24
-
25
25
  // Load user32.dll…
26
26
  const {
27
27
  symbols: { mouse_event },
@@ -52,6 +52,18 @@ const ClientPtr = cs2.modules['client.dll']?.base;
52
52
  if (ClientPtr === undefined) {
53
53
  throw new TypeError('ClientPtr must not be undefined.');
54
54
  }
55
+ // !
56
+
57
+ console.time('Read test');
58
+
59
+ for (let i = 0; i < 10_000_000; i++) {
60
+ // new Uint8Array((random() * 256 + 1) >> 0);
61
+ Buffer.allocUnsafe((random() * 256 + 1) >> 0);
62
+ }
63
+
64
+ console.timeEnd('Read test');
65
+
66
+ // !
55
67
 
56
68
  // Create a cache for class name strings… 🫠…
57
69
  const Cache_Names = new Map<bigint, string>();
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.1.11",
25
+ "version": "1.1.12",
26
26
  "main": "./index.ts",
27
27
  "keywords": [
28
28
  "bun",
package/structs/Memory.ts CHANGED
@@ -459,7 +459,7 @@ class Memory {
459
459
  public cString(address: bigint, value: CString): this;
460
460
  public cString(address: bigint, lengthOrValue: number | CString): CString | this {
461
461
  if (typeof lengthOrValue === 'number') {
462
- const scratch = Buffer.allocUnsafe(lengthOrValue);
462
+ const scratch = new Uint8Array(lengthOrValue);
463
463
 
464
464
  this.read(address, scratch);
465
465