node-opcua-status-code
Advanced tools
Comparing version 0.2.3 to 0.3.0
{ | ||
"name": "node-opcua-status-code", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "pure nodejs OPCUA SDK - module -status-code", | ||
@@ -10,3 +10,3 @@ "main": "./src/opcua_status_code.js", | ||
"dependencies": { | ||
"node-opcua-assert": "^0.2.0", | ||
"node-opcua-assert": "^0.3.0", | ||
"node-opcua-constants": "^0.2.0", | ||
@@ -16,3 +16,3 @@ "underscore": "^1.8.3" | ||
"devDependencies": { | ||
"node-opcua-binary-stream": "^0.2.3", | ||
"node-opcua-binary-stream": "^0.3.0", | ||
"should": "13.2.1" | ||
@@ -19,0 +19,0 @@ }, |
@@ -6,9 +6,9 @@ "use strict"; | ||
var util = require("util"); | ||
var _ = require("underscore"); | ||
var assert = require("node-opcua-assert"); | ||
const util = require("util"); | ||
const _ = require("underscore"); | ||
const assert = require("node-opcua-assert").assert; | ||
var StatusCodes = require("node-opcua-constants").StatusCodes; | ||
const StatusCodes = require("node-opcua-constants").StatusCodes; | ||
var extraStatusCodeBits = { | ||
const extraStatusCodeBits = { | ||
@@ -182,3 +182,3 @@ // StatusCode Special bits | ||
var encodeStatusCode = function (statusCode, stream) { | ||
const encodeStatusCode = function (statusCode, stream) { | ||
assert(statusCode instanceof StatusCode || statusCode instanceof ConstantStatusCode); | ||
@@ -191,10 +191,10 @@ stream.writeUInt32(statusCode.value); | ||
function b(c) { | ||
var tmp ="0000000000000000000000"+(c >>>0).toString(2); | ||
const tmp ="0000000000000000000000"+(c >>>0).toString(2); | ||
return tmp.substr(-32); | ||
} | ||
var decodeStatusCode = function (stream) { | ||
var code = stream.readUInt32(); | ||
const decodeStatusCode = function (stream) { | ||
const code = stream.readUInt32(); | ||
var code_without_info_bits = (code & 0xFFFF0000)>>>0; | ||
var info_bits = code & 0x0000FFFF; | ||
const code_without_info_bits = (code & 0xFFFF0000)>>>0; | ||
const info_bits = code & 0x0000FFFF; | ||
//xx console.log(b(mask)); | ||
@@ -204,3 +204,3 @@ //xx console.log(b(~mask)); | ||
//xx console.log(b(code_without_info_bits)); | ||
var sc = StatusCodes_reverse_map[code_without_info_bits]; | ||
let sc = StatusCodes_reverse_map[code_without_info_bits]; | ||
if(!sc) { | ||
@@ -211,3 +211,3 @@ sc = StatusCodes.Bad; | ||
if (info_bits) { | ||
var tmp = new ModifiableStatusCode({_base: sc}); | ||
const tmp = new ModifiableStatusCode({_base: sc}); | ||
tmp.set(info_bits); | ||
@@ -222,3 +222,3 @@ sc =tmp; | ||
/* construct status codes fast search indexes */ | ||
var StatusCodes_reverse_map = {}; | ||
const StatusCodes_reverse_map = {}; | ||
_.forEach(StatusCodes, function (code) { | ||
@@ -249,4 +249,4 @@ code = new ConstantStatusCode(code); | ||
var self = this; | ||
var str = []; | ||
const self = this; | ||
const str = []; | ||
_.forEach(extraStatusCodeBits,function(value,key){ | ||
@@ -281,5 +281,5 @@ if ((self._extraBits & value ) === value) { | ||
if (typeof bit === "string") { | ||
var bitsarray = bit.split(" | "); | ||
const bitsarray = bit.split(" | "); | ||
if (bitsarray.length > 1) { | ||
for (var i = 0; i < bitsarray.length; i++) { | ||
for (let i = 0; i < bitsarray.length; i++) { | ||
this.set(bitsarray[i]); | ||
@@ -289,3 +289,3 @@ } | ||
} | ||
var tmp = extraStatusCodeBits[bit]; | ||
const tmp = extraStatusCodeBits[bit]; | ||
if (!tmp) { | ||
@@ -303,5 +303,5 @@ throw new Error("Invalid StatusCode Bit "+ bit); | ||
var bitsarray = bit.split(" | "); | ||
const bitsarray = bit.split(" | "); | ||
if (bitsarray.length > 1) { | ||
for (var i = 0; i < bitsarray.length; i++) { | ||
for (let i = 0; i < bitsarray.length; i++) { | ||
@@ -314,3 +314,3 @@ console.log(" Unset",this._extraBits.toString(16)); | ||
} | ||
var tmp = extraStatusCodeBits[bit]; | ||
const tmp = extraStatusCodeBits[bit]; | ||
if (!tmp) { | ||
@@ -328,3 +328,3 @@ throw new Error("Invalid StatusCode Bit "+ bit); | ||
exports.StatusCodes.makeStatusCode = function(statusCode,optionalBits) { | ||
var tmp = new ModifiableStatusCode({ | ||
const tmp = new ModifiableStatusCode({ | ||
_base: statusCode | ||
@@ -331,0 +331,0 @@ }); |
var should = require("should"); | ||
var assert = require("node-opcua-assert"); | ||
const should = require("should"); | ||
const assert = require("node-opcua-assert").assert; | ||
var StatusCodes = require("..").StatusCodes; | ||
var StatusCode = require("..").StatusCode; | ||
var encodeStatusCode = require("..").encodeStatusCode; | ||
var decodeStatusCode = require("..").decodeStatusCode; | ||
const StatusCodes = require("..").StatusCodes; | ||
const StatusCode = require("..").StatusCode; | ||
const encodeStatusCode = require("..").encodeStatusCode; | ||
const decodeStatusCode = require("..").decodeStatusCode; | ||
var BinaryStream = require("node-opcua-binary-stream").BinaryStream; | ||
const BinaryStream = require("node-opcua-binary-stream").BinaryStream; | ||
@@ -33,7 +33,7 @@ describe("testing status code manipulation", function () { | ||
var stream = new BinaryStream(8); | ||
var statusCode = StatusCodes.BadNodeIdExists; | ||
const stream = new BinaryStream(8); | ||
const statusCode = StatusCodes.BadNodeIdExists; | ||
encodeStatusCode(statusCode, stream); | ||
stream.rewind(); | ||
var statusCode2 = decodeStatusCode(stream); | ||
const statusCode2 = decodeStatusCode(stream); | ||
statusCode2.should.eql(statusCode); | ||
@@ -57,3 +57,3 @@ | ||
it("GoodWithOverflowBit",function() { | ||
var statusCode2 = StatusCodes.makeStatusCode(StatusCodes.Good,"Overflow | InfoTypeDataValue"); | ||
const statusCode2 = StatusCodes.makeStatusCode(StatusCodes.Good,"Overflow | InfoTypeDataValue"); | ||
statusCode2.should.eql(StatusCodes.GoodWithOverflowBit); | ||
@@ -64,3 +64,3 @@ }); | ||
var statusCode2 = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
const statusCode2 = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
statusCode2.set("SemanticChanged"); | ||
@@ -73,3 +73,3 @@ statusCode2.value.should.eql(StatusCodes.BadNodeIdExists + 0x4000); | ||
var statusCode2 = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
const statusCode2 = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
statusCode2.set("Overflow"); | ||
@@ -82,3 +82,3 @@ statusCode2.value.should.eql(StatusCodes.BadNodeIdExists + 0x80); | ||
var statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
const statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
statusCode.set("Overflow | SemanticChanged"); | ||
@@ -96,9 +96,9 @@ | ||
var statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
const statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
statusCode.set("Overflow | SemanticChanged"); | ||
var stream = new BinaryStream(8); | ||
const stream = new BinaryStream(8); | ||
encodeStatusCode(statusCode, stream); | ||
stream.rewind(); | ||
var statusCode2 = decodeStatusCode(stream); | ||
const statusCode2 = decodeStatusCode(stream); | ||
statusCode2.should.eql(statusCode); | ||
@@ -115,3 +115,3 @@ | ||
var statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
const statusCode = StatusCodes.makeStatusCode(StatusCodes.BadNodeIdExists); | ||
statusCode.set("Overflow"); | ||
@@ -121,3 +121,3 @@ statusCode.hasOverflowBit.should.equal(true); | ||
var statusCode2 = StatusCodes.makeStatusCode(statusCode); | ||
const statusCode2 = StatusCodes.makeStatusCode(statusCode); | ||
statusCode2.hasOverflowBit.should.equal(true); | ||
@@ -137,3 +137,3 @@ statusCode2.hasSemanticChangedBit.should.equal(false); | ||
var statusCode =StatusCodes.Good; | ||
const statusCode =StatusCodes.Good; | ||
@@ -140,0 +140,0 @@ statusCode.set("Overflow"); // << set is not defined !!! |
19606
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addednode-opcua-assert@0.3.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removednode-opcua-assert@0.2.0(transitive)
Updatednode-opcua-assert@^0.3.0