node-opcua-binary-stream 2.176.0 → 2.180.0
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/binaryStream.d.ts +127 -1
- package/dist/binaryStream.js +259 -11
- package/dist/binaryStream.js.map +1 -1
- package/dist/binaryStreamSizeCalculator.d.ts +15 -9
- package/dist/binaryStreamSizeCalculator.js +22 -11
- package/dist/binaryStreamSizeCalculator.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +6 -6
- package/source/binaryStream.ts +305 -29
- package/source/binaryStreamSizeCalculator.ts +26 -14
- package/source/index.ts +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
4
|
import { assert } from "node-opcua-assert";
|
|
5
|
-
import { calculateByteLength } from "./binaryStream";
|
|
5
|
+
import { calculateByteLength, clampArrayBufferLength } from "./binaryStream";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* a BinaryStreamSizeCalculator can be used to quickly evaluate the required size
|
|
@@ -17,7 +17,6 @@ import { calculateByteLength } from "./binaryStream";
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
export class BinaryStreamSizeCalculator {
|
|
20
|
-
|
|
21
20
|
public length: number;
|
|
22
21
|
|
|
23
22
|
constructor() {
|
|
@@ -28,42 +27,55 @@ export class BinaryStreamSizeCalculator {
|
|
|
28
27
|
this.length = 0;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
public writeInt8(
|
|
30
|
+
public writeInt8(_value: number): void {
|
|
32
31
|
this.length += 1;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
public writeUInt8(
|
|
34
|
+
public writeUInt8(_value: number): void {
|
|
36
35
|
this.length += 1;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
public writeInt16(
|
|
38
|
+
public writeInt16(_value: number): void {
|
|
40
39
|
this.length += 2;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
public writeInteger(
|
|
42
|
+
public writeInteger(_value: number): void {
|
|
44
43
|
this.length += 4;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
public writeUInt32(
|
|
46
|
+
public writeUInt32(_value: number): void {
|
|
48
47
|
this.length += 4;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
public writeUInt16(
|
|
50
|
+
public writeUInt16(_value: number): void {
|
|
52
51
|
this.length += 2;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
public
|
|
54
|
+
public writeFloat(_value: number): void {
|
|
56
55
|
this.length += 4;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
public writeDouble(
|
|
58
|
+
public writeDouble(_value: number): void {
|
|
60
59
|
this.length += 8;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
/**
|
|
63
|
+
* counterpart of BinaryStream.reserveUInt32: only the 4 reserved bytes matter here.
|
|
64
|
+
* The returned position is meaningless for a calculator - patchUInt32 ignores it.
|
|
65
|
+
*/
|
|
66
|
+
public reserveUInt32(): number {
|
|
67
|
+
this.length += 4;
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public patchUInt32(_position: number, _value: number): void {
|
|
72
|
+
/* nothing to patch: a size calculator only accumulates a byte count */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public writeArrayBuffer(arrayBuf: ArrayBuffer, offset = 0, byteLength?: number): void {
|
|
65
76
|
assert(arrayBuf instanceof ArrayBuffer);
|
|
66
|
-
|
|
77
|
+
// must resolve (offset, byteLength) exactly as BinaryStream.writeArrayBuffer does
|
|
78
|
+
this.length += clampArrayBufferLength(arrayBuf.byteLength, offset, byteLength);
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
public writeByteStream(buf: Buffer): void {
|
|
@@ -75,7 +87,7 @@ export class BinaryStreamSizeCalculator {
|
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
public writeString(str: null|string): void {
|
|
90
|
+
public writeString(str: null | string): void {
|
|
79
91
|
if (str === undefined || str === null) {
|
|
80
92
|
this.writeUInt32(-1);
|
|
81
93
|
return;
|
package/source/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
|
-
import { BinaryStream } from "./binaryStream";
|
|
5
|
-
import { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
4
|
+
import type { BinaryStream } from "./binaryStream";
|
|
5
|
+
import type { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
6
6
|
export type OutputBinaryStream = BinaryStream | BinaryStreamSizeCalculator;
|
|
7
7
|
|
|
8
8
|
export * from "./binaryStream";
|