node-opcua-variant
Advanced tools
Comparing version 2.102.0 to 2.104.0
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.adjustVariant = void 0; | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const node_opcua_assert_1 = __importDefault(require("node-opcua-assert")); | ||
const DataType_enum_1 = require("./DataType_enum"); | ||
@@ -6,0 +9,0 @@ const VariantArrayType_enum_1 = require("./VariantArrayType_enum"); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -12,3 +35,3 @@ exports.sameVariant = exports.buildVariantArray = exports.isValidVariant = exports.coerceVariantType = exports.decodeVariant = exports.encodeVariant = exports.VARIANT_TYPE_MASK = exports.VARIANT_ARRAY_DIMENSIONS_MASK = exports.VARIANT_ARRAY_MASK = exports.Variant = void 0; | ||
const node_opcua_factory_1 = require("node-opcua-factory"); | ||
const utils = require("node-opcua-utils"); | ||
const utils = __importStar(require("node-opcua-utils")); | ||
const DataType_enum_1 = require("./DataType_enum"); | ||
@@ -106,2 +129,3 @@ const VariantArrayType_enum_1 = require("./VariantArrayType_enum"); | ||
} | ||
exports.Variant = Variant; | ||
Variant.maxTypedArrayLength = 16 * 1024 * 1024; | ||
@@ -112,3 +136,2 @@ Variant.maxArrayLength = 1 * 1024 * 1024; | ||
Variant.computer_default_value = () => new Variant({ dataType: DataType_enum_1.DataType.Null }); | ||
exports.Variant = Variant; | ||
Variant.prototype.schema = schemaVariant; | ||
@@ -179,31 +202,24 @@ function variantToString(self, options) { | ||
function encodeVariant(variant, stream) { | ||
try { | ||
if (!variant) { | ||
variant = nullVariant; | ||
} | ||
let encodingByte = variant.dataType; | ||
if (variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Array || variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
encodingByte |= exports.VARIANT_ARRAY_MASK; | ||
} | ||
if (variant.dimensions && variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
(0, node_opcua_assert_1.assert)(variant.dimensions.length >= 0); | ||
encodingByte |= exports.VARIANT_ARRAY_DIMENSIONS_MASK; | ||
} | ||
(0, node_opcua_basic_types_1.encodeUInt8)(encodingByte, stream); | ||
if (variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Array || variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
encodeVariantArray(variant.dataType, stream, variant.value); | ||
} | ||
else { | ||
const encode = get_encoder(variant.dataType || DataType_enum_1.DataType.Null); | ||
encode(variant.value, stream); | ||
} | ||
if ((encodingByte & exports.VARIANT_ARRAY_DIMENSIONS_MASK) === exports.VARIANT_ARRAY_DIMENSIONS_MASK && variant.dimensions) { | ||
encodeDimension(variant.dimensions, stream); | ||
} | ||
if (!variant) { | ||
variant = nullVariant; | ||
} | ||
catch (err) { | ||
console.log("Error encoding variant", err); | ||
console.log(variant === null || variant === void 0 ? void 0 : variant.toString()); | ||
throw err; | ||
let encodingByte = variant.dataType; | ||
if (variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Array || variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
encodingByte |= exports.VARIANT_ARRAY_MASK; | ||
} | ||
if (variant.dimensions && variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
(0, node_opcua_assert_1.assert)(variant.dimensions.length >= 0); | ||
encodingByte |= exports.VARIANT_ARRAY_DIMENSIONS_MASK; | ||
} | ||
(0, node_opcua_basic_types_1.encodeUInt8)(encodingByte, stream); | ||
if (variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Array || variant.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) { | ||
encodeVariantArray(variant.dataType, stream, variant.value); | ||
} | ||
else { | ||
const encode = get_encoder(variant.dataType || DataType_enum_1.DataType.Null); | ||
encode(variant.value, stream); | ||
} | ||
if ((encodingByte & exports.VARIANT_ARRAY_DIMENSIONS_MASK) === exports.VARIANT_ARRAY_DIMENSIONS_MASK && variant.dimensions) { | ||
encodeDimension(variant.dimensions, stream); | ||
} | ||
} | ||
@@ -213,2 +229,4 @@ exports.encodeVariant = encodeVariant; | ||
* @private | ||
* | ||
* istanbul ignore function | ||
*/ | ||
@@ -215,0 +233,0 @@ function decodeDebugVariant(self, stream, options) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
VariantArrayType[VariantArrayType["Matrix"] = 2] = "Matrix"; | ||
})(VariantArrayType = exports.VariantArrayType || (exports.VariantArrayType = {})); | ||
})(VariantArrayType || (exports.VariantArrayType = VariantArrayType = {})); | ||
const schemaVariantArrayType = { | ||
@@ -13,0 +13,0 @@ enumValues: VariantArrayType, |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.verifyRankAndDimensions = void 0; | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const node_opcua_assert_1 = __importDefault(require("node-opcua-assert")); | ||
/** | ||
@@ -6,0 +9,0 @@ * ValueRank indicates whether the Value Attribute of the Variable can be an Array and how many dimensions |
{ | ||
"name": "node-opcua-variant", | ||
"version": "2.102.0", | ||
"version": "2.104.0", | ||
"description": "pure nodejs OPCUA SDK - module variant", | ||
@@ -15,21 +15,21 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"node-opcua-assert": "2.98.1", | ||
"node-opcua-basic-types": "2.99.0", | ||
"node-opcua-binary-stream": "2.98.1", | ||
"node-opcua-data-model": "2.102.0", | ||
"node-opcua-enum": "2.98.1", | ||
"node-opcua-factory": "2.99.0", | ||
"node-opcua-nodeid": "2.99.0", | ||
"node-opcua-utils": "2.98.1" | ||
"node-opcua-assert": "2.104.0", | ||
"node-opcua-basic-types": "2.104.0", | ||
"node-opcua-binary-stream": "2.104.0", | ||
"node-opcua-data-model": "2.104.0", | ||
"node-opcua-enum": "2.104.0", | ||
"node-opcua-factory": "2.104.0", | ||
"node-opcua-nodeid": "2.104.0", | ||
"node-opcua-utils": "2.104.0" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "4.14.192", | ||
"@types/underscore": "^1.11.4", | ||
"@types/lodash": "4.14.195", | ||
"@types/underscore": "^1.11.5", | ||
"lodash": "4.17.21", | ||
"node-opcua-benchmarker": "2.98.1", | ||
"node-opcua-debug": "2.99.0", | ||
"node-opcua-extension-object": "2.99.0", | ||
"node-opcua-numeric-range": "2.102.0", | ||
"node-opcua-packet-analyzer": "2.102.0", | ||
"node-opcua-status-code": "2.98.1", | ||
"node-opcua-benchmarker": "2.104.0", | ||
"node-opcua-debug": "2.104.0", | ||
"node-opcua-extension-object": "2.104.0", | ||
"node-opcua-numeric-range": "2.104.0", | ||
"node-opcua-packet-analyzer": "2.104.0", | ||
"node-opcua-status-code": "2.104.0", | ||
"should": "^13.2.3", | ||
@@ -53,3 +53,3 @@ "underscore": "^1.13.6" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c", | ||
"gitHead": "3cd6d355e8b3c66822d08a3ca682659ea5d1a55d", | ||
"files": [ | ||
@@ -56,0 +56,0 @@ "dist", |
@@ -243,31 +243,25 @@ /** | ||
export function encodeVariant(variant: Variant | undefined | null, stream: OutputBinaryStream): void { | ||
try { | ||
if (!variant) { | ||
variant = nullVariant; | ||
} | ||
let encodingByte = variant.dataType; | ||
if (!variant) { | ||
variant = nullVariant; | ||
} | ||
let encodingByte = variant.dataType; | ||
if (variant.arrayType === VariantArrayType.Array || variant.arrayType === VariantArrayType.Matrix) { | ||
encodingByte |= VARIANT_ARRAY_MASK; | ||
} | ||
if (variant.dimensions && variant.arrayType === VariantArrayType.Matrix) { | ||
assert(variant.dimensions.length >= 0); | ||
encodingByte |= VARIANT_ARRAY_DIMENSIONS_MASK; | ||
} | ||
encodeUInt8(encodingByte, stream); | ||
if (variant.arrayType === VariantArrayType.Array || variant.arrayType === VariantArrayType.Matrix) { | ||
encodingByte |= VARIANT_ARRAY_MASK; | ||
} | ||
if (variant.dimensions && variant.arrayType === VariantArrayType.Matrix) { | ||
assert(variant.dimensions.length >= 0); | ||
encodingByte |= VARIANT_ARRAY_DIMENSIONS_MASK; | ||
} | ||
encodeUInt8(encodingByte, stream); | ||
if (variant.arrayType === VariantArrayType.Array || variant.arrayType === VariantArrayType.Matrix) { | ||
encodeVariantArray(variant.dataType, stream, variant.value); | ||
} else { | ||
const encode = get_encoder(variant.dataType || DataType.Null); | ||
encode(variant.value, stream); | ||
} | ||
if (variant.arrayType === VariantArrayType.Array || variant.arrayType === VariantArrayType.Matrix) { | ||
encodeVariantArray(variant.dataType, stream, variant.value); | ||
} else { | ||
const encode = get_encoder(variant.dataType || DataType.Null); | ||
encode(variant.value, stream); | ||
} | ||
if ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK && variant.dimensions) { | ||
encodeDimension(variant.dimensions, stream); | ||
} | ||
} catch (err) { | ||
console.log("Error encoding variant", err); | ||
console.log(variant?.toString()); | ||
throw err; | ||
if ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK && variant.dimensions) { | ||
encodeDimension(variant.dimensions, stream); | ||
} | ||
@@ -278,2 +272,4 @@ } | ||
* @private | ||
* | ||
* istanbul ignore function | ||
*/ | ||
@@ -423,3 +419,3 @@ function decodeDebugVariant(self: Variant, stream: BinaryStream, options: DecodeDebugOptions): void { | ||
"Variant#constructor : when using UInt64 ou Int64" + | ||
" arrayType must be specified , as automatic detection cannot be made" | ||
" arrayType must be specified , as automatic detection cannot be made" | ||
); | ||
@@ -453,7 +449,7 @@ } else { | ||
"Matrix Variant : invalid value size = options.value.length " + | ||
options.value.length + | ||
"!=" + | ||
calculate_product(options.dimensions) + | ||
" => " + | ||
JSON.stringify(options.dimensions) | ||
options.value.length + | ||
"!=" + | ||
calculate_product(options.dimensions) + | ||
" => " + | ||
JSON.stringify(options.dimensions) | ||
); | ||
@@ -473,10 +469,10 @@ } | ||
"Invalid variant arrayType: " + | ||
VariantArrayType[options.arrayType] + | ||
" dataType: " + | ||
DataType[options.dataType] + | ||
" value:" + | ||
options.value + | ||
" (javascript type = " + | ||
typeof options.value + | ||
" )" | ||
VariantArrayType[options.arrayType] + | ||
" dataType: " + | ||
DataType[options.dataType] + | ||
" value:" + | ||
options.value + | ||
" (javascript type = " + | ||
typeof options.value + | ||
" )" | ||
); | ||
@@ -540,3 +536,3 @@ } | ||
BYTES_PER_ELEMENT: number; | ||
new(buffer: any): any; | ||
new (buffer: any): any; | ||
} | ||
@@ -833,6 +829,6 @@ | ||
value === null || | ||
DataType.Int64 === dataType || | ||
DataType.ByteString === dataType || | ||
DataType.UInt64 === dataType || | ||
!(value instanceof Array) | ||
DataType.Int64 === dataType || | ||
DataType.ByteString === dataType || | ||
DataType.UInt64 === dataType || | ||
!(value instanceof Array) | ||
); | ||
@@ -839,0 +835,0 @@ assert(value === null || !(value instanceof Int32Array)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
139148
2450
+ Addednode-opcua-assert@2.104.0(transitive)
+ Addednode-opcua-basic-types@2.104.0(transitive)
+ Addednode-opcua-binary-stream@2.104.0(transitive)
+ Addednode-opcua-buffer-utils@2.104.0(transitive)
+ Addednode-opcua-data-model@2.104.0(transitive)
+ Addednode-opcua-date-time@2.104.0(transitive)
+ Addednode-opcua-debug@2.104.0(transitive)
+ Addednode-opcua-enum@2.104.0(transitive)
+ Addednode-opcua-factory@2.104.0(transitive)
+ Addednode-opcua-nodeid@2.104.0(transitive)
+ Addednode-opcua-status-code@2.104.0(transitive)
+ Addednode-opcua-utils@2.104.0(transitive)
- Removednode-opcua-assert@2.98.1(transitive)
- Removednode-opcua-basic-types@2.99.0(transitive)
- Removednode-opcua-binary-stream@2.98.1(transitive)
- Removednode-opcua-buffer-utils@2.98.1(transitive)
- Removednode-opcua-data-model@2.102.0(transitive)
- Removednode-opcua-date-time@2.99.0(transitive)
- Removednode-opcua-debug@2.99.0(transitive)
- Removednode-opcua-enum@2.98.1(transitive)
- Removednode-opcua-factory@2.99.0(transitive)
- Removednode-opcua-nodeid@2.99.0(transitive)
- Removednode-opcua-status-code@2.98.1(transitive)
- Removednode-opcua-utils@2.98.1(transitive)
Updatednode-opcua-assert@2.104.0
Updatednode-opcua-enum@2.104.0
Updatednode-opcua-factory@2.104.0
Updatednode-opcua-nodeid@2.104.0
Updatednode-opcua-utils@2.104.0