node-opcua-nodeid
Advanced tools
Comparing version 2.9.0 to 2.10.0
@@ -44,39 +44,36 @@ "use strict"; | ||
*/ | ||
let ExpandedNodeId = /** @class */ (() => { | ||
class ExpandedNodeId extends nodeid_1.NodeId { | ||
constructor(identifierType, value, namespace, namespaceUri, serverIndex) { | ||
super(identifierType, value, namespace); | ||
this.namespaceUri = namespaceUri || null; | ||
this.serverIndex = serverIndex || 0; | ||
class ExpandedNodeId extends nodeid_1.NodeId { | ||
constructor(identifierType, value, namespace, namespaceUri, serverIndex) { | ||
super(identifierType, value, namespace); | ||
this.namespaceUri = namespaceUri || null; | ||
this.serverIndex = serverIndex || 0; | ||
} | ||
static fromNodeId(nodeId, namespaceUri, serverIndex) { | ||
return new ExpandedNodeId(nodeId.identifierType, nodeId.value, nodeId.namespace, namespaceUri, serverIndex); | ||
} | ||
/** | ||
* @method toString | ||
* @return {string} | ||
*/ | ||
toString() { | ||
let str = nodeid_1.NodeId.prototype.toString.call(this); | ||
if (this.namespaceUri) { | ||
str += ";namespaceUri:" + this.namespaceUri; | ||
} | ||
static fromNodeId(nodeId, namespaceUri, serverIndex) { | ||
return new ExpandedNodeId(nodeId.identifierType, nodeId.value, nodeId.namespace, namespaceUri, serverIndex); | ||
if (this.serverIndex) { | ||
str += ";serverIndex:" + this.serverIndex; | ||
} | ||
/** | ||
* @method toString | ||
* @return {string} | ||
*/ | ||
toString() { | ||
let str = nodeid_1.NodeId.prototype.toString.call(this); | ||
if (this.namespaceUri) { | ||
str += ";namespaceUri:" + this.namespaceUri; | ||
} | ||
if (this.serverIndex) { | ||
str += ";serverIndex:" + this.serverIndex; | ||
} | ||
return str; | ||
} | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
* @method toJSON | ||
* @return {String} | ||
*/ | ||
toJSON() { | ||
return this.toString(); | ||
} | ||
return str; | ||
} | ||
ExpandedNodeId.nullExpandedNodeId = new ExpandedNodeId(nodeid_1.NodeIdType.NUMERIC, 0, 0); | ||
return ExpandedNodeId; | ||
})(); | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
* @method toJSON | ||
* @return {String} | ||
*/ | ||
toJSON() { | ||
return this.toString(); | ||
} | ||
} | ||
exports.ExpandedNodeId = ExpandedNodeId; | ||
ExpandedNodeId.nullExpandedNodeId = new ExpandedNodeId(nodeid_1.NodeIdType.NUMERIC, 0, 0); | ||
function coerceExpandedNodeId(value) { | ||
@@ -83,0 +80,0 @@ const n = nodeid_1.coerceNodeId(value); |
@@ -11,3 +11,3 @@ "use strict"; | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ /** |
@@ -54,111 +54,108 @@ "use strict"; | ||
*/ | ||
let NodeId = /** @class */ (() => { | ||
class NodeId { | ||
/** | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
*/ | ||
constructor(identifierType, value, namespace) { | ||
this.identifierType = identifierType; | ||
this.value = value; | ||
this.namespace = namespace || 0; | ||
// namespace shall be a UInt16 | ||
node_opcua_assert_1.assert(this.namespace >= 0 && this.namespace <= 0xFFFF); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.NUMERIC || (this.value >= 0 && this.value <= 0xFFFFFFFF)); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.GUID || node_opcua_guid_1.isValidGuid(this.value)); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.STRING || typeof this.value === "string"); | ||
} | ||
/** | ||
* get the string representation of the nodeID. | ||
* | ||
* @method toString | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeid = new NodeId(NodeIdType.NUMERIC, 123,1); | ||
* console.log(nodeid.toString()); | ||
* ``` | ||
* | ||
* ``` | ||
* >"ns=1;i=123" | ||
* ``` | ||
* | ||
* @param [options.addressSpace] {AddressSpace} | ||
* @return {String} | ||
*/ | ||
toString(options) { | ||
const addressSpace = options ? options.addressSpace : null; | ||
let str; | ||
switch (this.identifierType) { | ||
case NodeIdType.NUMERIC: | ||
str = "ns=" + this.namespace + ";i=" + this.value; | ||
break; | ||
case NodeIdType.STRING: | ||
str = "ns=" + this.namespace + ";s=" + this.value; | ||
break; | ||
case NodeIdType.GUID: | ||
str = "ns=" + this.namespace + ";g=" + this.value; | ||
break; | ||
default: | ||
node_opcua_assert_1.assert(this.identifierType === NodeIdType.BYTESTRING, "invalid identifierType in NodeId : " + this.identifierType); | ||
if (this.value) { | ||
str = "ns=" + this.namespace + ";b=" + this.value.toString("hex"); | ||
} | ||
else { | ||
str = "ns=" + this.namespace + ";b=<null>"; | ||
} | ||
break; | ||
} | ||
if (addressSpace) { | ||
if (this.namespace === 0 && (this.identifierType === NodeIdType.NUMERIC)) { | ||
// find standard browse name | ||
const name = reverse_map(this.value.toString()) || "<undefined>"; | ||
str += " " + chalk.green.bold(name); | ||
class NodeId { | ||
/** | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
*/ | ||
constructor(identifierType, value, namespace) { | ||
this.identifierType = identifierType; | ||
this.value = value; | ||
this.namespace = namespace || 0; | ||
// namespace shall be a UInt16 | ||
node_opcua_assert_1.assert(this.namespace >= 0 && this.namespace <= 0xFFFF); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.NUMERIC || (this.value >= 0 && this.value <= 0xFFFFFFFF)); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.GUID || node_opcua_guid_1.isValidGuid(this.value)); | ||
node_opcua_assert_1.assert(this.identifierType !== NodeIdType.STRING || typeof this.value === "string"); | ||
} | ||
/** | ||
* get the string representation of the nodeID. | ||
* | ||
* @method toString | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeid = new NodeId(NodeIdType.NUMERIC, 123,1); | ||
* console.log(nodeid.toString()); | ||
* ``` | ||
* | ||
* ``` | ||
* >"ns=1;i=123" | ||
* ``` | ||
* | ||
* @param [options.addressSpace] {AddressSpace} | ||
* @return {String} | ||
*/ | ||
toString(options) { | ||
const addressSpace = options ? options.addressSpace : null; | ||
let str; | ||
switch (this.identifierType) { | ||
case NodeIdType.NUMERIC: | ||
str = "ns=" + this.namespace + ";i=" + this.value; | ||
break; | ||
case NodeIdType.STRING: | ||
str = "ns=" + this.namespace + ";s=" + this.value; | ||
break; | ||
case NodeIdType.GUID: | ||
str = "ns=" + this.namespace + ";g=" + this.value; | ||
break; | ||
default: | ||
node_opcua_assert_1.assert(this.identifierType === NodeIdType.BYTESTRING, "invalid identifierType in NodeId : " + this.identifierType); | ||
if (this.value) { | ||
str = "ns=" + this.namespace + ";b=" + this.value.toString("hex"); | ||
} | ||
else if (addressSpace.findNode) { | ||
// let use the provided address space to figure out the browseNode of this node. | ||
// to make the message a little bit more useful. | ||
const n = addressSpace.findNode(this); | ||
str += " " + (n ? n.browseName.toString() : " (????)"); | ||
else { | ||
str = "ns=" + this.namespace + ";b=<null>"; | ||
} | ||
} | ||
return str; | ||
break; | ||
} | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
*/ | ||
toJSON() { | ||
return this.toString(); | ||
} | ||
displayText() { | ||
if (this.namespace === 0 && this.identifierType === NodeIdType.NUMERIC) { | ||
const name = reverse_map(this.value.toString()); | ||
if (name) { | ||
return name + " (" + this.toString() + ")"; | ||
} | ||
if (addressSpace) { | ||
if (this.namespace === 0 && (this.identifierType === NodeIdType.NUMERIC)) { | ||
// find standard browse name | ||
const name = reverse_map(this.value.toString()) || "<undefined>"; | ||
str += " " + chalk.green.bold(name); | ||
} | ||
return this.toString(); | ||
else if (addressSpace.findNode) { | ||
// let use the provided address space to figure out the browseNode of this node. | ||
// to make the message a little bit more useful. | ||
const n = addressSpace.findNode(this); | ||
str += " " + (n ? n.browseName.toString() : " (????)"); | ||
} | ||
} | ||
/** | ||
* returns true if the NodeId is null or empty | ||
*/ | ||
isEmpty() { | ||
switch (this.identifierType) { | ||
case NodeIdType.NUMERIC: | ||
return this.value === 0; | ||
case NodeIdType.STRING: | ||
return !this.value || this.value.length === 0; | ||
case NodeIdType.GUID: | ||
return !this.value || this.value === node_opcua_guid_1.emptyGuid; | ||
default: | ||
node_opcua_assert_1.assert(this.identifierType === NodeIdType.BYTESTRING, "invalid identifierType in NodeId : " + this.identifierType); | ||
return !this.value || this.value.length === 0; | ||
return str; | ||
} | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
*/ | ||
toJSON() { | ||
return this.toString(); | ||
} | ||
displayText() { | ||
if (this.namespace === 0 && this.identifierType === NodeIdType.NUMERIC) { | ||
const name = reverse_map(this.value.toString()); | ||
if (name) { | ||
return name + " (" + this.toString() + ")"; | ||
} | ||
} | ||
return this.toString(); | ||
} | ||
NodeId.NodeIdType = NodeIdType; | ||
return NodeId; | ||
})(); | ||
/** | ||
* returns true if the NodeId is null or empty | ||
*/ | ||
isEmpty() { | ||
switch (this.identifierType) { | ||
case NodeIdType.NUMERIC: | ||
return this.value === 0; | ||
case NodeIdType.STRING: | ||
return !this.value || this.value.length === 0; | ||
case NodeIdType.GUID: | ||
return !this.value || this.value === node_opcua_guid_1.emptyGuid; | ||
default: | ||
node_opcua_assert_1.assert(this.identifierType === NodeIdType.BYTESTRING, "invalid identifierType in NodeId : " + this.identifierType); | ||
return !this.value || this.value.length === 0; | ||
} | ||
} | ||
} | ||
exports.NodeId = NodeId; | ||
NodeId.NodeIdType = NodeIdType; | ||
NodeId.nullNodeId = new NodeId(NodeIdType.NUMERIC, 0); | ||
@@ -165,0 +162,0 @@ const regexNamespaceI = /ns=([0-9]+);i=([0-9]+)/; |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "pure nodejs OPCUA SDK - module -nodeid", | ||
@@ -15,11 +15,11 @@ "scripts": { | ||
"dependencies": { | ||
"chalk": "^4.0.0", | ||
"node-opcua-assert": "^2.6.1", | ||
"node-opcua-constants": "^2.9.0", | ||
"node-opcua-enum": "^2.8.1", | ||
"node-opcua-guid": "^2.6.1", | ||
"chalk": "^4.1.0", | ||
"node-opcua-assert": "2.10.0", | ||
"node-opcua-constants": "2.9.0", | ||
"node-opcua-enum": "2.10.0", | ||
"node-opcua-guid": "2.10.0", | ||
"underscore": "^1.10.2" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-benchmarker": "^2.8.1", | ||
"node-opcua-benchmarker": "2.10.0", | ||
"should": "^13.2.3", | ||
@@ -43,3 +43,3 @@ "source-map-support": "^0.5.19" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "66374de9fbf47e8ad7a3e869cad4ec332e256751" | ||
"gitHead": "f1c467c28f8bef1cc04ab54c57a555bd4c95ee45" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54581
1129
+ Addedansi-regex@2.1.1(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcss-select@4.3.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddom-converter@0.2.0(transitive)
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@4.3.1(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedentities@2.2.0(transitive)
+ Addedhtmlparser2@6.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addednode-opcua-assert@2.10.0(transitive)
+ Addednode-opcua-constants@2.9.0(transitive)
+ Addednode-opcua-enum@2.10.0(transitive)
+ Addednode-opcua-guid@2.10.0(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedpretty-error@2.1.2(transitive)
+ Addedrenderkid@2.0.7(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedutila@0.4.0(transitive)
- Removednode-opcua-assert@2.120.0(transitive)
- Removednode-opcua-constants@2.125.0(transitive)
- Removednode-opcua-enum@2.133.0(transitive)
- Removednode-opcua-guid@2.133.0(transitive)
Updatedchalk@^4.1.0
Updatednode-opcua-assert@2.10.0
Updatednode-opcua-constants@2.9.0
Updatednode-opcua-enum@2.10.0
Updatednode-opcua-guid@2.10.0