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/array.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
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;
|
|
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
45
|
//# sourceMappingURL=array.js.map
|
package/dist/attributeIds.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
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;
|
|
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
49
|
//# sourceMappingURL=attributeIds.js.map
|
package/dist/boolean.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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;
|
|
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
34
|
//# sourceMappingURL=boolean.js.map
|
package/dist/byte_string.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
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;
|
|
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
37
|
//# sourceMappingURL=byte_string.js.map
|
package/dist/data_type.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
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
|
-
}
|
|
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
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
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 = {}));
|
|
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
36
|
//# sourceMappingURL=data_type.js.map
|
package/dist/date_time.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* @module node-opcua-basic-types
|
|
3
|
-
*/
|
|
4
|
-
export * from "node-opcua-date-time";
|
|
5
|
-
import { DateWithPicoseconds } from "node-opcua-date-time";
|
|
6
|
-
export type DateTime = Date | DateWithPicoseconds | null;
|
|
1
|
+
/***
|
|
2
|
+
* @module node-opcua-basic-types
|
|
3
|
+
*/
|
|
4
|
+
export * from "node-opcua-date-time";
|
|
5
|
+
import { DateWithPicoseconds } from "node-opcua-date-time";
|
|
6
|
+
export type DateTime = Date | DateWithPicoseconds | null;
|