@ffflorian/mock-udp 1.7.5 → 1.7.6
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 +1 -1
- package/dist/index.js +4 -3
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
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
|
-
|
|
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 >
|
|
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.
|
|
7
|
-
"vitest": "3.
|
|
6
|
+
"typescript": "5.8.3",
|
|
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.
|
|
28
|
-
"gitHead": "
|
|
27
|
+
"version": "1.7.6",
|
|
28
|
+
"gitHead": "b834177d548b327ae16488fc9c8a55ba4cae02b3"
|
|
29
29
|
}
|