node-opcua-variant
Advanced tools
Comparing version 0.4.2 to 0.4.6
@@ -1,2 +0,2 @@ | ||
// --------- This code has been automatically generated !!! 2018-07-30T21:12:07.948Z | ||
// --------- This code has been automatically generated !!! 2018-09-22T13:24:56.466Z | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ /** |
{ | ||
"name": "node-opcua-variant", | ||
"version": "0.4.2", | ||
"version": "0.4.6", | ||
"description": "pure nodejs OPCUA SDK - module -variant", | ||
@@ -12,19 +12,19 @@ "main": "index.js", | ||
"dependencies": { | ||
"node-opcua-assert": "^0.4.0", | ||
"node-opcua-basic-types": "^0.4.2", | ||
"node-opcua-data-model": "^0.4.2", | ||
"node-opcua-factory": "^0.4.2", | ||
"node-opcua-nodeid": "^0.4.2", | ||
"node-opcua-utils": "^0.4.2", | ||
"node-opcua-assert": "^0.4.6", | ||
"node-opcua-basic-types": "^0.4.6", | ||
"node-opcua-data-model": "^0.4.6", | ||
"node-opcua-factory": "^0.4.6", | ||
"node-opcua-nodeid": "^0.4.6", | ||
"node-opcua-utils": "^0.4.6", | ||
"underscore": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-benchmarker": "^0.4.2", | ||
"node-opcua-binary-stream": "^0.4.2", | ||
"node-opcua-debug": "^0.4.2", | ||
"node-opcua-generator": "^0.4.2", | ||
"node-opcua-numeric-range": "^0.4.2", | ||
"node-opcua-packet-analyzer": "^0.4.2", | ||
"node-opcua-status-code": "^0.4.2", | ||
"should": "13.2.1" | ||
"node-opcua-benchmarker": "^0.4.6", | ||
"node-opcua-binary-stream": "^0.4.6", | ||
"node-opcua-debug": "^0.4.6", | ||
"node-opcua-generator": "^0.4.6", | ||
"node-opcua-numeric-range": "^0.4.6", | ||
"node-opcua-packet-analyzer": "^0.4.6", | ||
"node-opcua-status-code": "^0.4.6", | ||
"should": "13.2.3" | ||
}, | ||
@@ -45,3 +45,4 @@ "author": "Etienne Rossignon", | ||
], | ||
"homepage": "http://node-opcua.github.io/" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "537d2a1f4d88271c57389d8ed56d787cf67588d2" | ||
} |
@@ -392,2 +392,13 @@ "use strict"; | ||
// array type could be a string | ||
if (typeof options.arrayType === "string") { | ||
const at = VariantArrayType[options.arrayType]; | ||
// istanbul ignore next | ||
if (utils.isNullOrUndefined(at)) { | ||
throw new Error("ArrayType: invalid " + options.arrayType); | ||
} | ||
options.arrayType = at; | ||
} | ||
if (!options.arrayType && _.isArray(options.value)) { | ||
@@ -394,0 +405,0 @@ // when using UInt64 ou Int64 arrayType must be specified , as automatic detection cannot be made |
@@ -42,4 +42,3 @@ "use strict"; | ||
const factory = require("node-opcua-factory"); | ||
factory.registerSpecialVariantEncoder(Variant); |
@@ -1716,1 +1716,31 @@ "use strict"; | ||
describe("testing variant JSON conversion", function() { | ||
it("should produce the expected output when converting Variant to JSON",function() { | ||
const b1 = new Variant({ | ||
dataType: DataType.Boolean, | ||
arrayType: VariantArrayType.Matrix, | ||
dimensions: [2, 3], value: [true, true, true, true, true, true] | ||
}); | ||
const jsonStr = JSON.stringify(b1, null , ""); | ||
jsonStr.should.eql(`{"dataType":"Boolean","arrayType":"Matrix","value":[true,true,true,true,true,true],"dimensions":[2,3]}`); | ||
}); | ||
it("should construct a Variant from a JSON string generated by a Variant",function() { | ||
const b1 = new Variant({ | ||
dataType: DataType.Boolean, | ||
arrayType: VariantArrayType.Matrix, | ||
dimensions: [2, 3], value: [true, true, true, true, true, true] | ||
}); | ||
const jsonStr = JSON.stringify(b1, null , ""); | ||
console.log(JSON.parse(jsonStr)); | ||
const b2 = new Variant(JSON.parse(jsonStr)); | ||
const jsonStr2 = JSON.stringify(b2, null , ""); | ||
jsonStr2.should.eql(jsonStr); | ||
}); | ||
}); |
142401
3375
Updatednode-opcua-assert@^0.4.6
Updatednode-opcua-data-model@^0.4.6
Updatednode-opcua-factory@^0.4.6
Updatednode-opcua-nodeid@^0.4.6
Updatednode-opcua-utils@^0.4.6