New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-variant

Package Overview
Dependencies
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-variant - npm Package Compare versions

Comparing version 2.13.0 to 2.15.0

2

dist/variant.d.ts

@@ -60,3 +60,3 @@ /**

export declare function isValidVariant(arrayType: VariantArrayType, dataType: DataType, value: any, dimensions?: number[] | null): boolean;
export declare function buildVariantArray(dataType: DataType, nbElements: number, defaultValue: any): any[] | Uint8Array | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
export declare function buildVariantArray(dataType: DataType, nbElements: number, defaultValue: any): any[] | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array;
/***

@@ -63,0 +63,0 @@ * returns true if the two variant represent the same value

@@ -24,3 +24,3 @@ "use strict";

fieldType: "DataType",
name: "dataType"
name: "dataType",
},

@@ -30,3 +30,3 @@ {

fieldType: "VariantArrayType",
name: "arrayType"
name: "arrayType",
},

@@ -36,3 +36,3 @@ {

fieldType: "Any",
name: "value"
name: "value",
},

@@ -44,6 +44,6 @@ {

isArray: true,
name: "dimensions"
}
name: "dimensions",
},
],
name: "Variant"
name: "Variant",
});

@@ -55,94 +55,91 @@ function _coerceVariant(variantLike) {

}
let Variant = /** @class */ (() => {
class Variant extends node_opcua_factory_1.BaseUAObject {
constructor(options) {
super();
options = constructHook(options);
options = options ? options : {};
this.dataType = DataType_enum_1.DataType.Null;
this.arrayType = VariantArrayType_enum_1.VariantArrayType.Scalar;
const schema = schemaVariant;
/**
* the variant type.
* @property dataType
* @type {DataType}
* @default 0
*/
this.setDataType(node_opcua_factory_1.initialize_field(schema.fields[0], options.dataType));
/**
* @property arrayType
* @type {VariantArrayType}
* @default 0
*/
this.setArrayType(node_opcua_factory_1.initialize_field(schema.fields[1], options.arrayType));
/**
* @property value
* @default null
*/
this.value = node_opcua_factory_1.initialize_field(schema.fields[2], options.value);
/**
* the matrix dimensions
* @property dimensions
* @type {UInt32[]}
* @default null
*/
this.dimensions = node_opcua_factory_1.initialize_field_array(schema.fields[3], options.dimensions);
if (options.dataType === DataType_enum_1.DataType.ExtensionObject) {
if (this.arrayType === VariantArrayType_enum_1.VariantArrayType.Scalar) {
class Variant extends node_opcua_factory_1.BaseUAObject {
constructor(options) {
super();
options = constructHook(options);
options = options ? options : {};
this.dataType = DataType_enum_1.DataType.Null;
this.arrayType = VariantArrayType_enum_1.VariantArrayType.Scalar;
const schema = schemaVariant;
/**
* the variant type.
* @property dataType
* @type {DataType}
* @default 0
*/
this.setDataType(node_opcua_factory_1.initialize_field(schema.fields[0], options.dataType));
/**
* @property arrayType
* @type {VariantArrayType}
* @default 0
*/
this.setArrayType(node_opcua_factory_1.initialize_field(schema.fields[1], options.arrayType));
/**
* @property value
* @default null
*/
this.value = node_opcua_factory_1.initialize_field(schema.fields[2], options.value);
/**
* the matrix dimensions
* @property dimensions
* @type {UInt32[]}
* @default null
*/
this.dimensions = node_opcua_factory_1.initialize_field_array(schema.fields[3], options.dimensions);
if (options.dataType === DataType_enum_1.DataType.ExtensionObject) {
if (this.arrayType === VariantArrayType_enum_1.VariantArrayType.Scalar) {
/* istanbul ignore next */
if (this.value && !(this.value instanceof node_opcua_factory_1.BaseUAObject)) {
throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
}
}
else {
for (const e of this.value) {
/* istanbul ignore next */
if (this.value && !(this.value instanceof node_opcua_factory_1.BaseUAObject)) {
if (e && !(e instanceof node_opcua_factory_1.BaseUAObject)) {
throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
}
}
else {
for (const e of this.value) {
/* istanbul ignore next */
if (e && !(e instanceof node_opcua_factory_1.BaseUAObject)) {
throw new Error("A variant with DataType.ExtensionObject must have a ExtensionObject value");
}
}
}
}
}
// Define Enumeration setters
setDataType(value) {
const coercedValue = DataType_enum_1._enumerationDataType.get(value);
/* istanbul ignore next */
if (coercedValue === undefined || coercedValue === null) {
throw new Error("value cannot be coerced to DataType: " + value);
}
this.dataType = coercedValue.value;
}
// Define Enumeration setters
setDataType(value) {
const coercedValue = DataType_enum_1._enumerationDataType.get(value);
/* istanbul ignore next */
if (coercedValue === undefined || coercedValue === null) {
throw new Error("value cannot be coerced to DataType: " + value);
}
setArrayType(value) {
const coercedValue = VariantArrayType_enum_1._enumerationVariantArrayType.get(value);
/* istanbul ignore next */
if (coercedValue === undefined || coercedValue === null) {
throw new Error("value cannot be coerced to VariantArrayType: " + value);
}
this.arrayType = coercedValue.value;
this.dataType = coercedValue.value;
}
setArrayType(value) {
const coercedValue = VariantArrayType_enum_1._enumerationVariantArrayType.get(value);
/* istanbul ignore next */
if (coercedValue === undefined || coercedValue === null) {
throw new Error("value cannot be coerced to VariantArrayType: " + value);
}
encode(stream) {
encodeVariant(this, stream);
}
decode(stream) {
internalDecodeVariant(this, stream);
}
decodeDebug(stream, options) {
decodeDebugVariant(this, stream, options);
}
toString() {
return variantToString(this);
}
isValid() {
return isValidVariant(this.arrayType, this.dataType, this.value, this.dimensions);
}
clone() {
return new Variant(this);
}
this.arrayType = coercedValue.value;
}
Variant.schema = schemaVariant;
Variant.coerce = _coerceVariant;
return Variant;
})();
encode(stream) {
encodeVariant(this, stream);
}
decode(stream) {
internalDecodeVariant(this, stream);
}
decodeDebug(stream, options) {
decodeDebugVariant(this, stream, options);
}
toString() {
return variantToString(this);
}
isValid() {
return isValidVariant(this.arrayType, this.dataType, this.value, this.dimensions);
}
clone() {
return new Variant(this);
}
}
exports.Variant = Variant;
Variant.schema = schemaVariant;
Variant.coerce = _coerceVariant;
Variant.prototype.schema = schemaVariant;

@@ -314,3 +311,3 @@ function variantToString(self, options) {

dimensions: options.dimensions,
value: options.value
value: options.value,
};

@@ -379,5 +376,4 @@ if (opts.dataType === DataType_enum_1.DataType.ExtensionObject) {

if (options.arrayType === VariantArrayType_enum_1.VariantArrayType.Array) {
options.value = options.value || [];
const value1 = coerceVariantArray(options.dataType, options.value);
node_opcua_assert_1.assert(value1 !== options.value);
node_opcua_assert_1.assert(value1 === null || value1 !== options.value);
options.value = value1;

@@ -456,3 +452,3 @@ }

if (value === undefined || value === null) {
value = [];
return null;
}

@@ -508,2 +504,7 @@ if (arrayTypeConstructor && value instanceof arrayTypeConstructor) {

function encodeGeneralArray(dataType, stream, value) {
if (!value) {
node_opcua_assert_1.assert(value === null);
node_opcua_basic_types_1.encodeUInt32(0xffffffff, stream);
return;
}
const arr = value || [];

@@ -521,3 +522,3 @@ node_opcua_assert_1.assert(arr instanceof Array);

function encodeVariantArray(dataType, stream, value) {
if (value.buffer) {
if (value && value.buffer) {
try {

@@ -572,3 +573,3 @@ return _getHelper(dataType).encode(stream, value);

decode: decodeTypedArray.bind(null, typedArrayConstructor),
encode: encodeTypedArray.bind(null, typedArrayConstructor)
encode: encodeTypedArray.bind(null, typedArrayConstructor),
};

@@ -734,2 +735,5 @@ }

function isValidArrayVariant(dataType, value) {
if (value === null) {
return true;
}
if (dataType === DataType_enum_1.DataType.Float && value instanceof Float32Array) {

@@ -909,4 +913,4 @@ return true;

encode: encodeVariant,
decode: decodeVariant
decode: decodeVariant,
});
//# sourceMappingURL=variant.js.map
{
"name": "node-opcua-variant",
"version": "2.13.0",
"version": "2.15.0",
"description": "pure nodejs OPCUA SDK - module -variant",

@@ -48,3 +48,3 @@ "main": "./dist/index.js",

"homepage": "http://node-opcua.github.io/",
"gitHead": "3c8a33e1e9d7923c9434607ad22d51d6d8d58918"
"gitHead": "d92ce0bdee1ed90c2b38ee20420f091fe9bf7365"
}

@@ -26,3 +26,3 @@ /**

isValidUInt64,
isValidUInt8
isValidUInt8,
} from "node-opcua-basic-types";

@@ -38,3 +38,3 @@ import { LocalizedText, QualifiedName } from "node-opcua-data-model";

StructuredTypeSchema,
registerType
registerType,
} from "node-opcua-factory";

@@ -57,3 +57,3 @@

fieldType: "DataType",
name: "dataType"
name: "dataType",
},

@@ -63,3 +63,3 @@ {

fieldType: "VariantArrayType",
name: "arrayType"
name: "arrayType",
},

@@ -69,3 +69,3 @@ {

fieldType: "Any",
name: "value"
name: "value",
},

@@ -77,6 +77,6 @@ {

isArray: true,
name: "dimensions"
}
name: "dimensions",
},
],
name: "Variant"
name: "Variant",
});

@@ -394,3 +394,3 @@

dimensions: options.dimensions,
value: options.value
value: options.value,
};

@@ -463,5 +463,4 @@ if (opts.dataType === DataType.ExtensionObject) {

if (options.arrayType === VariantArrayType.Array) {
options.value = options.value || [];
const value1 = coerceVariantArray(options.dataType, options.value);
assert(value1 !== options.value);
assert(value1 === null || value1 !== options.value);
options.value = value1;

@@ -568,3 +567,3 @@ } else {

if (value === undefined || value === null) {
value = [];
return null;
}

@@ -639,2 +638,7 @@

function encodeGeneralArray(dataType: DataType, stream: OutputBinaryStream, value: any) {
if (!value) {
assert(value === null);
encodeUInt32(0xffffffff, stream);
return;
}
const arr = value || [];

@@ -653,3 +657,3 @@ assert(arr instanceof Array);

function encodeVariantArray(dataType: DataType, stream: OutputBinaryStream, value: any) {
if (value.buffer) {
if (value && value.buffer) {
try {

@@ -710,3 +714,3 @@ return _getHelper(dataType).encode(stream, value);

decode: decodeTypedArray.bind(null, typedArrayConstructor),
encode: encodeTypedArray.bind(null, typedArrayConstructor)
encode: encodeTypedArray.bind(null, typedArrayConstructor),
};

@@ -891,2 +895,5 @@ }

function isValidArrayVariant(dataType: DataType, value: any): boolean {
if (value === null) {
return true;
}
if (dataType === DataType.Float && value instanceof Float32Array) {

@@ -1077,3 +1084,3 @@ return true;

encode: encodeVariant,
decode: decodeVariant
decode: decodeVariant,
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc