Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const binaryEncodingNodeIds = results2.map((br: BrowseResult) => {
const defaultBin = br.references!.filter((r: ReferenceDescription) => r.browseName.toString() === "Default Binary");
/* istanbul ignore next */
if (defaultBin.length < 1) {
return ExpandedNodeId;
}
return ExpandedNodeId.fromNodeId(defaultBin[0].nodeId, namespaces[defaultBin[0].nodeId.namespace]);
});
const tuples = _.zip(references, binaryEncodingNodeIds);
for (const [ref, defaultBinary] of tuples) {
const name = ref.browseName!.name!.toString();
const constructor = getOrCreateConstructor(name, typeDictionary, defaultBinary);
/* istanbul ignore next */
if (doDebug) {
// let's verify that constructor is operational
try {
const testObject = new constructor();
debugLog(testObject.toString());
} catch (err) {
debugLog(err.message);
}
}
}
}
public getExtensionObjectConstructorFromDataType(
dataTypeNodeId: NodeId
): AnyConstructorFunc {
const typeDictionary = this.getTypeDictionaryForNamespace(dataTypeNodeId.namespace);
// find schema corresponding to dataTypeNodeId in typeDictionary
const schema = findSchemaForDataType(typeDictionary, dataTypeNodeId);
const Constructor = createDynamicObjectConstructor(schema, typeDictionary);
return Constructor;
}
public getExtensionObjectConstructorFromBinaryEncoding(
binaryEncodingNodeId: NodeId
): AnyConstructorFunc {
const typeDictionary = this.getTypeDictionaryForNamespace(binaryEncodingNodeId.namespace);
// find schema corresponding to binaryEncodingNodeId in typeDictionary
const schema = findSchemaForBinaryEncoding(typeDictionary, binaryEncodingNodeId);
const Constructor = createDynamicObjectConstructor(schema, typeDictionary);
return Constructor;
}