node-opcua-basic-types 2.97.0 → 2.98.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/package.json +10 -10
- package/dist/array.d.ts +0 -16
- package/dist/array.js +0 -45
- package/dist/array.js.map +0 -1
- package/dist/attributeIds.d.ts +0 -34
- package/dist/attributeIds.js +0 -49
- package/dist/attributeIds.js.map +0 -1
- package/dist/boolean.d.ts +0 -9
- package/dist/boolean.js +0 -34
- package/dist/boolean.js.map +0 -1
- package/dist/byte_string.d.ts +0 -11
- package/dist/byte_string.js +0 -37
- package/dist/byte_string.js.map +0 -1
- package/dist/data_type.d.ts +0 -31
- package/dist/data_type.js +0 -36
- package/dist/data_type.js.map +0 -1
- package/dist/date_time.d.ts +0 -6
- package/dist/date_time.js +0 -21
- package/dist/date_time.js.map +0 -1
- package/dist/floats.d.ts +0 -16
- package/dist/floats.js +0 -81
- package/dist/floats.js.map +0 -1
- package/dist/guid.d.ts +0 -9
- package/dist/guid.js +0 -122
- package/dist/guid.js.map +0 -1
- package/dist/index.d.ts +0 -19
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/integers.d.ts +0 -66
- package/dist/integers.js +0 -309
- package/dist/integers.js.map +0 -1
- package/dist/locale_id.d.ts +0 -9
- package/dist/locale_id.js +0 -19
- package/dist/locale_id.js.map +0 -1
- package/dist/node_id.d.ts +0 -9
- package/dist/node_id.js +0 -189
- package/dist/node_id.js.map +0 -1
- package/dist/round_to_float.d.ts +0 -1
- package/dist/round_to_float.js +0 -27
- package/dist/round_to_float.js.map +0 -1
- package/dist/status_code.d.ts +0 -4
- package/dist/status_code.js +0 -21
- package/dist/status_code.js.map +0 -1
- package/dist/string.d.ts +0 -12
- package/dist/string.js +0 -31
- package/dist/string.js.map +0 -1
- package/dist/utils.d.ts +0 -12
- package/dist/utils.js +0 -20
- package/dist/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-basic-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.98.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -basic-types",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"node-opcua-assert": "2.88.0",
|
|
15
|
-
"node-opcua-binary-stream": "2.
|
|
16
|
-
"node-opcua-buffer-utils": "2.
|
|
17
|
-
"node-opcua-date-time": "2.
|
|
15
|
+
"node-opcua-binary-stream": "2.98.0",
|
|
16
|
+
"node-opcua-buffer-utils": "2.98.0",
|
|
17
|
+
"node-opcua-date-time": "2.98.0",
|
|
18
18
|
"node-opcua-guid": "2.88.0",
|
|
19
|
-
"node-opcua-nodeid": "2.
|
|
20
|
-
"node-opcua-status-code": "2.
|
|
19
|
+
"node-opcua-nodeid": "2.98.0",
|
|
20
|
+
"node-opcua-status-code": "2.98.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "18.15.
|
|
24
|
-
"node-opcua-benchmarker": "2.
|
|
25
|
-
"node-opcua-debug": "2.
|
|
23
|
+
"@types/node": "18.15.11",
|
|
24
|
+
"node-opcua-benchmarker": "2.98.0",
|
|
25
|
+
"node-opcua-debug": "2.98.0",
|
|
26
26
|
"should": "^13.2.3"
|
|
27
27
|
},
|
|
28
28
|
"author": "Etienne Rossignon",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"internet of things"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "http://node-opcua.github.io/",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "e4d73afdfcccb3491423149d9b9785888f4ebb3c"
|
|
44
44
|
}
|
package/dist/array.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
2
|
-
/**
|
|
3
|
-
* @method encodeArray
|
|
4
|
-
* @param arr the array to encode.
|
|
5
|
-
* @param stream the stream.
|
|
6
|
-
* @param encodeElementFunc The function to encode a single array element.
|
|
7
|
-
*/
|
|
8
|
-
export declare function encodeArray(arr: any[] | null, stream: OutputBinaryStream, encodeElementFunc: (value: any, stream: OutputBinaryStream) => void): void;
|
|
9
|
-
/**
|
|
10
|
-
* decode an array from a BinaryStream
|
|
11
|
-
* @param stream the stream.
|
|
12
|
-
* @param decodeElementFunc The function to decode a single array element.
|
|
13
|
-
* This function returns the element decoded from the stream
|
|
14
|
-
* @returns an array of elements or nul
|
|
15
|
-
*/
|
|
16
|
-
export declare function decodeArray(stream: BinaryStream, decodeElementFunc: (stream: BinaryStream) => any): any[] | null;
|
package/dist/array.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeArray = exports.encodeArray = void 0;
|
|
4
|
-
/***
|
|
5
|
-
* @module node-opcua-basic-types
|
|
6
|
-
*/
|
|
7
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
-
/**
|
|
9
|
-
* @method encodeArray
|
|
10
|
-
* @param arr the array to encode.
|
|
11
|
-
* @param stream the stream.
|
|
12
|
-
* @param encodeElementFunc The function to encode a single array element.
|
|
13
|
-
*/
|
|
14
|
-
function encodeArray(arr, stream, encodeElementFunc) {
|
|
15
|
-
if (arr === null) {
|
|
16
|
-
stream.writeUInt32(0xffffffff);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
(0, node_opcua_assert_1.assert)(Array.isArray(arr));
|
|
20
|
-
stream.writeUInt32(arr.length);
|
|
21
|
-
for (const value of arr) {
|
|
22
|
-
encodeElementFunc(value, stream);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.encodeArray = encodeArray;
|
|
26
|
-
/**
|
|
27
|
-
* decode an array from a BinaryStream
|
|
28
|
-
* @param stream the stream.
|
|
29
|
-
* @param decodeElementFunc The function to decode a single array element.
|
|
30
|
-
* This function returns the element decoded from the stream
|
|
31
|
-
* @returns an array of elements or nul
|
|
32
|
-
*/
|
|
33
|
-
function decodeArray(stream, decodeElementFunc) {
|
|
34
|
-
const length = stream.readUInt32();
|
|
35
|
-
if (length === 0xffffffff) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const arr = [];
|
|
39
|
-
for (let i = 0; i < length; i++) {
|
|
40
|
-
arr.push(decodeElementFunc(stream));
|
|
41
|
-
}
|
|
42
|
-
return arr;
|
|
43
|
-
}
|
|
44
|
-
exports.decodeArray = decodeArray;
|
|
45
|
-
//# sourceMappingURL=array.js.map
|
package/dist/array.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../source/array.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAG3C;;;;;GAKG;AACH,SAAgB,WAAW,CACvB,GAAiB,EACjB,MAA0B,EAC1B,iBAAmE;IAEnE,IAAI,GAAG,KAAK,IAAI,EAAE;QACd,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC/B,OAAO;KACV;IACD,IAAA,0BAAM,EAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE;QACrB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KACpC;AACL,CAAC;AAdD,kCAcC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,MAAoB,EAAE,iBAAgD;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACnC,IAAI,MAAM,KAAK,UAAU,EAAE;QACvB,OAAO,IAAI,CAAC;KACf;IACD,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7B,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;KACvC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAVD,kCAUC"}
|
package/dist/attributeIds.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export declare enum AttributeIds {
|
|
2
|
-
NodeId = 1,
|
|
3
|
-
NodeClass = 2,
|
|
4
|
-
BrowseName = 3,
|
|
5
|
-
DisplayName = 4,
|
|
6
|
-
Description = 5,
|
|
7
|
-
WriteMask = 6,
|
|
8
|
-
UserWriteMask = 7,
|
|
9
|
-
IsAbstract = 8,
|
|
10
|
-
Symmetric = 9,
|
|
11
|
-
InverseName = 10,
|
|
12
|
-
ContainsNoLoops = 11,
|
|
13
|
-
EventNotifier = 12,
|
|
14
|
-
Value = 13,
|
|
15
|
-
DataType = 14,
|
|
16
|
-
ValueRank = 15,
|
|
17
|
-
ArrayDimensions = 16,
|
|
18
|
-
AccessLevel = 17,
|
|
19
|
-
UserAccessLevel = 18,
|
|
20
|
-
MinimumSamplingInterval = 19,
|
|
21
|
-
Historizing = 20,
|
|
22
|
-
Executable = 21,
|
|
23
|
-
UserExecutable = 22,
|
|
24
|
-
DataTypeDefinition = 23,
|
|
25
|
-
RolePermissions = 24,
|
|
26
|
-
UserRolePermissions = 25,
|
|
27
|
-
AccessRestrictions = 26,
|
|
28
|
-
AccessLevelEx = 27,
|
|
29
|
-
INVALID = 999
|
|
30
|
-
}
|
|
31
|
-
export declare const attributeNameById: {
|
|
32
|
-
[key: string]: string | number;
|
|
33
|
-
};
|
|
34
|
-
export declare function isValidAttributeId(attributeId: number): boolean;
|
package/dist/attributeIds.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidAttributeId = exports.attributeNameById = exports.AttributeIds = void 0;
|
|
4
|
-
var AttributeIds;
|
|
5
|
-
(function (AttributeIds) {
|
|
6
|
-
AttributeIds[AttributeIds["NodeId"] = 1] = "NodeId";
|
|
7
|
-
AttributeIds[AttributeIds["NodeClass"] = 2] = "NodeClass";
|
|
8
|
-
AttributeIds[AttributeIds["BrowseName"] = 3] = "BrowseName";
|
|
9
|
-
AttributeIds[AttributeIds["DisplayName"] = 4] = "DisplayName";
|
|
10
|
-
AttributeIds[AttributeIds["Description"] = 5] = "Description";
|
|
11
|
-
AttributeIds[AttributeIds["WriteMask"] = 6] = "WriteMask";
|
|
12
|
-
AttributeIds[AttributeIds["UserWriteMask"] = 7] = "UserWriteMask";
|
|
13
|
-
AttributeIds[AttributeIds["IsAbstract"] = 8] = "IsAbstract";
|
|
14
|
-
AttributeIds[AttributeIds["Symmetric"] = 9] = "Symmetric";
|
|
15
|
-
AttributeIds[AttributeIds["InverseName"] = 10] = "InverseName";
|
|
16
|
-
AttributeIds[AttributeIds["ContainsNoLoops"] = 11] = "ContainsNoLoops";
|
|
17
|
-
AttributeIds[AttributeIds["EventNotifier"] = 12] = "EventNotifier";
|
|
18
|
-
AttributeIds[AttributeIds["Value"] = 13] = "Value";
|
|
19
|
-
AttributeIds[AttributeIds["DataType"] = 14] = "DataType";
|
|
20
|
-
AttributeIds[AttributeIds["ValueRank"] = 15] = "ValueRank";
|
|
21
|
-
AttributeIds[AttributeIds["ArrayDimensions"] = 16] = "ArrayDimensions";
|
|
22
|
-
AttributeIds[AttributeIds["AccessLevel"] = 17] = "AccessLevel";
|
|
23
|
-
AttributeIds[AttributeIds["UserAccessLevel"] = 18] = "UserAccessLevel";
|
|
24
|
-
AttributeIds[AttributeIds["MinimumSamplingInterval"] = 19] = "MinimumSamplingInterval";
|
|
25
|
-
AttributeIds[AttributeIds["Historizing"] = 20] = "Historizing";
|
|
26
|
-
AttributeIds[AttributeIds["Executable"] = 21] = "Executable";
|
|
27
|
-
AttributeIds[AttributeIds["UserExecutable"] = 22] = "UserExecutable";
|
|
28
|
-
// new in 1.04
|
|
29
|
-
AttributeIds[AttributeIds["DataTypeDefinition"] = 23] = "DataTypeDefinition";
|
|
30
|
-
AttributeIds[AttributeIds["RolePermissions"] = 24] = "RolePermissions";
|
|
31
|
-
AttributeIds[AttributeIds["UserRolePermissions"] = 25] = "UserRolePermissions";
|
|
32
|
-
AttributeIds[AttributeIds["AccessRestrictions"] = 26] = "AccessRestrictions";
|
|
33
|
-
AttributeIds[AttributeIds["AccessLevelEx"] = 27] = "AccessLevelEx";
|
|
34
|
-
AttributeIds[AttributeIds["INVALID"] = 999] = "INVALID";
|
|
35
|
-
})(AttributeIds = exports.AttributeIds || (exports.AttributeIds = {}));
|
|
36
|
-
const AttributeIds_LAST = AttributeIds.AccessLevelEx;
|
|
37
|
-
// see https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/issues/296
|
|
38
|
-
function invert(a) {
|
|
39
|
-
return Object.entries(a).reduce((c, [k, v]) => {
|
|
40
|
-
c[v] = k;
|
|
41
|
-
return c;
|
|
42
|
-
}, {});
|
|
43
|
-
}
|
|
44
|
-
exports.attributeNameById = invert(AttributeIds);
|
|
45
|
-
function isValidAttributeId(attributeId) {
|
|
46
|
-
return attributeId >= 1 && attributeId <= AttributeIds_LAST;
|
|
47
|
-
}
|
|
48
|
-
exports.isValidAttributeId = isValidAttributeId;
|
|
49
|
-
//# sourceMappingURL=attributeIds.js.map
|
package/dist/attributeIds.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributeIds.js","sourceRoot":"","sources":["../source/attributeIds.ts"],"names":[],"mappings":";;;AAKA,IAAY,YA8BX;AA9BD,WAAY,YAAY;IACpB,mDAAU,CAAA;IACV,yDAAa,CAAA;IACb,2DAAc,CAAA;IACd,6DAAe,CAAA;IACf,6DAAe,CAAA;IACf,yDAAa,CAAA;IACb,iEAAiB,CAAA;IACjB,2DAAc,CAAA;IACd,yDAAa,CAAA;IACb,8DAAgB,CAAA;IAChB,sEAAoB,CAAA;IACpB,kEAAkB,CAAA;IAClB,kDAAU,CAAA;IACV,wDAAa,CAAA;IACb,0DAAc,CAAA;IACd,sEAAoB,CAAA;IACpB,8DAAgB,CAAA;IAChB,sEAAoB,CAAA;IACpB,sFAA4B,CAAA;IAC5B,8DAAgB,CAAA;IAChB,4DAAe,CAAA;IACf,oEAAmB,CAAA;IACnB,cAAc;IACd,4EAAuB,CAAA;IACvB,sEAAoB,CAAA;IACpB,8EAAwB,CAAA;IACxB,4EAAuB,CAAA;IACvB,kEAAkB,CAAA;IAClB,uDAAa,CAAA;AACjB,CAAC,EA9BW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA8BvB;AACD,MAAM,iBAAiB,GAAG,YAAY,CAAC,aAAa,CAAC;AAErD,kFAAkF;AAClF,SAAS,MAAM,CAAC,CAAqC;IACjD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1C,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACT,OAAO,CAAC,CAAC;IACb,CAAC,EAAE,EAAwC,CAAC,CAAC;AACjD,CAAC;AACY,QAAA,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAEtD,SAAgB,kBAAkB,CAAC,WAAmB;IAClD,OAAO,WAAW,IAAI,CAAC,IAAI,WAAW,IAAI,iBAAiB,CAAC;AAChE,CAAC;AAFD,gDAEC"}
|
package/dist/boolean.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
2
|
-
export declare function isValidBoolean(value: unknown): boolean;
|
|
3
|
-
export declare function randomBoolean(): boolean;
|
|
4
|
-
export declare function encodeBoolean(value: boolean, stream: OutputBinaryStream): void;
|
|
5
|
-
export declare function decodeBoolean(stream: BinaryStream, _value?: boolean): boolean;
|
|
6
|
-
export declare function coerceBoolean(value: string): boolean;
|
|
7
|
-
export type UABoolean = boolean;
|
|
8
|
-
export declare const encodeUABoolean: typeof encodeBoolean;
|
|
9
|
-
export declare const decodeUABoolean: typeof decodeBoolean;
|
package/dist/boolean.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeUABoolean = exports.encodeUABoolean = exports.coerceBoolean = exports.decodeBoolean = exports.encodeBoolean = exports.randomBoolean = exports.isValidBoolean = void 0;
|
|
4
|
-
/***
|
|
5
|
-
* @module node-opcua-basic-types
|
|
6
|
-
*/
|
|
7
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
-
function isValidBoolean(value) {
|
|
9
|
-
return typeof value === "boolean";
|
|
10
|
-
}
|
|
11
|
-
exports.isValidBoolean = isValidBoolean;
|
|
12
|
-
function randomBoolean() {
|
|
13
|
-
return Math.random() > 0.5;
|
|
14
|
-
}
|
|
15
|
-
exports.randomBoolean = randomBoolean;
|
|
16
|
-
function encodeBoolean(value, stream) {
|
|
17
|
-
(0, node_opcua_assert_1.assert)(isValidBoolean(value));
|
|
18
|
-
stream.writeUInt8(value ? 1 : 0);
|
|
19
|
-
}
|
|
20
|
-
exports.encodeBoolean = encodeBoolean;
|
|
21
|
-
function decodeBoolean(stream, _value) {
|
|
22
|
-
return !!stream.readUInt8();
|
|
23
|
-
}
|
|
24
|
-
exports.decodeBoolean = decodeBoolean;
|
|
25
|
-
const falseDetectionRegex = /^(?:f(?:alse)?|no?|0+)$/i;
|
|
26
|
-
function coerceBoolean(value) {
|
|
27
|
-
// http://stackoverflow.com/a/24744599/406458
|
|
28
|
-
return !falseDetectionRegex.test(value) && !!value;
|
|
29
|
-
// return !!(+value||String(value).toLowerCase().replace(!!0,''));
|
|
30
|
-
}
|
|
31
|
-
exports.coerceBoolean = coerceBoolean;
|
|
32
|
-
exports.encodeUABoolean = encodeBoolean;
|
|
33
|
-
exports.decodeUABoolean = decodeBoolean;
|
|
34
|
-
//# sourceMappingURL=boolean.js.map
|
package/dist/boolean.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../source/boolean.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAG3C,SAAgB,cAAc,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACtC,CAAC;AAFD,wCAEC;AAED,SAAgB,aAAa;IACzB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;AAC/B,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa,CAAC,KAAc,EAAE,MAA0B;IACpE,IAAA,0BAAM,EAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAHD,sCAGC;AAED,SAAgB,aAAa,CAAC,MAAoB,EAAE,MAAgB;IAChE,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;AAChC,CAAC;AAFD,sCAEC;AAED,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAEvD,SAAgB,aAAa,CAAC,KAAa;IACvC,6CAA6C;IAC7C,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IACnD,kEAAkE;AACtE,CAAC;AAJD,sCAIC;AAGY,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,eAAe,GAAG,aAAa,CAAC"}
|
package/dist/byte_string.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/***
|
|
3
|
-
* @module node-opcua-basic-types
|
|
4
|
-
*/
|
|
5
|
-
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
-
export declare function isValidByteString(value: unknown): boolean;
|
|
7
|
-
export type ByteString = Buffer;
|
|
8
|
-
export declare function randomByteString(value: unknown, len: number): ByteString;
|
|
9
|
-
export declare function encodeByteString(byteString: ByteString, stream: OutputBinaryStream): void;
|
|
10
|
-
export declare function decodeByteString(stream: BinaryStream, _value?: ByteString): ByteString;
|
|
11
|
-
export declare function coerceByteString(value: number[] | string | ByteString): ByteString;
|
package/dist/byte_string.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coerceByteString = exports.decodeByteString = exports.encodeByteString = exports.randomByteString = exports.isValidByteString = void 0;
|
|
4
|
-
const node_opcua_buffer_utils_1 = require("node-opcua-buffer-utils");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
function isValidByteString(value) {
|
|
7
|
-
return value === null || value instanceof Buffer;
|
|
8
|
-
}
|
|
9
|
-
exports.isValidByteString = isValidByteString;
|
|
10
|
-
function randomByteString(value, len) {
|
|
11
|
-
len = len || (0, utils_1.getRandomInt)(1, 200);
|
|
12
|
-
const b = (0, node_opcua_buffer_utils_1.createFastUninitializedBuffer)(len);
|
|
13
|
-
for (let i = 0; i < len; i++) {
|
|
14
|
-
b.writeUInt8((0, utils_1.getRandomInt)(0, 255), i);
|
|
15
|
-
}
|
|
16
|
-
return b;
|
|
17
|
-
}
|
|
18
|
-
exports.randomByteString = randomByteString;
|
|
19
|
-
function encodeByteString(byteString, stream) {
|
|
20
|
-
stream.writeByteStream(byteString);
|
|
21
|
-
}
|
|
22
|
-
exports.encodeByteString = encodeByteString;
|
|
23
|
-
function decodeByteString(stream, _value) {
|
|
24
|
-
return stream.readByteStream();
|
|
25
|
-
}
|
|
26
|
-
exports.decodeByteString = decodeByteString;
|
|
27
|
-
function coerceByteString(value) {
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
return Buffer.from(value);
|
|
30
|
-
}
|
|
31
|
-
if (typeof value === "string") {
|
|
32
|
-
return Buffer.from(value, "base64");
|
|
33
|
-
}
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
exports.coerceByteString = coerceByteString;
|
|
37
|
-
//# sourceMappingURL=byte_string.js.map
|
package/dist/byte_string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"byte_string.js","sourceRoot":"","sources":["../source/byte_string.ts"],"names":[],"mappings":";;;AAIA,qEAAwE;AAExE,mCAAuC;AAEvC,SAAgB,iBAAiB,CAAC,KAAc;IAC5C,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,YAAY,MAAM,CAAC;AACrD,CAAC;AAFD,8CAEC;AAID,SAAgB,gBAAgB,CAAC,KAAc,EAAE,GAAW;IACxD,GAAG,GAAG,GAAG,IAAI,IAAA,oBAAY,EAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,IAAA,uDAA6B,EAAC,GAAG,CAAC,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,CAAC,CAAC,UAAU,CAAC,IAAA,oBAAY,EAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;KACzC;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAPD,4CAOC;AAED,SAAgB,gBAAgB,CAAC,UAAsB,EAAE,MAA0B;IAC/E,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAFD,4CAEC;AAED,SAAgB,gBAAgB,CAAC,MAAoB,EAAE,MAAmB;IACtE,OAAO,MAAM,CAAC,cAAc,EAAgB,CAAC;AACjD,CAAC;AAFD,4CAEC;AAED,SAAgB,gBAAgB,CAAC,KAAqC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC7B;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;KACvC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AARD,4CAQC"}
|
package/dist/data_type.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
export declare enum DataType {
|
|
5
|
-
Null = 0,
|
|
6
|
-
Boolean = 1,
|
|
7
|
-
SByte = 2,
|
|
8
|
-
Byte = 3,
|
|
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/dist/data_type.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataType = void 0;
|
|
4
|
-
/***
|
|
5
|
-
* @module node-opcua-basic-types
|
|
6
|
-
*/
|
|
7
|
-
var DataType;
|
|
8
|
-
(function (DataType) {
|
|
9
|
-
DataType[DataType["Null"] = 0] = "Null";
|
|
10
|
-
DataType[DataType["Boolean"] = 1] = "Boolean";
|
|
11
|
-
DataType[DataType["SByte"] = 2] = "SByte";
|
|
12
|
-
DataType[DataType["Byte"] = 3] = "Byte";
|
|
13
|
-
DataType[DataType["Int16"] = 4] = "Int16";
|
|
14
|
-
DataType[DataType["UInt16"] = 5] = "UInt16";
|
|
15
|
-
DataType[DataType["Int32"] = 6] = "Int32";
|
|
16
|
-
DataType[DataType["UInt32"] = 7] = "UInt32";
|
|
17
|
-
DataType[DataType["Int64"] = 8] = "Int64";
|
|
18
|
-
DataType[DataType["UInt64"] = 9] = "UInt64";
|
|
19
|
-
DataType[DataType["Float"] = 10] = "Float";
|
|
20
|
-
DataType[DataType["Double"] = 11] = "Double";
|
|
21
|
-
DataType[DataType["String"] = 12] = "String";
|
|
22
|
-
DataType[DataType["DateTime"] = 13] = "DateTime";
|
|
23
|
-
DataType[DataType["Guid"] = 14] = "Guid";
|
|
24
|
-
DataType[DataType["ByteString"] = 15] = "ByteString";
|
|
25
|
-
DataType[DataType["XmlElement"] = 16] = "XmlElement";
|
|
26
|
-
DataType[DataType["NodeId"] = 17] = "NodeId";
|
|
27
|
-
DataType[DataType["ExpandedNodeId"] = 18] = "ExpandedNodeId";
|
|
28
|
-
DataType[DataType["StatusCode"] = 19] = "StatusCode";
|
|
29
|
-
DataType[DataType["QualifiedName"] = 20] = "QualifiedName";
|
|
30
|
-
DataType[DataType["LocalizedText"] = 21] = "LocalizedText";
|
|
31
|
-
DataType[DataType["ExtensionObject"] = 22] = "ExtensionObject";
|
|
32
|
-
DataType[DataType["DataValue"] = 23] = "DataValue";
|
|
33
|
-
DataType[DataType["Variant"] = 24] = "Variant";
|
|
34
|
-
DataType[DataType["DiagnosticInfo"] = 25] = "DiagnosticInfo";
|
|
35
|
-
})(DataType = exports.DataType || (exports.DataType = {}));
|
|
36
|
-
//# sourceMappingURL=data_type.js.map
|
package/dist/data_type.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data_type.js","sourceRoot":"","sources":["../source/data_type.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,QA2BX;AA3BD,WAAY,QAAQ;IAChB,uCAAQ,CAAA;IACR,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,2CAAU,CAAA;IACV,yCAAS,CAAA;IACT,2CAAU,CAAA;IACV,yCAAS,CAAA;IACT,2CAAU,CAAA;IACV,0CAAU,CAAA;IACV,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,gDAAa,CAAA;IACb,wCAAS,CAAA;IACT,oDAAe,CAAA;IACf,oDAAe,CAAA;IACf,4CAAW,CAAA;IACX,4DAAmB,CAAA;IACnB,oDAAe,CAAA;IACf,0DAAkB,CAAA;IAClB,0DAAkB,CAAA;IAClB,8DAAoB,CAAA;IACpB,kDAAc,CAAA;IACd,8CAAY,CAAA;IACZ,4DAAmB,CAAA;AACvB,CAAC,EA3BW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QA2BnB"}
|
package/dist/date_time.d.ts
DELETED
package/dist/date_time.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=date_time.js.map
|
package/dist/date_time.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date_time.js","sourceRoot":"","sources":["../source/date_time.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,uDAAqC"}
|
package/dist/floats.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=floats.js.map
|
package/dist/floats.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"floats.js","sourceRoot":"","sources":["../source/floats.ts"],"names":[],"mappings":";;;AAKA,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,GAAW,EAAE,GAAW;IAC7C,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED,SAAgB,YAAY,CAAC,KAAa;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,KAAK,GAAG,QAAQ,IAAI,KAAK,GAAG,QAAQ,CAAC;AAChD,CAAC;AALD,oCAKC;AAED,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAE9B,SAAS,YAAY,CAAC,KAAa;IAC/B,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACb,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC;AAClB,CAAC;AAID,SAAgB,WAAW;IACvB,OAAO,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW,CAAC,KAAY,EAAE,MAA0B;IAChE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW,CAAC,MAAoB,EAAE,KAAc;IAC5D,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC;AAFD,kCAEC;AAED,SAAgB,aAAa,CAAC,KAAa;IACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AALD,sCAKC;AAID,SAAgB,YAAY;IACxB,OAAO,eAAe,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,KAAa,EAAE,MAA0B;IAClE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,MAAoB,EAAE,KAAc;IAC7D,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC/B,CAAC;AAFD,oCAEC;AAED,SAAgB,WAAW,CAAC,KAA6B;IACrD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACvC,OAAO,GAAG,CAAC;KACd;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AARD,kCAQC;AAED,SAAgB,YAAY,CAAC,KAA6B;IACtD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACvC,OAAO,GAAG,CAAC;KACd;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AARD,oCAQC"}
|
package/dist/guid.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=guid.js.map
|