@ffflorian/mock-udp 1.7.5 → 1.7.7

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare class Scope {
2
2
  _done: boolean;
3
3
  address?: string;
4
- buffer?: Buffer | string | Uint8Array | any[];
4
+ buffer?: ArrayBuffer | SharedArrayBuffer | NodeJS.TypedArray | string | readonly any[];
5
5
  length?: number;
6
6
  offset?: number;
7
7
  port?: number;
package/dist/index.js CHANGED
@@ -16,13 +16,14 @@ function overriddenSocketSend(msg, offsetOrPortOrCallback, lengthOrAddressOrCall
16
16
  const length = hasLengthAndOffset ? lengthOrAddressOrCallback || 0 : 0;
17
17
  const offset = hasLengthAndOffset ? offsetOrPortOrCallback : 0;
18
18
  const port = hasLengthAndOffset ? portOrCallback : offsetOrPortOrCallback;
19
- if (offset >= msg.length) {
19
+ const msgLength = msg instanceof DataView ? msg.byteLength : msg.length;
20
+ if (offset >= msgLength) {
20
21
  throw new Error('Offset into buffer too large.');
21
22
  }
22
- if (offset + length > msg.length) {
23
+ if (offset + length > msgLength) {
23
24
  throw new Error('Offset + length beyond buffer length.');
24
25
  }
25
- const newBuffer = msg.slice(offset, offset + length);
26
+ const newBuffer = msg instanceof DataView ? msg.buffer.slice(offset, offset + length) : msg.slice(offset, offset + length);
26
27
  const host = `${address}:${port}`;
27
28
  if (intercepts.hasOwnProperty(host)) {
28
29
  intercepts[host].forEach(scope => {
package/package.json CHANGED
@@ -3,8 +3,8 @@
3
3
  "description": "Mock dgram udp requests.",
4
4
  "devDependencies": {
5
5
  "rimraf": "6.0.1",
6
- "typescript": "5.8.2",
7
- "vitest": "3.0.7"
6
+ "typescript": "5.9.2",
7
+ "vitest": "3.2.4"
8
8
  },
9
9
  "engines": {
10
10
  "node": ">= 18.0"
@@ -24,6 +24,6 @@
24
24
  "test": "vitest run"
25
25
  },
26
26
  "type": "module",
27
- "version": "1.7.5",
28
- "gitHead": "7704629d81392a9c7858e1bdd974762598e953a2"
27
+ "version": "1.7.7",
28
+ "gitHead": "1aa19f41f8580d261fc64fd46827a8c7c56a64be"
29
29
  }