Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-data-value

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-data-value - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

71

_generated_/_auto_generated_DataValue.js

@@ -1,2 +0,2 @@

// --------- This code has been automatically generated !!! 2018-03-24T16:23:36.609Z
// --------- This code has been automatically generated !!! 2018-04-16T04:56:39.340Z
"use strict";

@@ -6,23 +6,23 @@ /**

*/
var assert = require("node-opcua-assert");
var util = require("util");
var _ = require("underscore");
var makeNodeId = require("node-opcua-nodeid").makeNodeId;
var schema_helpers = require("node-opcua-factory/src/factories_schema_helpers");
var extract_all_fields = schema_helpers.extract_all_fields;
var resolve_schema_field_types = schema_helpers.resolve_schema_field_types;
var initialize_field = schema_helpers.initialize_field;
var initialize_field_array = schema_helpers.initialize_field_array;
var check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
var _defaultTypeMap = require("node-opcua-factory/src/factories_builtin_types")._defaultTypeMap;
var ec = require("node-opcua-basic-types");
var encodeArray = ec.encodeArray;
var decodeArray = ec.decodeArray;
var makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
var generate_new_id = require("node-opcua-factory").generate_new_id;
var _enumerations = require("node-opcua-factory/src/factories_enumerations")._private._enumerations;
var schema = require("../schemas/DataValue_schema").DataValue_Schema;
var getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
var Variant = getFactory("Variant");
var BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;
const assert = require("node-opcua-assert").assert;
const util = require("util");
const _ = require("underscore");
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const schema_helpers = require("node-opcua-factory/src/factories_schema_helpers");
const extract_all_fields = schema_helpers.extract_all_fields;
const resolve_schema_field_types = schema_helpers.resolve_schema_field_types;
const initialize_field = schema_helpers.initialize_field;
const initialize_field_array = schema_helpers.initialize_field_array;
const check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
const _defaultTypeMap = require("node-opcua-factory/src/factories_builtin_types")._defaultTypeMap;
const ec = require("node-opcua-basic-types");
const encodeArray = ec.encodeArray;
const decodeArray = ec.decodeArray;
const makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
const generate_new_id = require("node-opcua-factory").generate_new_id;
const _enumerations = require("node-opcua-factory/src/factories_enumerations")._private._enumerations;
const schema = require("../schemas/DataValue_schema").DataValue_Schema;
const getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
const Variant = getFactory("Variant");
const BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;

@@ -35,8 +35,2 @@ /**

* @param options {Object}
* @param [options.value = null] {Variant}
* @param [options.statusCode = 0] {StatusCode}
* @param [options.sourceTimestamp = null] {DateTime}
* @param [options.sourcePicoseconds = 0] {UInt16}
* @param [options.serverTimestamp = null] {DateTime}
* @param [options.serverPicoseconds = 0] {UInt16}
*/

@@ -48,3 +42,3 @@ function DataValue(options)

if (schema_helpers.doDebug) { check_options_correctness_against_schema(this,schema,options); }
var self = this;
const self = this;
assert(this instanceof BaseUAObject); // ' keyword "new" is required for constructor call')

@@ -115,8 +109,8 @@ resolve_schema_field_types(schema);

var encode_StatusCode = _defaultTypeMap.StatusCode.encode;
var decode_StatusCode = _defaultTypeMap.StatusCode.decode;
var encode_DateTime = _defaultTypeMap.DateTime.encode;
var decode_DateTime = _defaultTypeMap.DateTime.decode;
var encode_UInt16 = _defaultTypeMap.UInt16.encode;
var decode_UInt16 = _defaultTypeMap.UInt16.decode;
const encode_StatusCode = _defaultTypeMap.StatusCode.encode;
const decode_StatusCode = _defaultTypeMap.StatusCode.decode;
const encode_DateTime = _defaultTypeMap.DateTime.encode;
const decode_DateTime = _defaultTypeMap.DateTime.decode;
const encode_UInt16 = _defaultTypeMap.UInt16.encode;
const decode_UInt16 = _defaultTypeMap.UInt16.decode;
DataValue.prototype.encode = function(stream,options) {

@@ -130,6 +124,5 @@ schema.encode(this,stream,options);

* @param stream {BinaryStream}
* @param [option] {object}
*/
DataValue.prototype.decode = function(stream,options) {
schema.decode(this,stream,options);
DataValue.prototype.decode = function(stream) {
schema.decode(this,stream);
};

@@ -157,3 +150,3 @@ DataValue.prototype.decode_debug = function(stream,options) {

exports.DataValue = DataValue;
var register_class_definition = require("node-opcua-factory/src/factories_factories").register_class_definition;
const register_class_definition = require("node-opcua-factory/src/factories_factories").register_class_definition;
register_class_definition("DataValue",DataValue);
{
"name": "node-opcua-data-value",
"main": "./index.js",
"version": "0.2.3",
"version": "0.3.0",
"description": "pure nodejs OPCUA SDK - module -data-value",

@@ -12,17 +12,17 @@ "scripts": {

"dependencies": {
"node-opcua-assert": "^0.2.0",
"node-opcua-basic-types": "^0.2.3",
"node-opcua-binary-stream": "^0.2.3",
"node-opcua-date-time": "^0.2.3",
"node-opcua-factory": "^0.2.3",
"node-opcua-nodeid": "^0.2.3",
"node-opcua-status-code": "^0.2.3",
"node-opcua-utils": "^0.2.3",
"node-opcua-variant": "^0.2.3",
"node-opcua-assert": "^0.3.0",
"node-opcua-basic-types": "^0.3.0",
"node-opcua-binary-stream": "^0.3.0",
"node-opcua-date-time": "^0.3.0",
"node-opcua-factory": "^0.3.0",
"node-opcua-nodeid": "^0.3.0",
"node-opcua-status-code": "^0.3.0",
"node-opcua-utils": "^0.3.0",
"node-opcua-variant": "^0.3.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"node-opcua-generator": "^0.2.3",
"node-opcua-numeric-range": "^0.2.3",
"node-opcua-packet-analyzer": "^0.2.3",
"node-opcua-generator": "^0.3.0",
"node-opcua-numeric-range": "^0.3.0",
"node-opcua-packet-analyzer": "^0.3.0",
"should": "13.2.1"

@@ -29,0 +29,0 @@ },

"use strict";
var _ = require("underscore");
var assert = require("node-opcua-assert");
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
var factories = require("node-opcua-factory");
const factories = require("node-opcua-factory");
var set_flag = require("node-opcua-utils").set_flag;
var check_flag = require("node-opcua-utils").check_flag;
var ec = require("node-opcua-basic-types");
var StatusCodes = require("node-opcua-status-code").StatusCodes;
var StatusCode = require("node-opcua-status-code").StatusCode;
var Variant = require("node-opcua-variant").Variant;
var DataValueEncodingByte = require("../schemas/DataValueEncodingByte_enum").DataValueEncodingByte;
const set_flag = require("node-opcua-utils").set_flag;
const check_flag = require("node-opcua-utils").check_flag;
const ec = require("node-opcua-basic-types");
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const StatusCode = require("node-opcua-status-code").StatusCode;
const Variant = require("node-opcua-variant").Variant;
const DataValueEncodingByte = require("../schemas/DataValueEncodingByte_enum").DataValueEncodingByte;
function getDataValue_EncodingByte(dataValue) {
var encoding_mask = 0;
let encoding_mask = 0;

@@ -42,3 +42,3 @@ if (dataValue.value) {

// OPC-UA part 4 - $7.7
var DataValue_Schema = {
const DataValue_Schema = {
name: "DataValue",

@@ -57,3 +57,3 @@ id: factories.next_available_id(),

var encoding_mask = getDataValue_EncodingByte(dataValue);
const encoding_mask = getDataValue_EncodingByte(dataValue);

@@ -100,6 +100,6 @@ assert(_.isFinite(encoding_mask) && encoding_mask>=0 && encoding_mask<= 0x3F);

var tracer = options.tracer;
const tracer = options.tracer;
var cur = stream.length;
var encoding_mask = ec.decodeUInt8(stream);
let cur = stream.length;
const encoding_mask = ec.decodeUInt8(stream);
assert(encoding_mask<=0x3F);

@@ -150,3 +150,3 @@

var encoding_mask = ec.decodeUInt8(stream);
const encoding_mask = ec.decodeUInt8(stream);

@@ -153,0 +153,0 @@ if( check_flag(encoding_mask,DataValueEncodingByte.Value)) {

"use strict";
var factories = require("node-opcua-factory");
var DataValueEncodingByte_Schema = {
const factories = require("node-opcua-factory");
const DataValueEncodingByte_Schema = {
name:"DataValue_EncodingByte",

@@ -6,0 +6,0 @@ enumValues: {

"use strict";
var assert = require("node-opcua-assert");
var factories = require("node-opcua-factory");
var BinaryStream = require("node-opcua-binary-stream").BinaryStream;
var TimestampsToReturn;
var TimestampsToReturn_Schema = {
const assert = require("node-opcua-assert").assert;
const factories = require("node-opcua-factory");
const BinaryStream = require("node-opcua-binary-stream").BinaryStream;
let TimestampsToReturn;
const TimestampsToReturn_Schema = {
name: "TimestampsToReturn",

@@ -19,3 +19,3 @@ enumValues: {

assert(stream instanceof BinaryStream);
var value = stream.readInteger();
const value = stream.readInteger();
if (value<0 || value>3) {

@@ -22,0 +22,0 @@ return TimestampsToReturn.Invalid;

"use strict";
var assert = require("node-opcua-assert");
var _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const _ = require("underscore");
var DataValue = exports.DataValue = require("../_generated_/_auto_generated_DataValue").DataValue;
const DataValue = exports.DataValue = require("../_generated_/_auto_generated_DataValue").DataValue;
var DataType = require("node-opcua-variant").DataType;
var VariantArrayType = require("node-opcua-variant").VariantArrayType;
const DataType = require("node-opcua-variant").DataType;
const VariantArrayType = require("node-opcua-variant").VariantArrayType;
var TimestampsToReturn = require("../schemas/TimestampsToReturn_enum").TimestampsToReturn;
const TimestampsToReturn = require("../schemas/TimestampsToReturn_enum").TimestampsToReturn;
var registerSpecialVariantEncoder = require("node-opcua-factory").registerSpecialVariantEncoder;
const registerSpecialVariantEncoder = require("node-opcua-factory").registerSpecialVariantEncoder;
registerSpecialVariantEncoder(exports.DataValue);
var getCurrentClock = require("node-opcua-date-time").getCurrentClock;
const getCurrentClock = require("node-opcua-date-time").getCurrentClock;
var Variant = require("node-opcua-variant").Variant;
var sameVariant = require("node-opcua-variant/src/variant_tools").sameVariant;
const Variant = require("node-opcua-variant").Variant;
const sameVariant = require("node-opcua-variant/src/variant_tools").sameVariant;
DataValue.prototype.toString = function () {
var str = "DataValue:";
let str = "DataValue:";
if (this.value) {

@@ -38,4 +38,4 @@ str += "\n value: " + Variant.prototype.toString.apply(this.value);//this.value.toString();

DataValue.prototype.clone = function () {
var self = this;
var tmp = new DataValue({
const self = this;
const tmp = new DataValue({
serverTimestamp: self.serverTimestamp,

@@ -54,3 +54,3 @@ sourceTimestamp: self.sourceTimestamp,

function _partial_clone(dataValue) {
var cloneDataValue = new DataValue(null);
const cloneDataValue = new DataValue(null);
cloneDataValue.value = dataValue.value;

@@ -69,4 +69,4 @@ cloneDataValue.statusCode = dataValue.statusCode;

var cloneDataValue = null;
var now = null;
let cloneDataValue = null;
let now = null;
// apply timestamps

@@ -93,5 +93,5 @@ switch (timestampsToReturn) {

case TimestampsToReturn.Both:
if (false && attributeId !== 13 && dataValue.sourceTimestamp && dataValue.serverTimestamp) {
return dataValue;
}
//xxif (false && attributeId !== 13 && dataValue.sourceTimestamp && dataValue.serverTimestamp) {
//xx return dataValue;
//xx}
cloneDataValue = cloneDataValue || _partial_clone(dataValue);

@@ -125,7 +125,7 @@ cloneDataValue.serverTimestamp = dataValue.serverTimestamp;

var cloneDataValue = new DataValue({});
const cloneDataValue = new DataValue({});
cloneDataValue.value = dataValue.value;
cloneDataValue.statusCode = dataValue.statusCode;
var now = getCurrentClock();
const now = getCurrentClock();
// apply timestamps

@@ -136,6 +136,6 @@ switch (timestampsToReturn) {

cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
if (true || !cloneDataValue.serverTimestamp) {
//xxif (true || !cloneDataValue.serverTimestamp) {
cloneDataValue.serverTimestamp = now.timestamp;
cloneDataValue.serverPicoseconds = now.picoseconds;
}
//xx}
break;

@@ -149,6 +149,6 @@ case TimestampsToReturn.Source:

cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
if (true || !cloneDataValue.serverTimestamp) {
//xxif (true || !cloneDataValue.serverTimestamp) {
cloneDataValue.serverTimestamp = now.timestamp;
cloneDataValue.serverPicoseconds = now.picoseconds;
}
//xx}

@@ -179,3 +179,3 @@ cloneDataValue.sourceTimestamp = dataValue.sourceTimestamp;

var clonedDataValue = new DataValue({
const clonedDataValue = new DataValue({
statusCode: result.statusCode,

@@ -212,6 +212,6 @@ serverTimestamp: dataValue.serverTimestamp,

var variant = dataValue.value;
const variant = dataValue.value;
if (indexRange && canRange(dataValue)) {
// let's extract an array of elements corresponding to the indexRange
var result = indexRange.extract_values(variant.value, variant.dimensions);
const result = indexRange.extract_values(variant.value, variant.dimensions);
dataValue = _clone_with_array_replacement(dataValue, result);

@@ -247,3 +247,3 @@ //xx console.log(" dataValue =",dataValue.toString());

assert(dataValue2, "expecting valid dataValue2");
var hasChanged =
const hasChanged =
!sameDate(dataValue1.sourceTimestamp, dataValue2.sourceTimestamp) ||

@@ -259,3 +259,3 @@ (dataValue1.sourcePicoseconds !== dataValue2.sourcePicoseconds);

assert(dataValue2, "expecting valid dataValue2");
var hasChanged =
const hasChanged =
!sameDate(dataValue1.serverTimestamp, dataValue2.serverTimestamp) ||

@@ -262,0 +262,0 @@ (dataValue1.serverPicoseconds !== dataValue2.serverPicoseconds);

"use strict";
/* global describe,it*/
var DataValue = require("../src/datavalue").DataValue;
var Variant = require("node-opcua-variant").Variant;
var DataType = require("node-opcua-variant").DataType;
var StatusCodes = require("node-opcua-status-code").StatusCodes;
const DataValue = require("../src/datavalue").DataValue;
const Variant = require("node-opcua-variant").Variant;
const DataType = require("node-opcua-variant").DataType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
require("should");
var encode_decode_round_trip_test = require("node-opcua-packet-analyzer/test_helpers/encode_decode_round_trip_test").encode_decode_round_trip_test;
const encode_decode_round_trip_test = require("node-opcua-packet-analyzer/test_helpers/encode_decode_round_trip_test").encode_decode_round_trip_test;

@@ -17,3 +17,3 @@ describe("DataValue", function () {

var dataValue = new DataValue();
const dataValue = new DataValue();

@@ -27,3 +27,3 @@ encode_decode_round_trip_test(dataValue, function (buffer/*, id*/) {

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({dataType: DataType.String, value: "Hello"})

@@ -38,3 +38,3 @@ });

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({dataType: DataType.String, value: "Hello"}),

@@ -53,3 +53,3 @@ serverTimestamp: new Date(),

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({dataType: DataType.String, value: "Hello"}),

@@ -68,3 +68,3 @@ statusCode: StatusCodes.BadCertificateHostNameInvalid,

var dataValue = new DataValue({
let dataValue = new DataValue({
value: new Variant({dataType: DataType.String, value: "Hello"}),

@@ -77,3 +77,3 @@ statusCode: StatusCodes.BadCertificateHostNameInvalid,

});
var str = dataValue.toString();
let str = dataValue.toString();
str.split(/\n/).should.eql([

@@ -106,9 +106,9 @@ "DataValue:",

var extractRange = require("../src/datavalue").extractRange;
var VariantArrayType = require("node-opcua-variant").VariantArrayType;
var NumericRange = require("node-opcua-numeric-range").NumericRange;
const extractRange = require("../src/datavalue").extractRange;
const VariantArrayType = require("node-opcua-variant").VariantArrayType;
const NumericRange = require("node-opcua-numeric-range").NumericRange;
it("DataValue - extractRange on a Float Array", function () {
var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -120,3 +120,3 @@ dataType: DataType.Double,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
const dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
dataValue1.value.value.length.should.eql(2);

@@ -131,3 +131,3 @@ dataValue1.value.value[0].should.eql(3.0);

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -139,3 +139,3 @@ dataType: DataType.String,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
const dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
dataValue1.value.value.length.should.eql(2);

@@ -149,3 +149,3 @@ dataValue1.value.value.should.eql("34");

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -157,3 +157,3 @@ dataType: DataType.ByteString,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
const dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
dataValue1.value.value.length.should.eql(2);

@@ -168,3 +168,3 @@ dataValue1.value.value[0].should.eql(3.0);

it("DataValue - extractRange on a ByteString (null value)", function () {
var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -176,3 +176,3 @@ dataType: DataType.ByteString,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
const dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
dataValue1.value.dataType.should.eql(DataType.ByteString);

@@ -185,3 +185,3 @@ dataValue1.value.arrayType.should.eql(VariantArrayType.Scalar);

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -199,3 +199,3 @@ dataType: DataType.ByteString,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
const dataValue1 = extractRange(dataValue, new NumericRange("2:3"));
dataValue1.value.value.length.should.eql(2);

@@ -209,3 +209,3 @@ dataValue1.value.value[0].toString().should.eql("GHI");

var dataValue = new DataValue({
const dataValue = new DataValue({
value: new Variant({

@@ -234,3 +234,3 @@ dataType: DataType.ByteString,

});
var dataValue1 = extractRange(dataValue, new NumericRange("2,1:2"));
const dataValue1 = extractRange(dataValue, new NumericRange("2,1:2"));
dataValue1.value.value.length.should.eql(2);

@@ -260,3 +260,3 @@ dataValue1.value.value[0].toString().should.eql("32");

var dv = new DataValue({
const dv = new DataValue({
value: {

@@ -267,3 +267,3 @@ dataType: DataType.UInt32,

});
var cloned = copy_construct_or_clone_func(dv);
const cloned = copy_construct_or_clone_func(dv);

@@ -276,3 +276,3 @@ cloned.value.dataType.should.eql(dv.value.dataType);

var dv = new DataValue({
const dv = new DataValue({
value: {

@@ -284,3 +284,3 @@ dataType: DataType.UInt32,

var cloned = copy_construct_or_clone_func(dv);
const cloned = copy_construct_or_clone_func(dv);

@@ -301,3 +301,3 @@ cloned.value.dataType.should.eql(dv.value.dataType);

var dv = new DataValue({
const dv = new DataValue({
value: new Variant({

@@ -316,3 +316,3 @@ dataType: DataType.ByteString,

var cloned = copy_construct_or_clone_func(dv);
const cloned = copy_construct_or_clone_func(dv);

@@ -338,4 +338,4 @@ cloned.value.dataType.should.eql(dv.value.dataType);

var extObj = new SomeExtensionObject({a: 36});
var dv = new DataValue({
const extObj = new SomeExtensionObject({a: 36});
const dv = new DataValue({
value: {

@@ -347,3 +347,3 @@ dataType: DataType.ExtensionObject,

var cloned = copy_construct_or_clone_func(dv);
const cloned = copy_construct_or_clone_func(dv);

@@ -362,5 +362,5 @@ cloned.value.dataType.should.eql(dv.value.dataType);

it("should " + copy_construct_or_clone + " a DataValue with a variant containing a extension object array", function () {
var extObj1 = new SomeExtensionObject({a: 36});
var extObj2 = new SomeExtensionObject({a: 37});
var dv = new DataValue({
const extObj1 = new SomeExtensionObject({a: 36});
const extObj2 = new SomeExtensionObject({a: 37});
const dv = new DataValue({
value: {

@@ -375,3 +375,3 @@ dataType: DataType.ExtensionObject,

// copy construct;,
var cloned = copy_construct_or_clone_func(dv);
const cloned = copy_construct_or_clone_func(dv);

@@ -378,0 +378,0 @@ cloned.value.dataType.should.eql(dv.value.dataType);

"use strict";
var rs = require("..");
var should = require("should");
const rs = require("..");
const should = require("should");

@@ -9,3 +9,3 @@ describe("TimestampsToReturn", function () {

var v = rs.TimestampsToReturn.get(1000);
let v = rs.TimestampsToReturn.get(1000);
should.not.exist(v);

@@ -12,0 +12,0 @@ v = rs.TimestampsToReturn.get(0x03);

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