node-opcua-basic-types 2.71.0 → 2.74.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/LICENSE +3 -1
- package/dist/array.d.ts +16 -16
- package/dist/array.js +44 -44
- package/dist/attributeIds.d.ts +34 -34
- package/dist/attributeIds.js +48 -48
- package/dist/boolean.d.ts +9 -9
- package/dist/boolean.js +33 -33
- package/dist/byte_string.d.ts +11 -11
- package/dist/byte_string.js +36 -36
- package/dist/data_type.d.ts +31 -0
- package/dist/data_type.js +36 -0
- package/dist/data_type.js.map +1 -0
- package/dist/date_time.d.ts +6 -6
- package/dist/date_time.js +20 -20
- package/dist/floats.d.ts +16 -16
- package/dist/floats.js +80 -80
- package/dist/guid.d.ts +9 -9
- package/dist/guid.js +121 -121
- package/dist/index.d.ts +19 -18
- package/dist/index.js +33 -32
- package/dist/index.js.map +1 -1
- package/dist/integers.d.ts +66 -66
- package/dist/integers.js +308 -292
- package/dist/integers.js.map +1 -1
- package/dist/locale_id.d.ts +9 -9
- package/dist/locale_id.js +18 -18
- package/dist/node_id.d.ts +9 -9
- package/dist/node_id.js +188 -188
- package/dist/round_to_float.d.ts +1 -1
- package/dist/round_to_float.js +26 -26
- package/dist/status_code.d.ts +4 -4
- package/dist/status_code.js +20 -20
- package/dist/string.d.ts +12 -12
- package/dist/string.js +30 -30
- package/dist/utils.d.ts +12 -12
- package/dist/utils.js +19 -19
- package/package.json +13 -13
- package/source/data_type.ts +31 -0
- package/source/index.ts +9 -8
- package/source/integers.ts +18 -4
package/dist/string.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***
|
|
3
|
-
* @module node-opcua-basic-types
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.encodeUAString = exports.decodeUAString = exports.encodeString = exports.decodeString = exports.randomString = exports.isValidString = void 0;
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
function isValidString(value) {
|
|
9
|
-
return typeof value === "string";
|
|
10
|
-
}
|
|
11
|
-
exports.isValidString = isValidString;
|
|
12
|
-
function randomString() {
|
|
13
|
-
const nbCar = (0, utils_1.getRandomInt)(1, 20);
|
|
14
|
-
const cars = [];
|
|
15
|
-
for (let i = 0; i < nbCar; i++) {
|
|
16
|
-
cars.push(String.fromCharCode(65 + (0, utils_1.getRandomInt)(0, 26)));
|
|
17
|
-
}
|
|
18
|
-
return cars.join("");
|
|
19
|
-
}
|
|
20
|
-
exports.randomString = randomString;
|
|
21
|
-
function decodeString(stream, value) {
|
|
22
|
-
return stream.readString();
|
|
23
|
-
}
|
|
24
|
-
exports.decodeString = decodeString;
|
|
25
|
-
function encodeString(value, stream) {
|
|
26
|
-
stream.writeString(value);
|
|
27
|
-
}
|
|
28
|
-
exports.encodeString = encodeString;
|
|
29
|
-
exports.decodeUAString = decodeString;
|
|
30
|
-
exports.encodeUAString = encodeString;
|
|
1
|
+
"use strict";
|
|
2
|
+
/***
|
|
3
|
+
* @module node-opcua-basic-types
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.encodeUAString = exports.decodeUAString = exports.encodeString = exports.decodeString = exports.randomString = exports.isValidString = void 0;
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
function isValidString(value) {
|
|
9
|
+
return typeof value === "string";
|
|
10
|
+
}
|
|
11
|
+
exports.isValidString = isValidString;
|
|
12
|
+
function randomString() {
|
|
13
|
+
const nbCar = (0, utils_1.getRandomInt)(1, 20);
|
|
14
|
+
const cars = [];
|
|
15
|
+
for (let i = 0; i < nbCar; i++) {
|
|
16
|
+
cars.push(String.fromCharCode(65 + (0, utils_1.getRandomInt)(0, 26)));
|
|
17
|
+
}
|
|
18
|
+
return cars.join("");
|
|
19
|
+
}
|
|
20
|
+
exports.randomString = randomString;
|
|
21
|
+
function decodeString(stream, value) {
|
|
22
|
+
return stream.readString();
|
|
23
|
+
}
|
|
24
|
+
exports.decodeString = decodeString;
|
|
25
|
+
function encodeString(value, stream) {
|
|
26
|
+
stream.writeString(value);
|
|
27
|
+
}
|
|
28
|
+
exports.encodeString = encodeString;
|
|
29
|
+
exports.decodeUAString = decodeString;
|
|
30
|
+
exports.encodeUAString = encodeString;
|
|
31
31
|
//# sourceMappingURL=string.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* return a random integer value in the range of min inclusive and max exclusive
|
|
6
|
-
* @method getRandomInt
|
|
7
|
-
* @param min
|
|
8
|
-
* @param max
|
|
9
|
-
* @return {*}
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
export declare function getRandomInt(min: number, max: number): number;
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* return a random integer value in the range of min inclusive and max exclusive
|
|
6
|
+
* @method getRandomInt
|
|
7
|
+
* @param min
|
|
8
|
+
* @param max
|
|
9
|
+
* @return {*}
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRandomInt(min: number, max: number): number;
|
package/dist/utils.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRandomInt = void 0;
|
|
4
|
-
/***
|
|
5
|
-
* @module node-opcua-basic-types
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* return a random integer value in the range of min inclusive and max exclusive
|
|
9
|
-
* @method getRandomInt
|
|
10
|
-
* @param min
|
|
11
|
-
* @param max
|
|
12
|
-
* @return {*}
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
function getRandomInt(min, max) {
|
|
16
|
-
// note : Math.random() returns a random number between 0 (inclusive) and 1 (exclusive):
|
|
17
|
-
return Math.floor(Math.random() * (max - min)) + min;
|
|
18
|
-
}
|
|
19
|
-
exports.getRandomInt = getRandomInt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomInt = void 0;
|
|
4
|
+
/***
|
|
5
|
+
* @module node-opcua-basic-types
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* return a random integer value in the range of min inclusive and max exclusive
|
|
9
|
+
* @method getRandomInt
|
|
10
|
+
* @param min
|
|
11
|
+
* @param max
|
|
12
|
+
* @return {*}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
function getRandomInt(min, max) {
|
|
16
|
+
// note : Math.random() returns a random number between 0 (inclusive) and 1 (exclusive):
|
|
17
|
+
return Math.floor(Math.random() * (max - min)) + min;
|
|
18
|
+
}
|
|
19
|
+
exports.getRandomInt = getRandomInt;
|
|
20
20
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-basic-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.74.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -basic-types",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"lint": "eslint source/*.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"node-opcua-assert": "2.
|
|
15
|
-
"node-opcua-binary-stream": "2.
|
|
16
|
-
"node-opcua-buffer-utils": "2.
|
|
17
|
-
"node-opcua-date-time": "2.
|
|
18
|
-
"node-opcua-enum": "2.
|
|
19
|
-
"node-opcua-guid": "2.
|
|
20
|
-
"node-opcua-nodeid": "2.
|
|
21
|
-
"node-opcua-status-code": "2.
|
|
22
|
-
"node-opcua-utils": "2.
|
|
14
|
+
"node-opcua-assert": "2.74.0",
|
|
15
|
+
"node-opcua-binary-stream": "2.74.0",
|
|
16
|
+
"node-opcua-buffer-utils": "2.74.0",
|
|
17
|
+
"node-opcua-date-time": "2.74.0",
|
|
18
|
+
"node-opcua-enum": "2.74.0",
|
|
19
|
+
"node-opcua-guid": "2.74.0",
|
|
20
|
+
"node-opcua-nodeid": "2.74.0",
|
|
21
|
+
"node-opcua-status-code": "2.74.0",
|
|
22
|
+
"node-opcua-utils": "2.74.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "18.0.0",
|
|
26
|
-
"node-opcua-benchmarker": "2.
|
|
27
|
-
"node-opcua-debug": "2.
|
|
26
|
+
"node-opcua-benchmarker": "2.74.0",
|
|
27
|
+
"node-opcua-debug": "2.74.0",
|
|
28
28
|
"should": "^13.2.3"
|
|
29
29
|
},
|
|
30
30
|
"author": "Etienne Rossignon",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"internet of things"
|
|
43
43
|
],
|
|
44
44
|
"homepage": "http://node-opcua.github.io/",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "003ee041795f3b737afaaef5721045ee31ea9f77"
|
|
46
46
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
export enum DataType {
|
|
5
|
+
Null = 0,
|
|
6
|
+
Boolean = 1,
|
|
7
|
+
SByte = 2, // signed Byte = Int8
|
|
8
|
+
Byte = 3, // unsigned Byte = UInt8
|
|
9
|
+
Int16 = 4,
|
|
10
|
+
UInt16 = 5,
|
|
11
|
+
Int32 = 6,
|
|
12
|
+
UInt32 = 7,
|
|
13
|
+
Int64 = 8,
|
|
14
|
+
UInt64 = 9,
|
|
15
|
+
Float = 10,
|
|
16
|
+
Double = 11,
|
|
17
|
+
String = 12,
|
|
18
|
+
DateTime = 13,
|
|
19
|
+
Guid = 14,
|
|
20
|
+
ByteString = 15,
|
|
21
|
+
XmlElement = 16,
|
|
22
|
+
NodeId = 17,
|
|
23
|
+
ExpandedNodeId = 18,
|
|
24
|
+
StatusCode = 19,
|
|
25
|
+
QualifiedName = 20,
|
|
26
|
+
LocalizedText = 21,
|
|
27
|
+
ExtensionObject = 22,
|
|
28
|
+
DataValue = 23,
|
|
29
|
+
Variant = 24,
|
|
30
|
+
DiagnosticInfo = 25
|
|
31
|
+
}
|
package/source/index.ts
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* @module node-opcua-basic-types
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
export * from "./array";
|
|
6
|
+
export * from "./attributeIds";
|
|
5
7
|
export * from "./boolean";
|
|
6
|
-
export * from "./integers";
|
|
7
|
-
export * from "./floats";
|
|
8
|
-
export * from "./string";
|
|
9
|
-
export * from "./date_time";
|
|
10
8
|
export * from "./byte_string";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
9
|
+
export * from "./data_type";
|
|
10
|
+
export * from "./date_time";
|
|
11
|
+
export * from "./floats";
|
|
13
12
|
export * from "./guid";
|
|
14
|
-
export * from "./
|
|
13
|
+
export * from "./integers";
|
|
15
14
|
export * from "./locale_id";
|
|
16
|
-
export * from "./
|
|
15
|
+
export * from "./node_id";
|
|
17
16
|
export * from "./round_to_float";
|
|
17
|
+
export * from "./status_code";
|
|
18
|
+
export * from "./string";
|
|
18
19
|
export type ByteString = Buffer;
|
package/source/integers.ts
CHANGED
|
@@ -155,7 +155,7 @@ export function randomUInt64(): UInt64 {
|
|
|
155
155
|
return [getRandomInt(0, 0xffffffff), getRandomInt(0, 0xffffffff)];
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
export function encodeUInt64(value: UInt64 | number, stream: OutputBinaryStream): void
|
|
158
|
+
export function encodeUInt64(value: UInt64 | number, stream: OutputBinaryStream): void {
|
|
159
159
|
if (typeof value === "number") {
|
|
160
160
|
const arr = coerceUInt64(value);
|
|
161
161
|
stream.writeUInt32(arr[1]);
|
|
@@ -173,6 +173,10 @@ export function decodeUInt64(stream: BinaryStream, value?: UInt64): UInt64 {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export function constructInt64(high: UInt32, low: UInt32): Int64 {
|
|
176
|
+
if (high === 0 && low < 0) {
|
|
177
|
+
high = 0xffffffff;
|
|
178
|
+
low = 0xffffffff + low + 1;
|
|
179
|
+
}
|
|
176
180
|
assert(low >= 0 && low <= 0xffffffff);
|
|
177
181
|
assert(high >= 0 && high <= 0xffffffff);
|
|
178
182
|
return [high, low];
|
|
@@ -192,14 +196,24 @@ export function coerceUInt64(value: number | UInt64 | Int32 | string | null): UI
|
|
|
192
196
|
}
|
|
193
197
|
if (typeof value === "string") {
|
|
194
198
|
v = value.split(",");
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
if (v.length === 1) {
|
|
200
|
+
// was a single string, good news ! BigInt can be used with nodejs >=12
|
|
201
|
+
let a = BigInt(value);
|
|
202
|
+
if (a < BigInt(0)) {
|
|
203
|
+
const mask = BigInt("0xFFFFFFFFFFFFFFFF");
|
|
204
|
+
a = (mask + a + BigInt(1)) & mask;
|
|
205
|
+
}
|
|
206
|
+
high = Number(a >> BigInt(32));
|
|
207
|
+
low = Number(a & BigInt(0xffffffff));
|
|
208
|
+
} else {
|
|
209
|
+
high = parseInt(v[0], 10);
|
|
210
|
+
low = parseInt(v[1], 10);
|
|
211
|
+
}
|
|
197
212
|
return constructInt64(high, low);
|
|
198
213
|
}
|
|
199
214
|
if (value > 0xffffffff) {
|
|
200
215
|
// beware : as per javascript, value is a double here !
|
|
201
216
|
// our conversion will suffer from some inaccuracy
|
|
202
|
-
|
|
203
217
|
high = Math.floor(value / 0x100000000);
|
|
204
218
|
low = value - high * 0x100000000;
|
|
205
219
|
return constructInt64(high, low);
|