node-opcua-variant 2.164.0 → 2.167.0

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.
@@ -1,6 +1,3 @@
1
- /**
2
- * @module node-opcua-variant
3
- */
4
- import { Enum } from "node-opcua-enum";
1
+ import type { Enum } from "node-opcua-enum";
5
2
  export { DataType } from "node-opcua-basic-types";
6
3
  export declare const _enumerationDataType: Enum;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._enumerationDataType = exports.DataType = void 0;
4
- const node_opcua_factory_1 = require("node-opcua-factory");
4
+ /**
5
+ * @module node-opcua-variant
6
+ */
5
7
  const node_opcua_basic_types_1 = require("node-opcua-basic-types");
8
+ const node_opcua_factory_1 = require("node-opcua-factory");
6
9
  var node_opcua_basic_types_2 = require("node-opcua-basic-types");
7
10
  Object.defineProperty(exports, "DataType", { enumerable: true, get: function () { return node_opcua_basic_types_2.DataType; } });
8
11
  const schemaDataType = {
@@ -1 +1 @@
1
- {"version":3,"file":"DataType_enum.js","sourceRoot":"","sources":["../source/DataType_enum.ts"],"names":[],"mappings":";;;AAIA,2DAAyD;AACzD,mEAAkD;AAClD,iEAAkD;AAAzC,kHAAA,QAAQ,OAAA;AACjB,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,UAAU;IAEhB,UAAU,EAAE,iCAAQ;CACvB,CAAC;AACW,QAAA,oBAAoB,GAAS,IAAA,wCAAmB,EAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"DataType_enum.js","sourceRoot":"","sources":["../source/DataType_enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAAkD;AAElD,2DAAyD;AAEzD,iEAAkD;AAAzC,kHAAA,QAAQ,OAAA;AAEjB,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,UAAU;IAEhB,UAAU,EAAE,iCAAQ;CACvB,CAAC;AACW,QAAA,oBAAoB,GAAS,IAAA,wCAAmB,EAAC,cAAc,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module node-opcua-variant
3
3
  */
4
- import { Enum } from "node-opcua-enum";
4
+ import type { Enum } from "node-opcua-enum";
5
5
  export declare enum VariantArrayType {
6
6
  Scalar = 0,
7
7
  Array = 1,
@@ -1,3 +1,3 @@
1
- import { Variant } from "./variant";
2
1
  import { DataType } from "./DataType_enum";
2
+ import type { Variant } from "./variant";
3
3
  export declare function adjustVariant(variant: Variant, valueRank: number, targetDataType: DataType): Variant;
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.adjustVariant = adjustVariant;
7
- const node_opcua_assert_1 = __importDefault(require("node-opcua-assert"));
4
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
5
  const DataType_enum_1 = require("./DataType_enum");
9
6
  const VariantArrayType_enum_1 = require("./VariantArrayType_enum");
10
7
  function adjustVariant(variant, valueRank, targetDataType) {
@@ -13,8 +10,8 @@ function adjustVariant(variant, valueRank, targetDataType) {
13
10
  // Byte
14
11
  variant.arrayType = VariantArrayType_enum_1.VariantArrayType.Array;
15
12
  variant.dataType = DataType_enum_1.DataType.Byte;
16
- (0, node_opcua_assert_1.default)(variant.dataType === DataType_enum_1.DataType.Byte);
17
- (0, node_opcua_assert_1.default)(!variant.value || variant.value instanceof Buffer);
13
+ (0, node_opcua_assert_1.assert)(variant.dataType === DataType_enum_1.DataType.Byte);
14
+ (0, node_opcua_assert_1.assert)(!variant.value || variant.value instanceof Buffer);
18
15
  }
19
16
  }
20
17
  if (targetDataType === DataType_enum_1.DataType.ByteString && valueRank === -1 /* Scalar*/) {
@@ -22,8 +19,8 @@ function adjustVariant(variant, valueRank, targetDataType) {
22
19
  // Byte
23
20
  variant.arrayType = VariantArrayType_enum_1.VariantArrayType.Scalar;
24
21
  variant.dataType = DataType_enum_1.DataType.ByteString;
25
- (0, node_opcua_assert_1.default)(variant.dataType === DataType_enum_1.DataType.ByteString);
26
- (0, node_opcua_assert_1.default)(!variant.value || variant.value instanceof Buffer);
22
+ (0, node_opcua_assert_1.assert)(variant.dataType === DataType_enum_1.DataType.ByteString);
23
+ (0, node_opcua_assert_1.assert)(!variant.value || variant.value instanceof Buffer);
27
24
  }
28
25
  }
29
26
  return variant;
@@ -1 +1 @@
1
- {"version":3,"file":"adjust_variant.js","sourceRoot":"","sources":["../source/adjust_variant.ts"],"names":[],"mappings":";;;;;AAKA,sCAoBC;AAzBD,0EAAuC;AAEvC,mDAA2C;AAC3C,mEAA2D;AAE3D,SAAgB,aAAa,CAAC,OAAgB,EAAE,SAAiB,EAAE,cAAwB;IACvF,IAAI,cAAc,KAAK,wBAAQ,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,wCAAgB,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,UAAU,EAAE,CAAC;YAC5F,OAAO;YACP,OAAO,CAAC,SAAS,GAAG,wCAAgB,CAAC,KAAK,CAAC;YAC3C,OAAO,CAAC,QAAQ,GAAG,wBAAQ,CAAC,IAAI,CAAC;YACjC,IAAA,2BAAM,EAAC,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAA,2BAAM,EAAC,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;IACD,IAAI,cAAc,KAAK,wBAAQ,CAAC,UAAU,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACzE,IAAI,OAAO,CAAC,SAAS,KAAK,wCAAgB,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,IAAI,EAAE,CAAC;YACrF,OAAO;YACP,OAAO,CAAC,SAAS,GAAG,wCAAgB,CAAC,MAAM,CAAC;YAC5C,OAAO,CAAC,QAAQ,GAAG,wBAAQ,CAAC,UAAU,CAAC;YACvC,IAAA,2BAAM,EAAC,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,UAAU,CAAC,CAAC;YACjD,IAAA,2BAAM,EAAC,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"adjust_variant.js","sourceRoot":"","sources":["../source/adjust_variant.ts"],"names":[],"mappings":";;AAKA,sCAoBC;AAzBD,yDAA2C;AAC3C,mDAA2C;AAC3C,mEAA2D;AAG3D,SAAgB,aAAa,CAAC,OAAgB,EAAE,SAAiB,EAAE,cAAwB;IACvF,IAAI,cAAc,KAAK,wBAAQ,CAAC,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,wCAAgB,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,UAAU,EAAE,CAAC;YAC5F,OAAO;YACP,OAAO,CAAC,SAAS,GAAG,wCAAgB,CAAC,KAAK,CAAC;YAC3C,OAAO,CAAC,QAAQ,GAAG,wBAAQ,CAAC,IAAI,CAAC;YACjC,IAAA,0BAAM,EAAC,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAA,0BAAM,EAAC,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;IACD,IAAI,cAAc,KAAK,wBAAQ,CAAC,UAAU,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACzE,IAAI,OAAO,CAAC,SAAS,KAAK,wCAAgB,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,IAAI,EAAE,CAAC;YACrF,OAAO;YACP,OAAO,CAAC,SAAS,GAAG,wCAAgB,CAAC,MAAM,CAAC;YAC5C,OAAO,CAAC,QAAQ,GAAG,wBAAQ,CAAC,UAAU,CAAC;YACvC,IAAA,0BAAM,EAAC,OAAO,CAAC,QAAQ,KAAK,wBAAQ,CAAC,UAAU,CAAC,CAAC;YACjD,IAAA,0BAAM,EAAC,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,YAAY,MAAM,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cast_variant.js","sourceRoot":"","sources":["../source/cast_variant.ts"],"names":[],"mappings":";;AAGA,OAAO;AACP;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCE"}
1
+ {"version":3,"file":"cast_variant.js","sourceRoot":"","sources":["../source/cast_variant.ts"],"names":[],"mappings":";;AACA,OAAO;AACP;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCE"}
package/dist/index.d.ts CHANGED
@@ -23,9 +23,9 @@
23
23
  /**
24
24
  * @module node-opcua-variant
25
25
  */
26
+ export * from "./adjust_variant";
27
+ export * from "./cast_variant";
26
28
  export * from "./DataType_enum";
27
29
  export * from "./VariantArrayType_enum";
28
30
  export * from "./variant";
29
- export * from "./adjust_variant";
30
- export * from "./cast_variant";
31
31
  export * from "./verify_rank_and_dimension";
package/dist/index.js CHANGED
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
2
  /*!
18
3
  * The MIT License (MIT)
19
4
  * Copyright (c) 2022-2025 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
@@ -39,10 +24,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
24
  /**
40
25
  * @module node-opcua-variant
41
26
  */
27
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ var desc = Object.getOwnPropertyDescriptor(m, k);
30
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
+ desc = { enumerable: true, get: function() { return m[k]; } };
32
+ }
33
+ Object.defineProperty(o, k2, desc);
34
+ }) : (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ o[k2] = m[k];
37
+ }));
38
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
39
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ __exportStar(require("./adjust_variant"), exports);
43
+ __exportStar(require("./cast_variant"), exports);
42
44
  __exportStar(require("./DataType_enum"), exports);
43
45
  __exportStar(require("./VariantArrayType_enum"), exports);
44
46
  __exportStar(require("./variant"), exports);
45
- __exportStar(require("./adjust_variant"), exports);
46
- __exportStar(require("./cast_variant"), exports);
47
47
  __exportStar(require("./verify_rank_and_dimension"), exports);
48
48
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,kDAAgC;AAChC,0DAAwC;AACxC,4CAA0B;AAC1B,mDAAiC;AACjC,iDAA+B;AAC/B,8DAA4C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;;;;;;;;;;;;;;;;AAEH,mDAAiC;AACjC,iDAA+B;AAC/B,kDAAgC;AAChC,0DAAwC;AACxC,4CAA0B;AAC1B,8DAA4C"}
package/dist/variant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BaseUAObject, DecodeDebugOptions } from "node-opcua-factory";
2
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
1
+ import type { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ import { BaseUAObject, type DecodeDebugOptions } from "node-opcua-factory";
3
3
  import { DataType } from "./DataType_enum";
4
4
  import { VariantArrayType } from "./VariantArrayType_enum";
5
5
  export { VariantArrayType };
package/dist/variant.js CHANGED
@@ -11,12 +11,12 @@ exports.sameVariant = sameVariant;
11
11
  * @module node-opcua-variant
12
12
  */
13
13
  const node_opcua_assert_1 = require("node-opcua-assert");
14
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
14
  const node_opcua_basic_types_1 = require("node-opcua-basic-types");
16
15
  const node_opcua_data_model_1 = require("node-opcua-data-model");
16
+ const node_opcua_debug_1 = require("node-opcua-debug");
17
17
  const node_opcua_factory_1 = require("node-opcua-factory");
18
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
18
19
  const node_opcua_utils_1 = require("node-opcua-utils");
19
- const node_opcua_debug_1 = require("node-opcua-debug");
20
20
  const DataType_enum_1 = require("./DataType_enum");
21
21
  const VariantArrayType_enum_1 = require("./VariantArrayType_enum");
22
22
  Object.defineProperty(exports, "VariantArrayType", { enumerable: true, get: function () { return VariantArrayType_enum_1.VariantArrayType; } });
@@ -64,6 +64,7 @@ class Variant extends node_opcua_factory_1.BaseUAObject {
64
64
  static computer_default_value = () => new Variant({ dataType: DataType_enum_1.DataType.Null });
65
65
  dataType;
66
66
  arrayType;
67
+ // biome-ignore lint/suspicious/noExplicitAny: intentionally using any here
67
68
  value;
68
69
  dimensions;
69
70
  constructor(options) {
@@ -125,34 +126,38 @@ class Variant extends node_opcua_factory_1.BaseUAObject {
125
126
  }
126
127
  exports.Variant = Variant;
127
128
  Variant.prototype.schema = schemaVariant;
128
- function variantToString(self, options) {
129
- function toString(value) {
129
+ function variantToString(self, _options) {
130
+ function asString(value) {
130
131
  switch (self.dataType) {
131
132
  case DataType_enum_1.DataType.ByteString:
132
- return value ? "0x" + value.toString("hex") : "<null>";
133
+ return value ? `0x${value.toString("hex")}` : "<null>";
133
134
  case DataType_enum_1.DataType.NodeId:
134
- return value instanceof node_opcua_nodeid_1.NodeId ? value.displayText() : value ? value.toString(options) : "";
135
+ return value instanceof node_opcua_nodeid_1.NodeId ? value.displayText() : value ? String(value) : "";
135
136
  case DataType_enum_1.DataType.Boolean:
136
- return value.toString();
137
+ return String(value);
137
138
  case DataType_enum_1.DataType.DateTime:
138
- return value ? (value.toISOString ? value.toISOString() : value.toString()) : "<null>";
139
+ return value
140
+ ? typeof value.toISOString === "function"
141
+ ? value.toISOString()
142
+ : String(value)
143
+ : "<null>";
139
144
  default:
140
- return value ? value.toString(options) : "0";
145
+ return value ? String(value) : "0";
141
146
  }
142
147
  }
143
148
  function f(value) {
144
149
  if (value === undefined || (value === null && typeof value === "object")) {
145
150
  return "<null>";
146
151
  }
147
- return toString(value);
152
+ return asString(value);
148
153
  }
149
154
  let data = VariantArrayType_enum_1.VariantArrayType[self.arrayType];
150
155
  if (self.dimensions && self.dimensions.length >= 0) {
151
- data += "[ " + self.dimensions.join(",") + " ]";
156
+ data += `[ ${self.dimensions.join(",")} ]`;
152
157
  }
153
- data += "<" + DataType_enum_1.DataType[self.dataType] + ">";
158
+ data += `<${DataType_enum_1.DataType[self.dataType]}>`;
154
159
  if (self.arrayType === VariantArrayType_enum_1.VariantArrayType.Scalar) {
155
- data += ", value: " + f(self.value);
160
+ data += `, value: ${f(self.value)}`;
156
161
  }
157
162
  else if (self.arrayType === VariantArrayType_enum_1.VariantArrayType.Array || self.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix) {
158
163
  if (!self.value) {
@@ -167,10 +172,10 @@ function variantToString(self, options) {
167
172
  if (self.value.length > 10) {
168
173
  a.push("...");
169
174
  }
170
- data += ", l= " + self.value.length + ", value=[" + a.map(f).join(",") + "]";
175
+ data += `, l= ${self.value.length}, value=[${a.map(f).join(",")}]`;
171
176
  }
172
177
  }
173
- return "Variant(" + data + ")";
178
+ return `Variant(${data})`;
174
179
  }
175
180
  /***
176
181
  * @private
@@ -216,7 +221,7 @@ function encodeVariant(variant, stream) {
216
221
  function _decodeVariantArrayDebug(stream, decode, tracer, dataType) {
217
222
  let cursorBefore = stream.length;
218
223
  const length = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
219
- let i;
224
+ let i = 0;
220
225
  let element;
221
226
  tracer.trace("start_array", "Variant", -1, cursorBefore, stream.length);
222
227
  if (length === 0xffffffff) {
@@ -257,7 +262,7 @@ function decodeDebugVariant(self, stream, options) {
257
262
  const decode = (0, node_opcua_factory_1.findBuiltInType)(DataType_enum_1.DataType[self.dataType]).decode;
258
263
  /* c8 ignore next */
259
264
  if (!decode) {
260
- throw new Error("Variant.decode : cannot find decoder for type " + DataType_enum_1.DataType[self.dataType]);
265
+ throw new Error(`Variant.decode : cannot find decoder for type ${DataType_enum_1.DataType[self.dataType]}`);
261
266
  }
262
267
  const cursorBefore = stream.length;
263
268
  if (isArray) {
@@ -279,7 +284,7 @@ function decodeDebugVariant(self, stream, options) {
279
284
  // stop and raise a BadDecodingError.
280
285
  if (hasDimension) {
281
286
  self.dimensions = decodeDimension(stream);
282
- const verification = calculate_product(self.dimensions);
287
+ const _verification = calculate_product(self.dimensions);
283
288
  }
284
289
  }
285
290
  /* c8 ignore stop */
@@ -326,14 +331,14 @@ function constructHook(options) {
326
331
  };
327
332
  if (opts.dataType === DataType_enum_1.DataType.ExtensionObject) {
328
333
  if (opts.arrayType === VariantArrayType_enum_1.VariantArrayType.Scalar) {
329
- if (opts.value && opts.value.constructor) {
334
+ if (opts?.value?.constructor) {
330
335
  opts.value = new opts.value.constructor(opts.value);
331
336
  }
332
337
  }
333
338
  else {
334
339
  if (opts.value) {
335
340
  opts.value = opts.value.map((e) => {
336
- if (e && e.constructor) {
341
+ if (e?.constructor) {
337
342
  return new e.constructor(e);
338
343
  }
339
344
  return null;
@@ -352,7 +357,7 @@ function constructHook(options) {
352
357
  const d = (0, node_opcua_factory_1.findBuiltInType)(options.dataType);
353
358
  /* c8 ignore start */
354
359
  if (!d) {
355
- throw new Error("Cannot find Built-In data type or any DataType resolving to " + options.dataType);
360
+ throw new Error(`Cannot find Built-In data type or any DataType resolving to ${options.dataType}`);
356
361
  }
357
362
  /* c8 ignore stop */
358
363
  options.dataType = DataType_enum_1.DataType[d.name];
@@ -362,7 +367,7 @@ function constructHook(options) {
362
367
  const at = VariantArrayType_enum_1.VariantArrayType[options.arrayType];
363
368
  /* c8 ignore start */
364
369
  if (at === undefined) {
365
- throw new Error("ArrayType: invalid " + options.arrayType);
370
+ throw new Error(`ArrayType: invalid ${options.arrayType}`);
366
371
  }
367
372
  /* c8 ignore stop */
368
373
  options.arrayType = at;
@@ -375,8 +380,8 @@ function constructHook(options) {
375
380
  throw new Error("Variant#constructor : when using UInt64 ou Int64" +
376
381
  " arrayType must be specified , as automatic detection cannot be made");
377
382
  }
378
- /* c8 ignore stop */
379
383
  else {
384
+ /* c8 ignore stop */
380
385
  options.arrayType = VariantArrayType_enum_1.VariantArrayType.Array;
381
386
  isArrayTypeUnspecified = false;
382
387
  }
@@ -388,21 +393,16 @@ function constructHook(options) {
388
393
  (0, node_opcua_assert_1.assert)(value1 === null || value1 !== options.value);
389
394
  options.value = value1;
390
395
  }
391
- /* c8 ignore start */
392
396
  else {
397
+ /* c8 ignore start */
393
398
  (0, node_opcua_assert_1.assert)(options.arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix);
394
399
  options.value = options.value || [];
395
400
  options.value = coerceVariantArray(options.dataType, options.value);
396
401
  if (!options.dimensions) {
397
402
  throw new Error("Matrix Variant : missing dimensions");
398
403
  }
399
- if (options.value.length != 0 && options.value.length !== calculate_product(options.dimensions)) {
400
- throw new Error("Matrix Variant : invalid value size = options.value.length " +
401
- options.value.length +
402
- "!=" +
403
- calculate_product(options.dimensions) +
404
- " => " +
405
- JSON.stringify(options.dimensions));
404
+ if (options.value.length !== 0 && options.value.length !== calculate_product(options.dimensions)) {
405
+ throw new Error(`Matrix Variant : invalid value size = options.value.length ${options.value.length} != ${calculate_product(options.dimensions)} => ${JSON.stringify(options.dimensions)}`);
406
406
  }
407
407
  }
408
408
  /* c8 ignore stop */
@@ -410,20 +410,12 @@ function constructHook(options) {
410
410
  else {
411
411
  (0, node_opcua_assert_1.assert)(options.arrayType === VariantArrayType_enum_1.VariantArrayType.Scalar || options.arrayType === undefined);
412
412
  options.arrayType = VariantArrayType_enum_1.VariantArrayType.Scalar;
413
- const tmp = options.value;
413
+ const _tmp = options.value;
414
414
  // scalar
415
415
  options.value = coerceVariantType(options.dataType, options.value);
416
416
  /* c8 ignore start */
417
417
  if (!isValidVariant(options.arrayType, options.dataType, options.value, null)) {
418
- throw new Error("Invalid variant arrayType: " +
419
- VariantArrayType_enum_1.VariantArrayType[options.arrayType] +
420
- " dataType: " +
421
- DataType_enum_1.DataType[options.dataType] +
422
- " value:" +
423
- options.value +
424
- " (javascript type = " +
425
- typeof options.value +
426
- " )");
418
+ throw new Error(`Invalid variant arrayType: ${VariantArrayType_enum_1.VariantArrayType[options.arrayType]} dataType: ${DataType_enum_1.DataType[options.dataType]} value:${options.value} (javascript type = ${typeof options.value} )`);
427
419
  }
428
420
  /* c8 ignore stop */
429
421
  }
@@ -443,13 +435,13 @@ function get_encoder(dataType) {
443
435
  const dataTypeAsString = typeof dataType === "string" ? dataType : DataType_enum_1.DataType[dataType];
444
436
  /* c8 ignore start */
445
437
  if (!dataTypeAsString) {
446
- throw new Error("invalid dataType " + dataType);
438
+ throw new Error(`invalid dataType ${dataType}`);
447
439
  }
448
440
  /* c8 ignore stop */
449
441
  const encode = (0, node_opcua_factory_1.findBuiltInType)(dataTypeAsString).encode;
450
442
  /* c8 ignore start */
451
443
  if (!encode) {
452
- throw new Error("Cannot find encode function for dataType " + dataTypeAsString);
444
+ throw new Error(`Cannot find encode function for dataType ${dataTypeAsString}`);
453
445
  }
454
446
  /* c8 ignore stop */
455
447
  return encode;
@@ -459,7 +451,7 @@ function get_decoder(dataType) {
459
451
  const decode = (0, node_opcua_factory_1.findBuiltInType)(dataTypeAsString).decode;
460
452
  /* c8 ignore start */
461
453
  if (!decode) {
462
- throw new Error("Variant.decode : cannot find decoder for type " + dataTypeAsString);
454
+ throw new Error(`Variant.decode : cannot find decoder for type ${dataTypeAsString}`);
463
455
  }
464
456
  /* c8 ignore stop */
465
457
  return decode;
@@ -486,9 +478,9 @@ function convertTo(dataType, arrayTypeConstructor, value) {
486
478
  }
487
479
  // c8 ignore next
488
480
  if (arrayTypeConstructor && displayWarning && n > 10) {
489
- warningLog("Warning ! an array containing " + DataType_enum_1.DataType[dataType] + " elements has been provided as a generic array. ");
490
- warningLog(" This is inefficient as every array value will " + "have to be coerced and verified against the expected type");
491
- warningLog(" It is highly recommended that you use a " + " typed array ", arrayTypeConstructor.constructor.name, " instead");
481
+ warningLog(`Warning ! an array containing ${DataType_enum_1.DataType[dataType]} elements has been provided as a generic array. `);
482
+ warningLog(" This is inefficient as every array value will have to be coerced and verified against the expected type");
483
+ warningLog(" It is highly recommended that you use a typed array ", arrayTypeConstructor.constructor.name, " instead");
492
484
  }
493
485
  return newArr;
494
486
  }
@@ -506,10 +498,11 @@ function coerceVariantArray(dataType, value) {
506
498
  }
507
499
  }
508
500
  function encodeTypedArray(arrayTypeConstructor, stream, value) {
509
- (0, node_opcua_assert_1.assert)(value instanceof arrayTypeConstructor);
510
- (0, node_opcua_assert_1.assert)(value.buffer instanceof ArrayBuffer);
511
- (0, node_opcua_basic_types_1.encodeUInt32)(value.length, stream);
512
- stream.writeArrayBuffer(value.buffer, value.byteOffset, value.byteLength);
501
+ const typedValue = value;
502
+ (0, node_opcua_assert_1.assert)(typedValue instanceof arrayTypeConstructor);
503
+ (0, node_opcua_assert_1.assert)(typedValue.buffer instanceof ArrayBuffer);
504
+ (0, node_opcua_basic_types_1.encodeUInt32)(typedValue.length, stream);
505
+ stream.writeArrayBuffer(typedValue.buffer, typedValue.byteOffset, typedValue.byteLength);
513
506
  }
514
507
  function encodeGeneralArray(dataType, stream, value) {
515
508
  if (!value) {
@@ -594,10 +587,11 @@ function encodeDimension(dimensions, stream) {
594
587
  }
595
588
  function isEnumerationItem(value) {
596
589
  return (value instanceof Object &&
597
- Object.prototype.hasOwnProperty.call(value, "value") &&
598
- Object.prototype.hasOwnProperty.call(value, "key") &&
590
+ Object.hasOwn(value, "value") &&
591
+ Object.hasOwn(value, "key") &&
599
592
  value.constructor.name === "EnumValueType");
600
593
  }
594
+ // biome-ignore lint/suspicious/noExplicitAny: intentional
601
595
  function coerceVariantType(dataType, value) {
602
596
  /* eslint max-statements: ["error",1000], complexity: ["error",1000]*/
603
597
  if (value === undefined) {
@@ -608,7 +602,7 @@ function coerceVariantType(dataType, value) {
608
602
  // OPCUA Specification 1.0.3 5.8.2 encoding rules for various dataType:
609
603
  // [...]Enumeration are always encoded as Int32 on the wire [...]
610
604
  if (dataType !== DataType_enum_1.DataType.Int32 && dataType !== DataType_enum_1.DataType.ExtensionObject) {
611
- throw new Error("expecting DataType.Int32 for enumeration values ;" + " got DataType." + dataType.toString() + " instead");
605
+ throw new Error(`expecting DataType.Int32 for enumeration values ; got DataType.${dataType.toString()} instead`);
612
606
  }
613
607
  }
614
608
  /* c8 ignore stop */
@@ -633,8 +627,8 @@ function coerceVariantType(dataType, value) {
633
627
  (0, node_opcua_assert_1.assert)(value !== undefined);
634
628
  value = parseInt(value, 10);
635
629
  /* c8 ignore start */
636
- if (!isFinite(value)) {
637
- throw new Error("expecting a number " + value);
630
+ if (!Number.isFinite(value)) {
631
+ throw new Error(`expecting a number ${value}`);
638
632
  }
639
633
  /* c8 ignore stop */
640
634
  break;
@@ -664,17 +658,16 @@ function coerceVariantType(dataType, value) {
664
658
  default:
665
659
  (0, node_opcua_assert_1.assert)(dataType !== undefined && dataType !== null, "Invalid DataType");
666
660
  break;
667
- case DataType_enum_1.DataType.NodeId:
668
- break;
669
661
  }
670
662
  return value;
671
663
  }
664
+ // biome-ignore lint/suspicious/noExplicitAny: intentionally using an y here
672
665
  function isValidScalarVariant(dataType, value) {
673
666
  (0, node_opcua_assert_1.assert)(value === null ||
674
667
  DataType_enum_1.DataType.Int64 === dataType ||
675
668
  DataType_enum_1.DataType.ByteString === dataType ||
676
669
  DataType_enum_1.DataType.UInt64 === dataType ||
677
- !(value instanceof Array));
670
+ !Array.isArray(value));
678
671
  (0, node_opcua_assert_1.assert)(value === null || !(value instanceof Int32Array));
679
672
  (0, node_opcua_assert_1.assert)(value === null || !(value instanceof Uint32Array));
680
673
  switch (dataType) {
@@ -706,6 +699,7 @@ function isValidScalarVariant(dataType, value) {
706
699
  return true;
707
700
  }
708
701
  }
702
+ // biome-ignore lint/suspicious/noExplicitAny: intentional - polymorphic Variant value
709
703
  function isValidArrayVariant(dataType, value) {
710
704
  if (value === null) {
711
705
  return true;
@@ -744,6 +738,7 @@ function isValidArrayVariant(dataType, value) {
744
738
  return true;
745
739
  }
746
740
  /* c8 ignore start */
741
+ // biome-ignore lint/suspicious/noExplicitAny: intentional - polymorphic Variant value
747
742
  function isValidMatrixVariant(dataType, value, dimensions) {
748
743
  if (!dimensions) {
749
744
  return false;
@@ -762,7 +757,7 @@ function isValidVariant(arrayType, dataType, value, dimensions) {
762
757
  return isValidArrayVariant(dataType, value);
763
758
  default:
764
759
  (0, node_opcua_assert_1.assert)(arrayType === VariantArrayType_enum_1.VariantArrayType.Matrix);
765
- return isValidMatrixVariant(dataType, value, dimensions);
760
+ return isValidMatrixVariant(dataType, value, dimensions ?? null);
766
761
  }
767
762
  }
768
763
  function buildVariantArray(dataType, nbElements, defaultValue) {
@@ -804,9 +799,11 @@ function buildVariantArray(dataType, nbElements, defaultValue) {
804
799
  }
805
800
  // old version of nodejs do not provide a Buffer#equals test
806
801
  const oldNodeVersion = typeof process === "object" && process.versions && process.versions.node && process.versions.node.substring(0, 1) === "0";
802
+ // biome-ignore lint/suspicious/noExplicitAny: intentional - deep equality comparison of polymorphic values
807
803
  function __type(a) {
808
804
  return Object.prototype.toString.call(a);
809
805
  }
806
+ // biome-ignore lint/suspicious/noExplicitAny: intentional - deep equality comparison of polymorphic values
810
807
  function __check_same_object(o1, o2) {
811
808
  if (o1 === o2)
812
809
  return true;
@@ -854,11 +851,12 @@ function __check_same_object(o1, o2) {
854
851
  case "[object BigInt]":
855
852
  return o1 === o2;
856
853
  case "[object Date]":
857
- return o1.getTime() == o2.getTime();
854
+ return o1.getTime() === o2.getTime();
858
855
  default:
859
856
  return o1 === o2;
860
857
  }
861
858
  }
859
+ // biome-ignore lint/suspicious/noExplicitAny: intentional - deep equality comparison of polymorphic values
862
860
  function __check_same_array(arr1, arr2) {
863
861
  if (!arr1 || !arr2) {
864
862
  return !arr1 && !arr2;