node-opcua-basic-types 2.97.0 → 2.98.1
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/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 -31
- package/dist/data_type.js +35 -35
- 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 -19
- package/dist/index.js +33 -33
- package/dist/integers.d.ts +66 -66
- package/dist/integers.js +308 -308
- 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 +17 -13
- package/nyc.config.js +0 -16
package/dist/date_time.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
/***
|
|
18
|
-
* @module node-opcua-basic-types
|
|
19
|
-
*/
|
|
20
|
-
__exportStar(require("node-opcua-date-time"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/***
|
|
18
|
+
* @module node-opcua-basic-types
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("node-opcua-date-time"), exports);
|
|
21
21
|
//# sourceMappingURL=date_time.js.map
|
package/dist/floats.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
5
|
-
export declare function isValidFloat(value: number): boolean;
|
|
6
|
-
export type Float = number;
|
|
7
|
-
export declare function randomFloat(): Float;
|
|
8
|
-
export declare function encodeFloat(value: Float, stream: OutputBinaryStream): void;
|
|
9
|
-
export declare function decodeFloat(stream: BinaryStream, value?: number): Float;
|
|
10
|
-
export declare function isValidDouble(value: number): boolean;
|
|
11
|
-
export type Double = number;
|
|
12
|
-
export declare function randomDouble(): Double;
|
|
13
|
-
export declare function encodeDouble(value: Double, stream: OutputBinaryStream): void;
|
|
14
|
-
export declare function decodeDouble(stream: BinaryStream, value?: number): Double;
|
|
15
|
-
export declare function coerceFloat(value: number | null | string): Float;
|
|
16
|
-
export declare function coerceDouble(value: number | null | string): Double;
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
5
|
+
export declare function isValidFloat(value: number): boolean;
|
|
6
|
+
export type Float = number;
|
|
7
|
+
export declare function randomFloat(): Float;
|
|
8
|
+
export declare function encodeFloat(value: Float, stream: OutputBinaryStream): void;
|
|
9
|
+
export declare function decodeFloat(stream: BinaryStream, value?: number): Float;
|
|
10
|
+
export declare function isValidDouble(value: number): boolean;
|
|
11
|
+
export type Double = number;
|
|
12
|
+
export declare function randomDouble(): Double;
|
|
13
|
+
export declare function encodeDouble(value: Double, stream: OutputBinaryStream): void;
|
|
14
|
+
export declare function decodeDouble(stream: BinaryStream, value?: number): Double;
|
|
15
|
+
export declare function coerceFloat(value: number | null | string): Float;
|
|
16
|
+
export declare function coerceDouble(value: number | null | string): Double;
|
package/dist/floats.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coerceDouble = exports.coerceFloat = exports.decodeDouble = exports.encodeDouble = exports.randomDouble = exports.isValidDouble = exports.decodeFloat = exports.encodeFloat = exports.randomFloat = exports.isValidFloat = void 0;
|
|
4
|
-
const minFloat = -3.4 * Math.pow(10, 38);
|
|
5
|
-
const maxFloat = 3.4 * Math.pow(10, 38);
|
|
6
|
-
/**
|
|
7
|
-
* return a random float value in the range of min inclusive and max exclusive
|
|
8
|
-
* @method getRandomInt
|
|
9
|
-
* @param min
|
|
10
|
-
* @param max
|
|
11
|
-
* @return {*}
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
function getRandomDouble(min, max) {
|
|
15
|
-
return Math.random() * (max - min) + min;
|
|
16
|
-
}
|
|
17
|
-
function isValidFloat(value) {
|
|
18
|
-
if (!isFinite(value)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return value > minFloat && value < maxFloat;
|
|
22
|
-
}
|
|
23
|
-
exports.isValidFloat = isValidFloat;
|
|
24
|
-
const r = new Float32Array(1);
|
|
25
|
-
function roundToFloat(float) {
|
|
26
|
-
r[0] = float;
|
|
27
|
-
const floatR = r[0];
|
|
28
|
-
return floatR;
|
|
29
|
-
}
|
|
30
|
-
function randomFloat() {
|
|
31
|
-
return roundToFloat(getRandomDouble(-1000, 1000));
|
|
32
|
-
}
|
|
33
|
-
exports.randomFloat = randomFloat;
|
|
34
|
-
function encodeFloat(value, stream) {
|
|
35
|
-
stream.writeFloat(value);
|
|
36
|
-
}
|
|
37
|
-
exports.encodeFloat = encodeFloat;
|
|
38
|
-
function decodeFloat(stream, value) {
|
|
39
|
-
return stream.readFloat();
|
|
40
|
-
}
|
|
41
|
-
exports.decodeFloat = decodeFloat;
|
|
42
|
-
function isValidDouble(value) {
|
|
43
|
-
if (!isFinite(value)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
exports.isValidDouble = isValidDouble;
|
|
49
|
-
function randomDouble() {
|
|
50
|
-
return getRandomDouble(-1000000, 1000000);
|
|
51
|
-
}
|
|
52
|
-
exports.randomDouble = randomDouble;
|
|
53
|
-
function encodeDouble(value, stream) {
|
|
54
|
-
stream.writeDouble(value);
|
|
55
|
-
}
|
|
56
|
-
exports.encodeDouble = encodeDouble;
|
|
57
|
-
function decodeDouble(stream, value) {
|
|
58
|
-
return stream.readDouble();
|
|
59
|
-
}
|
|
60
|
-
exports.decodeDouble = decodeDouble;
|
|
61
|
-
function coerceFloat(value) {
|
|
62
|
-
if (value === null || value === undefined) {
|
|
63
|
-
return 0.0;
|
|
64
|
-
}
|
|
65
|
-
if (typeof value === "number") {
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
return parseFloat(value);
|
|
69
|
-
}
|
|
70
|
-
exports.coerceFloat = coerceFloat;
|
|
71
|
-
function coerceDouble(value) {
|
|
72
|
-
if (value === null || value === undefined) {
|
|
73
|
-
return 0.0;
|
|
74
|
-
}
|
|
75
|
-
if (typeof value === "number") {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
return parseFloat(value);
|
|
79
|
-
}
|
|
80
|
-
exports.coerceDouble = coerceDouble;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coerceDouble = exports.coerceFloat = exports.decodeDouble = exports.encodeDouble = exports.randomDouble = exports.isValidDouble = exports.decodeFloat = exports.encodeFloat = exports.randomFloat = exports.isValidFloat = void 0;
|
|
4
|
+
const minFloat = -3.4 * Math.pow(10, 38);
|
|
5
|
+
const maxFloat = 3.4 * Math.pow(10, 38);
|
|
6
|
+
/**
|
|
7
|
+
* return a random float value in the range of min inclusive and max exclusive
|
|
8
|
+
* @method getRandomInt
|
|
9
|
+
* @param min
|
|
10
|
+
* @param max
|
|
11
|
+
* @return {*}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
function getRandomDouble(min, max) {
|
|
15
|
+
return Math.random() * (max - min) + min;
|
|
16
|
+
}
|
|
17
|
+
function isValidFloat(value) {
|
|
18
|
+
if (!isFinite(value)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return value > minFloat && value < maxFloat;
|
|
22
|
+
}
|
|
23
|
+
exports.isValidFloat = isValidFloat;
|
|
24
|
+
const r = new Float32Array(1);
|
|
25
|
+
function roundToFloat(float) {
|
|
26
|
+
r[0] = float;
|
|
27
|
+
const floatR = r[0];
|
|
28
|
+
return floatR;
|
|
29
|
+
}
|
|
30
|
+
function randomFloat() {
|
|
31
|
+
return roundToFloat(getRandomDouble(-1000, 1000));
|
|
32
|
+
}
|
|
33
|
+
exports.randomFloat = randomFloat;
|
|
34
|
+
function encodeFloat(value, stream) {
|
|
35
|
+
stream.writeFloat(value);
|
|
36
|
+
}
|
|
37
|
+
exports.encodeFloat = encodeFloat;
|
|
38
|
+
function decodeFloat(stream, value) {
|
|
39
|
+
return stream.readFloat();
|
|
40
|
+
}
|
|
41
|
+
exports.decodeFloat = decodeFloat;
|
|
42
|
+
function isValidDouble(value) {
|
|
43
|
+
if (!isFinite(value)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
exports.isValidDouble = isValidDouble;
|
|
49
|
+
function randomDouble() {
|
|
50
|
+
return getRandomDouble(-1000000, 1000000);
|
|
51
|
+
}
|
|
52
|
+
exports.randomDouble = randomDouble;
|
|
53
|
+
function encodeDouble(value, stream) {
|
|
54
|
+
stream.writeDouble(value);
|
|
55
|
+
}
|
|
56
|
+
exports.encodeDouble = encodeDouble;
|
|
57
|
+
function decodeDouble(stream, value) {
|
|
58
|
+
return stream.readDouble();
|
|
59
|
+
}
|
|
60
|
+
exports.decodeDouble = decodeDouble;
|
|
61
|
+
function coerceFloat(value) {
|
|
62
|
+
if (value === null || value === undefined) {
|
|
63
|
+
return 0.0;
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === "number") {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
return parseFloat(value);
|
|
69
|
+
}
|
|
70
|
+
exports.coerceFloat = coerceFloat;
|
|
71
|
+
function coerceDouble(value) {
|
|
72
|
+
if (value === null || value === undefined) {
|
|
73
|
+
return 0.0;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "number") {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
return parseFloat(value);
|
|
79
|
+
}
|
|
80
|
+
exports.coerceDouble = coerceDouble;
|
|
81
81
|
//# sourceMappingURL=floats.js.map
|
package/dist/guid.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
5
|
-
export { isValidGuid, emptyGuid } from "node-opcua-guid";
|
|
6
|
-
export type Guid = string;
|
|
7
|
-
export declare function randomGuid(): Guid;
|
|
8
|
-
export declare function encodeGuid(guid: Guid, stream: OutputBinaryStream): void;
|
|
9
|
-
export declare function decodeGuid(stream: BinaryStream, value?: Guid): Guid;
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
5
|
+
export { isValidGuid, emptyGuid } from "node-opcua-guid";
|
|
6
|
+
export type Guid = string;
|
|
7
|
+
export declare function randomGuid(): Guid;
|
|
8
|
+
export declare function encodeGuid(guid: Guid, stream: OutputBinaryStream): void;
|
|
9
|
+
export declare function decodeGuid(stream: BinaryStream, value?: Guid): Guid;
|
package/dist/guid.js
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***
|
|
3
|
-
* @module node-opcua-basic-types
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decodeGuid = exports.encodeGuid = exports.randomGuid = exports.emptyGuid = exports.isValidGuid = void 0;
|
|
7
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
-
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
9
|
-
const node_opcua_guid_1 = require("node-opcua-guid");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
var node_opcua_guid_2 = require("node-opcua-guid");
|
|
12
|
-
Object.defineProperty(exports, "isValidGuid", { enumerable: true, get: function () { return node_opcua_guid_2.isValidGuid; } });
|
|
13
|
-
Object.defineProperty(exports, "emptyGuid", { enumerable: true, get: function () { return node_opcua_guid_2.emptyGuid; } });
|
|
14
|
-
function toHex(i, nb) {
|
|
15
|
-
return i.toString(16).padStart(nb, "0");
|
|
16
|
-
}
|
|
17
|
-
function randomGuid() {
|
|
18
|
-
const b = new node_opcua_binary_stream_1.BinaryStream(20);
|
|
19
|
-
for (let i = 0; i < 20; i++) {
|
|
20
|
-
b.writeUInt8((0, utils_1.getRandomInt)(0, 255));
|
|
21
|
-
}
|
|
22
|
-
b.rewind();
|
|
23
|
-
const value = decodeGuid(b);
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
exports.randomGuid = randomGuid;
|
|
27
|
-
// 1 2 3
|
|
28
|
-
// 012345678901234567890123456789012345
|
|
29
|
-
// | | | | | | | | | | |
|
|
30
|
-
// 12345678-1234-1234-ABCD-0123456789AB
|
|
31
|
-
// 00000000-0000-0000-0000-000000000000";
|
|
32
|
-
const hexCharToNum = (h) => {
|
|
33
|
-
// tslint:disable-next-line: no-bitwise
|
|
34
|
-
const l = h & 0x5f;
|
|
35
|
-
const r = l <= 25 ? l - 16 : l - 55;
|
|
36
|
-
// xx assert(r >= 0 && r < 16);
|
|
37
|
-
return r;
|
|
38
|
-
};
|
|
39
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("A".charCodeAt(0)) === 10);
|
|
40
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("a".charCodeAt(0)) === 10);
|
|
41
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("b".charCodeAt(0)) === 11);
|
|
42
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("B".charCodeAt(0)) === 11);
|
|
43
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("0".charCodeAt(0)) === 0);
|
|
44
|
-
(0, node_opcua_assert_1.default)(hexCharToNum("9".charCodeAt(0)) === 9);
|
|
45
|
-
const doDebug = false;
|
|
46
|
-
function write_UInt32(stream, guid, starts) {
|
|
47
|
-
const n = starts.length;
|
|
48
|
-
for (let i = 0; i < n; i++) {
|
|
49
|
-
const start = starts[i];
|
|
50
|
-
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
51
|
-
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
52
|
-
const d3 = hexCharToNum(guid.charCodeAt(start + 2));
|
|
53
|
-
const d4 = hexCharToNum(guid.charCodeAt(start + 3));
|
|
54
|
-
const d5 = hexCharToNum(guid.charCodeAt(start + 4));
|
|
55
|
-
const d6 = hexCharToNum(guid.charCodeAt(start + 5));
|
|
56
|
-
const d7 = hexCharToNum(guid.charCodeAt(start + 6));
|
|
57
|
-
const d8 = hexCharToNum(guid.charCodeAt(start + 7));
|
|
58
|
-
// tslint:disable-next-line: no-bitwise
|
|
59
|
-
const value = (((((((((((((d1 << 4) | d2) << 4) | d3) << 4) | d4) << 4) | d5) << 4) | d6) << 4) | d7) << 4) | d8;
|
|
60
|
-
stream.writeInteger(value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function write_UInt16(stream, guid, starts) {
|
|
64
|
-
const n = starts.length;
|
|
65
|
-
for (let i = 0; i < n; i++) {
|
|
66
|
-
const start = starts[i];
|
|
67
|
-
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
68
|
-
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
69
|
-
const d3 = hexCharToNum(guid.charCodeAt(start + 2));
|
|
70
|
-
const d4 = hexCharToNum(guid.charCodeAt(start + 3));
|
|
71
|
-
// tslint:disable-next-line: no-bitwise
|
|
72
|
-
const value = (((((d1 << 4) | d2) << 4) | d3) << 4) | d4;
|
|
73
|
-
stream.writeUInt16(value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function write_UInt8(stream, guid, starts) {
|
|
77
|
-
const n = starts.length;
|
|
78
|
-
for (let i = 0; i < n; i++) {
|
|
79
|
-
const start = starts[i];
|
|
80
|
-
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
81
|
-
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
82
|
-
// tslint:disable-next-line: no-bitwise
|
|
83
|
-
const value = (d1 << 4) | d2;
|
|
84
|
-
stream.writeUInt8(value);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function encodeGuid(guid, stream) {
|
|
88
|
-
if (!(0, node_opcua_guid_1.isValidGuid)(guid)) {
|
|
89
|
-
throw new Error(" Invalid GUID : '" + JSON.stringify(guid) + ": the format should be 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'");
|
|
90
|
-
}
|
|
91
|
-
write_UInt32(stream, guid, [0]);
|
|
92
|
-
write_UInt16(stream, guid, [9, 14]);
|
|
93
|
-
write_UInt8(stream, guid, [19, 21, 24, 26, 28, 30, 32, 34]);
|
|
94
|
-
}
|
|
95
|
-
exports.encodeGuid = encodeGuid;
|
|
96
|
-
function read_UInt32(stream) {
|
|
97
|
-
return toHex(stream.readUInt32(), 8);
|
|
98
|
-
}
|
|
99
|
-
function read_UInt16(stream) {
|
|
100
|
-
return toHex(stream.readUInt16(), 4);
|
|
101
|
-
}
|
|
102
|
-
function read_UInt8(stream) {
|
|
103
|
-
return toHex(stream.readUInt8(), 2);
|
|
104
|
-
}
|
|
105
|
-
function read_many(stream, func, nb) {
|
|
106
|
-
let result = "";
|
|
107
|
-
for (let i = 0; i < nb; i++) {
|
|
108
|
-
result += func(stream);
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
function decodeGuid(stream, value) {
|
|
113
|
-
const data1 = read_UInt32(stream);
|
|
114
|
-
const data2 = read_UInt16(stream);
|
|
115
|
-
const data3 = read_UInt16(stream);
|
|
116
|
-
const data45 = read_many(stream, read_UInt8, 2);
|
|
117
|
-
const data6B = read_many(stream, read_UInt8, 6);
|
|
118
|
-
const guid = data1 + "-" + data2 + "-" + data3 + "-" + data45 + "-" + data6B;
|
|
119
|
-
return guid.toUpperCase();
|
|
120
|
-
}
|
|
121
|
-
exports.decodeGuid = decodeGuid;
|
|
1
|
+
"use strict";
|
|
2
|
+
/***
|
|
3
|
+
* @module node-opcua-basic-types
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.decodeGuid = exports.encodeGuid = exports.randomGuid = exports.emptyGuid = exports.isValidGuid = void 0;
|
|
7
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
+
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
9
|
+
const node_opcua_guid_1 = require("node-opcua-guid");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
var node_opcua_guid_2 = require("node-opcua-guid");
|
|
12
|
+
Object.defineProperty(exports, "isValidGuid", { enumerable: true, get: function () { return node_opcua_guid_2.isValidGuid; } });
|
|
13
|
+
Object.defineProperty(exports, "emptyGuid", { enumerable: true, get: function () { return node_opcua_guid_2.emptyGuid; } });
|
|
14
|
+
function toHex(i, nb) {
|
|
15
|
+
return i.toString(16).padStart(nb, "0");
|
|
16
|
+
}
|
|
17
|
+
function randomGuid() {
|
|
18
|
+
const b = new node_opcua_binary_stream_1.BinaryStream(20);
|
|
19
|
+
for (let i = 0; i < 20; i++) {
|
|
20
|
+
b.writeUInt8((0, utils_1.getRandomInt)(0, 255));
|
|
21
|
+
}
|
|
22
|
+
b.rewind();
|
|
23
|
+
const value = decodeGuid(b);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
exports.randomGuid = randomGuid;
|
|
27
|
+
// 1 2 3
|
|
28
|
+
// 012345678901234567890123456789012345
|
|
29
|
+
// | | | | | | | | | | |
|
|
30
|
+
// 12345678-1234-1234-ABCD-0123456789AB
|
|
31
|
+
// 00000000-0000-0000-0000-000000000000";
|
|
32
|
+
const hexCharToNum = (h) => {
|
|
33
|
+
// tslint:disable-next-line: no-bitwise
|
|
34
|
+
const l = h & 0x5f;
|
|
35
|
+
const r = l <= 25 ? l - 16 : l - 55;
|
|
36
|
+
// xx assert(r >= 0 && r < 16);
|
|
37
|
+
return r;
|
|
38
|
+
};
|
|
39
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("A".charCodeAt(0)) === 10);
|
|
40
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("a".charCodeAt(0)) === 10);
|
|
41
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("b".charCodeAt(0)) === 11);
|
|
42
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("B".charCodeAt(0)) === 11);
|
|
43
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("0".charCodeAt(0)) === 0);
|
|
44
|
+
(0, node_opcua_assert_1.default)(hexCharToNum("9".charCodeAt(0)) === 9);
|
|
45
|
+
const doDebug = false;
|
|
46
|
+
function write_UInt32(stream, guid, starts) {
|
|
47
|
+
const n = starts.length;
|
|
48
|
+
for (let i = 0; i < n; i++) {
|
|
49
|
+
const start = starts[i];
|
|
50
|
+
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
51
|
+
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
52
|
+
const d3 = hexCharToNum(guid.charCodeAt(start + 2));
|
|
53
|
+
const d4 = hexCharToNum(guid.charCodeAt(start + 3));
|
|
54
|
+
const d5 = hexCharToNum(guid.charCodeAt(start + 4));
|
|
55
|
+
const d6 = hexCharToNum(guid.charCodeAt(start + 5));
|
|
56
|
+
const d7 = hexCharToNum(guid.charCodeAt(start + 6));
|
|
57
|
+
const d8 = hexCharToNum(guid.charCodeAt(start + 7));
|
|
58
|
+
// tslint:disable-next-line: no-bitwise
|
|
59
|
+
const value = (((((((((((((d1 << 4) | d2) << 4) | d3) << 4) | d4) << 4) | d5) << 4) | d6) << 4) | d7) << 4) | d8;
|
|
60
|
+
stream.writeInteger(value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function write_UInt16(stream, guid, starts) {
|
|
64
|
+
const n = starts.length;
|
|
65
|
+
for (let i = 0; i < n; i++) {
|
|
66
|
+
const start = starts[i];
|
|
67
|
+
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
68
|
+
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
69
|
+
const d3 = hexCharToNum(guid.charCodeAt(start + 2));
|
|
70
|
+
const d4 = hexCharToNum(guid.charCodeAt(start + 3));
|
|
71
|
+
// tslint:disable-next-line: no-bitwise
|
|
72
|
+
const value = (((((d1 << 4) | d2) << 4) | d3) << 4) | d4;
|
|
73
|
+
stream.writeUInt16(value);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function write_UInt8(stream, guid, starts) {
|
|
77
|
+
const n = starts.length;
|
|
78
|
+
for (let i = 0; i < n; i++) {
|
|
79
|
+
const start = starts[i];
|
|
80
|
+
const d1 = hexCharToNum(guid.charCodeAt(start));
|
|
81
|
+
const d2 = hexCharToNum(guid.charCodeAt(start + 1));
|
|
82
|
+
// tslint:disable-next-line: no-bitwise
|
|
83
|
+
const value = (d1 << 4) | d2;
|
|
84
|
+
stream.writeUInt8(value);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function encodeGuid(guid, stream) {
|
|
88
|
+
if (!(0, node_opcua_guid_1.isValidGuid)(guid)) {
|
|
89
|
+
throw new Error(" Invalid GUID : '" + JSON.stringify(guid) + ": the format should be 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'");
|
|
90
|
+
}
|
|
91
|
+
write_UInt32(stream, guid, [0]);
|
|
92
|
+
write_UInt16(stream, guid, [9, 14]);
|
|
93
|
+
write_UInt8(stream, guid, [19, 21, 24, 26, 28, 30, 32, 34]);
|
|
94
|
+
}
|
|
95
|
+
exports.encodeGuid = encodeGuid;
|
|
96
|
+
function read_UInt32(stream) {
|
|
97
|
+
return toHex(stream.readUInt32(), 8);
|
|
98
|
+
}
|
|
99
|
+
function read_UInt16(stream) {
|
|
100
|
+
return toHex(stream.readUInt16(), 4);
|
|
101
|
+
}
|
|
102
|
+
function read_UInt8(stream) {
|
|
103
|
+
return toHex(stream.readUInt8(), 2);
|
|
104
|
+
}
|
|
105
|
+
function read_many(stream, func, nb) {
|
|
106
|
+
let result = "";
|
|
107
|
+
for (let i = 0; i < nb; i++) {
|
|
108
|
+
result += func(stream);
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
function decodeGuid(stream, value) {
|
|
113
|
+
const data1 = read_UInt32(stream);
|
|
114
|
+
const data2 = read_UInt16(stream);
|
|
115
|
+
const data3 = read_UInt16(stream);
|
|
116
|
+
const data45 = read_many(stream, read_UInt8, 2);
|
|
117
|
+
const data6B = read_many(stream, read_UInt8, 6);
|
|
118
|
+
const guid = data1 + "-" + data2 + "-" + data3 + "-" + data45 + "-" + data6B;
|
|
119
|
+
return guid.toUpperCase();
|
|
120
|
+
}
|
|
121
|
+
exports.decodeGuid = decodeGuid;
|
|
122
122
|
//# sourceMappingURL=guid.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
export * from "./array";
|
|
6
|
-
export * from "./attributeIds";
|
|
7
|
-
export * from "./boolean";
|
|
8
|
-
export * from "./byte_string";
|
|
9
|
-
export * from "./data_type";
|
|
10
|
-
export * from "./date_time";
|
|
11
|
-
export * from "./floats";
|
|
12
|
-
export * from "./guid";
|
|
13
|
-
export * from "./integers";
|
|
14
|
-
export * from "./locale_id";
|
|
15
|
-
export * from "./node_id";
|
|
16
|
-
export * from "./round_to_float";
|
|
17
|
-
export * from "./status_code";
|
|
18
|
-
export * from "./string";
|
|
19
|
-
export type ByteString = Buffer;
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
export * from "./array";
|
|
6
|
+
export * from "./attributeIds";
|
|
7
|
+
export * from "./boolean";
|
|
8
|
+
export * from "./byte_string";
|
|
9
|
+
export * from "./data_type";
|
|
10
|
+
export * from "./date_time";
|
|
11
|
+
export * from "./floats";
|
|
12
|
+
export * from "./guid";
|
|
13
|
+
export * from "./integers";
|
|
14
|
+
export * from "./locale_id";
|
|
15
|
+
export * from "./node_id";
|
|
16
|
+
export * from "./round_to_float";
|
|
17
|
+
export * from "./status_code";
|
|
18
|
+
export * from "./string";
|
|
19
|
+
export type ByteString = Buffer;
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***
|
|
3
|
-
* @module node-opcua-basic-types
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
__exportStar(require("./array"), exports);
|
|
21
|
-
__exportStar(require("./attributeIds"), exports);
|
|
22
|
-
__exportStar(require("./boolean"), exports);
|
|
23
|
-
__exportStar(require("./byte_string"), exports);
|
|
24
|
-
__exportStar(require("./data_type"), exports);
|
|
25
|
-
__exportStar(require("./date_time"), exports);
|
|
26
|
-
__exportStar(require("./floats"), exports);
|
|
27
|
-
__exportStar(require("./guid"), exports);
|
|
28
|
-
__exportStar(require("./integers"), exports);
|
|
29
|
-
__exportStar(require("./locale_id"), exports);
|
|
30
|
-
__exportStar(require("./node_id"), exports);
|
|
31
|
-
__exportStar(require("./round_to_float"), exports);
|
|
32
|
-
__exportStar(require("./status_code"), exports);
|
|
33
|
-
__exportStar(require("./string"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/***
|
|
3
|
+
* @module node-opcua-basic-types
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./array"), exports);
|
|
21
|
+
__exportStar(require("./attributeIds"), exports);
|
|
22
|
+
__exportStar(require("./boolean"), exports);
|
|
23
|
+
__exportStar(require("./byte_string"), exports);
|
|
24
|
+
__exportStar(require("./data_type"), exports);
|
|
25
|
+
__exportStar(require("./date_time"), exports);
|
|
26
|
+
__exportStar(require("./floats"), exports);
|
|
27
|
+
__exportStar(require("./guid"), exports);
|
|
28
|
+
__exportStar(require("./integers"), exports);
|
|
29
|
+
__exportStar(require("./locale_id"), exports);
|
|
30
|
+
__exportStar(require("./node_id"), exports);
|
|
31
|
+
__exportStar(require("./round_to_float"), exports);
|
|
32
|
+
__exportStar(require("./status_code"), exports);
|
|
33
|
+
__exportStar(require("./string"), exports);
|
|
34
34
|
//# sourceMappingURL=index.js.map
|